/* LinkTech AaaS — Sistema de diseño 2026
   Una sola hoja para el panel y las páginas legales. Sin Tailwind, sin CDN.
   Temas: html[data-theme="light"|"dark"]. El script de <head> lo fija antes de pintar. */

@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/static/fonts/jk-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(/static/fonts/jk-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --rail-w: 248px; --rail-w-min: 68px; --top-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;

  /* Claro: papel azulado, tinta navy */
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --inset: #EDF1F7;
  --line: #DCE2EC;
  --line-strong: #C4CDDB;
  --text: #0E1A33;
  --text-2: #3B4A66;
  --muted: #5B6A85;
  --accent: #4338CA;
  --accent-hover: #3730A3;
  --accent-soft: #E9E8FB;
  --accent-text: #4338CA;
  --on-accent: #FFFFFF;
  --cyan: #0E7490;
  --ok: #047857;   --ok-soft: #DDF5EA;
  --warn: #92400E; --warn-soft: #FDEFD3;
  --bad: #B91C1C;  --bad-soft: #FBE1E1;
  --rail-bg: #0E1A33;
  --rail-text: #C9D3E6;
  --rail-muted: #8593AE;
  --rail-hover: rgba(255,255,255,.07);
  --rail-active: rgba(129,140,248,.2);
  --rail-line: rgba(255,255,255,.09);
  --shadow: 0 1px 2px rgba(14,26,51,.06), 0 1px 1px rgba(14,26,51,.04);
  --shadow-pop: 0 18px 40px -12px rgba(14,26,51,.28), 0 4px 10px rgba(14,26,51,.08);
  --focus: #4F46E5;
}
html[data-theme="dark"] {
  color-scheme: dark;
  /* Oscuro: el navy de linktech-academy.com */
  --bg: #0B0F19;
  --surface: #121826;
  --surface-2: #161D2E;
  --inset: #0E1421;
  --line: #222C42;
  --line-strong: #31405E;
  --text: #E8ECF5;
  --text-2: #BCC6DB;
  --muted: #8C9AB5;
  --accent: #7C83FF;
  --accent-hover: #9AA0FF;
  --accent-soft: #1E2240;
  --accent-text: #A5AAFF;
  --on-accent: #0B0F19;
  --cyan: #38D0EE;
  --ok: #3DD9A0;   --ok-soft: #0E2A25;
  --warn: #F2B84B; --warn-soft: #30250E;
  --bad: #FF8A8A;  --bad-soft: #341517;
  --rail-bg: #0E1320;
  --rail-text: #C2CCE0;
  --rail-muted: #7D8BA8;
  --rail-hover: rgba(255,255,255,.06);
  --rail-active: rgba(124,131,255,.18);
  --rail-line: rgba(255,255,255,.07);
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --shadow-pop: 0 20px 44px -12px rgba(0,0,0,.65), 0 4px 10px rgba(0,0,0,.3);
  --focus: #A5AAFF;
}

/* ---------- Base ---------- */
.ds *, .ds *::before, .ds *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ds {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}
.ds h1, .ds h2, .ds h3, .ds h4, .ds p, .ds ul, .ds ol, .ds dl, .ds figure { margin: 0; }
.ds h1, .ds h2, .ds h3 { text-wrap: balance; letter-spacing: -.012em; }
.ds p { text-wrap: pretty; }
:where(.ds) a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:where(.ds) a:hover { color: var(--accent-hover); }
.ds :where(button, input, select, textarea) { font: inherit; color: inherit; }
.ds :where(button) { cursor: pointer; }
.ds :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.ds ::selection { background: var(--accent); color: var(--on-accent); }
.ds svg, .ds img { display: block; max-width: 100%; }
.ds [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 200; background: var(--accent); color: var(--on-accent) !important;
  padding: 8px 14px; border-radius: var(--r-sm); font-weight: 600; text-decoration: none; transition: top .15s; }
.skip-link:focus { top: 12px; }
.ds ::-webkit-scrollbar { width: 10px; height: 10px; }
.ds ::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
.ds ::-webkit-scrollbar-track { background: transparent; }

