/* Tokens: paleta slate de doble tema (design D1). Los NOMBRES son contrato
   congelado; solo cambian los valores. Semántica de estado pinada:
   verde = con corriente, rojo = sin corriente, ámbar = mantenimiento. */
:root{
  color-scheme:dark;
  --bg:#0F172A; --bg-header:#0B1220; --surface:#111827; --surface-2:#1E293B;
  --border:#334155; --border-2:#475569;
  --text:#F8FAFC; --text-soft:#CBD5E1; --text-muted:#A9B7C9; --text-dim:#94A3B8;
  --text-strong:#FFFFFF; --ring:#16A34A; --focus:0 0 0 3px var(--ring);
  --red:#DC2626; --red-t:#FCA5A5; --red-bg:#3A1A1C;
  --green:#16A34A; --green-t:#4ADE80; --green-bg:#12301D;
  --amber:#F5A623; --amber-t:#F5C576; --amber-bg:#33270A;
  --blue:#3B82F6; --blue-t:#93C5FD; --blue-bg:#14263F;
  --gray:#64748B; --gray-t:#9AA7B8; --gray-bg:#2A3648;
  --gold:#FBBF24; --accent:#34D399; --cta:#22C55E; --on-cta:#06210F;
  --mono:ui-monospace,"SF Mono","JetBrains Mono",Menlo,Consolas,monospace;
  --fuente-sans:"Inter",-apple-system,"Segoe UI",Roboto,sans-serif;
}
/* Inter autoalojada (D5/R9): 400/700 latin pre-subset, sin CDN, con swap y el
   fallback métricamente compatible anterior como respaldo. Licencia OFL.txt. */
