/* Torre de Control 399 SLP · identidad Mantenme: teal #2b5d76, profundo #1f4556, naranja #f1971e.
   Oscuro por defecto; [data-tema="claro"] activa el claro. Contrastes de texto verificados AA. */
:root {
  --bg: #0f1c22; --surface: #16272f; --surface-2: #1c3039; --ink: #eaf1f3; --muted: #a9bec7;
  --line: #2a4552; --teal: #2b5d76; --teal-deep: #1f4556; --teal-text: #8cc6de; --orange: #f1971e;
  --orange-text: #f5ad52; --good: #6fcf9a; --good-bg: #173628; --warn: #f2c063; --warn-bg: #3a2e14;
  --bad: #f28b80; --bad-bg: #42211e; --n-bg: #233a44;
  --display: "Oswald", "Arial Narrow", Arial, sans-serif;
  --body: "Public Sans", "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-tema="claro"] {
  --bg: #f3f5f4; --surface: #ffffff; --surface-2: #eef3f4; --ink: #15262f; --muted: #4f626c;
  --line: #d3dde1; --teal-text: #2b5d76; --orange-text: #9a5207; --good: #1b6e45; --good-bg: #dcefe4;
  --warn: #8a5700; --warn-bg: #fbedd0; --bad: #a3352a; --bad-bg: #f6dcd8; --n-bg: #e6edf0;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 140px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
.wrap { max-width: 1280px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
a { color: var(--teal-text); }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.saltar { position: absolute; left: -9999px; top: 8px; z-index: 20; background: var(--orange); color: #111; padding: 8px 12px; border-radius: 6px; }
.saltar:focus { left: 8px; }

/* Encabezado */
header.top { position: sticky; top: 0; z-index: 10; background: var(--teal-deep); color: #eaf1f3; border-bottom: 3px solid var(--orange); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; padding-top: 12px; }
.marca { display: flex; flex-direction: column; }
.marca b { font: 600 20px/1.1 var(--display); letter-spacing: .04em; text-transform: uppercase; }
.marca b i { font-style: normal; color: var(--orange); }
.marca span { font-size: 13px; color: #c3d6dd; }
.sello { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: #c3d6dd; }
.btn-tema { font: 600 12px var(--body); color: #eaf1f3; background: transparent; border: 1px solid #6f97a8; border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 32px; }
.pestanas { flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.pestanas a { color: #c3d6dd; text-decoration: none; padding: 10px 12px; font: 500 14px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; border-bottom: 3px solid transparent; white-space: nowrap; }
.pestanas a:hover { color: #fff; }
.pestanas a[aria-current="page"] { color: #fff; border-bottom-color: var(--orange); }

/* Aviso y filtros */
.aviso { margin-top: 14px; padding: 10px 14px; border: 2px dashed var(--orange); border-radius: 8px; background: var(--surface); }
.aviso b { color: var(--orange-text); }
.filtros { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; margin: 14px 0 0; }
.filtros label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.filtros select, .filtros input { font: 15px var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; min-height: 40px; min-width: 0; max-width: 100%; }
.rango-texto { margin: 0 0 4px auto; font-size: 13px; color: var(--muted); }

/* Contenido */
main { padding-top: 18px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 16px; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
h1 { font: 600 26px/1.15 var(--display); letter-spacing: .02em; text-transform: uppercase; margin: 0; }
h2 { font: 600 16px/1.2 var(--display); letter-spacing: .05em; text-transform: uppercase; margin: 0; }
.sub { color: var(--muted); margin: 4px 0 0; max-width: 80ch; }
.grid { display: grid; gap: 12px; }
.k4 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.c2 { grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.card .hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi { position: relative; padding-top: 19px; }
.kpi::before { content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 3px; background: var(--estado, var(--teal-text)); border-radius: 0 0 2px 2px; }
.kpi .lb { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .v { font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.kpi .v small { font: 500 14px var(--body); color: var(--muted); margin-left: 4px; }
.kpi .v.sin { font-size: 20px; color: var(--muted); }
.kpi .ft { font-size: 13px; color: var(--muted); }
.fresco { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.fresco::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.fresco.atrasada::before { background: var(--warn); }
.fresco.sin_dato::before { background: var(--muted); }

.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.n { background: var(--n-bg); color: var(--muted); }

/* Excepciones */
.excepciones { display: flex; flex-direction: column; }
.ex { display: grid; grid-template-columns: 6px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.ex:first-child { border-top: 0; }
.ex .barra { border-radius: 3px; background: var(--warn); }
.ex.alta .barra { background: var(--bad); }
.ex b { display: block; font-size: 16px; }
.ex p { margin: 2px 0 6px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 13px; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.chip:hover { border-color: var(--teal-text); }
.vacio { color: var(--muted); padding: 8px 0; }

/* Tablas */
.tabla { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
caption { text-align: left; color: var(--muted); font-size: 13px; padding-bottom: 6px; }
th { font: 600 12px var(--body); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 3px solid var(--orange); }
td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.txt { white-space: normal; min-width: 180px; }
.num { text-align: right; }
tr:last-child td { border-bottom: 0; }

/* Barras y gráficas */
.barras { display: grid; gap: 8px; }
.hb { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 64px; gap: 10px; align-items: center; font-size: 14px; }
.hb .tr { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hb .tr i { display: block; height: 100%; background: var(--teal-text); border-radius: 5px; }
.hb .vv { text-align: right; font-weight: 600; }
svg.gr { width: 100%; height: auto; display: block; }
svg.gr text { fill: var(--muted); font: 11px var(--body); }
svg.gr .gl { stroke: var(--line); }
.leyenda { font-size: 13px; color: var(--muted); }

.ficha-cab { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; }
.volver { font-size: 14px; }
.pie { color: var(--muted); font-size: 12px; padding-bottom: 32px; }

@media (max-width: 560px) {
  header.top { position: static; }
  html { scroll-padding-top: 0; }
  h1 { font-size: 22px; }
  .kpi .v { font-size: 26px; }
  .hb { grid-template-columns: 96px 1fr 52px; }
  .sello { margin-left: 0; }
  .rango-texto { margin-left: 0; }
  .filtros label { flex: 1 1 140px; }
}