/* ---------- Iconos (Font Awesome autoalojado) ---------- */
.ic { width: 1.25em; text-align: center; flex: none; }

/* ---------- Botones ---------- */
.btn, .btn:hover { text-decoration: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 13px; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .1s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--inset); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Selector de tema: tres opciones, una activa */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--inset); }
.seg button { width: 32px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow); }

/* ---------- Estado ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.dot.live { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); animation: ping 2.2s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent); } 80%, 100% { box-shadow: 0 0 0 8px transparent; } }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--inset); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.badge.ok .dot { background: var(--ok); } .badge.warn .dot { background: var(--warn); } .badge.bad .dot { background: var(--bad); }

/* ---------- Estructura de la aplicación ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .25s var(--ease); }
.app[data-rail="min"] { grid-template-columns: var(--rail-w-min) minmax(0, 1fr); }

.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--rail-bg); color: var(--rail-text);
  border-right: 1px solid var(--rail-line); z-index: 60; overflow: hidden; }
.rail-brand { display: flex; align-items: center; gap: 12px; height: var(--top-h); padding: 0 16px; border-bottom: 1px solid var(--rail-line); flex: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, #6366F1, #06B6D4); }
.brand-name { font-weight: 800; font-size: 15px; color: #fff; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.brand-sub { font-size: 11.5px; color: var(--rail-muted); white-space: nowrap; }
.rail-scroll { flex: 1; overflow-y: auto; padding: 14px 10px; scrollbar-width: thin; scrollbar-color: var(--rail-line) transparent; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title { padding: 0 10px 6px; font-size: 12px; font-weight: 600; color: var(--rail-muted); white-space: nowrap; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--rail-text); text-decoration: none !important; font-size: 13.5px; font-weight: 500; text-align: left; white-space: nowrap; }
.nav-item .ic { font-size: 15px; color: var(--rail-muted); transition: color .15s; }
.nav-item:hover { background: var(--rail-hover); color: #fff !important; }
.nav-item:hover .ic { color: #fff; }
.nav-item[aria-current="page"] { background: var(--rail-active); color: #fff !important; font-weight: 700; }
.nav-item[aria-current="page"] .ic { color: #A5B4FC; }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #818CF8; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-count { min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--rail-hover); color: var(--rail-text); font-size: 11.5px; font-weight: 700; text-align: center; }
.nav-count.alert { background: #B91C1C; color: #fff; }
.rail-foot { flex: none; padding: 10px; border-top: 1px solid var(--rail-line); display: grid; gap: 6px; }
.rail-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); background: var(--rail-hover); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--rail-active); color: #C7D2FE; font-weight: 700; font-size: 12.5px; flex: none; }
.rail-user-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.rail-user-role { font-size: 11.5px; color: var(--rail-muted); }
.rail-collapse { display: flex; }
.rail-theme { display: none; align-items: center; justify-content: space-between; padding: 4px 10px; color: var(--rail-muted); font-size: 12.5px; }
.rail-theme .seg { background: rgba(255,255,255,.06); border-color: var(--rail-line); }
.rail-theme .seg button { color: var(--rail-muted); }
.rail-theme .seg button[aria-pressed="true"] { background: var(--rail-active); color: #fff; box-shadow: none; }

/* Rail compacto (solo iconos) */
.app[data-rail="min"] .nav-text, .app[data-rail="min"] .nav-count, .app[data-rail="min"] .nav-title, .app[data-rail="min"] .brand-text,
.app[data-rail="min"] .rail-user > div:not(.avatar) { display: none; }
.app[data-rail="min"] .nav-item { justify-content: center; padding: 0; }
.app[data-rail="min"] .rail-brand { justify-content: center; padding: 0; }
.app[data-rail="min"] .nav-group + .nav-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--rail-line); }
.app[data-rail="min"] .rail-user { justify-content: center; padding: 6px; }
.app[data-rail="min"] .nav-item[aria-current="page"]::before { left: -10px; }
.app[data-rail="min"] .nav-item:hover::after, .app[data-rail="min"] .nav-item:focus-visible::after {
  content: attr(data-label); position: fixed; left: calc(var(--rail-w-min) + 6px); padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-pop); pointer-events: none; z-index: 80; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.top-title { min-width: 0; flex: 0 1 auto; }
