/* CLAIRA demo: tema claro y oscuro */
/* Paleta "Claridad": grises neutros fríos, un solo azul nítido y el ámbar del logo como chispa.
   Movimiento: resortes críticamente amortiguados (sin rebote) salvo donde hay impulso del usuario. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #ededf0;
  --surface-3: #fafafc;
  --border: #e4e4e9;
  --border-strong: #d1d1d6;
  --text: #1d1d1f;
  --text-2: #3a3a3c;
  --muted: #6e6e73;
  --accent: #0a63e0;
  --accent-hover: #0a59c9;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fd;
  --accent-text: #0a59c9;
  --gold: #a14e00;
  --gold-soft: #fff3e3;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --ok-ink: #ffffff;
  --warn: #b35c00;
  --warn-soft: #fff1e0;
  --bad: #d1242f;
  --bad-soft: #fde8e9;
  --logo-bg: #0a63e0;
  --spark: #ffb224;
  --serie-actual: var(--accent);
  --serie-anterior: #8a8a90;
  --serie-meta: #d4600a;
  --material: rgba(250, 250, 252, 0.72);
  --material-fuerte: rgba(245, 245, 247, 0.82);
  --scrim: rgba(0, 0, 0, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-alto: 0 2px 6px rgba(0, 0, 0, 0.05), 0 24px 60px -12px rgba(0, 0, 0, 0.22);
  --r: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  /* Resortes (aprox. con linear()): respuesta ~0,35 s, amortiguación 1 (sin rebote) y 0,8 (con impulso) */
  --resorte: linear(0.000 0%, 0.082 6.2%, 0.243 12.5%, 0.413 18.8%, 0.562 25%, 0.682 31.2%, 0.774 37.5%, 0.841 43.8%, 0.890 50%, 0.925 56.2%, 0.949 62.5%, 0.965 68.8%, 0.977 75%, 0.984 81.2%, 0.990 87.5%, 0.993 93.8%, 1.000 100%);
  --resorte-impulso: linear(0.000 0%, 0.116 6.2%, 0.343 12.5%, 0.568 18.8%, 0.747 25%, 0.871 31.2%, 0.948 37.5%, 0.990 43.8%, 1.009 50%, 1.015 56.2%, 1.014 62.5%, 1.011 68.8%, 1.008 75%, 1.005 81.2%, 1.002 87.5%, 1.001 93.8%, 1.000 100%);
  --t-resorte: 420ms;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #161618;
  --border: #2c2c2e;
  --border-strong: #3a3a3c;
  --text: #f5f5f7;
  --text-2: #d1d1d6;
  --muted: #9a9aa1;
  --accent: #3b8cff;
  --accent-hover: #5ea2ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(59, 140, 255, 0.16);
  --accent-text: #5ea2ff;
  --gold: #ffb85c;
  --gold-soft: rgba(255, 178, 36, 0.14);
  --ok: #34c77b;
  --ok-soft: rgba(52, 199, 123, 0.14);
  --ok-ink: #04220f;
  --warn: #ffa94d;
  --warn-soft: rgba(255, 169, 77, 0.14);
  --bad: #ff6961;
  --bad-soft: rgba(255, 105, 97, 0.14);
  --logo-bg: #2f7cf6;
  --serie-anterior: #7c7c84;
  --serie-meta: #d97a22;
  --material: rgba(28, 28, 30, 0.72);
  --material-fuerte: rgba(11, 11, 13, 0.8);
  --scrim: rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-alto: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.hint { font-size: 12.5px; color: var(--muted); }