@font-face {
  font-family: "Inter";
  src: url(/fonts/inter-latin-400.woff2) format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url(/fonts/inter-latin-700.woff2) format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
/* Tema claro paralelo: mismas reglas, otros valores (design D1/R2).
   data-theme lo fija el script sin destello del <head> o el botón del tema. */
[data-theme="light"]{
  color-scheme:light;
  --bg:#F8FAFC; --bg-header:#FFFFFF; --surface:#FFFFFF; --surface-2:#F1F5F9;
  --border:#CBD5E1; --border-2:#94A3B8;
  --text:#0F172A; --text-soft:#334155; --text-muted:#475569; --text-dim:#5C6B7F;
  --text-strong:#020617; --ring:#15803D; --focus:0 0 0 3px var(--ring);
  --red:#DC2626; --red-t:#B91C1C; --red-bg:#FEE2E2;
  --green:#16A34A; --green-t:#15803D; --green-bg:#DCFCE7;
  --amber:#D97706; --amber-t:#92400E; --amber-bg:#FEF3C7;
  --blue:#2563EB; --blue-t:#1D4ED8; --blue-bg:#DBEAFE;
  --gray:#64748B; --gray-t:#475569; --gray-bg:#E2E8F0;
  --gold:#B45309; --accent:#047857; --cta:#15803D; --on-cta:#FFFFFF;
}
* { box-sizing: border-box; }
/* Iconos del sprite (R8/D4): 1em alineado con el texto; el color sale de
   currentColor. Los puntos de estado (.est-*) van sobre icon-dot-status con el
   color del estado; averías (púrpura) y reportes (naranja) heredan el color
   duro de sus barras/capas, que no tienen token. */
.ico { width: 1em; height: 1em; vertical-align: -.125em; flex: none; }
.est-sin { color: var(--red); }
.est-con { color: var(--green); }
.est-disc { color: var(--amber); }
.est-asum { color: var(--blue); }
.est-desc { color: var(--gray); }
.est-daf { color: var(--gold); }
.est-av { color: #b455c8; }
.est-rep { color: #e07b00; }
/* Foco visible global (R4): anillo con --ring, ≥3:1 en ambos temas. */
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
/* Movimiento reducido (R4/S5): sin transiciones ni animaciones si el sistema
   lo pide; el foco por teclado sigue mostrando el anillo. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--fuente-sans);
  display: flex; flex-direction: column; min-height: 100vh;
}
header { padding: 10px 16px 4px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
h1 { font-size: 1.15rem; margin: 0; }
#actualizado { margin: 0; color: var(--text-muted); font-size: .8rem; }

/* ---------- portada: resumen por circuito ---------- */
#resumen-circuitos { padding: 8px 16px 4px; }
#resumen-circuitos:empty { display: none; }
.rc-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
/* con tarjetas: Circuitos (recortado) | más horas (centro) | Personas (compacto) */
.rc-grid.tres { grid-template-columns: minmax(240px, .85fr) minmax(0, 1.7fr) minmax(210px, .65fr); }
.rc-box-cards { min-width: 0; }
.rc-box-cards .rc-cards {
  display: flex; overflow-x: auto; gap: 8px; padding-bottom: 2px;
  scrollbar-width: thin;
}
.rc-box-cards .rc-card { flex: 0 0 148px; }
.rc-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 9px;
}
.rc-box-t {
  display: flex; align-items: baseline; gap: 8px; font-size: .78rem;
  font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.rc-box-t .rc-n { font-size: 1.05rem; color: var(--text); letter-spacing: 0; }
.rc-mas { margin-left: auto; color: var(--accent); text-decoration: none; font-size: .76rem;
  font-weight: 600; text-transform: none; letter-spacing: 0; }
.rc-mas:hover { text-decoration: underline; }
.rc-barra {
  display: flex; height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--border);
}
.rc-barra .seg { transition: width .6s ease; }
.rc-barra .seg.sin { background: var(--red); }
.rc-barra .seg.con { background: var(--green); }
.rc-barra .seg.discrepado { background: var(--amber); }
.rc-barra .seg.asum { background: var(--blue); }
.rc-barra .seg.nd { background: var(--gray); }
.rc-barra .seg.desc { background: var(--gray); }
.rc-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.rc-chip {
  font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 3px 10px;
  background: var(--surface-2);
}
.rc-chip::before { content: "●"; margin-right: 5px; font-size: .6rem; vertical-align: 1px; }
.rc-chip.sin { color: var(--red-t); } .rc-chip.sin::before { color: var(--red); }
.rc-chip.con { color: var(--green-t); } .rc-chip.con::before { color: var(--green); }
.rc-chip.discrepado { color: var(--amber-t); cursor: help; } .rc-chip.discrepado::before { color: var(--amber); }
.rc-chip.asum { color: var(--blue-t); cursor: help; } .rc-chip.asum::before { color: var(--blue); }
.rc-chip.nd { color: var(--gray-t); cursor: help; } .rc-chip.nd::before { color: var(--gray); }
.rc-chip.desc { color: var(--gray-t); cursor: help; } .rc-chip.desc::before { color: var(--gray); }
.rc-pnums { display: flex; gap: 14px; flex-wrap: wrap; }
.rc-pnum b { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; display: block; line-height: 1.15; }
.rc-pnum small { color: var(--text-muted); font-size: .72rem; }
.rc-pnum.sin b { color: var(--red-t); }
.rc-pnum.con b { color: var(--green-t); }
.rc-fuente { font-size: .68rem; color: var(--text-dim); }
.rc-info { cursor: help; color: var(--accent); font-weight: 400; font-size: .8rem; }
.rc-tit {
  font-size: .74rem; font-weight: 700; margin: 12px 0 6px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.rc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 8px; }
.rc-card {
  display: flex; flex-direction: column; gap: 3px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--red);
  border-radius: 10px; padding: 10px 12px; transition: border-color .15s, transform .15s;
}
.rc-card:hover { border-color: var(--border-2); border-left-color: var(--red); transform: translateY(-1px); }
.rc-card-cab { font-weight: 800; font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.rc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 6px rgba(239, 68, 68, .53); flex: 0 0 auto; }
.rc-card-h { font-size: 1.35rem; font-weight: 800; color: var(--red-t); line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.rc-card-h small { font-size: .66rem; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.rc-card-det {
  font-size: .68rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
/* barrita compacta (solo móvil): resumen colapsable para que el mapa mande */
.rc-toggle { display: none; }
.rc-cuerpo { display: block; }
@media (max-width: 720px) {
  #resumen-circuitos { padding: 6px 10px 2px; }
  .rc-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
    color: inherit; font: inherit; padding: 8px 12px; cursor: pointer;
  }
  .rc-mini-barra {
    display: flex; height: 8px; border-radius: 999px; overflow: hidden;
    background: var(--border); flex: 0 0 74px;
  }
  .rc-mini-barra .seg.sin { background: var(--red); }
  .rc-mini-barra .seg.con { background: var(--green); }
  .rc-mini-barra .seg.discrepado { background: var(--amber); }
  .rc-mini-barra .seg.asum { background: var(--blue); }
  .rc-mini-barra .seg.nd { background: var(--gray); }
  .rc-mini-barra .seg.desc { background: var(--gray); }
  .rc-mini-txt { font-size: .74rem; color: var(--text-muted); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .rc-mini-txt b.sin { color: var(--red-t); } .rc-mini-txt b.con { color: var(--green-t); }
  .rc-mini-txt b.desc { color: var(--gray-t); } .rc-mini-txt b.discrepado { color: var(--amber-t); }
  .rc-flecha { margin-left: auto; color: var(--text-muted); font-size: .7rem; }
  .rc-cuerpo { display: none; }
  .rc-cuerpo.abierto { display: block; margin-top: 8px; }
  .rc-grid, .rc-grid.tres { grid-template-columns: 1fr; gap: 8px; }
  .rc-box { padding: 10px 12px; }
  .rc-pnums { gap: 14px; }
  .rc-pnum b { font-size: 1.1rem; }
  /* tarjetas: tira horizontal deslizable con snap */
  .rc-cards {
    display: flex; overflow-x: auto; gap: 8px; padding-bottom: 4px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
  }
  .rc-cards::-webkit-scrollbar { display: none; }
  .rc-card { flex: 0 0 auto; width: 148px; scroll-snap-align: start; }
}

#aviso-nacional {
  margin: 4px 16px 0; padding: 9px 12px; border-radius: 8px;
  background: var(--red-bg); border: 1px solid var(--red); color: var(--red-t);
  font-size: .82rem; line-height: 1.35;
}
#aviso-nacional b { color: var(--red-t); }
@media (max-width: 640px) { #aviso-nacional { margin: 4px 10px 0; font-size: .74rem; } }

#aviso-deficit {
  margin: 6px 16px 0; padding: 7px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  color: var(--text-muted); font-size: .76rem; line-height: 1.4;
}
#aviso-deficit b { color: var(--text-soft); }
#aviso-deficit .def-ico { opacity: .8; margin-right: 2px; }
#aviso-deficit .def-circ { margin: 6px 0 0; padding-left: 18px; columns: 2; font-size: .78rem; }
#aviso-deficit .def-circ li { margin-bottom: 2px; }
#aviso-deficit .cal { color: #b9a86a; }
/* en móvil la nota informativa se oculta: el mapa manda (la info vive en Circuitos) */
@media (max-width: 720px) { #aviso-deficit { display: none; } }

#mapa { flex: 1; min-height: 420px; background: var(--bg); }
.leaflet-container { background: var(--bg); }

footer { padding: 8px 16px; font-size: .7rem; color: var(--text-dim); }
footer a { color: var(--accent); }

.popup h3 { margin: 0 0 4px; font-size: .95rem; }
.popup ul { margin: 4px 0 0; padding-left: 16px; max-height: 220px; overflow-y: auto; }
.popup li { margin-bottom: 5px; font-size: .78rem; }
.popup .hora { color: var(--text-muted); }
.popup .rep { font-size: .75rem; color: var(--red-t); margin: 2px 0 0; }
/* Leaflet tematizado con tokens (D8): popup, punta, atribución, barra y
   leyenda consumen los mismos pares que el resto del sitio, en ambos temas. */
.leaflet-popup-content-wrapper {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--border); }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }
.leaflet-control-attribution { background: var(--surface); color: var(--text-muted); }
.leaflet-control-attribution a { color: var(--accent); }
.leaflet-bar a { background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); }
.leaflet-bar a:hover { background: var(--surface-2); }

.leyenda {
  background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; font-size: .7rem; max-width: 230px;
}

/* Botón de tema (D2): píldora alineada con las pestañas, nombre accesible. */
#boton-tema {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 0 14px; min-height: 44px; cursor: pointer;
  font-size: 1rem; line-height: 1; display: inline-flex; align-items: center;
  font-family: var(--mono);
}
#boton-tema:hover { border-color: var(--border-2); color: var(--accent); }