.top-title h1 { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-sep { width: 1px; height: 24px; background: var(--line); }
.menu-btn { display: none; }

.workspace-select { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--muted); }
.workspace-select select { border: 0; background: transparent; height: 32px; padding: 0 6px; font-weight: 600; font-size: 13px; color: var(--text); max-width: 200px; text-overflow: ellipsis; }
.workspace-select select:focus-visible { outline-offset: 4px; }

.page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 24px 48px; display: grid; gap: 24px; flex: 1; align-content: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.page-head p { margin-top: 6px; color: var(--muted); max-width: 62ch; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-head h3 .ic { color: var(--accent-text); }
.panel-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

/* ---------- Indicadores (una sola franja, no cuatro tarjetas) ---------- */
.vitals { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; background: var(--line); overflow: hidden; border-radius: var(--r-lg); }
.vital { padding: 18px 20px; display: grid; gap: 2px; align-content: start; background: var(--surface); }
.vital-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.vital-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.vital-note { font-size: 12px; color: var(--muted); }
.vital-value.bad { color: var(--bad); } .vital-value.ok { color: var(--ok); } .vital-value.warn { color: var(--warn); }

/* ---------- Tablero de agentes ---------- */
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.roster { list-style: none; margin: 0; padding: 0; }
.agent-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 150px 130px; align-items: center; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line); }
.agent-row:first-child { border-top: 0; }
.roster-group { padding: 10px 20px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--line); }
.roster-group:first-child { border-top: 0; }
.agent-row:hover { background: var(--surface-2); }
.agent-ico { width: 40px; height: 40px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--inset); color: var(--accent-text); font-size: 17px; border: 1px solid var(--line); }
.agent-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.agent-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.agent-state { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; min-width: 0; }
.agent-state span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-act { display: flex; justify-content: flex-end; }

