/* ── SOMA Theme System ───────────────────────────────────────────────────────
   Dark mode tokens + hardcoded-value overrides.
   Loaded in <head> after inline :root styles so it wins the cascade.
   Applied via html[data-theme="dark"].
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Dark tokens ──────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  /* ── Elevation ladder (Claude-inspired: coherente, no navy-vs-azul) ──────────
     Decisión de Eric (2026-06-17): el chrome navy-casi-negro chocaba con el
     contenido gris-azul. Tomamos la coherencia de la dark de Claude:
       (1) CROMA MUY BAJO (~0.008) → superficies casi neutras, no azul saturado;
       (2) chrome CERCA del contenido (Δ~3 L, no un pozo negro) → una sola familia;
       (3) separación por hairline + sombra, no por saltos tonales.
     Se mantiene un susurro de hue navy (265) para no caer en gris frío puro, y el
     magenta sigue siendo la identidad. Aparta el "navy dueño del tono" del
     PRODUCT.md a propósito, por dirección explícita de Eric.
       chrome(16.5) · body(19) · card(22.5) · surface(26.5) · hover(30.5) */
  --c-body:       oklch(19%   0.007 265);   /* canvas */
  --c-card:       oklch(22.5% 0.008 265);   /* paneles primarios: dashboard, panel, burbujas */
  --c-sidebar:    oklch(16.5% 0.008 265);   /* chrome: solo ~2.5 bajo el body → coherente, sin pozo negro */
  --c-border:     oklch(31%   0.007 265);   /* hairline */
  --c-text:       oklch(94%   0.004 265);   /* off-white casi neutro */
  --c-text-sec:   oklch(72%   0.008 265);
  --c-text-muted: oklch(62%   0.008 265);
  --c-success:    oklch(72%   0.16  162);
  --c-warning:    oklch(78%   0.15  80);
  --c-error:      oklch(68%   0.19  25);
  /* Principio #3 (dark UI): los saturados VIBRAN en oscuro. Bajamos el croma del
     magenta (#DD1A72 ≈ L56 C0.205) manteniendo el MISMO L → no pierde contraste con
     el texto blanco de los botones, pero deja de sangrar/vibrar sobre el neutro. */
  --c-accent:     oklch(56%   0.17  352);

  /* Internal aliases for hardcoded-value overrides */
  --_surface:     oklch(26.5% 0.008 265);   /* raised: metric cards, inputs, code, tags */
  --_surface-alt: oklch(30.5% 0.008 265);   /* hover / pressed state */
  --_ring:        oklch(40%   0.008 265);   /* hover / focus border */
  --_shadow:      rgba(0, 0, 0, .50);        /* elevation drop shadow */
  --_overlay:     rgba(0, 0, 0, .60);
  --_glow:        0 2px 20px -6px rgba(221,26,114,.55);   /* glow de acento — SOLO elementos clave */
}

/* ── Elevation shadows (principio #6: profundidad por capas) ──────────────────
   Sombra en DOS capas — contacto (corta, definida) + ambiente (larga, difusa) —
   más un realce superior de 1px. Vende la profundidad sin glass ni glow de relleno.
   Solo en las superficies de contenido primarias (no el chrome, no los chips). */
html[data-theme="dark"] :is(.dash, .acard, .hist-row, .upd-card, .cfg-section, .login-card, .client-row, .ins-criteria-row) {
  box-shadow:
    0 1px 0 rgba(255,255,255,.05) inset,
    0 2px 5px -2px rgba(0,0,0,.5),
    0 14px 30px -12px rgba(0,0,0,.55);
}
html[data-theme="dark"] :is(.acard, .hist-row, .upd-card, .client-row):hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,.07) inset,
    0 3px 8px -3px rgba(0,0,0,.55),
    0 20px 40px -14px rgba(0,0,0,.6);
}

/* ── Glow de acento — disciplinado: SOLO CTAs de acento y estado activo ───────
   El glow comunica "esto es la acción / esto está vivo". Nunca decorativo, nunca
   en superficies neutras. */
html[data-theme="dark"] :is(.dash-gen-btn, .pabtn.primary, .ac-btn.p, .soma-deepdive.on) {
  box-shadow: var(--_glow);
}
html[data-theme="dark"] :is(.dash-gen-btn:hover, .pabtn.primary:hover, .ac-btn.p:hover) {
  box-shadow: 0 3px 26px -6px rgba(221,26,114,.7);
}
/* Pestaña activa: un resplandor tenue bajo el borde magenta (no un bloque). */
html[data-theme="dark"] .soma-tab.on {
  box-shadow: 0 6px 16px -10px rgba(221,26,114,.8);
}

/* ── Base reset ───────────────────────────────────────────────────────────── */
html[data-theme="dark"] body {
  background: var(--c-body);
  color: var(--c-text);
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .topbar {
  background: var(--c-sidebar);
  border-bottom-color: var(--c-accent);
}
/* La marca SOMA (neurona rosa) va limpia sobre el chrome oscuro, sin el recuadro
   magenta sólido que la ensuciaba. Igual que el tema claro. */
html[data-theme="dark"] .tb-dot {
  background: transparent;
}
html[data-theme="dark"] .tb-logo-name strong {
  color: #fff;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .sidebar {
  background: var(--c-sidebar);
  border-right-color: rgba(255,255,255,.05);
}
html[data-theme="dark"] .sb-row:hover,
html[data-theme="dark"] .sb-row.on {
  background: rgba(255,255,255,.05);
}
html[data-theme="dark"] .sb-foot-row:hover {
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.5);
}
html[data-theme="dark"] .sb-user {
  border-top-color: rgba(255,255,255,.05);
}
html[data-theme="dark"] .sb-lbl {
  color: rgba(255,255,255,.25);
}
html[data-theme="dark"] .sb-chip.r { background: rgba(226,75,74,.3);  color: oklch(72% 0.14 25); }
html[data-theme="dark"] .sb-chip.a { background: rgba(245,158,11,.2); color: oklch(78% 0.15 78); }