#buscador { position: relative; flex: 1; min-width: 220px; max-width: 380px; margin-left: auto; }
#buscador > .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#busqueda {
  width: 100%; padding: 6px 10px 6px 32px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text); font-size: .85rem;
}
#resultados {
  position: absolute; top: 34px; left: 0; right: 0; z-index: 2000;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 8px;
  max-height: 260px; overflow-y: auto;
}
#resultados div { padding: 12px 10px; font-size: .82rem; cursor: pointer; }
#resultados div:hover { background: var(--border-2); }
#resultados .muni { color: var(--text-muted); font-size: .72rem; }

.btn-reporte {
  display: inline-block; margin-top: 6px; padding: 10px 14px; border-radius: 6px;
  background: var(--red); color: #fff; border: 0; cursor: pointer; font-size: .8rem; min-height: 44px;
}
.btn-reporte:disabled { background: var(--text-dim); }
.btn-reporte.con { background: var(--green); margin-left: 4px; }

.pin-busqueda {
  font-size: 28px; line-height: 30px; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
}

/* ---------- móvil ---------- */
@media (max-width: 640px) {
  body { height: 100dvh; }
  header { padding: 8px 10px 2px; gap: 6px; }
  h1 { font-size: 1rem; }
  #actualizado { font-size: .7rem; }
  #buscador { min-width: 100%; max-width: none; margin: 0; order: 3; }
  #busqueda { font-size: 16px; /* evita el auto-zoom de iOS al enfocar */ }

  #mapa { min-height: 0; }
  footer { padding: 4px 10px; font-size: .6rem; }

  .leyenda { max-width: 170px; font-size: .6rem; padding: 4px 7px; }
  .leaflet-control-layers { font-size: .72rem; }
}