/* ---------- Supervisor ---------- */
.sup-numbers { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); }
.sup-numbers > div { padding: 10px 12px; }
.sup-numbers > div + div { border-left: 1px solid var(--line); }
.sup-numbers b { display: block; font-size: 22px; font-weight: 800; line-height: 1.2; }
.sup-numbers span { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }
.chip.ok .dot { background: var(--ok); } .chip.warning .dot, .chip.high .dot { background: var(--warn); } .chip.critical .dot, .chip.error .dot { background: var(--bad); }
.chip.warning, .chip.high { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.chip.critical, .chip.error { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.incidents { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.incident { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.incident p { min-width: 0; }
.incident .t { font-weight: 600; font-size: 13px; }
.incident .m { font-size: 12px; color: var(--muted); }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.note { font-size: 12.5px; color: var(--muted); }
.note.ok { color: var(--ok); }

/* ---------- Conexión de WhatsApp ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; counter-increment: step; }
.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; font-size: 13px; }
.steps .btn { width: 100%; justify-content: flex-start; }
.scan { position: relative; min-height: 220px; display: grid; place-items: center; text-align: center; padding: 22px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: var(--inset); }
.scan img { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: var(--r-md); }
.pair-code { font-size: 28px; font-weight: 800; letter-spacing: .22em; padding: 8px 18px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn); display: inline-block; margin: 8px 0; }
.ring-flash { animation: flash 1.8s var(--ease); }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* ---------- Simulador de chat ---------- */
.chat { display: flex; flex-direction: column; height: 560px; }
.chat-stream { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--inset); }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg.me { justify-content: flex-end; }
.msg-av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--line); }
.bubble { max-width: min(78%, 62ch); padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); line-height: 1.55; overflow-wrap: anywhere; }
.msg.ai .bubble { border-top-left-radius: 4px; }
.msg.me .bubble { background: var(--accent); border-color: var(--accent); color: var(--on-accent); border-top-right-radius: 4px; }
.bubble-meta { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bubble-meta a { padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-strong); text-decoration: none; }
.chat-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); align-items: center; }
.chat-tools .note { margin-right: auto; }
.chat-form { display: flex; gap: 8px; padding: 12px 20px 16px; }
.input { width: 100%; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); }
.input::placeholder { color: var(--muted); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bob 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Listas y tablas ---------- */
.course-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.course-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--line); font-size: 13px; }
.course-list li:first-child { border-top: 0; }
.table-wrap { overflow: auto; max-height: 320px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 20px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 20px; border-top: 1px solid var(--line); vertical-align: top; }
.table tbody tr:first-child td { border-top: 0; }
.table td.when { color: var(--muted); white-space: nowrap; font-size: 12.5px; }
.tag { padding: 2px 8px; border-radius: var(--r-sm); background: var(--inset); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Avisos emergentes ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 13px; animation: rise .25s var(--ease); }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
html[data-theme="dark"] .toast.ok, html[data-theme="dark"] .toast.bad { color: #0B0F19; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .75; padding: 0 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Pie ---------- */
.foot { border-top: 1px solid var(--line); padding: 20px 24px; color: var(--muted); font-size: 12.5px; }
.foot-in { max-width: 1320px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot a, .foot .link-btn { color: var(--text-2); font-weight: 500; text-decoration: none; }
.foot a:hover, .foot .link-btn:hover { color: var(--accent-text); text-decoration: underline; }
.foot a[aria-current="page"] { color: var(--accent-text); font-weight: 700; }

/* ---------- Páginas de documentos (legal, manual, FAQ) ---------- */
.doc-top { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.doc-brand { display: flex; align-items: center; gap: 10px; color: var(--text) !important; font-weight: 800; letter-spacing: -.02em; text-decoration: none !important; }
.doc-brand .brand-mark { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
.doc-wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 36px 24px 56px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; flex: 1; align-items: start; }
.doc-nav { position: sticky; top: calc(var(--top-h) + 24px); display: grid; gap: 2px; }
.doc-nav h2 { font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 0 10px 6px; }
.doc-nav a { display: block; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.doc-nav a:hover { background: var(--inset); color: var(--text); }
.doc-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 700; }
.doc-nav .sep { height: 1px; background: var(--line); margin: 10px 0; }
.doc-head { padding-bottom: 20px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.doc-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.doc-head p { margin-top: 8px; color: var(--muted); font-size: 13px; }
.prose { max-width: 70ch; font-size: 15px; line-height: 1.7; color: var(--text-2); }
.prose h2 { font-size: 20px; font-weight: 800; color: var(--text); margin: 36px 0 10px; scroll-margin-top: 80px; }
.prose h3 { font-size: 16px; font-weight: 700; color: var(--text); margin: 24px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }
.prose .table-wrap { max-height: none; border: 1px solid var(--line); border-radius: var(--r-md); margin: 6px 0 18px; }
.prose .table th, .prose .table td { padding: 10px 14px; }
.prose code, .kbd { padding: 1px 6px; border-radius: 5px; background: var(--inset); border: 1px solid var(--line); font: 600 .88em ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text); }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); background: var(--accent-soft); color: var(--text); margin: 0 0 18px; font-size: 14px; }
.callout .ic { color: var(--accent-text); margin-top: 3px; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); } .callout.warn .ic { color: var(--warn); }
.toc-inline { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }
.toc-inline a { padding: 4px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; text-decoration: none; color: var(--text-2); background: var(--surface); }
.toc-inline a:hover { border-color: var(--accent); color: var(--accent-text); }
.faq details { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 14px 18px; font-weight: 700; color: var(--text); list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "\f078"; font: 900 11px "Font Awesome 6 Free"; color: var(--muted); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(180deg); }
.faq details p { padding: 0 18px 16px; margin: 0; }
.release { padding-left: 20px; border-left: 2px solid var(--line-strong); margin: 0 0 28px; position: relative; }
.release::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.release h2 { margin-top: 0; }
.release time { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.manual-step { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.manual-step > b { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 800; }

/* ---------- Adaptación ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(5, 9, 20, .6); z-index: 55; backdrop-filter: blur(2px); }
@media (max-width: 1180px) {
  .grid-main, .split { grid-template-columns: minmax(0, 1fr); }
  .vitals:not([data-n="2"]) { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vitals:not([data-n="2"]) .vital:last-child:nth-child(3n+1) { grid-column: 1 / -1; }
  .vitals:not([data-n="2"]) .vital:last-child:nth-child(3n+2) { grid-column: span 2; }
}
@media (max-width: 1023px) {
  .app, .app[data-rail="min"] { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-pop); }
  .app[data-drawer="open"] .rail { transform: none; }
  .app[data-rail="min"] .nav-text, .app[data-rail="min"] .nav-count, .app[data-rail="min"] .nav-title, .app[data-rail="min"] .brand-text, .app[data-rail="min"] .rail-user > div:not(.avatar) { display: revert; }
  .app[data-rail="min"] .nav-item { justify-content: flex-start; padding: 0 10px; }
  .app[data-rail="min"] .nav-item::after { display: none !important; }
  .rail-collapse { display: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 10px; }
  .top-title p, .workspace-select .lbl { display: none; }
  .badge .wa-lbl { display: none; }
  .page { padding: 20px 14px 40px; }
  .doc-wrap { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px 16px 40px; }
  .doc-nav { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .doc-nav h2, .doc-nav .sep { display: none; }
}
@media (max-width: 520px) {
  .top-title { display: none; }
  .top-spacer { flex: 1; }
}
@media (max-width: 760px) {
  .vitals:not([data-n="2"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vitals:not([data-n="2"]) .vital:last-child:nth-child(n) { grid-column: auto; }
  .vitals:not([data-n="2"]) .vital:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .top-actions .seg, .top-actions .help-link { display: none; }
  .rail-theme { display: flex !important; }
  .agent-row { grid-template-columns: 40px minmax(0, 1fr) auto; row-gap: 8px; }
  .agent-state { grid-column: 2 / 3; grid-row: 2; }
  .agent-act { grid-column: 3; grid-row: 1; }
  .top-actions .hide-sm, .top-sep { display: none; }
  .workspace-select select { max-width: 150px; }
  .page-head h2 { font-size: 22px; }
  .chat { height: 520px; }
  .bubble { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  .ds *, .ds *::before, .ds *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print { .rail, .topbar, .doc-top, .foot, .doc-nav, .cc-root { display: none !important; } .app { display: block; } body.ds { background: #fff; color: #000; } }

/* ---------- Páginas a pantalla completa (bandeja) ---------- */
.page.page-fill { max-width: none; height: calc(100vh - var(--top-h)); min-height: 560px; padding: 16px 20px; flex: none; }
.page.page-fill + .foot { margin-top: 0; }
.inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 300px; gap: 16px; min-height: 0; height: 100%; }
.inbox > .panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pane-title { font-size: 13.5px; font-weight: 700; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex: none; }
.pane-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.thread { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; background: transparent; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--accent-soft); border-left-color: var(--accent); }
.thread-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.thread-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; gap: 8px; }
.ib-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--inset); }
.ib-row { display: flex; }
.ib-row.out { justify-content: flex-end; }
.ib-bubble { max-width: min(75%, 60ch); padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.ib-text { white-space: pre-wrap; }
.ib-row.out .ib-bubble { border-radius: 14px 14px 4px 14px; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.ib-row.out.op .ib-bubble { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ib-who { font-size: 12px; font-weight: 700; color: var(--accent-text); margin-bottom: 2px; }
.ib-row.op .ib-who, .ib-row.op .ib-time { color: inherit; opacity: .85; }
.ib-time { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.composer { padding: 12px 14px; border-top: 1px solid var(--line); flex: none; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; padding: 10px 14px; min-height: 64px; line-height: 1.45; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; text-align: right; }
.hint { margin-top: 14px; padding: 12px; border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); font-size: 13px; }
.hint b { display: block; font-size: 12.5px; color: var(--accent-text); margin-bottom: 2px; }
.mini-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); margin-top: 8px; font-size: 13px; }
@media (max-width: 1180px) {
  .page.page-fill { height: auto; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: auto; }
  .inbox > .panel:nth-child(1) { height: 280px; }
  .inbox > .panel:nth-child(2) { height: 70vh; min-height: 460px; }
}

/* ---------- Formularios, barras de herramientas y diálogos ---------- */
.ds .hidden { display: none !important; }
.field { display: grid; gap: 6px; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-all { grid-column: 1 / -1; }
.ds select.input { padding-right: 10px; }
.ds textarea.input { padding: 10px 14px; line-height: 1.5; resize: vertical; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.search .input { padding-left: 36px; }
.modal { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; background: rgba(5, 9, 20, .62); backdrop-filter: blur(2px); }
.modal-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.table .num { text-align: right; white-space: nowrap; }
.table td .cell-link { color: inherit; text-decoration: none; font-weight: 600; }
.table td .cell-link:hover { color: var(--accent-text); text-decoration: underline; }
.table th.act, .table td.act { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.table-scroll .table th { position: static; }
.badge.neutral { background: var(--inset); }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); overflow: hidden; border-radius: var(--r-lg); }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); } .kpi-row { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Utilidades de páginas internas ---------- */
.seg.text button { width: auto; padding: 0 12px; font-weight: 600; font-size: 12.5px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card-item { padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); display: flex; flex-direction: column; gap: 10px; justify-content: space-between; }
.card-item h4 { font-size: 14.5px; font-weight: 700; }
.stat { padding: 16px 20px; display: grid; gap: 2px; }
.stat .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; color: var(--text-2); }
.muted { color: var(--muted); }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Diálogos nativos, listas de definición y verificaciones ---------- */
.ds dialog { max-width: 900px; width: calc(100% - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-pop); }
.ds dialog::backdrop { background: rgba(5, 9, 20, .62); }
.ds dialog h2 { font-size: 18px; font-weight: 800; }
.ds dialog h3 { font-size: 14px; font-weight: 800; margin: 18px 0 6px; }
dl.cfg { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 18px; margin: 0; font-size: 13.5px; }
dl.cfg dt { color: var(--muted); }
dl.cfg dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.checklist li:last-child { border-bottom: 0; }
.checklist li b { min-width: 9.5rem; }
.checklist li .note { flex: 1 1 16rem; min-width: 0; overflow-wrap: anywhere; }
.vitals.sm .vital-value { font-size: 20px; overflow-wrap: anywhere; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus-visible td { background: var(--surface-2); }
.bubble.customer { background: var(--inset); }
.bubble.agent { background: var(--accent-soft); margin-left: auto; }
.bubble small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }

