.viz-root {
  color-scheme: light;
  --surface-0: #f4f3f0; --surface-1: #fcfcfb; --borde: #dedcd6; --grid: #e9e7e2;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #77756f;
  --series-1: #2a78d6;           /* ruta regular */
  --series-2: #eb6834;           /* ruta de emergencia */
  --boton-2: #c4511f;
  --acento: #1c5cab;
  /* rampa ordinal azul para las 4 fases */
  --f1: #6da7ec; --f2: #3987e5; --f3: #256abf; --f4: #184f95;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --borde: #34332f; --grid: #2a2a27;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
    --series-1: #3987e5; --series-2: #d95926; --boton-2: #d95926; --acento: #86b6ef;
    --f1: #256abf; --f2: #3987e5; --f3: #5598e7; --f4: #86b6ef;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: #f4f3f0; }
@media (prefers-color-scheme: dark) { body { background: #121211; } }
.viz-root {
  background: var(--surface-0); color: var(--text-primary);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px;
}
a { color: var(--acento); }
h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.1; margin: .15em 0 .4em; }
h2 { font-size: 1.45rem; margin: 2.2em 0 .4em; }
h3 { font-size: 1.15rem; margin: 0 0 .3em; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin: 0 0 .4em; }
.antetitulo { text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; color: var(--text-secondary); margin: 0; }
.contexto { font-size: 1.08rem; max-width: 70ch; }
.ayuda, .sub, .nota { color: var(--text-secondary); font-size: .92rem; margin: 0 0 .8em; }
.nota { margin-top: .8em; max-width: 95ch; }
.descargas { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 6px; }
.boton { display: inline-block; padding: 10px 16px; border-radius: 8px; text-decoration: none; border: 1px solid var(--borde);
  background: var(--surface-1); color: var(--text-primary); font-weight: 600; }
.boton.principal { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.boton.principal.naranja { background: var(--boton-2); border-color: var(--boton-2); }
.boton:hover { filter: brightness(.95); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 22px; }
.kpi { background: var(--surface-1); border: 1px solid var(--borde); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; }
.kpi.destacado { box-shadow: inset 0 3px 0 var(--series-2); }
.kpi-et { font-size: .82rem; color: var(--text-secondary); }
.kpi-val { font-size: 2.1rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-val.kpi-txt { font-size: 1.6rem; padding: .2em 0; }
.kpi-sub { font-size: .82rem; color: var(--text-muted); }

.cabecera-seccion { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; }
.cabecera-seccion h2 { margin-bottom: .2em; }
.segmentos { display: inline-flex; border: 1px solid var(--borde); border-radius: 999px; padding: 3px; background: var(--surface-1); }
.segmentos button { font: inherit; font-size: .92rem; font-weight: 600; border: 0; background: transparent; color: var(--text-secondary);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.segmentos button[aria-pressed="true"] { background: var(--series-1); color: #fff; }
.segmentos button[data-ruta="emergencia"][aria-pressed="true"] { background: var(--boton-2); }

.fases { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .fases { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .fases { grid-template-columns: 1fr; } }
.fases > li { position: relative; }
@media (min-width: 901px) {
  .fases > li:not(:last-child)::after { content: "›"; position: absolute; right: -12px; top: 38px; font-size: 1.6rem; color: var(--text-muted); }
}
.fase { width: 100%; height: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-1); border: 1px solid var(--borde); border-top: 6px solid var(--c); border-radius: 12px; padding: 14px 16px; }
.fase .num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 700; }
.fase .nom { font-weight: 700; font-size: 1.2rem; line-height: 1.2; margin-top: 4px; }
.fase .preg { color: var(--text-secondary); font-size: .9rem; font-style: italic; }
.fase .hitos { margin: 6px 0 0; padding-left: 1.1em; font-size: .86rem; color: var(--text-primary); flex: 1; }
.fase .hitos li { margin-bottom: 3px; }
.fase .cnt { font-size: .85rem; font-weight: 600; color: var(--acento); margin-top: 6px; }
.fase[aria-pressed="true"] { outline: 3px solid var(--c); outline-offset: 1px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }

.detalle { margin-top: 16px; background: var(--surface-1); border: 1px solid var(--borde); border-left: 6px solid var(--c); border-radius: 12px; padding: 18px 22px; }
.detalle > p { max-width: 90ch; }
.grupos { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 24px; margin-top: 10px; }
.grupo ul { list-style: none; padding: 0; margin: 0; }
.grupo li { padding: 6px 0; border-top: 1px solid var(--grid); }
.grupo li a { font-weight: 600; text-decoration: none; }
.grupo li a:hover { text-decoration: underline; }
.grupo li span { display: block; font-size: .8rem; color: var(--text-muted); }

.tarjeta { background: var(--surface-1); border: 1px solid var(--borde); border-radius: 12px; padding: 16px; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico text { fill: var(--text-primary); font-size: 14px; }
.grafico .eje { fill: var(--text-secondary); font-size: 12px; }
.grafico .etq-ruta { font-weight: 600; font-size: 15px; }
.grafico .total { font-weight: 700; font-size: 22px; }
.grafico .rejilla-l { stroke: var(--grid); }
.grafico .tramo { cursor: pointer; }
.grafico .tramo.regular { fill: var(--series-1); }
.grafico .tramo.emergencia { fill: var(--series-2); }
.grafico .tramo:hover { filter: brightness(1.15); }

.linea-tiempo { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .linea-tiempo { grid-template-columns: 1fr; } }
.linea-tiempo li { background: var(--surface-1); border: 1px solid var(--borde); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.linea-tiempo .fecha { font-size: .8rem; font-weight: 700; color: var(--acento); letter-spacing: .03em; }
.linea-tiempo span:last-child { font-size: .9rem; color: var(--text-secondary); }
.cambios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 820px) { .cambios { grid-template-columns: 1fr; } }
.cambio { border-left: 4px solid var(--series-1); background: var(--surface-1); border-radius: 0 10px 10px 0; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.cambio span { font-size: .9rem; color: var(--text-secondary); }
.aviso { margin-top: 16px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--borde); background: var(--surface-1); font-size: .92rem; max-width: 100ch; }

.filtros { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; background: var(--surface-1); border: 1px solid var(--borde); border-radius: 10px; padding: 12px 14px; }
.filtros label { display: flex; flex-direction: column; font-size: .8rem; color: var(--text-secondary); gap: 3px; }
.filtros .ancho { flex: 1 1 220px; }
.filtros select, .filtros input, .filtros button { font: inherit; font-size: .92rem; padding: 6px 8px; border: 1px solid var(--borde); border-radius: 6px; background: var(--surface-0); color: var(--text-primary); }
.filtros button { cursor: pointer; font-weight: 600; }
.resumen-filtro { font-size: .9rem; color: var(--text-secondary); min-height: 1.4em; }
.tabla-envoltura { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--borde); border-radius: 10px; max-height: 640px; overflow-y: auto; }
.tabla { border-collapse: collapse; width: 100%; font-size: .88rem; }
.tabla th, .tabla td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
.tabla th { position: sticky; top: 0; background: var(--surface-1); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ruta { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .82rem; }
.ruta::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--series-1); }
.ruta.emergencia::before { background: var(--series-2); }

.tooltip { position: fixed; pointer-events: none; z-index: 10; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--borde); border-radius: 8px; padding: 8px 10px; font-size: .85rem; max-width: 300px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
.tooltip b { display: block; }
.metodo { color: var(--text-secondary); font-size: .93rem; }
.metodo li { margin-bottom: 6px; }
.firma { margin-top: 20px; font-weight: 600; color: var(--text-primary); }