/* ---------- pestaña de partes oficiales ---------- */
#feed { padding: 8px 16px 40px; max-width: 820px; width: 100%; margin: 0 auto; }
#feed .dia {
  font-size: .82rem; color: var(--text-muted); text-transform: capitalize;
  margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border-2);
}
#feed .dia:first-child { margin-top: 4px; }
.parte { background: var(--surface-2); border-radius: 10px; padding: 10px 13px; margin-bottom: 10px; }
.parte.destacada {
  border: 1px solid #8a741f; box-shadow: 0 0 0 3px rgba(255, 206, 77, .12);
  animation: parte-destacada 1.2s ease-out;
}
@keyframes parte-destacada {
  from { background: #393117; }
  to { background: var(--surface-2); }
}
.parte-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.parte-tag { font-size: .72rem; font-weight: 600; background: var(--bg); border-radius: 999px; padding: 2px 9px; color: var(--text-soft); }
.parte-hora { font-size: .74rem; color: var(--text-muted); }
.parte-tg { font-size: .72rem; color: var(--accent); text-decoration: none; margin-left: auto; }
.parte-txt { font-size: .86rem; line-height: 1.4; color: var(--text-soft); white-space: normal; word-break: break-word; }
#filtro {
  width: 100%; padding: 6px 10px 6px 32px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text); font-size: .85rem;
}
@media (max-width: 640px) { #feed { padding: 6px 10px 32px; } #filtro { font-size: 16px; } }

/* ---------- pestaña de sugerencias/bugs ---------- */
#sug-main { padding: 12px 16px 40px; max-width: 640px; width: 100%; margin: 0 auto; }
.sug-form { display: flex; flex-direction: column; gap: 12px; }
.sug-campo { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--text-soft); }
.sug-campo em { color: var(--text-dim); font-style: normal; }
.sug-campo select, .sug-campo input, .sug-campo textarea {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); border-radius: 8px;
  padding: 8px 10px; font-size: .9rem; font-family: inherit; width: 100%;
}
.sug-campo textarea { resize: vertical; }
#sug-enviar {
  background: var(--cta); color: var(--on-cta); border: 0; border-radius: 8px; padding: 12px 18px;
  font-size: .9rem; cursor: pointer; align-self: flex-start; min-height: 44px;
}
#sug-enviar:disabled { background: var(--text-dim); cursor: default; }
.sug-estado { font-size: .82rem; margin: 2px 0 0; min-height: 1em; }
.sug-estado.ok { color: var(--green-t); }
.sug-estado.err { color: var(--red-t); }
.sug-estado a { color: var(--accent); }
/* Resumen de errores enfocable (D7/R11): role=alert al inicio del form */
.sug-resumen {
  background: var(--red-bg); border: 1px solid var(--red); color: var(--red-t);
  border-radius: 10px; padding: 12px 14px; font-size: .84rem; line-height: 1.4;
  margin-bottom: 12px;
}
.sug-resumen:focus { outline: 3px solid var(--ring); }
.sug-resumen p { margin: 0 0 6px; font-weight: 700; }
.sug-resumen ul { margin: 0; padding-left: 18px; }
.sug-resumen a { color: var(--red-t); }
/* Validación en línea: pista estática, hueco de error y borde inválido */
.sug-hint { color: var(--text-dim); font-style: normal; font-weight: 400; }
.sug-error { color: var(--red-t); font-size: .78rem; margin: 0; }
.sug-campo [aria-invalid="true"] { border-color: var(--red); }
/* Caja de éxito (D7): sustituye al formulario tras un envío válido */
.sug-exito {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--green-bg); border: 1px solid var(--green); color: var(--green-t);
  border-radius: 10px; padding: 14px 16px; font-size: .9rem; line-height: 1.4;
}
.sug-exito .ico { margin-top: 2px; }
.sug-nota { font-size: .74rem; color: var(--text-dim); margin-top: 16px; line-height: 1.4; }
.sug-nota a { color: var(--accent); }
@media (max-width: 640px) {
  #sug-main { padding: 10px 12px 32px; }
  .sug-campo select, .sug-campo input, .sug-campo textarea { font-size: 16px; }  /* evita zoom iOS */
}