/* ---------- Medidores ---------- */
.meter { height: 10px; border-radius: 99px; background: var(--inset); border: 1px solid var(--line); overflow: hidden; }
.meter > div { height: 100%; border-radius: 99px; background: var(--accent); transition: width .5s var(--ease); }

/* ---------- Interruptor ---------- */
.switch { position: relative; flex: none; width: 44px; height: 26px; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.toggle-row b { display: block; font-size: 13.5px; }
.tg-msg { padding: 14px 16px; border-left: 3px solid var(--cyan); border-radius: var(--r-md); background: var(--inset); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); line-height: 1.6; overflow-wrap: anywhere; }
.tg-msg + .tg-msg { margin-top: 10px; }
.tg-msg .tg-meta { font-size: 12px; font-weight: 700; color: var(--accent-text); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Pestañas con subrayado ---------- */
.tablist { display: flex; gap: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tablist button { background: transparent; border: 0; border-bottom: 3px solid transparent; color: var(--muted); min-height: 42px; padding: 0 14px; white-space: nowrap; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.tablist button:hover { color: var(--text); }
.tablist button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.copy-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); white-space: pre-line; line-height: 1.6; font-size: 13px; overflow-wrap: anywhere; max-height: 280px; overflow-y: auto; }
.copy-box.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.post-card { padding: 22px; display: grid; gap: 18px; }
