/* Panel del bot SIS Window Films. Autocontenido: sin fuentes, scripts ni CDN externos.
   Colores con significado:
     verde  = listo / funcionando      ámbar = siguiente paso / acción pendiente
     rojo   = problema                 gris  = pendiente para después            */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #0b1220;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e6e8ec;
  --line-2: #f0f2f5;

  --ok: #12b76a;
  --ok-ink: #067647;
  --ok-soft: #ecfdf3;
  --ok-ring: #abefc6;

  --next: #f79009;
  --next-btn: #fdb022;
  --next-btn-hover: #f9a20a;
  --next-ink: #b54708;
  --next-soft: #fffaeb;
  --next-ring: #fedf89;

  --bad: #f04438;
  --bad-btn: #d92d20;
  --bad-ink: #b42318;
  --bad-soft: #fef3f2;
  --bad-ring: #fecdca;

  --later: #98a2b3;
  --later-ink: #475467;
  --later-soft: #f2f4f7;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-2: 0 1px 3px rgba(16, 24, 40, .06), 0 12px 32px -8px rgba(16, 24, 40, .10);
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
  --sidebar: 256px;
  --tabbar: 64px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--later-soft); color: var(--ink-2); padding: 1px 6px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
/* Anillo de foco sólido (>=3:1 sobre blanco, el gris de fondo y el botón ámbar). */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- marca ---------- */
.logo { width: 38px; height: 38px; flex: none; display: block; }
.logo-bg { fill: var(--ink); }
.logo-film { fill: none; stroke: #3ddc97; stroke-width: 2.6; stroke-linecap: round; }
.logo-lg { width: 56px; height: 56px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.brand-text small { font-size: 12.5px; color: var(--muted); }

/* ---------- estructura ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 20;
  display: flex; flex-direction: column; gap: 8px;
  padding: 22px 16px 18px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 2px 8px 22px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a, .side-logout {
  display: flex; align-items: center; gap: 12px;
  height: 46px; padding: 0 14px; border-radius: 12px;
  color: var(--ink-2); font-weight: 600; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.side-nav a .ic, .side-logout .ic { color: var(--faint); transition: color .15s; }
.side-nav a:hover, .side-logout:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a.on { background: var(--ink); color: #fff; box-shadow: var(--sh-1); }
.side-nav a.on .ic { color: #3ddc97; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line-2); padding-top: 12px; }
.side-logout { width: 100%; border: 0; background: none; cursor: pointer; }

.topbar, .tabbar { display: none; }

.main {
  margin-left: var(--sidebar);
  padding: 40px 48px 64px;
  max-width: calc(var(--sidebar) + 1120px);
}

/* ---------- encabezados ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; font-weight: 700; line-height: 1.15; }
.lead { color: var(--muted); font-size: 15px; margin-top: 4px; }
.page-head-center { justify-content: center; text-align: center; }
.page-head-tight { margin-bottom: 18px; }
.head-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.back .ic { width: 18px; height: 18px; }
.back:hover { color: var(--ink); }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  font-weight: 650; font-size: 14.5px; line-height: 1;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 18px; height: 18px; }
.btn-lg { height: 52px; padding: 0 22px; font-size: 16px; border-radius: 14px; }
.btn-lg .ic { width: 20px; height: 20px; }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-xs { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; box-shadow: none; }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--sh-1); }
.btn-primary:hover { background: #1d2939; }
.btn-next {
  background: var(--next-btn); color: #1f1300;
  box-shadow: 0 1px 2px rgba(181, 71, 8, .2), 0 8px 20px -6px rgba(247, 144, 9, .55);
}
.btn-next:hover { background: var(--next-btn-hover); }
.btn-quiet { background: var(--surface); color: var(--ink-2); border-color: var(--line); box-shadow: var(--sh-1); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost { background: rgba(255, 255, 255, .8); color: var(--ok-ink); border-color: var(--ok-ring); }
.btn-ghost:hover { background: #fff; }
.btn-danger { background: var(--bad-btn); color: #fff; box-shadow: 0 1px 2px rgba(180, 35, 24, .25); }
.btn-danger:hover { background: var(--bad-ink); }
.btn-danger-ghost { background: var(--surface); color: var(--bad-ink); border-color: var(--bad-ring); }
.btn-danger-ghost:hover { background: var(--bad-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- pastillas y chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px;
  border-radius: 999px; font-size: 13.5px; font-weight: 650; border: 1px solid transparent;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill-done { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-ring); }
.pill-next { background: var(--next-soft); color: var(--next-ink); border-color: var(--next-ring); }
.pill-error { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-ring); }
.pill-later { background: var(--later-soft); color: var(--later-ink); border-color: var(--line); }
.pill-live .dot { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(247, 144, 9, .55); }
  100% { box-shadow: 0 0 0 9px rgba(247, 144, 9, 0); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px;
  border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.chip .ic { width: 14px; height: 14px; }
.chip-sm { height: 22px; padding: 0 8px; font-size: 11.5px; }
.chip-sm .ic { width: 12px; height: 12px; }
.chip-done { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-ring); }
.chip-next { background: var(--next-soft); color: var(--next-ink); border-color: var(--next-ring); }
.chip-error { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-ring); }
.chip-neutral { background: var(--later-soft); color: var(--later-ink); border-color: var(--line); }

/* ---------- avisos ---------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 13px 16px; margin-bottom: 20px; border-radius: var(--r);
  border: 1px solid; font-weight: 550; font-size: 14.5px;
}
.flash .ic { margin-top: 1px; }
.flash code { word-break: break-all; }
.flash-ok { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-ring); }
.flash-error { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-ring); }
.flash-next { background: var(--next-soft); color: var(--next-ink); border-color: var(--next-ring); }

/* ---------- tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); padding: 24px;
}
.card-flush { padding: 0; overflow: hidden; }

/* ---------- Inicio: tarjeta del siguiente paso ---------- */
.hero {
  display: flex; align-items: center; gap: 22px;
  padding: 28px; border-radius: 24px; border: 1px solid; margin-bottom: 16px;
  box-shadow: var(--sh-2); position: relative; overflow: hidden;
}
.hero-icon {
  width: 64px; height: 64px; border-radius: 18px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.hero-icon .ic { width: 30px; height: 30px; }
.hero-body { flex: 1; min-width: 0; }
.eyebrow { display: inline-block; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.hero h2 { font-size: 26px; font-weight: 700; line-height: 1.2; }
.hero p { color: var(--ink-2); margin-top: 6px; font-size: 15.5px; }
.hero-cta { flex: none; }
.hero-next { background: linear-gradient(135deg, #fff7e0 0%, #fffcf3 55%, #ffffff 100%); border-color: var(--next-ring); }
.hero-next .hero-icon { background: var(--next-btn); color: #1f1300; box-shadow: 0 10px 24px -8px rgba(247, 144, 9, .7); }
.hero-next .eyebrow { color: var(--next-ink); }
.hero-done { background: linear-gradient(135deg, #e3f9ec 0%, #f4fdf8 55%, #ffffff 100%); border-color: var(--ok-ring); }
.hero-done .hero-icon { background: #079455; box-shadow: 0 10px 24px -8px rgba(18, 183, 106, .7); }
.hero-done .eyebrow { color: var(--ok-ink); }
.hero-error { background: linear-gradient(135deg, #fde8e6 0%, #fff6f5 55%, #ffffff 100%); border-color: var(--bad-ring); }
.hero-error .hero-icon { background: var(--bad-btn); box-shadow: 0 10px 24px -8px rgba(240, 68, 56, .7); }
.hero-error .eyebrow { color: var(--bad-ink); }

/* ---------- Inicio: pasos ---------- */
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step a {
  display: flex; align-items: center; gap: 12px; height: 100%;
  padding: 14px 14px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--sh-1);
  transition: border-color .15s, box-shadow .15s;
}
.step a:hover { border-color: #d0d5dd; box-shadow: var(--sh-2); }
.step-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.step-text strong { font-size: 14px; font-weight: 650; }
.step-text small { font-size: 13px; font-weight: 600; }
.step-go { width: 16px; height: 16px; color: var(--faint); }
.lbl-short { display: none; }
.steps-summary { display: none; }
.step.s-done small { color: var(--ok-ink); }
.step.s-next a { border-color: var(--next-ring); background: var(--next-soft); }
.step.s-next small { color: var(--next-ink); }
.step.s-error a { border-color: var(--bad-ring); background: var(--bad-soft); }
.step.s-error small { color: var(--bad-ink); }
.step.s-later strong { color: var(--ink-2); }
.step.s-later small { color: var(--muted); }

.state-dot {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.state-dot .ic { width: 17px; height: 17px; stroke-width: 2.6; }
.state-dot.s-done { background: #079455; color: #fff; }   /* blanco sobre #079455 = 3.8:1 */
.state-dot.s-next { background: var(--next-btn); color: #1f1300; box-shadow: 0 0 0 4px rgba(247, 144, 9, .2); }
.state-dot.s-error { background: var(--bad-btn); color: #fff; }
.state-dot.s-later { background: var(--later-soft); color: var(--muted); border: 1px dashed #d0d5dd; }

/* ---------- Inicio: indicadores ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 20px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
}
.tile-link { transition: border-color .15s, box-shadow .15s; }
.tile-link:hover { border-color: #d0d5dd; box-shadow: var(--sh-2); }
.tile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tile-label { font-size: 13.5px; font-weight: 600; color: var(--muted); flex: 1; min-width: 0; }
.tile-go { width: 16px; height: 16px; color: var(--faint); }
.tile-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.tile-ic .ic { width: 19px; height: 19px; }
.tile-ic.s-done { background: var(--ok-soft); color: var(--ok-ink); }
.tile-ic.s-next { background: var(--next-soft); color: var(--next-ink); }
.tile-ic.s-error { background: var(--bad-soft); color: var(--bad-ink); }
.tile-ic.s-later, .tile-ic.s-neutral { background: var(--later-soft); color: var(--later-ink); }
.tile-value { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.tile-value.num { font-size: 38px; font-variant-numeric: tabular-nums; }
.tile-status { font-size: 22px; }
.t-done { color: var(--ok-ink); }
.t-next { color: var(--next-ink); }
.t-error { color: var(--bad-ink); }
.t-later { color: var(--later-ink); }

/* ---------- Inicio: opciones avanzadas ---------- */
.advanced { border-radius: var(--r-lg); background: transparent; border: 1px dashed #d0d5dd; }
.advanced[open] { background: var(--surface); border-style: solid; border-color: var(--line); box-shadow: var(--sh-1); }
.advanced > summary {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  cursor: pointer; list-style: none; color: var(--muted); font-weight: 600; font-size: 14.5px;
}
.advanced > summary::-webkit-details-marker, .confirm > summary::-webkit-details-marker { display: none; }
.advanced > summary span { flex: 1; }
.advanced > summary:hover { color: var(--ink); }
.advanced .chev { transition: transform .2s; }
.advanced[open] .chev { transform: rotate(180deg); }
.advanced-body { padding: 4px 18px 20px; }
.facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  margin: 0 0 18px; background: var(--line-2); border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden;
}
.facts div { background: var(--surface); padding: 12px 14px; min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 3px 0 0; font-size: 14px; font-weight: 550; overflow-wrap: anywhere; }
.facts .fact-wide { grid-column: 1 / -1; }
.adv-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.adv-actions form { margin: 0; }
.confirm > summary { list-style: none; }
.confirm[open] > summary { background: var(--bad-soft); }
.confirm-box {
  margin-top: 10px; padding: 14px 16px; border-radius: var(--r);
  background: var(--bad-soft); border: 1px solid var(--bad-ring); color: var(--bad-ink);
  max-width: 420px; display: flex; flex-direction: column; gap: 12px; font-size: 14px;
}
.confirm-box .btn { align-self: flex-start; }
.confirm-pop { position: relative; }
.confirm-pop[open] > summary { background: var(--surface-2); }
.confirm-pop .confirm-box {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 6; width: 260px; margin: 0;
  background: var(--surface); border-color: var(--line); color: var(--ink-2); box-shadow: var(--sh-2);
}

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
input:not([type=checkbox]):not([type=file]):not([type=hidden]), textarea {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 15px; line-height: 1.45; box-shadow: var(--sh-1);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type=checkbox]):focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }

.settings { display: flex; flex-direction: column; gap: 16px; max-width: 920px; }
.chat-list, .thread, .thread-head { max-width: 920px; }
.set-card { scroll-margin-top: 24px; }
.set-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.set-head > div { flex: 1; min-width: 0; }
.set-head h2 { font-size: 17px; font-weight: 700; }
.set-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.set-ic {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}

.switch-row {
  position: relative; display: flex; align-items: center; gap: 16px; cursor: pointer;
  padding: 16px 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface-2);
}
.switch-text { flex: 1; display: flex; flex-direction: column; }
.switch-ui { order: 2; }
.switch-text .on { color: var(--ok-ink); font-weight: 600; }
.switch:checked ~ .switch-text .off, .switch:not(:checked) ~ .switch-text .on { display: none; }
.switch-text strong { font-size: 15.5px; color: var(--ink); }
.switch-text small { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.switch { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  position: relative; width: 56px; height: 32px; flex: none; border-radius: 999px;
  background: #d0d5dd; transition: background .2s;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .25); transition: transform .2s;
}
.switch:checked + .switch-ui { background: #079455; }
.switch:checked + .switch-ui::after { transform: translateX(24px); }
.switch:focus-visible + .switch-ui { outline: 2px solid var(--ink); outline-offset: 3px; }
.switch-row:has(.switch:checked) { background: var(--ok-soft); border-color: var(--ok-ring); }

/* Barra de guardado: botón compacto a la derecha sobre un degradado que difumina el contenido. */
.savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  margin-top: -16px; padding: 36px 0 20px;
  background: linear-gradient(to bottom, rgba(244, 245, 247, 0) 0%, rgba(244, 245, 247, .94) 45%, var(--bg) 100%);
  pointer-events: none;
}
.savebar > * { pointer-events: auto; }
.savebar .btn { box-shadow: 0 1px 2px rgba(16, 24, 40, .1), 0 10px 24px -8px rgba(11, 18, 32, .45); }

/* ---------- Base de conocimiento ---------- */
.kb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.editor { display: flex; flex-direction: column; overflow: visible; }
.editor-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.editor-head .set-ic { width: 34px; height: 34px; border-radius: 10px; }
.editor-head .set-ic .ic { width: 18px; height: 18px; }
.editor-head label { font-size: 15px; color: var(--ink); font-weight: 650; }
.editor textarea {
  border: 0; border-radius: 0; box-shadow: none; min-height: 560px;
  padding: 20px 24px; font-family: var(--font); font-size: 15px; line-height: 1.65; background: var(--surface);
}
.editor textarea:focus { border: 0; box-shadow: inset 0 0 0 2px var(--ink); background: var(--surface); }
.savebar.savebar-in {
  position: sticky; bottom: 0; margin: 0; pointer-events: auto; justify-content: stretch;
  padding: 12px; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: rgba(255, 255, 255, .94); box-shadow: 0 -8px 24px -12px rgba(16, 24, 40, .12);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.savebar.savebar-in .btn { box-shadow: var(--sh-1); }
.savebar-in input { flex: 1; min-width: 0; }
.kb-side { display: flex; flex-direction: column; gap: 16px; }
.kb-side > * { min-width: 0; }
.upload .set-head { margin-bottom: 14px; }
.file-drop {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 72px; padding: 14px; margin-bottom: 12px; border-radius: var(--r);
  border: 1.5px dashed #d0d5dd; background: var(--surface-2); cursor: pointer;
  color: var(--ink-2); font-size: 14.5px; font-weight: 650; transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--faint); background: var(--surface); }
.file-drop .ic { color: var(--muted); }
.file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop .fd-ready { display: none; }
.file-drop:has(.file-input:valid) { border-style: solid; border-color: var(--ok-ring); background: var(--ok-soft); color: var(--ok-ink); }
.file-drop:has(.file-input:valid) .ic { color: var(--ok-ink); }
.file-drop:has(.file-input:valid) .fd-empty { display: none; }
.file-drop:has(.file-input:valid) .fd-ready { display: inline; }
.file-drop:has(.file-input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.versions .set-head { margin-bottom: 8px; }
.ver-list { list-style: none; margin: 0; padding: 0; }
.ver-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line-2); }
.ver-num {
  width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--later-soft); color: var(--later-ink); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.ver-list li.is-active .ver-num { background: var(--ok-soft); color: var(--ok-ink); }
.ver-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ver-main strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver-main small { font-size: 12.5px; color: var(--muted); }
.ver-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.ver-actions form { margin: 0; }
.ver-actions .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
.doc { margin: 0; padding: 24px 28px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font); font-size: 15px; line-height: 1.65; }

/* ---------- Conversaciones ---------- */
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-list li + li { border-top: 1px solid var(--line-2); }
.chat-list a { display: flex; align-items: center; gap: 14px; padding: 14px 20px; transition: background .12s; }
.chat-list a:hover { background: var(--surface-2); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.tone-0 { background: #e0f2fe; color: #026aa2; }
.tone-1 { background: #fce7f6; color: #c11574; }
.tone-2 { background: #ebe9fe; color: #5925dc; }
.tone-3 { background: #e4e7ec; color: #344054; }
.tone-4 { background: #fbe8ff; color: #9f1ab1; }
.tone-5 { background: #ccfbef; color: #107569; }
.avatar-anon { background: var(--later-soft); color: var(--later-ink); }
.avatar-anon .ic { width: 22px; height: 22px; }
.avatar-lg.avatar-anon .ic { width: 26px; height: 26px; }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.chat-main strong { font-size: 15px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.chat-side time { font-size: 12.5px; color: var(--muted); font-weight: 550; font-variant-numeric: tabular-nums; }

.thread-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.thread-head h1 { font-size: 24px; font-weight: 700; overflow-wrap: anywhere; }
.thread-head .lead { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.thread-head .lead > span:not(.chip) + span:not(.chip)::before { content: "\00b7"; margin-right: 10px; color: var(--faint); }
.thread-title { min-width: 0; }
.thread { background: #eef1f4; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.day { display: flex; justify-content: center; margin: 8px 0; }
.day span {
  font-size: 12px; font-weight: 650; color: var(--later-ink); background: rgba(255, 255, 255, .9);
  padding: 4px 12px; border-radius: 999px; box-shadow: var(--sh-1);
}
.bubble-row { display: flex; }
.bubble-row.from-bot { justify-content: flex-end; }
.bubble {
  max-width: min(72%, 620px); padding: 10px 14px 8px; border-radius: 18px;
  background: var(--surface); box-shadow: 0 1px 1px rgba(16, 24, 40, .08);
}
.from-user .bubble { border-top-left-radius: 6px; }
.from-bot .bubble { background: #dff7e9; border-top-right-radius: 6px; }
.who { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.from-bot .who { color: var(--ok-ink); }
.who .ic { width: 14px; height: 14px; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.5; }
.text-media { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-style: italic; }
.text-media .ic { width: 16px; height: 16px; color: var(--muted); }
.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.bubble-meta time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- vacío / error ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 56px 24px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1);
}
.empty h1, .empty h2 { font-size: 20px; font-weight: 700; }
.empty p { color: var(--muted); max-width: 440px; overflow-wrap: anywhere; }
.empty .btn { margin-top: 10px; }
.empty-ic { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--later-soft); color: var(--later-ink); margin-bottom: 4px; }
.empty-ic .ic { width: 28px; height: 28px; }
.empty-error .empty-ic { background: var(--bad-soft); color: var(--bad-ink); }
.empty-next .empty-ic { background: var(--next-soft); color: var(--next-ink); }
.empty form { margin-top: 10px; }
.empty form .btn { margin-top: 0; }
.back-center { margin: 8px 0 0; }
.more-center { margin-top: 6px; }
.more-center code { display: inline-block; margin-top: 8px; max-width: 440px; overflow-wrap: anywhere; }
.empty-inline { box-shadow: none; border: 0; background: transparent; padding: 32px; }

/* ---------- QR ---------- */
.qr-card {
  max-width: 540px; margin: 0 auto; padding: 28px 28px 22px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--sh-2);
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.qr-frame {
  padding: 16px; border-radius: 22px; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 0 0 8px var(--surface-2);
}
.qr { display: block; width: 280px; height: auto; max-width: 100%; image-rendering: pixelated; }
.qr-wait { width: 312px; max-width: 100%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--later-ink); background: var(--later-soft); border-color: var(--line); }
.qr-wait .ic { width: 40px; height: 40px; }
.qr-wait p { font-weight: 600; }
.pairing p { font-size: 13px; color: var(--muted); margin: 8px 0; }
.pairing code { display: inline-block; font-size: 20px; letter-spacing: .18em; padding: 6px 14px; border-radius: 10px; color: var(--ink); }
.qr-steps { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.qr-steps li {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 600; color: var(--ink-2); line-height: 1.3;
}
.qr-steps li > .ic { width: 40px; height: 40px; padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.qr-steps b {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 11px; vertical-align: 1px;
}
.qr-foot { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.qr-foot .ic { width: 16px; height: 16px; }

/* ---------- plegables y estado de la IA ---------- */
.more > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  color: var(--muted); font-size: 13.5px; font-weight: 600; border-radius: 8px;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { color: var(--ink); }
.more > summary .chev { width: 16px; height: 16px; transition: transform .2s; }
.more[open] > summary .chev { transform: rotate(90deg); }
.set-card .more { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.set-card .more .field { margin-top: 12px; max-width: 420px; }
.ia-rows { display: flex; flex-direction: column; gap: 16px; }
.ia-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ia-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.inline-alert {
  display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; padding: 10px 12px; border-radius: 12px;
  background: var(--bad-soft); color: var(--bad-ink); font-size: 14px; font-weight: 600;
}
.inline-alert .ic { width: 18px; height: 18px; }

/* ---------- Acceso ---------- */
body.login-page {
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(61, 220, 151, .16), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(253, 176, 34, .14), transparent 60%),
    var(--bg);
}
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth > .flash { width: min(420px, 100%); }
.login-card {
  width: min(420px, 100%); padding: 40px 36px 28px; border-radius: 28px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2);
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-card h1 { font-size: 26px; font-weight: 700; margin-top: 20px; }
.login-card .lead { margin-bottom: 24px; }
.login-card .flash { width: 100%; text-align: left; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.login-form .btn { margin-top: 12px; }
.input-icon { position: relative; }
.input-icon > .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 18px; height: 18px; pointer-events: none; }
.input-icon input:not([type=checkbox]):not([type=file]):not([type=hidden]) { padding-left: 42px; min-height: 52px; font-size: 16px; }
.login-foot { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; font-size: 12.5px; color: var(--muted); }
.login-foot .ic { width: 15px; height: 15px; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

@media (max-width: 1100px) {
  .steps, .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .sidebar { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 60px; padding: 0 16px;
    background: rgba(255, 255, 255, .92); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .topbar .logo { width: 32px; height: 32px; }
  .topbar form { margin: 0; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  }
  .tabbar a {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 650; color: var(--muted); min-width: 0;
  }
  .tabbar a .ic { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on::before {
    content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--ink);
  }
  .tabbar a span { max-width: 100%; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
  .main { margin-left: 0; padding: 22px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); max-width: none; }
  .set-card { scroll-margin-top: 76px; }   /* barra superior fija de 60 px + aire */
  .savebar { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .savebar.savebar-in { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .page-head { margin-bottom: 18px; align-items: flex-start; }
  .page-head h1 { font-size: 26px; }
  .hero { flex-direction: column; align-items: stretch; gap: 16px; padding: 22px; border-radius: 22px; }
  .hero-icon { width: 52px; height: 52px; border-radius: 15px; }
  .hero-icon .ic { width: 26px; height: 26px; }
  .hero h2 { font-size: 22px; }
  .hero-cta .btn, .hero-cta form { width: 100%; }
  .steps { gap: 8px; }
  .step a { padding: 12px; gap: 10px; }
  .step-go { display: none; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .steps.is-complete { display: none; }
  .steps-summary {
    display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 12px 14px; border-radius: 16px;
    background: var(--ok-soft); border: 1px solid var(--ok-ring); color: var(--ok-ink); font-weight: 650; font-size: 14.5px;
  }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div { padding: 10px 12px; }
  .facts dt { font-size: 11px; }
  .facts dd { font-size: 13.5px; }
  .state-dot { width: 30px; height: 30px; font-size: 13px; }
  .tiles { gap: 8px; }
  .tile { padding: 16px; }
  .tile-top { margin-bottom: 4px; }
  .tile-value.num { font-size: 32px; }
  .tile-status { font-size: 18px; }
  .tile-label { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tile-go { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .card, .set-card { padding: 18px; }
  .card-flush { padding: 0; }
  .set-head { flex-wrap: wrap; row-gap: 10px; }
  .set-head > div { flex: 1 1 calc(100% - 54px); }
  .set-head .chip { margin: 0 0 0 54px; }
  .confirm-pop .confirm-box { width: min(260px, calc(100vw - 64px)); }
  .savebar { padding: 24px 0 12px; }
  .savebar .btn { width: 100%; height: 48px; }
  .savebar-in { flex-wrap: wrap; }
  .savebar-in input { flex-basis: 100%; }
  .kb-side { display: flex; align-items: stretch; }
  .editor textarea { min-height: 420px; padding: 16px; font-size: 15px; }
  .chat-list a { padding: 12px 16px; gap: 12px; }
  .thread { padding: 12px; }
  .bubble { max-width: 86%; }
  .qr-card { padding: 22px 16px 18px; border-radius: 24px; }
  .qr-steps li { padding: 12px 4px; font-size: 12px; }
  .login-card { padding: 32px 22px 24px; }
  .adv-actions .btn, .adv-actions form, .adv-actions .confirm { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