/* ---------- pestaña de circuitos ---------- */
#daf-oficial { padding: 10px 16px 0; max-width: 820px; width: 100%; margin: 0 auto; }
/* Card DAF: todo en tokens ámbar de doble tema — los hexes fijos de tema
   oscuro eran ilegibles sobre claro (reporte del dueño desde el preview). */
.daf-card {
  background: linear-gradient(135deg, var(--amber-bg), var(--surface-2) 58%);
  border: 1px solid var(--border); border-left: 4px solid var(--gold);
  border-radius: 12px; padding: 13px 15px;
}
.daf-card.vencido { background: var(--surface-2); border-color: var(--border-2); opacity: .88; }
.daf-cab { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.daf-titulo { color: var(--gold); font-size: .92rem; font-weight: 700; }
.daf-periodo { color: var(--amber-t); font-size: .72rem; margin-top: 3px; }
.daf-card p { color: var(--text-soft); font-size: .78rem; line-height: 1.4; margin: 9px 0; }
.daf-fuente { color: var(--accent); font-size: .72rem; text-decoration: none; white-space: nowrap; }
.daf-codigos { display: flex; flex-wrap: wrap; gap: 6px; }
.daf-codigo {
  border: 1px solid var(--gold); border-radius: 999px; padding: 10px 12px;
  background: var(--amber-bg); color: var(--gold); font-size: .72rem;
  font-weight: 600; font-family: inherit; cursor: pointer; min-height: 44px;
}
.daf-codigo:hover, .daf-codigo:focus-visible {
  background: var(--amber-t); color: var(--amber-bg); outline: none;
}
#lista { padding: 8px 16px 40px; max-width: 820px; width: 100%; margin: 0 auto; }
.circ { background: var(--surface-2); border-radius: 10px; padding: 10px 13px; margin-bottom: 9px; }
.circ-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.circ-cod { font-weight: 700; font-size: .92rem; color: var(--text); letter-spacing: .3px; }
/* en las páginas de municipio el código es enlace: misma pinta que el span */
a.circ-cod { text-decoration: none; }
a.circ-cod:hover { text-decoration: underline; }
.circ-b { font-size: .7rem; background: var(--bg); border-radius: 999px; padding: 2px 9px; color: var(--text-soft); }
.circ-daf { font-size: .7rem; background: var(--amber-bg); border-radius: 999px; padding: 2px 9px; color: var(--gold); }
.circ-of { font-size: .7rem; background: var(--green-bg); border-radius: 999px; padding: 2px 9px; color: var(--green-t); }
.circ-est { font-size: .7rem; border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.circ-est.con { background: var(--green-bg); color: var(--green-t); }
.circ-est.con-vec { background: var(--green-bg); color: var(--green-t); }
.circ-est.sin { background: var(--red-bg); color: var(--red-t); }
.circ-est.discrepado { background: var(--amber-bg); color: var(--amber-t); }
.circ-est.nd { background: var(--gray-bg); color: var(--text-muted); }
.circ-est.desc { background: var(--gray-bg); color: var(--text-muted); }
.circ-est.asum { background: var(--blue-bg); color: var(--accent); }
.circ-lleva { font-size: .7rem; font-weight: 600; }
.circ-lleva.sin { color: var(--red-t); }
.circ-lleva.con { color: var(--green-t); }
.circ-lleva.con-vec { color: var(--green-t); }
.circ-lleva.discrepado { color: var(--amber-t); }
.circ-lleva.nd { color: var(--text-muted); }
.circ-lleva.desc { color: var(--text-muted); }
.circ-meta { font-size: .7rem; color: var(--text-muted); margin-left: auto; }
.circ-calles { font-size: .82rem; line-height: 1.35; color: var(--text-soft); }
.circ-sininfo { color: var(--text-muted); font-style: italic; }
.circ-acciones { display: flex; gap: 10px; margin-left: auto; }
.circ-mapa, .circ-parte { color: var(--accent); text-decoration: none; font-size: .72rem; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 640px) {
  #daf-oficial { padding: 8px 10px 0; }
  .daf-cab { display: block; }
  .daf-fuente { display: inline-block; margin-top: 7px; }
  #lista { padding: 6px 10px 32px; }
  .circ-meta { margin-left: 0; flex-basis: 100%; }
  .circ-acciones { margin-left: 0; }
}

/* ---------- página 404 ---------- */
#error-404 { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; }
#error-404 p { line-height: 1.45; font-size: .86rem; }

/* ---------- FAQ: acordeón nativo details/summary (D6/R10) ---------- */
#faq-preguntas { max-width: 760px; width: 100%; margin: 0 auto; padding: 8px 16px 40px; }
details.faq {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 14px; margin-bottom: 10px;
}
details.faq summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px;
  min-height: 48px; font-weight: 700; color: var(--text); font-size: .92rem;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::before {
  content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform .15s ease;
}
details.faq[open] summary::before { transform: rotate(225deg); }
.faq-a {
  padding: 10px 0 12px; line-height: 1.45; font-size: .86rem; color: var(--text-soft);
  border-top: 1px solid var(--border);
}
.faq-a a { color: var(--accent); }

/* ---------- pestaña de análisis ---------- */
.tabs { font-size: .85rem; margin-left: auto; }
.tabs a, .tabs .activo { color: var(--accent); text-decoration: none; padding: 10px 12px; border-radius: 6px; display: inline-flex; align-items: center; min-height: 44px; }
.tabs .activo { background: var(--surface-2); color: var(--text); }
/* móvil: pestañas como fila propia de píldoras deslizables (sin regarse) */
@media (max-width: 720px) {
  .tabs {
    margin-left: 0; order: 2; flex: 1 0 100%;
    display: flex; gap: 5px; overflow-x: auto; white-space: nowrap;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a, .tabs .activo {
    flex: 0 0 auto; padding: 10px 14px; border-radius: 999px; font-size: .78rem;
    background: var(--surface); border: 1px solid var(--border); min-height: 44px;
  }
  .tabs .activo { background: var(--surface-2); border-color: var(--blue); color: var(--text); }
}

#controles { display: flex; gap: 6px; padding: 8px 16px; flex-wrap: wrap; align-items: center; }
#controles button {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2);
  border-radius: 6px; padding: 10px 14px; cursor: pointer; font-size: .82rem; min-height: 44px;
}
#controles button.sel { background: var(--cta); border-color: var(--cta); color: var(--on-cta); }
.desde-hasta { color: var(--text-muted); font-size: .78rem; margin-left: 6px; }
.desde-hasta input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); border-radius: 5px; padding: 3px 6px; }

