/* =====================================================================
   Web de la demo · Analytica de Negocios
   Estructura de plataforma (como el Board Dashboard de CEBOL): menú lateral de hojas,
   barra superior con la corrida, filtros globales y cada hoja como una página de análisis.
   Identidad ADN: navy, verde agua, Fraunces para títulos e Inter para el resto.
   ===================================================================== */
:root {
  --primary: #0B1F3A; --muted: #5b6b80; --accent: #0F766E; --accent-2: #2DD4BF;
  --positive: #1E7B4F; --negative: #B23A2A; --warning: #9A6A00; --neutral: #8A97A8;
  --background: #F3F5F8; --panel: #FFFFFF; --text: #0B1F3A; --line: #DDE4ED; --soft: #EBEFF4;
  --real: #0B1F3A; --budget: #0F766E; --ly: #8A97A8;
  --posbg: #E3F1E9; --negbg: #F7E3DF; --warnbg: #F6EDD3;
  --side: #0B1F3A; --side-2: #12294A; --side-ink: #E6EDF5; --side-mute: rgba(230, 237, 245, 0.58); --sidew: 268px;
  --f-disp: "Fraunces", Georgia, "Times New Roman", serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--background); color: var(--text); font-family: var(--f-body); font-size: 13.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eyb { display: block; font-size: 10.5px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.up { color: var(--positive); } .dn { color: var(--negative); } .flat { color: var(--muted); }

/* ---------- Aplicación: menú lateral + área de trabajo ---------- */
body[data-acceso="pendiente"] .app { display: none; }
.app { display: grid; grid-template-columns: var(--sidew) minmax(0, 1fr); min-height: 100vh;
  /* La columna de la barra queda azul de punta a punta, aunque la hoja sea más larga que la pantalla. */
  background: linear-gradient(to right, var(--side) calc(var(--sidew) - 3px), var(--accent-2) calc(var(--sidew) - 3px), var(--accent-2) var(--sidew), transparent var(--sidew)); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; gap: 18px; padding: 22px 14px 18px; border-right: 3px solid var(--accent-2); scrollbar-width: thin; }
.sbrand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.sbrand svg { width: 20px; height: 38px; flex: none; }
.sbrand b { display: block; font-family: var(--f-disp); font-weight: 500; font-size: 17px; line-height: 1.1; }
.sbrand small { display: block; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--side-mute); margin-top: 3px; }
.side .eyb { color: var(--side-mute); padding: 0 10px; }
.sclient { display: grid; gap: 3px; padding: 12px 10px; border-radius: 8px; background: var(--side-2); }
.sclient b { font-family: var(--f-disp); font-weight: 500; font-size: 15px; line-height: 1.2; }
.sclient span:last-child { font-size: 12px; color: var(--side-mute); }
nav.hojas { display: grid; gap: 2px; margin-top: -8px; }
nav.hojas button { display: grid; grid-template-columns: 26px 1fr; column-gap: 6px; text-align: left; font: 500 13px/1.3 var(--f-body); color: var(--side-ink); opacity: 0.8; background: none; border: 0; border-left: 3px solid transparent; border-radius: 0 7px 7px 0; padding: 8px 10px 8px 9px; cursor: pointer; }
nav.hojas button b { grid-row: span 2; font-weight: 600; color: var(--side-mute); font-variant-numeric: tabular-nums; }
nav.hojas button small { grid-column: 2; font-size: 11.5px; font-weight: 400; color: var(--side-mute); margin-top: 2px; }
nav.hojas button:hover { opacity: 1; background: var(--side-2); }
nav.hojas button[aria-current="true"] { opacity: 1; background: var(--side-2); border-left-color: var(--accent-2); color: #fff; }
nav.hojas button[aria-current="true"] b { color: var(--accent-2); }
nav.hojas button.pendiente { opacity: 0.5; }
.slegend { margin-top: auto; display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid rgba(230, 237, 245, 0.12); }
.spill { display: flex; gap: 7px; align-items: flex-start; font-size: 11px; line-height: 1.35; padding: 5px 8px; border-radius: 6px; background: var(--side-2); color: var(--side-ink); }
.spill i { flex: none; width: 8px; height: 8px; border-radius: 2px; margin-top: 3px; background: var(--c, var(--accent-2)); }
.spill.warn { background: rgba(230, 191, 99, 0.14); color: #E6BF63; }
.side .salir { background: none; border: 1px solid rgba(230, 237, 245, 0.22); color: var(--side-ink); border-radius: 6px; padding: 6px; font: 500 12px var(--f-body); cursor: pointer; }

.work { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 28px; }
.tb { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: flex-end; justify-content: space-between; }
.tbt { font-family: var(--f-disp); font-weight: 500; font-size: 20px; }
.tbt i { font-style: normal; color: var(--muted); font-size: 0.8em; }
.tbs { font-size: 12px; color: var(--muted); }

/* ---------- Filtros globales ---------- */
.filtros { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); padding: 8px 28px; }
.frow { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.fg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 500; background: var(--background); border: 1px solid var(--line); border-radius: 8px; padding: 3px 4px 3px 9px; }
.fg.off { opacity: 0.4; pointer-events: none; }
.seg { display: inline-flex; border-radius: 7px; overflow: hidden; background: var(--panel); }
.seg button { font: 500 12px var(--f-body); color: var(--muted); background: none; border: 0; padding: 5px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.fg select { font: 500 12.5px var(--f-body); color: var(--text); background: var(--panel); border: 0; border-radius: 7px; padding: 5px 8px; }
.dq { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: 500 12px var(--f-body); color: var(--warning); background: var(--warnbg); border: 0; border-radius: 999px; padding: 4px 10px; cursor: pointer; }

/* ---------- Hoja ---------- */
main { width: 100%; padding: 24px 28px 40px; }
.hoja { display: grid; gap: 14px; }
.shead { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
.q { font-family: var(--f-disp); font-weight: 500; font-size: clamp(22px, 2.6vw, 30px); letter-spacing: -0.01em; text-wrap: balance; }
.q small { display: block; font-family: var(--f-body); font-size: 10.5px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.ctx { color: var(--muted); font-size: 12.5px; }
.conclusion { font-family: var(--f-disp); font-size: 18px; line-height: 1.35; margin: -4px 0 0; max-width: 110ch; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g2, .g3, .g12, .g21 { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.card h3 { font-size: 13.5px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: space-between; align-items: baseline; }
.card h3 span { font-weight: 400; color: var(--muted); font-size: 12px; }
.fuente { font-size: 11px; color: var(--muted); margin: 0; }
.aviso { color: var(--warning); font-size: 13px; }
.vacia { border: 1px dashed var(--line); border-radius: 8px; padding: 40px; text-align: center; color: var(--muted); font-size: 14px; background: var(--panel); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--panel); padding: 13px 15px; display: grid; gap: 3px; align-content: start; position: relative; }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--st, transparent); }
.kpi .lb { font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.kpi .v { font-family: var(--f-disp); font-weight: 600; font-size: 27px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .cmp { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi .d { font-weight: 600; }

/* Mensajes clave */
.msgs { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.msgs li { display: grid; grid-template-columns: 6px 1fr; gap: 10px; font-size: 13.5px; }
.msgs li::before { content: ""; border-radius: 3px; background: var(--c, var(--accent)); }
.msgs b { font-weight: 600; }

/* Gráficos de Chart.js */
.chart { position: relative; height: 280px; min-width: 0; }
.chart.t { height: 340px; } .chart.s { height: 220px; } .chart.xs { height: 170px; }
.key { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { width: 11px; height: 11px; border-radius: 2px; background: var(--c); }
.key i.l { height: 0; width: 16px; border-top: 2.5px solid var(--c); border-radius: 0; background: none; }
.key i.l.p { border-top-style: dashed; }

/* Tablas */
.tbl { overflow: auto; }
.tbl.alta { max-height: 520px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 9px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.03em; text-transform: uppercase; vertical-align: bottom; background: var(--panel); position: sticky; top: 0; }
th.vr { border-top: 3px solid var(--real); } th.vb { border-top: 3px solid var(--budget); } th.vl { border-top: 3px solid var(--ly); }
tr.sub td { font-weight: 600; background: var(--soft); }
td.l, th.l { white-space: normal; text-align: left; }
td.neg { color: var(--negative); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; white-space: nowrap; }
.tag.p { background: var(--warnbg); color: var(--warning); } .tag.d { background: var(--negbg); color: var(--negative); }
.tag.a { background: var(--posbg); color: var(--positive); } .tag.m { background: var(--soft); color: var(--muted); }
.tabla-calor td.calor { text-align: center; font-weight: 600; background: rgba(15, 118, 110, calc(0.08 + var(--tono) * 0.55)); border: 2px solid var(--panel); }
.tabla-calor td.calor small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.tabla-calor th { white-space: normal; position: static; }

/* Cifras chicas y listas */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.ac { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; display: grid; gap: 3px; }
.ac .lb { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.ac .v { font-family: var(--f-disp); font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.ac .s { font-size: 11.5px; color: var(--muted); }
.ins { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ins li { font-size: 13px; padding: 8px 11px; border-radius: 8px; background: var(--soft); border-left: 3px solid var(--c, var(--accent)); display: grid; gap: 2px; }
.ins li b { font-weight: 600; }
.ins li span { font-size: 12px; color: var(--muted); }
.control-fila { display: grid; grid-template-columns: 1fr 28px; gap: 2px 8px; font-size: 12.5px; }
.control-total { text-align: right; color: var(--muted); }
.control-barra { grid-column: 1 / -1; display: flex; height: 15px; gap: 2px; }
.control-barra i { display: grid; place-items: center; font-style: normal; font-size: 10px; font-weight: 600; color: #fff; border-radius: 1.5px; min-width: 16px; }
.control-barra i.ok { background: var(--accent); } .control-barra i.warn { background: #D59A3A; } .control-barra i.mute { background: #A3AFC0; } .control-barra i.neg { background: var(--negative); }

/* Gráficos SVG propios (cascadas y barras) */
.graf { display: block; max-width: 100%; height: auto; overflow: visible; font-family: var(--f-body); }
.graf .etq { font-size: 12px; fill: var(--muted); }
.graf .etq.fuerte { fill: var(--text); font-weight: 600; }
.graf .val { font-size: 12px; font-weight: 600; fill: var(--text); font-variant-numeric: tabular-nums; }
.graf .val.neg { fill: var(--negative); } .graf .val.pos { fill: var(--positive); }
.graf .barra.total { fill: var(--primary); } .graf .barra.neg { fill: #C8574A; } .graf .barra.pos { fill: #2F8F62; } .graf .barra { fill: #8FA3BC; }
.graf .eje { stroke: var(--line); }

/* Bajada */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; }
.crumbs button { font: 500 12.5px var(--f-body); background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; }
.crumbs > * + *::before { content: "›"; color: var(--muted); margin-right: 6px; }
.crumbs span[aria-current] { font-weight: 600; padding: 2px 4px; }
.tabla-bajada tr.clic { cursor: pointer; }
.tabla-bajada tr.clic:hover td, .tabla-bajada tr.clic:focus td { background: #E6F4F1; }
.tabla-bajada tr.clic:focus { outline: none; }
.bajada-abajo { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 12px; color: var(--muted); }
.bajada-abajo p { margin: 0; flex: 1; }
.btn { font: 500 12px var(--f-body); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; }

/* Inicio */
.inicio { background: var(--primary); color: #fff; border-radius: 12px; padding: 56px 56px 44px; display: grid; gap: 18px; }
.inicio .eyb { color: rgba(255, 255, 255, 0.7); }
.inicio h1 { font-family: var(--f-disp); font-weight: 500; font-size: clamp(34px, 4.4vw, 58px); line-height: 1.08; letter-spacing: -0.02em; max-width: 20ch; }
.inicio h1 em { color: var(--accent-2); }
.inicio p { margin: 0; font-size: 18px; color: rgba(255, 255, 255, 0.82); max-width: 70ch; }
.recorrido { list-style: none; margin: 18px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.recorrido button { all: unset; cursor: pointer; display: grid; gap: 2px; border-top: 2px solid rgba(45, 212, 191, 0.45); padding-top: 9px; font-size: 13.5px; color: rgba(255, 255, 255, 0.86); }
.recorrido button b { font-family: var(--f-disp); font-weight: 500; font-size: 24px; color: var(--accent-2); }
.recorrido button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 4px; }
.respaldo { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 13.5px; color: rgba(255, 255, 255, 0.78); margin-top: 6px; }
.respaldo .tag { background: rgba(45, 212, 191, 0.16); color: var(--accent-2); }

footer { padding: 0 28px 28px; font-size: 11.5px; color: var(--muted); display: grid; gap: 3px; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); max-width: min(760px, 92vw); padding: 18px 20px; }
dialog::backdrop { background: rgba(7, 21, 41, 0.45); }
dialog ol { padding-left: 20px; display: grid; gap: 6px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: none; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 3px solid var(--accent-2); padding: 14px 12px; gap: 10px; }
  .sclient, .slegend { display: none; }
  nav.hojas { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  nav.hojas button small { display: none; }
  .topbar, .filtros, main, footer { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Acceso (login con segundo factor) ---------- */
body[data-acceso="ok"] .acceso, body[data-acceso="vista-previa"] .acceso { display: none; }
.acceso { position: fixed; inset: 0; overflow-y: auto; background: var(--primary); display: grid; place-items: center; padding: 32px 16px; color: #fff; z-index: 20; }
.acceso-caja { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
.acceso-marca { display: flex; align-items: center; gap: 12px; }
.acceso-marca svg { width: 24px; height: 46px; flex: none; }
.acceso-marca b { display: block; font-family: var(--f-disp); font-weight: 500; font-size: 22px; }
.acceso-marca small { display: block; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6); margin-top: 3px; }
.acceso-espera { color: rgba(255, 255, 255, 0.7); margin: 0; }
.acceso-paso { display: flex; flex-direction: column; gap: 10px; }
.acceso-paso h1 { font-family: var(--f-disp); font-weight: 500; font-size: 32px; line-height: 1.15; }
.acceso-nota { margin: 0 0 8px; font-size: 14px; line-height: 1.5; color: rgba(255, 255, 255, 0.75); }
.acceso-nota code { font-size: 13px; color: var(--accent-2); word-break: break-all; }
.acceso-paso label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600; color: rgba(255, 255, 255, 0.65); margin-top: 6px; }
.acceso-paso input { font: 16px var(--f-body); padding: 11px 12px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.25); background: #10294B; color: #fff; }
.acceso-paso input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; border-color: var(--accent-2); }
.acceso-codigo { font-size: 26px !important; letter-spacing: 0.35em; font-variant-numeric: tabular-nums; text-align: center; }
.acceso-paso button[type="submit"] { margin-top: 12px; font: 600 15px var(--f-body); padding: 12px; border: 0; border-radius: 4px; background: var(--accent-2); color: #071529; cursor: pointer; }
.acceso-paso button[disabled] { opacity: 0.6; cursor: wait; }
.acceso-link { background: none; border: 0; color: rgba(255, 255, 255, 0.7); font: 14px var(--f-body); text-decoration: underline; cursor: pointer; padding: 6px 0; align-self: flex-start; }
.acceso-error { margin: 0; padding: 10px 12px; border-left: 3px solid #F97066; background: rgba(249, 112, 102, 0.12); font-size: 14px; color: #FECDCA; }
.acceso-pasos { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: rgba(255, 255, 255, 0.85); }
.acceso-qr { background: #fff; border-radius: 4px; padding: 12px; align-self: center; }
.acceso-qr img { display: block; width: 200px; height: 200px; }

@media print { .side { position: static; height: auto; overflow: visible; } .filtros { position: static; } }