/* ── Panel (left analysis pane) ───────────────────────────────────────────── */
html[data-theme="dark"] .panel {
  background: var(--c-card);
  border-right-color: var(--c-border);
}
html[data-theme="dark"] .panel-head {
  border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .panel-badge.r {
  background: oklch(18% 0.07 25);
  color: oklch(72% 0.14 25);
}
html[data-theme="dark"] .panel-badge.a {
  background: oklch(18% 0.06 78);
  color: oklch(78% 0.15 78);
}
html[data-theme="dark"] .panel-badge.g {
  background: oklch(18% 0.07 155);
  color: oklch(75% 0.15 155);
}
html[data-theme="dark"] .msv-phase-val {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .status-chip.done {
  background: oklch(18% 0.07 155);
  color: oklch(75% 0.15 155);
}
html[data-theme="dark"] .status-chip.monday {
  background: oklch(18% 0.07 352);
  color: oklch(75% 0.15 352);
}
html[data-theme="dark"] .sprint-section-title.logros {
  color: oklch(74% 0.15 160);
}
html[data-theme="dark"] .gap-sent {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .monday-synced-ok {
  color: oklch(72% 0.16 155);
  border-color: rgba(22,163,74,.35);
  background: rgba(22,163,74,.16);
}
html[data-theme="dark"] .panel-lbl {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .panel-m {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .panel-mv {
  color: var(--c-text);
}
html[data-theme="dark"] .panel-sugs {
  border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .panel-actions {
  border-top-color: var(--c-border);
}
html[data-theme="dark"] .panel-ago {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .panel-corr {
  color: var(--c-text-sec);
}

/* ── Metrics grid ─────────────────────────────────────────────────────────── */
html[data-theme="dark"] .panel-mg {
  background: var(--_surface);
  border-color: var(--c-border);
}

/* ── MSV block ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .panel-msv {
  border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .msv-score-lbl,
html[data-theme="dark"] .msv-freq,
html[data-theme="dark"] .msv-empty {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .msv-phase-lbl {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .msv-phase-track {
  background: var(--c-border);
}
html[data-theme="dark"] .msv-badge {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}

/* ── Alert context cards ──────────────────────────────────────────────────── */
html[data-theme="dark"] .alert-ctx.critical {
  background: oklch(20% 0.055 25);
  border-color: oklch(34% 0.11 25);
}
html[data-theme="dark"] .alert-ctx.warning {
  background: oklch(20% 0.05 78);
  border-color: oklch(34% 0.10 78);
}
html[data-theme="dark"] .alert-ctx.positive {
  background: oklch(20% 0.05 155);
  border-color: oklch(34% 0.09 155);
}
html[data-theme="dark"] .alert-ctx.critical .alert-ctx-header { color: oklch(68% 0.18 25); }
html[data-theme="dark"] .alert-ctx.warning  .alert-ctx-header { color: oklch(74% 0.17 78); }
html[data-theme="dark"] .alert-ctx.positive .alert-ctx-header { color: oklch(66% 0.18 155); }
html[data-theme="dark"] .alert-ctx-msg { color: var(--c-text-sec); }
html[data-theme="dark"] .alert-ctx .sug {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .alert-ctx .sug:hover {
  background: var(--_surface-alt);
  border-color: var(--_ring);
}

/* ── Suggestion buttons ───────────────────────────────────────────────────── */
html[data-theme="dark"] .sug {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .sug:hover {
  background: var(--_surface-alt);
  border-color: var(--_ring);
}
html[data-theme="dark"] .sug:hover .sug-txt {
  color: var(--c-text);
}
html[data-theme="dark"] .sug-txt {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .sug-group-hdr {
  color: var(--c-text);
}

/* ── Tabs bar ─────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .tabs-bar {
  background: var(--c-card);
  border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .tab-btn {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .tab-btn:hover {
  color: var(--c-text);
}
html[data-theme="dark"] .tab-btn.on {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
}

/* ── Chat area ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .chat-msgs {
  background: var(--c-body);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) {
  background: var(--c-card);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) h2,
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) h3,
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) h4,
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) strong {
  color: var(--c-text);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) table {
  color: var(--c-text);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) tr:hover td {
  background: var(--_surface);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) th {
  background: var(--_surface);
  color: var(--c-text-muted);
  border-color: var(--c-border);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) td {
  border-color: var(--c-border);
}
/* The dashboard (renderSomaJSON) draws its dividers as INLINE border colors on
   <tr> and <div> (hardcoded light hex for light mode). Inline styles beat the
   stylesheet, so dark mode can't recolor them via td/th rules. Override the
   inline borders directly so the row/section separators stay visible on the
   dark card instead of vanishing or reading as harsh near-white lines. */
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) [style*="border-bottom"] {
  border-bottom-color: rgba(255,255,255,.14) !important;
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) [style*="border-left"] {
  border-left-color: rgba(255,255,255,.18) !important;
}
/* ── TOOL-WIDE inline dark-mode sweep ─────────────────────────────────────────
   Every page paints JS-rendered content with hardcoded LIGHT hex (built for
   light mode). theme.css class rules can't reach inline styles, so this remaps
   the WHOLE inline palette across the app by property+value. Case-insensitive
   (i). Dark theme only — light mode is never touched. Surfaces↔text are paired
   inversions of the same hue so contrast stays correct. Saturated accent fills
   (magenta #DD1A72, #D97706, #059669, #0284C7, status dots, change pills text)
   are LEFT vivid — they read fine on dark. */

/* Neutral light surfaces → dark elevation */
html[data-theme="dark"] [style*="background:#FAFBFC" i],
html[data-theme="dark"] [style*="background:#F4F6FB" i],
html[data-theme="dark"] [style*="background:#E6EBF4" i],
html[data-theme="dark"] [style*="background:#FAFAFA" i],
html[data-theme="dark"] [style*="background:#E9EDF5" i],
html[data-theme="dark"] [style*="background:#FFFFFF" i],
html[data-theme="dark"] [style*="background: #fff;" i],
html[data-theme="dark"] [style*="background:#fff;" i],
html[data-theme="dark"] .soma-gap-card {
  background: var(--_surface) !important;
}
html[data-theme="dark"] [style*="background:#DDE3EE" i],
html[data-theme="dark"] [style*="background:#C4CCDC" i] { background: var(--c-border) !important; }
/* Tinted light surfaces → dark tint of the same hue */
html[data-theme="dark"] [style*="background:#FEE2E2" i],
html[data-theme="dark"] [style*="background:#FEF2F2" i],
html[data-theme="dark"] [style*="background:#FFF1F2" i],
html[data-theme="dark"] [style*="background:#FCE7F3" i],
html[data-theme="dark"] [style*="background:#FDF2F8" i] { background: rgba(220,38,38,.16) !important; }
html[data-theme="dark"] [style*="background:#DCFCE7" i],
html[data-theme="dark"] [style*="background:#ECFDF5" i],
html[data-theme="dark"] [style*="background:#F0FDF4" i] { background: rgba(22,163,74,.16) !important; }
html[data-theme="dark"] [style*="background:#FFFBEB" i],
html[data-theme="dark"] [style*="background:#FEF3C7" i],
html[data-theme="dark"] [style*="background:#FEF9C3" i] { background: rgba(245,158,11,.15) !important; }
html[data-theme="dark"] [style*="background:#EFF6FF" i],
html[data-theme="dark"] [style*="background:#F0F9FF" i],
html[data-theme="dark"] [style*="background:#DBEAFE" i] { background: oklch(22% 0.045 245) !important; }
html[data-theme="dark"] [style*="background:#F9F5FF" i],
html[data-theme="dark"] [style*="background:#F3E8FF" i] { background: oklch(24% 0.05 300) !important; }

/* ── Extended sweep — light fills enumerated from EVERY page/tab ───────────────
   Backgrounds the original sweep missed (attribution resumen/chips, plan, pérdidas,
   oportunidades, diagnóstico, etc.). Same hue-paired remapping. Keeps the sweep
   tool-wide so any tab inherits dark surfaces without per-view CSS. */
/* Neutral fills → dark elevation */
html[data-theme="dark"] [style*="background:#F1F5FB" i],
html[data-theme="dark"] [style*="background:#F8FAFC" i],
html[data-theme="dark"] [style*="background:#F1F5F9" i],
html[data-theme="dark"] [style*="background: #F1F5FB" i],
html[data-theme="dark"] [style*="background:#EEF2F8" i] { background: var(--_surface) !important; }
/* Pink / magenta fills (attribution resumen) → dark pink tint */
html[data-theme="dark"] [style*="background:#FFF7FB" i],
html[data-theme="dark"] [style*="background:#FFF0F6" i],
html[data-theme="dark"] [style*="background:#FDE4EF" i],
html[data-theme="dark"] [style*="background:#FFF1F7" i] { background: oklch(22% 0.05 350) !important; }
/* Green fills → dark green tint */
html[data-theme="dark"] [style*="background:#D1FAE5" i],
html[data-theme="dark"] [style*="background:#BBF7D0" i] { background: rgba(22,163,74,.16) !important; }
/* Blue fills → dark blue tint */
html[data-theme="dark"] [style*="background:#E0F2FE" i],
html[data-theme="dark"] [style*="background:#E0E7FF" i] { background: oklch(22% 0.045 245) !important; }
/* Purple fills → dark purple tint */
html[data-theme="dark"] [style*="background:#DDD6FE" i],
html[data-theme="dark"] [style*="background:#EDE9FE" i] { background: oklch(24% 0.05 300) !important; }

/* Light tint BORDERS → dark-tint border of the same hue (kills harsh light hairlines
   on tinted cards). The vivid metric-card borders (#F87171/#4ADE80) are NOT listed,
   so they stay bold. Matches the "solid #HEX" inline form. */
html[data-theme="dark"] [style*="solid #F3D4E4" i],
html[data-theme="dark"] [style*="solid #F4C4DA" i],
html[data-theme="dark"] [style*="solid #F9D1E6" i],
html[data-theme="dark"] [style*="solid #FBCFE8" i],
html[data-theme="dark"] [style*="solid #FDE4EF" i],
html[data-theme="dark"] [style*="solid #F9D1E6" i] { border-color: rgba(232,31,118,.34) !important; }
html[data-theme="dark"] [style*="solid #FECACA" i],
html[data-theme="dark"] [style*="solid #FCA5A5" i],
html[data-theme="dark"] [style*="solid #FECDD3" i] { border-color: rgba(220,38,38,.38) !important; }
html[data-theme="dark"] [style*="solid #FDE68A" i],
html[data-theme="dark"] [style*="solid #FCD34D" i] { border-color: rgba(245,158,11,.38) !important; }
html[data-theme="dark"] [style*="solid #86EFAC" i],
html[data-theme="dark"] [style*="solid #A7F3D0" i],
html[data-theme="dark"] [style*="solid #BBF7D0" i] { border-color: rgba(22,163,74,.38) !important; }
html[data-theme="dark"] [style*="solid #BAE6FD" i],
html[data-theme="dark"] [style*="solid #BFDBFE" i],
html[data-theme="dark"] [style*="solid #93C5FD" i] { border-color: rgba(59,130,246,.40) !important; }
html[data-theme="dark"] [style*="solid #E8DEF8" i],
html[data-theme="dark"] [style*="solid #DDD6FE" i] { border-color: rgba(139,92,246,.40) !important; }
html[data-theme="dark"] [style*="solid #D8D4C8" i] { border-color: var(--c-border) !important; }
html[data-theme="dark"] [style*="solid #DDE3EE" i],
html[data-theme="dark"] [style*="dashed #DDE3EE" i],
html[data-theme="dark"] [style*="dashed #C4CCDC" i] { border-color: var(--c-border) !important; }

/* Dark text → readable light (paired with the surfaces above) */
html[data-theme="dark"] [style*="color:#0F172A" i],
html[data-theme="dark"] [style*="color:#78350F" i],
html[data-theme="dark"] [style*="color:#1E293B" i] { color: var(--c-text) !important; }
html[data-theme="dark"] [style*="color:#334155" i],
html[data-theme="dark"] [style*="color:#475569" i],
html[data-theme="dark"] [style*="color:#586273" i] { color: var(--c-text-sec) !important; }
html[data-theme="dark"] [style*="color:#7F1D1D" i],
html[data-theme="dark"] [style*="color:#991B1B" i],
html[data-theme="dark"] [style*="color:#B91C1C" i],
html[data-theme="dark"] [style*="color:#E5484D" i] { color: oklch(70% 0.17 25) !important; }
html[data-theme="dark"] [style*="color:#14532D" i],
html[data-theme="dark"] [style*="color:#166534" i],
html[data-theme="dark"] [style*="color:#065F46" i],
html[data-theme="dark"] [style*="color:#15803D" i],
html[data-theme="dark"] [style*="color:#16A34A" i],
html[data-theme="dark"] [style*="color:#0E9F6E" i] { color: oklch(72% 0.16 155) !important; }
html[data-theme="dark"] [style*="color:#1E3A5F" i],
html[data-theme="dark"] [style*="color:#0369A1" i],
html[data-theme="dark"] [style*="color:#1E3A8A" i],
html[data-theme="dark"] [style*="color:#0C4A6E" i],
html[data-theme="dark"] [style*="color:#2563EB" i] { color: oklch(82% 0.07 245) !important; }
html[data-theme="dark"] [style*="color:#92400E" i],
html[data-theme="dark"] [style*="color:#B45309" i],
html[data-theme="dark"] [style*="color:#A16207" i],
html[data-theme="dark"] [style*="color:#B8730A" i] { color: oklch(80% 0.13 75) !important; }
html[data-theme="dark"] [style*="color:#6B21A8" i],
html[data-theme="dark"] [style*="color:#4A154B" i] { color: oklch(78% 0.12 300) !important; }
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) a {
  color: oklch(68% 0.18 245);
}
html[data-theme="dark"] :is(.mbubble.soma,.dash-content) code {
  background: var(--_surface);
  color: var(--c-text);
}
html[data-theme="dark"] .mavatar.soma {
  background: oklch(13% 0.04 260);
  color: var(--c-accent);
  border-color: rgba(232,31,118,.25);
}
html[data-theme="dark"] .typing span {
  background: var(--c-border);
}
html[data-theme="dark"] .stop-btn {
  background: var(--c-card);
  border-color: var(--c-border);
  color: var(--c-text-muted);
}
html[data-theme="dark"] .stop-btn:hover {
  color: var(--c-text);
  border-color: var(--_ring);
}
html[data-theme="dark"] .empty-state {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .retry-btn {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] .retry-row {
  background: oklch(14% 0.05 25);
  border-color: oklch(22% 0.09 25);
}

/* ── Chat input ───────────────────────────────────────────────────────────── */
html[data-theme="dark"] .chat-input-area {
  background: var(--c-card);
  border-top-color: var(--c-border);
}
html[data-theme="dark"] .chat-input-wrap {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .chat-input-wrap:focus-within {
  border-color: var(--_ring);
}
html[data-theme="dark"] .chat-input-wrap input {
  color: var(--c-text);
}
html[data-theme="dark"] .chat-input-wrap input::placeholder {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .chat-hint {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .clip-btn {
  border-color: var(--c-border);
  color: var(--c-text-muted);
}
html[data-theme="dark"] .clip-btn:hover {
  background: var(--_surface);
  border-color: var(--_ring);
  color: var(--c-text);
}
html[data-theme="dark"] .clip-btn.has-file {
  color: var(--c-accent);
  border-color: var(--c-accent);
}

/* ── File preview chip ────────────────────────────────────────────────────── */
html[data-theme="dark"] .file-preview {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] .file-preview .fp-size {
  color: var(--c-text-muted);
}

/* ── Magic prompt menu ────────────────────────────────────────────────────── */
html[data-theme="dark"] .magic-btn {
  border-color: var(--c-border);
  color: var(--c-text-muted);
}
html[data-theme="dark"] .magic-btn:hover {
  background: var(--_surface);
  border-color: var(--_ring);
  color: var(--c-text);
}
html[data-theme="dark"] .magic-menu {
  background: var(--c-card);
  border-color: var(--c-border);
  box-shadow: 0 8px 32px var(--_shadow);
}
html[data-theme="dark"] .magic-head {
  border-bottom-color: var(--c-border);
  color: var(--c-text-muted);
}
html[data-theme="dark"] .magic-head button { color: var(--c-text-muted); }
html[data-theme="dark"] .magic-head button:hover { color: var(--c-text); }
html[data-theme="dark"] .magic-cat:hover {
  background: var(--_surface);
}
html[data-theme="dark"] .magic-prompt:hover {
  background: oklch(17% 0.04 350);
  color: var(--c-text);
}

/* ── Action buttons ───────────────────────────────────────────────────────── */
html[data-theme="dark"] .pabtn {
  background: var(--c-card);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] .pabtn:hover {
  background: var(--_surface);
  border-color: var(--_ring);
  color: var(--c-text);
}
html[data-theme="dark"] .pabtn.primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* ── Dashboard tab ────────────────────────────────────────────────────────── */
html[data-theme="dark"] .dash {
  background: var(--c-card);
}
html[data-theme="dark"] .dash-empty {
  color: var(--c-text-muted);
}

/* ── Panel badges (alertas sidebar) ──────────────────────────────────────── */
html[data-theme="dark"] .sb-chip {
  color: var(--c-text-muted);
}

/* ── Confirm overlay ──────────────────────────────────────────────────────── */
html[data-theme="dark"] .confirm-overlay {
  background: var(--_overlay);
}
html[data-theme="dark"] .confirm-card {
  background: var(--c-card);
  box-shadow: 0 12px 40px var(--_shadow);
}
html[data-theme="dark"] .confirm-title {
  color: var(--c-text);
}
html[data-theme="dark"] .confirm-body {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .confirm-cancel {
  background: var(--c-card);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] .confirm-cancel:hover {
  border-color: var(--_ring);
  color: var(--c-text);
}

/* ── Insights panel (index/overview) ─────────────────────────────────────── */
html[data-theme="dark"] .insights-panel,
html[data-theme="dark"] .ov-panel {
  background: var(--c-body);
}
html[data-theme="dark"] .ins-avg-lbl,
html[data-theme="dark"] .ins-phase-name,
html[data-theme="dark"] .ins-stat-lbl,
html[data-theme="dark"] .ins-delta-domain,
html[data-theme="dark"] .ins-section-lbl {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .ins-phase-track {
  background: var(--c-border);
}
html[data-theme="dark"] .ins-stat {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .ins-delta-item {
  border-bottom-color: var(--c-border);
}
html[data-theme="dark"] .ins-criteria-row {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .ins-compare-col {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .ins-compare-divider {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .ins-compare-col-label {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .ins-compare-phase-name {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .ins-compare-phase-track {
  background: var(--c-border);
}
html[data-theme="dark"] .ins-compare-stats {
  background: var(--_surface);
  border-color: var(--c-border);
}

/* ── Overview / main page cards ───────────────────────────────────────────── */
html[data-theme="dark"] .acard {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .acard:hover {
  border-color: var(--_ring);
}
html[data-theme="dark"] .ac-domain {
  color: var(--c-text);
}
html[data-theme="dark"] .ac-score-lbl,
html[data-theme="dark"] .ac-meta {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .ac-btn {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text-sec);
}
html[data-theme="dark"] .ac-btn:hover {
  background: var(--_surface-alt);
  color: var(--c-text);
}
html[data-theme="dark"] .ac-btn.p {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

/* ── Historial ────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .hist-row {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .hist-domain {
  color: var(--c-text);
}
html[data-theme="dark"] .hist-date,
html[data-theme="dark"] .hist-meta {
  color: var(--c-text-muted);
}

/* ── Actualizaciones ──────────────────────────────────────────────────────── */
html[data-theme="dark"] .upd-card {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .upd-title {
  color: var(--c-text);
}
html[data-theme="dark"] .upd-body {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .upd-date {
  color: var(--c-text-muted);
}
html[data-theme="dark"] .tag {
  background: var(--_surface);
  color: var(--c-text-sec);
}

/* ── Configuracion ────────────────────────────────────────────────────────── */
html[data-theme="dark"] .cfg-section {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .cfg-label {
  color: var(--c-text-sec);
}
html[data-theme="dark"] .cfg-input,
html[data-theme="dark"] .cfg-select {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text);
}
html[data-theme="dark"] .cfg-input:focus,
html[data-theme="dark"] .cfg-select:focus {
  border-color: var(--_ring);
  outline: 2px solid rgba(232,31,118,.25);
}
html[data-theme="dark"] .cfg-hint {
  color: var(--c-text-muted);
}

/* ── Login ────────────────────────────────────────────────────────────────── */
html[data-theme="dark"] .login-card {
  background: var(--c-card);
  border-color: var(--c-border);
  box-shadow: 0 8px 32px var(--_shadow);
}
html[data-theme="dark"] .login-input {
  background: var(--_surface);
  border-color: var(--c-border);
  color: var(--c-text);
}
html[data-theme="dark"] .login-input:focus {
  border-color: var(--_ring);
}
html[data-theme="dark"] .login-label {
  color: var(--c-text-sec);
}

/* ── Clientes page ────────────────────────────────────────────────────────── */
html[data-theme="dark"] .client-row {
  background: var(--c-card);
  border-color: var(--c-border);
}
html[data-theme="dark"] .client-row:hover {
  border-color: var(--_ring);
}
html[data-theme="dark"] .client-name {
  color: var(--c-text);
}
html[data-theme="dark"] .client-meta {
  color: var(--c-text-muted);
}

/* ── Main / .main / .page areas ──────────────────────────────────────────── */
html[data-theme="dark"] .main,
html[data-theme="dark"] .page {
  background: var(--c-body);
}

/* ── Page headings ────────────────────────────────────────────────────────── */
html[data-theme="dark"] .page-title {
  color: var(--c-text);
}
html[data-theme="dark"] .page-sub,
html[data-theme="dark"] .page-desc {
  color: var(--c-text-sec);
}

/* ── Scrollbars (Webkit) ──────────────────────────────────────────────────── */
html[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--c-body);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: oklch(28% 0.018 258);
  border-radius: 4px;
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: oklch(34% 0.018 258);
}

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: none;
  border: 1px solid rgba(255, 255, 255, .13);
  color: rgba(255, 255, 255, .55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: border-color .12s, color .12s, background .12s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: rgba(255, 255, 255, .3);
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .05);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* ── Transition for smooth theme switching ─────────────────────────────────  */
*, *::before, *::after {
  transition:
    background-color .18s ease,
    border-color .18s ease,
    color .18s ease,
    box-shadow .18s ease;
}
/* Exclude elements where transitions cause jank */
.chat-msgs *,
.mbubble *,
.typing span,
[class*="animate"],
.chart-container * {
  transition: none !important;
}

/* ── Feedback en el toque, no en el clic (apple-design §1 — Respuesta) ───────
   Antes NINGÚN botón de SOMA tenía :active — solo :hover, así que el toque no
   se sentía hasta que el clic terminaba. No se toca la propiedad `transition`
   (cada página ya declara la suya para border/background/color por botón; una
   regla nueva de `transition` en el mismo selector la reemplazaría entera, no
   se suma). Por eso esto es solo el cambio de `transform` en :active — se ve
   al instante en el press y el navegador lo revierte sin animación al soltar,
   que sigue siendo "responde en el momento", no un salto tardío al final. */
button:not(:disabled):active,
[role="button"]:active,
a.btn-primary:active,
a.btn-google:active,
a.nav-cta:active {
  transform: scale(.97);
}

/* ── Dropdowns anclados al trigger (apple-design §7/§12 — Consistencia
   espacial + materializar) ───────────────────────────────────────────────
   .avatar-menu, .ac-menu, .sb-client-menu y #clientSwitchMenu (cephalopoda)
   eran display:none→block instantáneo — sin relación visual con el botón
   que los abre. .magic-menu ya resolvía esto con un scale/fade anclado
   (@keyframes magicIn en cada página); esto lleva el mismo tratamiento a
   los otros cuatro, con transform-origin real por posición de cada uno
   (avatar-menu/ac-menu cuelgan a la derecha del trigger → top right;
   sb-client-menu es full-width bajo el botón → top center; #clientSwitchMenu
   cuelga a la izquierda → top left). No se toca `display`, solo se agrega
   `animation` a la clase .open ya existente — mismo patrón no-destructivo
   que el fix de :active de arriba. */
@keyframes soma-menu-in {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
.avatar-menu.open,
.ac-menu.open {
  animation: soma-menu-in .13s cubic-bezier(.2, .8, .2, 1);
  transform-origin: top right;
}
.sb-client-menu.open {
  animation: soma-menu-in .13s cubic-bezier(.2, .8, .2, 1);
  transform-origin: top center;
}
#clientSwitchMenu.open {
  animation: soma-menu-in .13s cubic-bezier(.2, .8, .2, 1);
  transform-origin: top left;
}
/* cephalopoda.html no declara su propio @media(prefers-reduced-motion) —
   a diferencia de las otras 11 páginas — así que #clientSwitchMenu
   necesita este override aquí para no ignorar la preferencia del usuario. */
@media (prefers-reduced-motion: reduce) {
  .avatar-menu.open,
  .ac-menu.open,
  .sb-client-menu.open,
  #clientSwitchMenu.open {
    animation: none;
  }
}

/* ── Modales/diálogos: materializar en vez de aparecer de golpe
   (apple-design §12 — Materializar, no solo desvanecer) ────────────────────
   .slack-dialog/.ctx-dialog/.confirm-overlay se crean vía JS ya completos
   (dialog.className='...'; document.body.appendChild(...)) y se destruyen con
   .remove() al cerrar — no hay clase .open que alternar, así que la animación
   va directo en la clase base: corre sola en cuanto el elemento entra al
   árbol de render, sin JS nuevo, y no vuelve a correr porque el elemento no
   se reutiliza (se crea de cero cada vez que se abre).
   #settingsOverlay (drawer de configuración del cliente, analisis.html) es la
   excepción: vive siempre en el DOM y se alterna con style.display inline
   ('none'→'block'). Un elemento con display:none no está en el árbol de
   render, así que volver a 'block' technically re-entra al árbol — el
   navegador reinicia cualquier animation definida en él, igual que una
   inserción nueva. Es un drawer de borde derecho (position:absolute;right:0),
   no un modal centrado, así que entra con slide horizontal (mismo origen
   espacial que su posición final — apple-design §7), no con scale. */
@keyframes soma-scrim-in  { from { opacity: 0 } to { opacity: 1 } }
@keyframes soma-card-in   { from { opacity: 0; transform: scale(.95) } to { opacity: 1; transform: scale(1) } }
@keyframes soma-drawer-in { from { transform: translateX(100%) } to { transform: translateX(0) } }

.slack-dialog, .ctx-dialog, .confirm-overlay, #settingsOverlay {
  animation: soma-scrim-in .15s ease-out;
}
.slack-box, .ctx-box, .confirm-card {
  animation: soma-card-in .18s cubic-bezier(.2, .8, .2, 1);
}
#settingsOverlay > div {
  animation: soma-drawer-in .22s cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .slack-dialog, .ctx-dialog, .confirm-overlay, .slack-box, .ctx-box, .confirm-card,
  #settingsOverlay, #settingsOverlay > div {
    animation: none;
  }
}

/* ── Page class-rule overrides (each page's own <style> hardcodes light hex) ──
   These cannot be reached by the inline sweep above; they live in per-page
   stylesheets. Add dark variants by class. Dark theme only. */

/* Shared GSC / update status bar (clientes, alertas, actualizaciones, historial) */
html[data-theme="dark"] .gsc-bar {
  background: rgba(16,185,129,.12) !important;
  border-bottom-color: rgba(16,185,129,.28) !important;
  color: oklch(80% 0.12 162) !important;
}
html[data-theme="dark"] .gsc-bar.warn {
  background: rgba(245,158,11,.13) !important;
  border-color: rgba(245,158,11,.30) !important;
  color: oklch(84% 0.11 80) !important;
}

/* Alerts page: metric strip + secondary buttons */
html[data-theme="dark"] .ac-metrics { background: var(--_surface) !important; }
html[data-theme="dark"] .ac-m + .ac-m { border-left-color: var(--c-border) !important; }
/* NOTA: esta regla antes ponía background:var(--_surface) con !important, que
   silenciosamente anulaba el var(--_surface-alt) de la regla de arriba (línea
   ~654) — el hover de .ac-btn nunca se veía distinto del estado normal. Ahora
   usa el mismo valor que esa regla en vez de cancelarlo, y solo añade lo que
   esa regla no tenía (border-color). */
html[data-theme="dark"] .ac-btn:hover {
  background: var(--_surface-alt) !important;
  border-color: var(--_ring) !important;
}

/* ── Form fields + skeletons (tool-wide; inputs default to white otherwise) ── */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--_surface) !important;
  color: var(--c-text) !important;
  border-color: var(--c-border) !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: var(--c-text-muted) !important; }
html[data-theme="dark"] .skeleton { background: var(--c-border) !important; }

/* ── Colored tint CLASSES across pages (banners, badges, tags, buttons) ───────
   Each page's stylesheet hardcodes light tints with dark text. In dark mode
   give them a dark tint of the same hue + light text. Enumerated from the
   per-page stylesheets. */

/* Amber banners (prominent) */
html[data-theme="dark"] .update-banner {
  background: rgba(245,158,11,.13) !important;
  border-color: rgba(245,158,11,.30) !important;
  border-left-color: #F59E0B !important;
  color: oklch(84% 0.11 80) !important;
}
/* Amber badge/score tints */
html[data-theme="dark"] .ac-badge.a,
html[data-theme="dark"] .tag.a,
html[data-theme="dark"] .type-spam,
html[data-theme="dark"] .msv-score.ok,
html[data-theme="dark"] .badge-active {
  background: rgba(245,158,11,.18) !important;
  color: oklch(83% 0.12 80) !important;
}
/* Red / pink tints */
html[data-theme="dark"] .ac-badge.r,
html[data-theme="dark"] .tag.r,
html[data-theme="dark"] .msv-score.bad,
html[data-theme="dark"] .btn-remove,
html[data-theme="dark"] .btn-hide.is-hidden,
html[data-theme="dark"] .type-link-spam,
html[data-theme="dark"] .cfg-msg.err {
  background: rgba(220,38,38,.16) !important;
  color: oklch(74% 0.16 25) !important;
}
html[data-theme="dark"] .btn-remove:hover,
html[data-theme="dark"] .btn-delete:hover { background: rgba(220,38,38,.26) !important; }
/* Blue tints */
html[data-theme="dark"] .account-badge,
html[data-theme="dark"] .tag.b,
html[data-theme="dark"] .type-core {
  background: rgba(59,130,246,.16) !important;
  color: oklch(80% 0.10 245) !important;
}
/* Purple tints */
html[data-theme="dark"] .btn-slack.linked,
html[data-theme="dark"] .type-product-reviews {
  background: rgba(139,92,246,.18) !important;
  color: oklch(80% 0.12 300) !important;
}
/* Magenta retry buttons (keep accent text/border, dark surface) */
/* .retry-btn background ya está cubierto arriba (línea ~449) — esta era una
   redeclaración redundante del mismo valor, dejada de un parche incremental. */
html[data-theme="dark"] .retry-btn:hover { background: var(--_surface-alt) !important; }
/* Gray hovers / separators / stripes */
html[data-theme="dark"] .btn-cancel:hover,
html[data-theme="dark"] .ctx-chip:hover,
html[data-theme="dark"] .selector-sep,
html[data-theme="dark"] .acard-stripe.pending { background: var(--c-border) !important; }

/* Update banner inner text (dark browns → light amber on the dark banner) */
html[data-theme="dark"] .update-banner-title { color: oklch(88% 0.10 82) !important; }
html[data-theme="dark"] .update-banner-desc  { color: oklch(80% 0.09 78) !important; }
html[data-theme="dark"] .update-banner-date  { color: oklch(72% 0.08 72) !important; }

/* ── Action-plan badges (renderSomaJSON .actions) ─────────────────────────────
   Level/impact/effort/agent badges use saturated light-mode TEXT colors that
   are too dark to read on the dark card. Lighten only the text; the faint tint
   backgrounds (hex+alpha) read fine on dark. */
html[data-theme="dark"] [style*="color:#021D49" i] { color: var(--c-text) !important; }       /* agent label */
html[data-theme="dark"] [style*="color:#DC2626" i] { color: oklch(72% 0.17 25)  !important; } /* red / bloqueo / alto */
html[data-theme="dark"] [style*="color:#EA580C" i] { color: oklch(76% 0.16 50)  !important; } /* orange / estructura */
html[data-theme="dark"] [style*="color:#D97706" i] { color: oklch(81% 0.13 70)  !important; } /* amber / fundamento / medio */
html[data-theme="dark"] [style*="color:#0284C7" i] { color: oklch(76% 0.13 240) !important; } /* blue / optimización / page */
html[data-theme="dark"] [style*="color:#059669" i] { color: oklch(74% 0.15 160) !important; } /* green / crecimiento / bajo */
html[data-theme="dark"] [style*="color:#7C3AED" i] { color: oklch(73% 0.15 295) !important; } /* purple / autoridad */

/* ── Análisis: dashboard chrome + secondary buttons ───────────────────────────
   Class rules in analisis.html that hardcode light hex and weren't reachable by
   the inline sweep. The sticky tabbar / toolbar now use var(--c-card)+var(--c-border)
   directly (correct in both themes); these cover the remaining secondary surfaces. */
/* COPIAR — ghost button: kill the white fill, soften the pink border on dark */
html[data-theme="dark"] .pabtn.ghost-accent {
  background: transparent;
  border-color: rgba(232,31,118,.45);
}
html[data-theme="dark"] .pabtn.ghost-accent:hover {
  background: rgba(232,31,118,.12);
  color: var(--c-accent);
}
/* "Refrescar y comparar" panel */
html[data-theme="dark"] .compare-panel {
  background: var(--_surface);
  border-color: var(--c-border);
}
html[data-theme="dark"] .compare-panel .cp-base { color: var(--c-text-muted); }
/* Deep-dive ghost button hover (transparent base is fine on dark) */
html[data-theme="dark"] .soma-deepdive:hover,
html[data-theme="dark"] .soma-deepdive.on {
  background: var(--c-accent);
  color: #fff;
}

/* ── Brief de Sprint + Forecast SEO (clases con hex claro, no alcanzadas por el
   barrido inline). Sin override, sus tarjetas quedaban CLARAS y el texto var(--c-text)
   —casi blanco en dark— resultaba invisible encima. */
html[data-theme="dark"] .sprint-list li { background: var(--_surface); }
html[data-theme="dark"] .sprint-priority {
  background: var(--_surface);
  border-left-color: oklch(62% 0.16 295);   /* púrpura legible en dark (era #6d28d9 oscuro) */
}
html[data-theme="dark"] .sprint-priority-action { color: var(--c-text); }
html[data-theme="dark"] .sprint-question {
  background: oklch(22% 0.045 245);          /* tinte azul oscuro */
  border-color: oklch(34% 0.07 245);
}
html[data-theme="dark"] .sprint-section-title.prioridades { color: oklch(74% 0.14 295); }
html[data-theme="dark"] .sprint-section-title.situacion   { color: oklch(78% 0.10 245); }
html[data-theme="dark"] .sprint-section-title.incidentes  { color: oklch(78% 0.13 70); }
html[data-theme="dark"] .forecast-scenario { background: var(--_surface); }
html[data-theme="dark"] .forecast-scenario.primary {
  background: oklch(22% 0.05 350);           /* tinte rosa oscuro */
  border-color: rgba(232,31,118,.34);
}
html[data-theme="dark"] .forecast-disclaimer { background: var(--_surface); }
html[data-theme="dark"] .forecast-badge.alta  { background: rgba(22,163,74,.16);  color: oklch(78% 0.14 162); }
html[data-theme="dark"] .forecast-badge.media { background: rgba(245,158,11,.16); color: oklch(82% 0.12 80); }
html[data-theme="dark"] .forecast-badge.baja  { background: rgba(220,38,38,.16);  color: oklch(74% 0.16 25); }
/* Badges del menú ✨ (Nuevo/Junta): texto medio-oscuro sobre tinte → aclarar en dark */
html[data-theme="dark"] [style*="color:#be185d" i] { color: oklch(76% 0.15 0) !important; }
html[data-theme="dark"] [style*="color:#1d4ed8" i] { color: oklch(78% 0.12 262) !important; }

/* ── Barrido agente-por-página (2026-06-17): reglas de CLASE con fondo/borde claro
   sin override dark, halladas auditando las 9 páginas. El barrido inline no alcanza
   reglas de clase; éstas cierran ese hueco de raíz. theme.css es compartido → una
   regla cubre la misma clase en todas las páginas que la usen. */

/* index.html (overview) */
/* .act.light de la landing es una SECCIÓN (no una card): tiene texto oscuro propio
   para su fondo claro. Al oscurecer el fondo en dark, el texto hay que aclararlo
   también o queda invisible. Queda como sección oscura coherente + texto claro. */
html[data-theme="dark"] .act.light { background: var(--_surface); }
html[data-theme="dark"] .act.light .act-title,
html[data-theme="dark"] .act.light .act-list li strong { color: var(--c-text); }
html[data-theme="dark"] .act.light .act-lead,
html[data-theme="dark"] .act.light .act-list li,
html[data-theme="dark"] .act.light .tl-key { color: var(--c-text-sec); }
/* Igual para el panel .signals (otra superficie "clara" de la landing oscurecida
   en dark): su texto estaba en oscuro para el panel blanco → aclararlo. */
html[data-theme="dark"] .sig-name { color: var(--c-text); }
html[data-theme="dark"] .sig-desc { color: var(--c-text-sec); }
html[data-theme="dark"] .signals { background: var(--_surface); border-color: var(--c-border); }
html[data-theme="dark"] .sig { border-color: var(--c-border); }
html[data-theme="dark"] .gbar { background: var(--c-border); }
html[data-theme="dark"] .btn-google { background: var(--_surface); border-color: var(--c-border); color: var(--c-text); }

/* historial.html */
html[data-theme="dark"] .btn-done:hover { background: rgba(22,163,74,.16); }
html[data-theme="dark"] .btn-done.is-done { background: rgba(22,163,74,.16); }
html[data-theme="dark"] .btn-done.is-done:hover { background: rgba(220,38,38,.16); }
html[data-theme="dark"] .badge.monday { background: rgba(232,31,118,.16); }
html[data-theme="dark"] .rail-item:hover { background: var(--_surface); }
html[data-theme="dark"] .group-hd { border-bottom-color: var(--c-border); }

/* configuracion.html */
html[data-theme="dark"] :is(.cfg-hd, .cfg-row, .gsc-row) { border-bottom-color: var(--c-border); }
html[data-theme="dark"] .toggle-sl { background: var(--c-border); }
html[data-theme="dark"] .gsc-dot.off { background: var(--c-border); }
html[data-theme="dark"] .gsc-btn:hover { border-color: var(--_ring); }
html[data-theme="dark"] .cfg-msg.ok { background: rgba(22,163,74,.16); color: oklch(78% 0.14 162); }

/* clientes.html */
html[data-theme="dark"] .table-search { border-bottom-color: var(--c-border); }
html[data-theme="dark"] .msv-score.good { background: rgba(22,163,74,.16); color: oklch(78% 0.14 162); }
html[data-theme="dark"] .btn-hide:hover { border-color: var(--_ring); }

/* share.html */
html[data-theme="dark"] .error-card { background: var(--c-card); border-color: var(--c-border); }
html[data-theme="dark"] .error-card i { color: var(--c-text-muted); }
html[data-theme="dark"] .error-card p { color: var(--c-text-muted); }
html[data-theme="dark"] .footer { border-top-color: var(--c-border); color: var(--c-text-muted); }
/* Antes solo se cubrían los bordes de esta página — el fondo y el texto
   quedaban con los valores de tema claro incluso con html[data-theme="dark"]
   activo (share.html sí carga theme.css y sí respeta el tema guardado). */
html[data-theme="dark"] body { background: var(--c-body); color: var(--c-text); }
html[data-theme="dark"] .header-title { color: var(--c-text); }
html[data-theme="dark"] .header-meta { color: var(--c-text-muted); }
html[data-theme="dark"] .mbubble { color: var(--c-text); }
html[data-theme="dark"] .mbubble.soma { background: var(--c-card); border-color: var(--c-border); }

/* share.html + actualizaciones.html (clase compartida) */
html[data-theme="dark"] .section-lbl { border-bottom-color: var(--c-border); color: var(--c-text-muted); }

/* actualizaciones.html */
html[data-theme="dark"] .type-helpful-content { background: rgba(22,163,74,.16); color: oklch(78% 0.14 162); }

/* alertas.html — chips de estado (.ac-status.*): fondo claro + texto oscuro → tinte
   oscuro + texto claro del mismo hue para que el estado se siga leyendo. */
html[data-theme="dark"] .ac-status.new        { background: oklch(22% 0.045 245); color: oklch(80% 0.10 262); }
html[data-theme="dark"] .ac-status.in_review  { background: rgba(245,158,11,.15); color: oklch(82% 0.12 80); }
html[data-theme="dark"] .ac-status.analyzed   { background: oklch(23% 0.05 275);  color: oklch(80% 0.10 275); }
html[data-theme="dark"] .ac-status.tasks_pushed { background: oklch(24% 0.05 300); color: oklch(80% 0.12 300); }
html[data-theme="dark"] .ac-status.resolved   { background: rgba(22,163,74,.16);  color: oklch(78% 0.14 162); }
html[data-theme="dark"] .ac-status.dismissed  { background: var(--c-border);      color: var(--c-text-sec); }
html[data-theme="dark"] .ac-status.superseded { background: var(--_surface);       color: var(--c-text-sec); }

/* Tablas genéricas (clientes y cualquier tabla): bordes de fila claros → hairline dark */
html[data-theme="dark"] thead th { border-bottom-color: var(--c-border); }
html[data-theme="dark"] tbody tr { border-bottom-color: var(--c-border); }

/* analisis.html (gaps remanentes) */
html[data-theme="dark"] .fc-row { background: var(--_surface); }
html[data-theme="dark"] .msv-phase-bar { background: var(--c-border); }
html[data-theme="dark"] .sprint-status-badge { background: rgba(22,163,74,.16); border-color: rgba(22,163,74,.34); }

/* ── Light: chrome SIN navy ───────────────────────────────────────────────────
   El sidebar/topbar eran navy (#021D49). Eric: "basta con el navy". Como el chrome
   lleva texto/iconos blancos (diseñado para fondo oscuro), lo correcto es navy →
   charcoal NEUTRO (mismo patrón sidebar-oscura sobre contenido claro, sin azul).
   Override del token en light; el dark ya tiene el suyo. */
html[data-theme="light"] { --c-sidebar: oklch(22% 0.005 255); }

/* ── Mejoras de diseño portadas al tema LIGHT (2026-06-17) ────────────────────
   Las mismas ideas que pulieron el dark —profundidad por capas + glow de acento
   en CTAs— pero con valores propios de light: sombra suave TINTADA DE NAVY (no las
   pesadas negras del dark) y glow magenta más discreto. NO incluye .dash (en
   analisis es el contenedor de scroll; en index es una card oscura especial). */

/* Elevación en REPOSO: sombra NEUTRA (sin tinte navy), las cards se despegan del blanco. */
html[data-theme="light"] :is(.acard, .hist-row, .upd-card, .cfg-section, .login-card, .client-row, .ins-criteria-row) {
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.10);
}
html[data-theme="light"] :is(.acard, .hist-row, .upd-card, .client-row):hover {
  box-shadow: 0 2px 5px rgba(0,0,0,.06), 0 16px 36px -14px rgba(0,0,0,.14);
}

/* Glow de acento — disciplinado: SOLO CTAs de acento y pestaña activa (como en dark,
   pero más tenue: en claro el magenta ya resalta sobre blanco). */
html[data-theme="light"] :is(.dash-gen-btn, .pabtn.primary, .ac-btn.p, .soma-deepdive.on) {
  box-shadow: 0 2px 14px -5px rgba(221,26,114,.32);
}
html[data-theme="light"] :is(.dash-gen-btn:hover, .pabtn.primary:hover, .ac-btn.p:hover) {
  box-shadow: 0 3px 20px -5px rgba(221,26,114,.45);
}
html[data-theme="light"] .soma-tab.on {
  box-shadow: 0 6px 14px -10px rgba(221,26,114,.6);
}

/* ── P1: tabular numerals for data tables (digits align when scanning) ──────── */
table { font-variant-numeric: tabular-nums; }