#paneles { padding: 8px 16px 40px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
@media (max-width: 720px) { #paneles { grid-template-columns: minmax(0,1fr); } }
.kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 12px; text-align: center; }
/* Énfasis de KPI (R12/D11): --text-strong + escala tipográfica */
.kpi .num { display: block; font-size: 2rem; font-weight: 800; color: var(--text-strong); letter-spacing: -.02em; }
.kpi .et { font-size: .72rem; color: var(--text-muted); }

.panel { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; }
/* Agrupación por sección (R12/D11): acento izquierdo por grupo con tokens */
.sec-circuitos { border-left: 3px solid var(--red); }
.sec-records { border-left: 3px solid var(--gold); }
.sec-deficit { border-left: 3px solid var(--amber); }
.sec-averias { border-left: 3px solid var(--blue); }
.sec-avisos { border-left: 3px solid var(--accent); }
.sec-reportes { border-left: 3px solid var(--green); }
/* Paneles a lo ancho: clase de token en lugar del style= en línea */
.panel-ancho { grid-column: 1 / -1; }
/* Respaldo sin JavaScript (S16): descripción + enlace al JSON mismo-origen */
.chart-respaldo { font-size: .8rem; color: var(--text-dim); margin: 0; line-height: 1.4; }
.chart-respaldo a { color: var(--accent); }
.panel h2 { font-size: .9rem; margin: 0 0 10px; color: var(--text-soft); }
.vacio { color: var(--text-dim); font-size: .8rem; }