.row { display: flex; align-items: center; }
.gap { gap: 12px; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; border-right: 1px solid var(--border); background: var(--surface-3); position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.logo { width: 34px; height: 34px; }
.logo-bg { fill: var(--logo-bg); }
.brand-name { font-weight: 700; letter-spacing: 0.08em; font-size: 15px; }
.brand-org { font-size: 12px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: none; cursor: pointer; color: var(--text-2); font-weight: 500; text-align: left; min-height: 42px; }
.nav-item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.badge { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 1px 8px; }
.badge:empty { display: none; }
.nav-spacer { flex: 1; }
.nav-foot { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.modo { flex: 1; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.modo .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.modo.guion .dot { background: var(--warn); }
.theme-btn, .icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.theme-btn svg, .icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.main { flex: 1; min-width: 0; }
.vista { max-width: 1180px; margin: 0 auto; padding: 32px 36px 56px; display: flex; flex-direction: column; gap: 22px; }

/* Botones */
.btn-primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 0 18px; min-height: 44px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; min-height: 40px; font-weight: 500; cursor: pointer; }
.btn-secondary:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn-ok { background: var(--ok); color: var(--ok-ink); border: 0; border-radius: 9px; padding: 0 14px; min-height: 38px; font-weight: 600; cursor: pointer; }
.btn-ghost { background: none; border: 1px solid var(--border); border-radius: 9px; padding: 0 14px; min-height: 38px; cursor: pointer; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }

/* Inicio */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px 32px 26px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; border: 40px solid var(--accent-soft); pointer-events: none; }
.eyebrow { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.hero h1 { font-size: 30px; font-weight: 700; }
.sub { margin: 6px 0 0; color: var(--muted); }
.ask { position: relative; z-index: 1; margin-top: 20px; display: flex; gap: 10px; align-items: center; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 14px; padding: 6px 6px 6px 14px; max-width: 760px; }
.ask:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-ico { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.ask input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 15.5px; padding: 8px 0; }
.chips { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 13px; cursor: pointer; color: var(--text-2); min-height: 36px; }
.chip:hover { border-color: var(--accent); color: var(--accent-text); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.15; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.ico-box { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: none; }
.ico-box svg { width: 18px; height: 18px; fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linejoin: round; }
.attention { display: flex; flex-direction: column; gap: 10px; }
.att { display: flex; gap: 13px; align-items: center; width: 100%; text-align: left; padding: 13px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-3); cursor: pointer; }
.att:hover { border-color: var(--border-strong); }
.att .i { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none; font-weight: 700; }
.att.warn .i { background: var(--warn-soft); color: var(--warn); }
.att.bad .i { background: var(--bad-soft); color: var(--bad); }
.att.info .i { background: var(--accent-soft); color: var(--accent-text); }
.att .t { font-weight: 600; }
.att .d { font-size: 12.5px; color: var(--muted); }
.att .go { margin-left: auto; color: var(--muted); }

/* Agente */
.agente { display: flex; flex-direction: column; gap: 14px; }
.agente .panel-head { margin-bottom: 0; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.pausa { background: var(--warn-soft); color: var(--warn); }
.agente-horas { font-size: 13px; }
.slots-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.slots { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
.slots span { height: 22px; border-radius: 3px; background: var(--border); }
.slots .ok, .leyenda .ok { background: var(--ok); }
.slots .pausa, .leyenda .pausa { background: var(--warn); }
.slots .error, .leyenda .error { background: var(--bad); }
.leyenda { display: flex; gap: 14px; margin-top: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.leyenda span { display: inline-flex; align-items: center; gap: 5px; }
.leyenda i { width: 9px; height: 9px; border-radius: 2px; }
.metricas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.metrica { text-align: left; border: 1px solid var(--border); background: var(--surface-3); border-radius: 10px; padding: 11px 12px; cursor: pointer; min-height: 70px; }
.metrica:hover { border-color: var(--border-strong); }
.metrica .v { display: block; font-size: 21px; font-weight: 600; }
.metrica .l { display: block; font-size: 12.5px; color: var(--text-2); }
.metrica .s { display: block; font-size: 11.5px; color: var(--muted); }

/* Chat */
#vista-chat { min-height: 100vh; padding-bottom: 20px; }
.chat-head { display: flex; align-items: center; gap: 14px; }
.chat-head h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.04em; }
.aviso { background: var(--warn-soft); color: var(--text-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; font-size: 13px; }
.log { flex: 1; display: flex; flex-direction: column; gap: 22px; max-width: 900px; width: 100%; }
.vacio { text-align: center; padding: 56px 16px 10px; color: var(--muted); }
.vacio h2 { color: var(--text); font-size: 22px; margin-bottom: 6px; }
.vacio .chips { justify-content: center; margin-top: 18px; }
.msg-user { align-self: flex-end; max-width: 78%; background: var(--accent); color: var(--accent-ink); padding: 11px 15px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.msg-bot { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 30px; height: 30px; flex: none; }
.bot-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.trazas { display: flex; flex-wrap: wrap; gap: 6px; }
.traza { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 3px 10px; }
.traza b { color: var(--text-2); font-weight: 600; }
.texto p { margin: 0 0 8px; }
.texto p:last-child { margin-bottom: 0; }
.texto ul { margin: 0 0 8px; padding-left: 20px; }
.pensando { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.pensando i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: latido 1.2s ease-in-out infinite; }
.pensando i:nth-child(2) { animation-delay: 0.15s; } .pensando i:nth-child(3) { animation-delay: 0.3s; }
@keyframes latido { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
.descarga { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 14px; }
.descarga:hover { border-color: var(--accent); }
.descarga svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tarjeta-inline { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px 14px; }
.barras { display: flex; flex-direction: column; gap: 6px; }
.barra { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.barra .b { height: 10px; border-radius: 0 4px 4px 0; background: var(--accent); width: var(--w); transform-origin: left; animation: crece 0.6s cubic-bezier(.2,.7,.2,1) both; }
.barra span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra .n { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.composer { position: sticky; bottom: 16px; max-width: 900px; width: 100%; display: flex; gap: 10px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 10px 10px 10px 16px; box-shadow: var(--shadow); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; background: none; resize: none; outline: none; font-size: 15px; max-height: 220px; }
.send { width: 44px; height: 44px; border-radius: 11px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; }
.send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.send:disabled { opacity: 0.5; cursor: default; }

/* Tablas */
.tabla-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-3); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-3); }
.tabla-pie { font-size: 12.5px; color: var(--muted); padding: 8px 12px; border-top: 1px solid var(--border); }
.clasif { font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 7px; letter-spacing: 0.02em; }
.clasif.SUPERVIP { background: var(--gold-soft); color: var(--gold); }
.clasif.VIP { background: var(--accent-soft); color: var(--accent-text); }
.correo-bad { color: var(--bad); font-size: 12px; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; }
.filtros input, .filtros select { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 0 12px; min-height: 42px; }
.filtros input { flex: 1; min-width: 240px; }

/* Aprobaciones */
.aprob-lista { display: flex; flex-direction: column; gap: 10px; }
.aprob { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 15px 18px; }
.aprob .cuerpo { flex: 1; min-width: 260px; }
.aprob .tit { font-weight: 600; }
.aprob .det { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.aprob .mot { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.cambio-de { text-decoration: line-through; color: var(--muted); }
.cambio-a { font-weight: 600; color: var(--ok); }
.estado { font-size: 12.5px; font-weight: 600; border-radius: 999px; padding: 3px 10px; }
.estado.aprobada { background: var(--ok-soft); color: var(--ok); }
.estado.rechazada { background: var(--surface-2); color: var(--muted); }
.tag { font-size: 11.5px; border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; color: var(--muted); }

/* Ficha */
.drawer-bg { position: fixed; inset: 0; background: var(--scrim); z-index: 20; opacity: 0; pointer-events: none; transition: opacity 280ms ease; }
.drawer-bg.abierto { opacity: 1; pointer-events: auto; }
/* Ficha: entra y sale por el mismo borde; la transición CSS retoma desde el valor en pantalla, así que se puede revertir a medio camino. */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); border-left: 1px solid var(--border); z-index: 21; padding: 26px; overflow-y: auto; box-shadow: var(--shadow-alto); transform: translateX(104%); visibility: hidden; transition: transform var(--t-resorte) var(--resorte), visibility 0s linear var(--t-resorte); will-change: transform; overscroll-behavior: contain; }
.drawer.abierto { transform: none; visibility: visible; transition: transform var(--t-resorte) var(--resorte), visibility 0s; }
.drawer-asa { display: none; }
.cerrar { position: absolute; top: 18px; right: 18px; }
.ficha h2 { font-size: 21px; margin-right: 44px; }
.ficha .meta { color: var(--muted); margin-top: 4px; }
.ficha dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 18px 0; font-size: 13.5px; }
.ficha dt { color: var(--muted); }
.ficha dd { margin: 0; overflow-wrap: anywhere; }
.ficha h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 8px; }
.evento { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, calc(100% + 30px)); opacity: 0; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 13.5px; box-shadow: var(--shadow-alto); pointer-events: none; transition: transform var(--t-resorte) var(--resorte), opacity 200ms ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 20; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 2px 6px; flex: 1; }
  .brand-org { display: none; }
  .nav-item { order: 3; width: auto; flex: 1 1 0; justify-content: center; gap: 6px; padding: 8px 4px; font-size: 13px; min-height: 40px; }
  .nav-item svg { display: none; }
  .nav-spacer, .nav-foot .modo, .nav-cta { display: none; }
  .nav-foot { order: 2; border: 0; padding: 0; }
  .vista { padding: 18px 16px 40px; gap: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 22px 18px; }
  .hero::after { display: none; }
  .hero h1 { font-size: 26px; }
  .barra { grid-template-columns: 96px 1fr 34px; }
  .ask { flex-wrap: wrap; }
  .ask .btn-primary { width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .v { font-size: 24px; }
  .col-org, .col-correo { display: none; }
  .aprob .cuerpo { min-width: 0; }
  .acciones { width: 100%; justify-content: flex-end; }
  .ocultar-movil { display: none; }
  .demo-banner { padding: 8px 16px; font-size: 12.5px; }
  .flujo { grid-template-columns: 1fr; }
  .flujo-flecha svg { transform: rotate(90deg); width: 34px; }
  .fusion { grid-template-columns: 1fr; }
  .fusion .vs { display: none; }
  .composer { bottom: 10px; }
  /* En el celular la ficha es una hoja que sube desde abajo y se baja arrastrando */
  .drawer { top: auto; left: 0; width: 100%; height: min(88vh, 900px); border-left: 0; border-radius: 20px 20px 0 0; padding: 12px 20px 28px; transform: translateY(104%); }
  .drawer.abierto { transform: translateY(var(--arrastre, 0px)); }
  .drawer-asa { display: flex; justify-content: center; padding: 4px 0 14px; margin: 0 -20px; cursor: grab; touch-action: none; }
  .drawer-asa span { width: 38px; height: 5px; border-radius: 3px; background: var(--border-strong); }
  .drawer .cerrar { top: 14px; }
}
@media (prefers-reduced-motion: reduce) { .pensando i { animation: none; } }

/* --- Demo pública --- */
.nav-cta { display: block; margin: 10px 4px 12px; padding: 11px 12px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13.5px; text-align: center; text-decoration: none; line-height: 1.3; }
.nav-cta:hover { background: var(--accent-hover); }
.demo-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 9px 36px; background: var(--gold-soft); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.demo-banner a { color: var(--accent-text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.demo-banner a:hover { text-decoration: underline; }
.link { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 600; cursor: pointer; font-size: 13px; margin-top: 10px; }
.link:hover { text-decoration: underline; }

.flujo { display: grid; grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr); gap: 18px; align-items: center; }
.flujo-col { display: flex; flex-direction: column; gap: 6px; }
.fuente { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-3); font-size: 13.5px; }
.fuente b { font-family: var(--mono); font-weight: 500; }
.flujo-flecha { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.flujo-flecha svg { width: 60px; height: 12px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.flujo-res { padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); }
.flujo-res .v { font-size: 34px; font-weight: 700; color: var(--accent-text); line-height: 1.1; }
.flujo-res .l { font-weight: 600; }
.flujo-res .s { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.fusion { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 8px; }
.fusion .vs { font-size: 20px; color: var(--muted); }
.registro { border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface-3); font-size: 13px; line-height: 1.5; }

.cruce { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; max-width: 460px; }
.cruce div { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.cruce b { display: block; font-size: 22px; }
.cruce span { font-size: 12.5px; color: var(--muted); }

.sugerencias { margin-top: 14px; }
.sugerencias .chip { font-size: 12.5px; background: var(--surface-3); }
.traza { animation: entra 0.25s ease-out both; }
.aparece { animation: entra 0.35s ease-out both; }
@keyframes entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes crece { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .traza, .aparece, .barra .b { animation: none; } }

/* --- Aviso de cookies (landing y demo) --- */
.cookies { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; max-width: 560px; margin: 0 auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); font-size: 13.5px; color: var(--text-2); }
.cookies p { flex: 1 1 260px; margin: 0; }
.cookies a { color: var(--accent-text); }
.cookies-acciones { display: flex; gap: 8px; }
.cookies .btn-primary { min-height: 38px; padding: 0 16px; }
.msg-bot { scroll-margin-top: 70px; }
.aprob.tipo-fusion .cuerpo { flex-basis: 100%; }
.aprob.tipo-fusion .acciones { margin-left: auto; }
.aprob.tipo-fusion .fusion { max-width: 760px; }
.registro { overflow-wrap: anywhere; min-width: 0; }

/* Modo video: interfaz limpia para grabar */
.modo-video .demo-banner, .modo-video .nav-cta, .modo-video .cookies { display: none !important; }

/* --- Navegación con más vistas --- */
.nav-items { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 900px) {
  .nav-items { order: 3; width: 100%; flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav-items::-webkit-scrollbar { display: none; }
  .nav-items .nav-item { flex: 0 0 auto; padding: 8px 12px; }
  .sidebar .nav-cta { display: none; }
}

/* --- Tableros --- */
.kpi small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi-link { text-align: left; cursor: pointer; font: inherit; color: inherit; }
.kpi-link:hover { border-color: var(--accent); }
.delta { font-weight: 600; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.delta.sube span:first-child { color: var(--ok); }
.delta.baja span:first-child { color: var(--bad); }
.delta span:first-child { font-size: 9px; vertical-align: 1px; }
.kpis-chat { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpis-chat .kpi { padding: 14px; }
.kpis-chat .kpi .v { font-size: 22px; }
.kpis-mini { margin-bottom: 14px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; position: relative; }
.tab-ind { position: absolute; left: 0; bottom: 0; height: 2px; width: 0; border-radius: 2px; background: var(--accent); transition: transform var(--t-resorte) var(--resorte), width var(--t-resorte) var(--resorte); pointer-events: none; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: 42px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); }
.tabs:not(:has(.tab-ind)) .tab.active { border-bottom-color: var(--accent); }
#tablero { display: flex; flex-direction: column; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.grid-3 .barra, .grid-2 .barra { grid-template-columns: 118px 1fr 40px; }

.grafico-fig { margin: 0; }
.grafico-fig figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.g-tit { font-weight: 700; font-size: 15px; }
.g-leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.ley { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--serie-actual); }
.sw.anterior { background: var(--serie-anterior); }
.sw.meta { background: repeating-linear-gradient(90deg, var(--serie-meta) 0 4px, transparent 4px 7px); }
.sw.proy { background: repeating-linear-gradient(90deg, var(--serie-actual) 0 4px, transparent 4px 7px); }
.grafico { position: relative; width: 100%; }
.grafico svg { display: block; overflow: visible; }
.grafico .grid { stroke: var(--border); stroke-width: 1; }
.grafico .eje { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.grafico .linea { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafico .linea.actual { stroke: var(--serie-actual); stroke-width: 2.5; }
.grafico .linea.anterior { stroke: var(--serie-anterior); }
.grafico .linea.proy { stroke: var(--serie-actual); stroke-dasharray: 5 5; opacity: 0.8; }
.grafico .meta { stroke: var(--serie-meta); stroke-width: 1.5; stroke-dasharray: 4 4; }
.grafico .et, .grafico .et-meta { font-size: 11.5px; font-weight: 600; fill: var(--text-2); }
.grafico .punto { stroke: var(--surface); stroke-width: 2; fill: var(--serie-actual); }
.grafico .punto.anterior { fill: var(--serie-anterior); }
.grafico .guia line { stroke: var(--border-strong); stroke-width: 1; }
.grafico .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; top: 8px; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: var(--shadow); white-space: nowrap; z-index: 2; }
.tip-t { color: var(--muted); margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; }
.tip b { margin-left: auto; padding-left: 10px; font-family: var(--mono); font-weight: 500; }

.callout { display: flex; align-items: center; justify-content: space-between; gap: 14px 20px; flex-wrap: wrap; padding: 16px 20px; border-radius: 14px; background: var(--accent-soft); color: var(--text); }
.callout > div { flex: 1 1 360px; }
.estado-pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.estado-pill.ok { background: var(--ok-soft); color: var(--ok); }
.estado-pill.info { background: var(--accent-soft); color: var(--accent-text); }
.estado-pill.warn { background: var(--warn-soft); color: var(--warn); }
.estado-pill.bad { background: var(--bad-soft); color: var(--bad); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tarjeta-inline.bi { margin-top: 12px; padding: 16px; }
.tarjeta-inline.bi .tabla-wrap { border: 0; }

.score-wrap { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 14px; }
.score-wrap.compacto { grid-template-columns: 1fr; }
.score { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.compacto .score, .compacto .dims { border: 0; padding: 0; background: none; }
.score-v { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.score-v small { font-size: 20px; color: var(--muted); font-weight: 500; }
.spark { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.spark polyline { fill: none; stroke: var(--serie-actual); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dims { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.dim-h { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 6px; }
.dim-b { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.dim-b span { display: block; height: 100%; width: var(--w); background: var(--accent); border-radius: 4px; transform-origin: left; animation: crece 0.6s cubic-bezier(.2,.7,.2,1) both; }
.dim .link { margin-top: 0; font-size: 12.5px; }
.auto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.auto { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-3); }
.auto .v { font-size: 22px; font-weight: 700; }
.auto .l { font-weight: 600; font-size: 13.5px; }

/* --- Fuentes y reportes --- */
.fuentes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.fuente-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-3); }
.fuente-card.aviso { border-color: var(--warn); }
.fc-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fuente-card dl { display: grid; grid-template-columns: 82px 1fr; gap: 4px 10px; margin: 10px 0 0; font-size: 13px; }
.fuente-card dt { color: var(--muted); }
.fuente-card dd { margin: 0; }
.reportes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.reporte { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-3); }
.rep-h { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rep-prev { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--border-strong); font-size: 13px; }
.rep-prev ul { margin: 4px 0 0; padding-left: 18px; }
.solicitudes { display: flex; flex-direction: column; }
.sol { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.sol .tag { justify-self: start; }

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .score-wrap { grid-template-columns: 1fr; }
  .sol { grid-template-columns: 1fr; gap: 4px; }
  .reportes { grid-template-columns: 1fr; }
  .callout .btn-primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .dim-b span { animation: none; } }
.att { text-align: left; }
.nowrap { white-space: nowrap; }

/* --- Hallazgos --- */
.hallazgos { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.hallazgos-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hallazgos-chat { margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.hz { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.hz-riesgo { border-left-color: var(--warn); }
.hz-tendencia, .hz-patron { border-left-color: var(--muted); }
.hz-oportunidad { border-left-color: var(--ok); }
.hz-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.hz-tipo { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.hz-oportunidad .hz-tipo span { color: var(--ok); }
.hz-riesgo .hz-tipo span { color: var(--warn); }
.hz-cruce { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.hz h3 { font-size: 15.5px; line-height: 1.35; }
.hz-cifra { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hz-cifra b { font-size: 26px; letter-spacing: -0.02em; }
.hz-cifra span { font-size: 12.5px; color: var(--muted); }
.hz p { margin: 0; color: var(--text-2); font-size: 13.5px; }
.hz .barras { margin-top: 2px; }
.hz .barra { grid-template-columns: 120px 1fr 54px; }
.hz-comp { display: flex; flex-direction: column; gap: 6px; }
.hz-c { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }
.hz-c b { font-family: var(--mono); font-weight: 500; font-size: 12.5px; text-align: right; }
.hz-b { height: 10px; border-radius: 0 4px 4px 0; background: var(--accent); width: var(--w); animation: crece 0.6s cubic-bezier(.2,.7,.2,1) both; transform-origin: left; }
.hz-b.otro { background: var(--serie-anterior); }
.hz-accion { margin-top: auto; padding-top: 4px; text-align: left; }
.hz-filtros { display: flex; gap: 8px; flex-wrap: wrap; }
.chip.activo { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
@media (max-width: 900px) {
  .hallazgos, .hallazgos-3 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .hz-b { animation: none; } }
.tabla-wrap + .tabla-wrap { margin-top: 12px; }


/* --- Principios de diseño de Apple aplicados a la web --- */
/* Tipografía: fuente del sistema con tamaño óptico; tracking según tamaño (negativo en títulos, levemente positivo en texto chico). */
body { font-optical-sizing: auto; letter-spacing: -0.003em; text-rendering: optimizeLegibility; }
h1, h2 { letter-spacing: -0.022em; }
h3 { letter-spacing: -0.012em; }
.hint, .kpi .l, .kpi .s, .hz-tipo, .eyebrow, .tag, .estado-pill, th { letter-spacing: 0.005em; }
.kpi .v, .score-v, .hz-cifra b, .auto .v { letter-spacing: -0.028em; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Respuesta: feedback en el momento de presionar, no al soltar. */
button, a, .chip, .kpi-link, .att, .metrica, .nav-item, .tab, .fuente-card { -webkit-tap-highlight-color: transparent; }
.btn-primary, .btn-secondary, .btn-ok, .btn-ghost, .chip, .send, .theme-btn, .icon-btn, .nav-cta, .tab, .link, .descarga { transition: transform 120ms ease-out, background-color 150ms ease, border-color 150ms ease, color 150ms ease; }
.btn-primary:active, .btn-secondary:active, .btn-ok:active, .btn-ghost:active, .chip:active, .send:active, .theme-btn:active, .icon-btn:active, .nav-cta:active, .descarga:active { transform: scale(0.96); transition-duration: 60ms; }
.kpi-link, .att, .metrica, .nav-item, .hz { transition: transform 160ms ease-out, border-color 150ms ease, background-color 150ms ease, box-shadow 200ms ease; }
.kpi-link:active, .att:active, .metrica:active, .nav-item:active { transform: scale(0.985); transition-duration: 60ms; }
.kpi-link:hover, .hz:hover { box-shadow: var(--shadow); }

/* Materiales: barras flotantes translúcidas, el contenido pasa por debajo. */
.composer { background: var(--material); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border-color: var(--border); box-shadow: var(--shadow-alto); }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-alto), 0 0 0 3px var(--accent-soft); }
.sidebar { background: var(--surface-3); }
@media (max-width: 900px) {
  .sidebar { background: var(--material-fuerte); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border-bottom-color: transparent; transition: border-color 200ms ease, box-shadow 200ms ease; }
  .con-scroll .sidebar { border-bottom-color: var(--border); box-shadow: 0 8px 20px -16px rgba(0, 0, 0, 0.35); }
}
.cookies { background: var(--material); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); box-shadow: var(--shadow-alto); }
.tip { background: var(--material); -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%); }

/* Contenido que aparece: llega con un resorte corto, sin rebote. */
.aparece { animation: entra 360ms var(--resorte) both; }
.vista:not(.hidden) { animation: entra 320ms var(--resorte) both; }

/* Cambio de tema suave: sin saltos bruscos de brillo. */
html.cambio-tema, html.cambio-tema * { transition: background-color 320ms ease, color 320ms ease, border-color 320ms ease, fill 320ms ease, stroke 320ms ease !important; }

/* Accesibilidad: menos movimiento, menos transparencia, más contraste. */
@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.abierto, .toast, .tab-ind { transition: opacity 200ms ease, visibility 0s !important; }
  .drawer:not(.abierto) { opacity: 0; }
  .vista:not(.hidden), .aparece { animation: none; }
  .btn-primary:active, .btn-secondary:active, .chip:active, .kpi-link:active, .att:active, .nav-item:active, .send:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .composer, .cookies, .tip, .sidebar { background: var(--surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
@media (prefers-contrast: more) {
  :root { --border: #b8b8bf; --border-strong: #8e8e93; --muted: #4a4a4f; }
  :root[data-theme="dark"] { --border: #5a5a60; --border-strong: #7c7c84; --muted: #c7c7cc; }
  .composer, .cookies, .tip { background: var(--surface); }
}
