/* Tema del panel interno. admin-dark.css (generado por scripts/build_admin_dark.py) traduce los
   colores de app.css; aquí van el botón de tema y los ajustes finos del oscuro que no se deducen
   solos: profundidad de las superficies, barra superior, foco, selección y barras de desplazamiento.

   Paleta oscura: carbón cálido y marfil, como el logotipo sobre negro. Tres alturas de superficie y una línea:
   --dk-page (fondo), --dk-card (tarjetas), --dk-raised (controles, filas activas), --dk-line. */

/* ---------- Botón de tema (ambos temas) ---------- */
.theme-toggle { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line-soft); border-radius: 11px; background: #fff; color: #58554e; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, transform .16s cubic-bezier(.23, 1, .32, 1); }
.theme-toggle:hover { border-color: #d0ccc3; background: #f5f8fc; }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle:focus-visible { outline: 3px solid #fbbf24; outline-offset: 1px; }
.theme-icon { grid-area: 1 / 1; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: opacity .2s ease, transform .3s cubic-bezier(.23, 1, .32, 1); }
.theme-icon-moon { fill: currentColor; stroke: none; }
/* En oscuro se ofrece el sol (pasar a claro); en claro, la luna. */
html[data-theme="dark"] .theme-icon-moon, html:not([data-theme="dark"]) .theme-icon-sun { opacity: 0; transform: rotate(-40deg) scale(.6); }
@media (prefers-reduced-motion: reduce) { .theme-icon, .theme-toggle { transition: none; } }

/* ---------- Oscuro ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --dk-page: #151413;
  --dk-card: #232220;
  --dk-raised: #2e2c29;
  --dk-line: #363430;
  --dk-line-strong: #45423d;
  --dk-text: #ece8df;
  --dk-muted: #a8a397;
  --dk-accent: #f4efe2;
  --sim-line: var(--dk-line);
  --sim-wash: #1f1e1c;
  --sim-muted: var(--dk-muted);
  --sim-ink: #ece8df;
  --line-soft: var(--dk-line);
  --ink: #ece8df;
  scrollbar-color: #4a4742 var(--dk-page);
}
html[data-theme="dark"] .admin-app { background: var(--dk-page); color: var(--dk-text); }
html[data-theme="dark"] ::selection { background: #f4efe2; color: #151413; }

/* Barra superior: vidrio oscuro sobre la página, sin el borde blanco de arriba. */
html[data-theme="dark"] .topbar { background: rgba(21, 20, 19, .94); box-shadow: 0 0 0 1px var(--dk-line), 0 14px 32px -20px rgba(0, 0, 0, .8); }
html[data-theme="dark"] .admin-app .topbar::before { background: var(--dk-page); }
html[data-theme="dark"] .topbar-sources { background: #1c1b19; border-color: var(--dk-line); }
html[data-theme="dark"] .topbar-sources button { color: #c4bfb4; }
html[data-theme="dark"] .topbar-sources button b { background: #34322e; color: #d1cdc4; }
html[data-theme="dark"] .topbar-sources button[aria-pressed="true"] { background: #46433e; color: #fff; box-shadow: inset 0 0 0 1px #5a564f; }
html[data-theme="dark"] .topbar-sources button[aria-pressed="true"] b { background: #2f4e7e; color: #fff; }
html[data-theme="dark"] .topbar-sources button:hover:not([aria-pressed="true"]) { background: #2b2926; }
html[data-theme="dark"] .theme-toggle, html[data-theme="dark"] .health-toggle, html[data-theme="dark"] .topbar-button, html[data-theme="dark"] .topbar-menu { border-color: var(--dk-line); background: var(--dk-raised); color: #dddad4; }
html[data-theme="dark"] .theme-toggle:hover, html[data-theme="dark"] .health-toggle:hover, html[data-theme="dark"] .topbar-button:hover { border-color: var(--dk-line-strong); background: #3a3833; }
html[data-theme="dark"] .theme-toggle { color: #fbd56b; }

/* Fondo de la página: un solo azul noche, sin el degradado claro del tema original. */
html[data-theme="dark"], html[data-theme="dark"] body.admin-app { background: var(--dk-page); }

/* Barra superior: con el botón de tema, el subtítulo y el atajo no se parten en dos líneas. */
.topbar-title small, .topbar-search kbd { white-space: nowrap; }
.topbar-title small { overflow: hidden; text-overflow: ellipsis; }

/* Mapas en oscuro: la intensidad sigue a la certeza. «Seguro» es el color más vivo y «ligero» el más
   apagado, para que lo más claro no parezca lo más fuerte sobre fondo oscuro. */
html[data-theme="dark"] .admin-app .sim-state { stroke: var(--dk-page); }
html[data-theme="dark"] .admin-app .sim-state.dem.safe, html[data-theme="dark"] .sim-scale-legend .dem.safe { --c: #4b8fe2; }
html[data-theme="dark"] .admin-app .sim-state.dem.likely, html[data-theme="dark"] .sim-scale-legend .dem.likely { --c: #346aa8; }
html[data-theme="dark"] .admin-app .sim-state.dem.lean, html[data-theme="dark"] .sim-scale-legend .dem.lean { --c: #284a73; }
html[data-theme="dark"] .admin-app .sim-state.rep.safe, html[data-theme="dark"] .sim-scale-legend .rep.safe { --c: #e0625a; }
html[data-theme="dark"] .admin-app .sim-state.rep.likely, html[data-theme="dark"] .sim-scale-legend .rep.likely { --c: #a9463f; }
html[data-theme="dark"] .admin-app .sim-state.rep.lean, html[data-theme="dark"] .sim-scale-legend .rep.lean { --c: #6a3536; }
html[data-theme="dark"] .admin-app .sim-state.tossup, html[data-theme="dark"] .sim-scale-legend .tossup { --c: #67635b; }
html[data-theme="dark"] .admin-app .sim-state.none { fill: #2a2926; }

/* Medios y redes en oscuro: verde y naranja que se leen sobre azul noche. */
html[data-theme="dark"] .media-panel { --up: #4ccf8a; --up-soft: rgba(76, 207, 138, .14); --down: #f08a5a; --down-soft: rgba(240, 138, 90, .15); }
html[data-theme="dark"] .media-sources-box.has-warn > summary { border-color: #6b5320; background: rgba(251, 191, 36, .1); color: #f6c453; }
.media-sources-box.has-warn > summary { border-color: #ecd49a; background: #fff8e6; color: #7a5a12; }
html[data-theme="dark"] .media-area .media-area-stop-bottom { stop-color: var(--dk-card); }
html[data-theme="dark"] .media-area-mid { stroke: var(--dk-line-strong); }
html[data-theme="dark"] .media-switch-track { background: #45423d; }
html[data-theme="dark"] .media-switch input:checked + .media-switch-track { background: #3f7fd6; }
html[data-theme="dark"] .media-mover-card:hover, html[data-theme="dark"] .social-icon:hover { border-color: var(--dk-line-strong); }
html[data-theme="dark"] .media-variation.is-on { border-color: #6b5320; background: rgba(251, 191, 36, .07); }
html[data-theme="dark"] .media-variation.is-on .media-variation-count { color: #f6c453; }
html[data-theme="dark"] .toast { border-color: var(--dk-line-strong); background: #2b2926; box-shadow: 0 20px 44px -16px rgba(0, 0, 0, .75); }
html[data-theme="dark"] .toast-body strong { color: var(--dk-text); }
html[data-theme="dark"] .toast-body span { color: var(--dk-muted); }
html[data-theme="dark"] .toast-close:hover { background: #3a3833; }
html[data-theme="dark"] .sim-blend-cell.is-result { border-color: #5a564f; background: #46433e; }

/* Notificaciones en oscuro. */
html[data-theme="dark"] .notif-toggle { border-color: var(--dk-line); background: var(--dk-raised); color: #dddad4; }
html[data-theme="dark"] .notif-toggle:hover { border-color: var(--dk-line-strong); background: #3a3833; }
html[data-theme="dark"] .notif-count { border-color: var(--dk-page); background: #e0625a; }
html[data-theme="dark"] .notif-scrim { background: rgba(0, 0, 0, .55); }
html[data-theme="dark"] .notif-panel { border-color: var(--dk-line-strong); background: var(--dk-card); box-shadow: 0 30px 70px -24px rgba(0, 0, 0, .85); }
html[data-theme="dark"] .notif-head h2, html[data-theme="dark"] .notif-title, html[data-theme="dark"] .notif-empty strong { color: var(--dk-text); }
html[data-theme="dark"] .notif-head p, html[data-theme="dark"] .notif-body, html[data-theme="dark"] .notif-empty p { color: #c4bfb4; }
html[data-theme="dark"] .notif-close { color: #c4bfb4; }
html[data-theme="dark"] .notif-close:hover, html[data-theme="dark"] .notif-go:hover { background: #3a3833; }
html[data-theme="dark"] .notif-filters, html[data-theme="dark"] .notif-item { border-color: var(--dk-line); }
html[data-theme="dark"] .notif-chip { border-color: var(--dk-line); background: var(--dk-raised); color: #dddad4; }
html[data-theme="dark"] .notif-chip:hover { border-color: var(--dk-line-strong); }
html[data-theme="dark"] .notif-chip b { color: var(--dk-muted); }
html[data-theme="dark"] .notif-chip[aria-pressed="true"] { border-color: #5a564f; background: #46433e; color: #fff; }
html[data-theme="dark"] .notif-select select { border-color: var(--dk-line); background-color: var(--dk-raised); color: var(--dk-text); }
html[data-theme="dark"] .notif-parties { background: #1c1b19; }
html[data-theme="dark"] .notif-title .notif-party { background: #7f7a71; }
html[data-theme="dark"] .notif-title .notif-party.dem { background: #3b74e0; }
html[data-theme="dark"] .notif-title .notif-party.rep { background: #c9534a; }
html[data-theme="dark"] .notif-seg { color: #c4bfb4; }
html[data-theme="dark"] .notif-seg[aria-pressed="true"] { background: #46433e; color: #fff; box-shadow: none; }
html[data-theme="dark"] .notif-seg.dem[aria-pressed="true"] { color: #9cc0ff; }
html[data-theme="dark"] .notif-seg.rep[aria-pressed="true"] { color: #ffaaa3; }
html[data-theme="dark"] .notif-status, html[data-theme="dark"] .notif-meta, html[data-theme="dark"] .notif-day { color: var(--dk-muted); }
html[data-theme="dark"] .notif-day { background: var(--dk-card); }
html[data-theme="dark"] .notif-kind { color: #dddad4; }
html[data-theme="dark"] .notif-platform { background: #34322e; color: #dddad4; }
html[data-theme="dark"] .notif-links a, html[data-theme="dark"] .notif-go { color: var(--dk-accent); }
html[data-theme="dark"] .notif-go { border-color: var(--dk-line); }
html[data-theme="dark"] .notif-icon { background: rgba(244, 239, 226, .1); color: var(--dk-accent); }
html[data-theme="dark"] .notif-item.up .notif-icon { background: rgba(76, 207, 138, .14); color: #4ccf8a; }
html[data-theme="dark"] .notif-item.down .notif-icon { background: rgba(240, 120, 100, .15); color: #f39a8a; }
html[data-theme="dark"] .notif-item.flip .notif-icon { background: rgba(246, 196, 83, .14); color: #f6c453; }
html[data-theme="dark"] .notif-item.sev-alta.up .notif-icon { background: #2f9e67; color: #fff; }
html[data-theme="dark"] .notif-item.sev-alta.down .notif-icon { background: #c9534a; color: #fff; }
html[data-theme="dark"] .notif-item.sev-alta.flip .notif-icon { background: #b8860f; color: #fff; }
html[data-theme="dark"] .notif-item.is-new .notif-title::after { background: var(--dk-accent); }
html[data-theme="dark"] .live-state-alerts button { color: var(--dk-text); }
html[data-theme="dark"] .live-state-alerts .down button { color: #f39a8a; }
html[data-theme="dark"] .live-state-alerts .up button { color: #4ccf8a; }
html[data-theme="dark"] .live-state-alerts small { color: var(--dk-muted); }

/* Estados con sólo primarias: un dorado apagado que no se confunde con los partidos. */
html[data-theme="dark"] .admin-app .sim-state.primary { --c: #7d6c3c; }
html[data-theme="dark"] .admin-app .sim-map-card .sim-legend .primary::before { background: #7d6c3c; }

/* Inicio en oscuro: el bloque de quién va adelante queda un escalón arriba de la tarjeta. */
html[data-theme="dark"] .home-verdict { background: var(--dk-raised); box-shadow: inset 0 0 0 1px var(--dk-line-strong); }
html[data-theme="dark"] .home-ledger-bar { background: #1c1b19; }
html[data-theme="dark"] .home-sub, html[data-theme="dark"] .home-office-name, html[data-theme="dark"] .home-col b,
html[data-theme="dark"] .home-changes-table tbody th, html[data-theme="dark"] .home-changes-table td b,
html[data-theme="dark"] .home-battles-head h2, html[data-theme="dark"] .battle-match, html[data-theme="dark"] .battle-bar b,
html[data-theme="dark"] .battle-stats dd { color: var(--dk-text); }
html[data-theme="dark"] .home-office, html[data-theme="dark"] .battle-button { border-color: var(--dk-line); background: var(--dk-card); }
html[data-theme="dark"] .home-office:hover, html[data-theme="dark"] .battle-button:hover { border-color: var(--dk-line-strong); box-shadow: 0 12px 28px -16px rgba(0, 0, 0, .8); }
html[data-theme="dark"] .home-office-plot, html[data-theme="dark"] .home-changes-table th, html[data-theme="dark"] .home-changes-table td,
html[data-theme="dark"] .battle-stats { border-color: var(--dk-line); }
html[data-theme="dark"] .home-col.dem b, html[data-theme="dark"] .home-changes-table td.dem b { color: #8db8ec; }
html[data-theme="dark"] .home-col.rep b, html[data-theme="dark"] .home-changes-table td.rep b { color: #f29a90; }
html[data-theme="dark"] .home-col.toss b { color: #c5c0b5; }
html[data-theme="dark"] .home-col.dem i, html[data-theme="dark"] .battle-bar.dem i { background: #4a86cf; }
html[data-theme="dark"] .home-col.rep i, html[data-theme="dark"] .battle-bar.rep i { background: #d5544b; }
html[data-theme="dark"] .home-col i, html[data-theme="dark"] .battle-track i { background: #827d74; }
html[data-theme="dark"] .home-delta.up { background: rgba(76, 207, 138, .14); color: #4ccf8a; }
html[data-theme="dark"] .home-delta.down { background: rgba(240, 120, 100, .15); color: #f39a8a; }
html[data-theme="dark"] .battle-race b, html[data-theme="dark"] .battle-name { color: #dddad4; }
html[data-theme="dark"] .battle-track { background: #1c1b19; }
html[data-theme="dark"] .battle-lead .sen-avatar { box-shadow: 0 0 0 2px var(--dk-card), 0 0 0 4px var(--c); }
html[data-theme="dark"] .battle.dem { --c: #6ea6e8; } html[data-theme="dark"] .battle.rep { --c: #ec7f74; }
html[data-theme="dark"] .battle.toss .battle-odds strong { color: #d1cdc4; }
html[data-theme="dark"] .battle-stats .up dd { color: #4ccf8a; } html[data-theme="dark"] .battle-stats .down dd { color: #f39a8a; } html[data-theme="dark"] .battle-stats .flip dd { color: #f6c453; }
html[data-theme="dark"] .home-verdict-title, html[data-theme="dark"] .home-ledger b { color: var(--dk-text); }
html[data-theme="dark"] .home-verdict-title .dem, html[data-theme="dark"] .home-ledger .dem b { color: #8db8ec; }
html[data-theme="dark"] .home-verdict-title .rep, html[data-theme="dark"] .home-ledger .rep b { color: #f29a90; }
html[data-theme="dark"] .home-ledger { color: #cfcbc3; }
html[data-theme="dark"] .home-verdict-meta { border-color: var(--dk-line-strong); color: var(--dk-muted); }
html[data-theme="dark"] .home-ledger-bar .toss { background: #827d74; } html[data-theme="dark"] .home-ledger-bar .dem { background: #4a86cf; } html[data-theme="dark"] .home-ledger-bar .rep { background: #d5544b; }

/* Tarjetas de contienda del análisis de sentimiento. */
html[data-theme="dark"] .rc-card { --rc-bg: #252321; --rc-soft: #2f2d2a; --rc-favor: #4ccf8a; --rc-neutral: #6a6762; --rc-against: #f08a5a; }