.fila { display: grid; grid-template-columns: 130px minmax(0,1fr) 62px; align-items: center; gap: 8px; margin-bottom: 5px; }
.fila .etq { font-size: .74rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .etq a { color: inherit; text-decoration: none; }
.fila .etq a:hover { text-decoration: underline; }
.fila .barra { background: var(--bg); border-radius: 4px; height: 15px; overflow: hidden; }
.fila .barra span { display: block; height: 100%; border-radius: 4px; }
.fila .val { font-size: .76rem; text-align: right; color: var(--text); }
.fila .val em { color: var(--text-muted); font-style: normal; font-size: .68rem; }

.chart-tira { display: flex; align-items: flex-end; gap: 2px; height: 150px; overflow-x: auto; }
.chart-tira .col { flex: 1 0 14px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.chart-tira .cbarra { width: 70%; border-radius: 2px 2px 0 0; min-height: 1px; }
.chart-tira .clabel { font-size: .58rem; color: var(--text-muted); margin-top: 3px; white-space: nowrap; }

.panel h2 .nota { font-weight: 400; font-size: .7rem; color: var(--text-dim); }
.records { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.rec { background: var(--bg); border-radius: 8px; padding: 9px 10px; }
.rec .rt { display: block; font-size: .68rem; color: var(--text-muted); }
.rec .rv { display: block; font-size: 1.2rem; font-weight: 700; color: var(--text); }
.rec .rs { display: block; font-size: .66rem; color: var(--text-dim); }

/* ---------- análisis en móvil ---------- */
@media (max-width: 640px) {
  #controles { padding: 6px 10px; }
  #controles button { padding: 5px 9px; font-size: .78rem; }
  .desde-hasta { flex-basis: 100%; margin: 4px 0 0; }
  .desde-hasta input { font-size: 16px; }  /* evita zoom iOS */

  #paneles { padding: 8px 10px 32px; gap: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi { min-width: 0; padding: 10px 6px; }
  .kpi .num { font-size: 1.4rem; }
  .records { grid-template-columns: minmax(0,1fr); }
  .rec { min-width: 0; }
  .rec .rv { font-size: 1.05rem; }
  /* barras: etiqueta más estrecha y todo encogible */
  .fila { grid-template-columns: 92px minmax(0,1fr) 48px; gap: 6px; }
  .fila > * { min-width: 0; }
  .fila .val { font-size: .7rem; }
  .panel h2 .nota { display: block; }
}

/* ---------- páginas generadas: municipio, hub e instantánea SEO ---------- */
/* Columna de contenido legible: max-width como en #feed/#lista/#paneles,
   nada de anchos fijos en píxeles (mobile-readable). */
.pagina-municipio { max-width: 820px; width: 100%; margin: 0 auto; padding: 8px 16px 40px; }
.pagina-municipio h2 { font-size: .95rem; color: var(--text-soft); margin: 20px 0 8px; }
.pagina-municipio p { line-height: 1.45; font-size: .86rem; }
.pagina-municipio ul { padding-left: 18px; line-height: 1.7; font-size: .82rem; color: var(--text-soft); }
.pagina-municipio .circ-meta { margin-left: 0; }
.stamp { font-size: .72rem; color: var(--text-muted); }
/* "Circuitos más afectados": ranking histórico de HORAS sin corriente con
   selector de rango. El default (todo) va server-rendered; las píldoras solo
   re-ranquean en vivo (web/horas.js). */
.afect-ranking { margin: 8px 0; padding-left: 18px; line-height: 1.7; font-size: .82rem; color: var(--text-soft); }
.afect-h { color: var(--red-t); font-weight: 600; margin-left: 8px; font-family: var(--mono); font-size: .76rem; }
.afect-p { color: var(--text-muted); margin-left: 8px; font-family: var(--mono); font-size: .72rem; }
.afect-vacio { color: var(--text-dim); list-style: none; margin-left: -18px; }
.afect-rangos { display: inline-flex; gap: 5px; margin-left: 4px; vertical-align: middle; }
.afect-rango {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 999px; padding: 4px 11px; min-height: 32px; cursor: pointer;
  font-size: .72rem; font-family: var(--mono);
}
.afect-rango:hover { border-color: var(--border-2); color: var(--text); }
.afect-rango.activo { background: var(--surface-2); border-color: var(--blue); color: var(--text); }
/* duración del estado vigente dentro de la fila del catálogo (.circ-fila) */
.circ-dur { color: var(--text-muted); font-size: .78rem; }
#seo-resumen { max-width: 820px; width: 100%; margin: 0 auto; padding: 8px 16px 0; font-size: .86rem; }
#seo-resumen h2 { font-size: .95rem; color: var(--text-soft); margin: 6px 0; }
#seo-resumen ul { padding-left: 18px; line-height: 1.7; }
#hub-municipios { max-width: 820px; width: 100%; margin: 0 auto; padding: 8px 16px 40px; }
#hub-municipios h2 { font-size: 1.05rem; margin: 4px 0 12px; }
#hub-municipios .rc-cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
#hub-municipios .rc-card-h { font-size: 1rem; }
#hub-municipios .rc-card-h small { font-size: .7rem; font-weight: 600; color: var(--text-muted); }
.rc-card.sin-afect { border-left-color: var(--green); }
.rc-card.sin-afect .rc-card-h { color: var(--green-t); }
@media (max-width: 720px) {
  /* el hub es grilla también en móvil: 15 tarjetas no caben en una tira */
  #hub-municipios .rc-cards { display: grid; overflow: visible; }
  #hub-municipios .rc-card { width: auto; flex: none; }
  .pagina-municipio { padding: 6px 10px 32px; }
}

/* ---------- signature rules (merged from the validated theme preview) ---------- */
/* monospace on numeric/data classes */
.rc-n,.rc-card-h,.rc-pnum b,.rc-pnum small,.circ-cod,.circ-b,.circ-daf,.circ-of,.circ-est,.fila .val,.rec .rv,.kpi,.parte-tag,.rc-chip,.daf-codigo,#controles button,#actualizado{font-family:var(--mono)}
/* header as a bar with a green status dot before the title */
header{background:var(--bg-header);border-bottom:1px solid var(--border)}
h1::before{content:"●";color:var(--green);margin-right:8px;font-size:.8em;vertical-align:2px;text-shadow:0 0 10px var(--green)}
/* circuit card status dot top-right (mirrors the mockup) */
.rc-card{position:relative}
.rc-card::after{content:"";position:absolute;top:12px;right:12px;width:9px;height:9px;border-radius:50%;background:var(--red);box-shadow:0 0 8px var(--red)}
.rc-card.con::after{background:var(--green);box-shadow:0 0 8px var(--green)}
/* links: emerald accent (restores the validated preview); card titles read as headings */
a{color:var(--accent)}
.rc-card-cab{color:var(--text);text-decoration:none}
.rc-card-cab:hover{color:var(--accent);text-decoration:underline}
/* sparkline 24h por circuito */
.spark{display:flex;gap:2px;margin-top:8px}
.spark i{flex:1 1 0;height:10px;min-width:2px;border-radius:2px;background:var(--gray-bg)}
.spark i.con{background:var(--green)}
.spark i.sin{background:var(--red)}
.spark i.nd{background:var(--amber)}
