/* DatosClaros - v4 (con modo oscuro) */

/* ──────────────────────────────────────────
   MODO OSCURO via variables CSS
   ────────────────────────────────────────── */
:root {
  --bg: #fafafa;
  --bg-elev: #fff;
  --bg-subtle: #f5f5f5;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #ececec;
  --border-strong: #d4d4d4;
  --accent: #2563eb;
}
html[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-elev: #1a1a1a;
  --bg-subtle: #242424;
  --text: #e8e8e8;
  --text-muted: #a0a0a0;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --accent: #60a5fa;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .chart-box,
html[data-theme="dark"] .section-card,
html[data-theme="dark"] .stat,
html[data-theme="dark"] table,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .site-submenu,
html[data-theme="dark"] .site-drawer,
html[data-theme="dark"] .footer { background: var(--bg-elev) !important; border-color: var(--border) !important; color: var(--text) !important; }
html[data-theme="dark"] .site-logo,
html[data-theme="dark"] .page-title,
html[data-theme="dark"] .hero h1 { color: var(--text) !important; }
html[data-theme="dark"] .site-logo em { color: #999 !important; }
html[data-theme="dark"] .site-nav a,
html[data-theme="dark"] .site-nav .site-nav-toggle { color: #b0b0b0 !important; }
html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .site-nav .site-nav-toggle:hover { color: #fff !important; }
html[data-theme="dark"] .muted,
html[data-theme="dark"] .page-desc { color: var(--text-muted) !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .input { background: var(--bg-subtle) !important; color: var(--text) !important; border-color: var(--border-strong) !important; }
html[data-theme="dark"] table th { background: var(--bg-subtle) !important; color: var(--text) !important; }
html[data-theme="dark"] table tr:hover { background: var(--bg-subtle) !important; }
html[data-theme="dark"] table td { border-color: var(--border) !important; }
html[data-theme="dark"] .btn { background: var(--bg-subtle); color: var(--text); border-color: var(--border-strong); }
html[data-theme="dark"] .site-nav a.active::after,
html[data-theme="dark"] .site-nav li.has-active > .site-nav-toggle::after { background: #fff; }
html[data-theme="dark"] .site-burger span { background: var(--text); }
html[data-theme="dark"] .site-submenu a { color: var(--text) !important; }
html[data-theme="dark"] .site-submenu a:hover { background: var(--bg-subtle) !important; color: #fff !important; }
html[data-theme="dark"] .site-drawer a { color: var(--text) !important; border-color: var(--border) !important; }
html[data-theme="dark"] .site-drawer-title { color: var(--text) !important; }
html[data-theme="dark"] .section-card h3 { color: var(--text) !important; }
html[data-theme="dark"] .section-card p { color: var(--text-muted) !important; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text);
  margin-left: 12px;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--bg-subtle); }

/* Global search */
.global-search {
  position: relative;
  margin-left: 16px;
}
.global-search input {
  width: 180px;
  padding: 6px 10px 6px 30px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  font-size: 13px;
  background: var(--bg-subtle);
  color: var(--text);
  font-family: inherit;
}
.global-search::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.6;
  pointer-events: none;
}
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  z-index: 1000;
  padding: 8px;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 8px 10px; border-radius: 4px; color: var(--text); font-size: 13px; text-decoration: none; border-bottom: 1px solid var(--border); }
.search-results a:hover { background: var(--bg-subtle); }
.search-results a small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }

@media (max-width: 1150px) {
  .global-search, .theme-toggle { display: none; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ──────────────────────────────────────────
   SITE HEADER · Namespace .site-* para evitar colisiones
   ────────────────────────────────────────── */
.site-header {
  background: #fff;
  border-bottom: 1px solid #ececec;
  padding: 20px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 24px;
  font-weight: 600;
  color: #1a1a1a !important;
  letter-spacing: -0.5px;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
}
.site-logo:hover { text-decoration: none; }
.site-logo em {
  font-style: italic;
  font-weight: 500;
  color: #555 !important;
}
.site-logo .site-tagline {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #999 !important;
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: lowercase;
}

/* Nav principal desktop */
.site-nav {
  display: flex;
  gap: 28px;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav > li { position: relative; list-style: none; }
.site-nav a,
.site-nav .site-nav-toggle {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #555 !important;
  font-weight: 500;
  padding: 6px 0;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  border: none;
  text-decoration: none;
  position: relative;
}
.site-nav a:hover,
.site-nav .site-nav-toggle:hover { color: #000 !important; text-decoration: none; }
.site-nav a.active::after,
.site-nav li.has-active > .site-nav-toggle::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: #000;
}
.site-nav-chev { font-size: 8px; margin-left: 3px; opacity: 0.6; }

/* Submenu desktop (oculto por defecto, SIEMPRE) */
.site-submenu {
  display: none !important;
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 2px;
  min-width: 240px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  padding: 8px;
  z-index: 1000;
  list-style: none;
}
.site-nav li:hover > .site-submenu,
.site-nav li:focus-within > .site-submenu { display: block !important; }
.site-submenu::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 16px;
}
.site-submenu li { list-style: none; }
.site-submenu a {
  display: block;
  padding: 10px 14px;
  color: #333 !important;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.2px;
  text-transform: none !important;
  border-radius: 2px;
}
.site-submenu a::after { display: none !important; }
.site-submenu a:hover { background: #f7f7f7; text-decoration: none; color: #000 !important; }
.site-submenu a.active { background: #f0f0f0; color: #000 !important; font-weight: 500; }

/* Hamburger */
.site-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 1101;
}
.site-burger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: #1a1a1a;
  margin: 5px 0;
  transition: transform 0.3s, opacity 0.3s;
}
.site-burger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.site-burger.open span:nth-child(2) { opacity: 0; }
.site-burger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* Mobile drawer */
.site-drawer {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 340px;
  height: 100vh;
  background: #fff;
  box-shadow: -10px 0 40px rgba(0,0,0,0.08);
  padding: 80px 32px 40px;
  z-index: 1100;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.35s ease;
}
.site-drawer.open { transform: translateX(0); }
.site-drawer .site-drawer-group { margin-bottom: 28px; }
.site-drawer .site-drawer-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  color: #000 !important;
  margin-bottom: 12px;
  font-style: italic;
}
.site-drawer a {
  display: block;
  padding: 12px 0;
  color: #333 !important;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.site-drawer a.active { color: #000 !important; font-weight: 600; }
.site-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1099;
}
.site-overlay.open { display: block; }

/* Breakpoints */
@media (max-width: 1150px) {
  .site-nav { display: none !important; }
  .site-burger { display: block; }
  .site-drawer { display: block; }
  .site-header { padding: 18px 24px; }
}
@media (max-width: 600px) {
  .site-header { padding: 16px 20px; }
  .site-logo { font-size: 21px; }
  .site-logo .site-tagline { display: none; }
}

/* Landing */
.hero {
  text-align: center;
  padding: 100px 20px 60px;
  background: #fff;
}
.hero h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 64px;
  font-weight: 500;
  margin-bottom: 16px;
  letter-spacing: -1.5px;
  line-height: 1.05;
  color: #0a0a0a;
}
.hero h1 em { font-style: italic; font-weight: 500; color: #333; }
.hero p {
  font-size: 18px;
  color: #666;
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}
@media (max-width: 600px) { .hero { padding: 60px 20px 40px; } .hero h1 { font-size: 42px; } }
.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}
.section-card {
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 4px;
  padding: 28px 24px;
  transition: all 0.25s ease;
  display: block;
  color: inherit;
}
.section-card:hover {
  border-color: #1a1a1a;
  transform: translateY(-3px);
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
}
.section-card .icon { font-size: 28px; margin-bottom: 16px; opacity: 0.85; }
.section-card h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 10px;
  color: #0a0a0a;
  letter-spacing: -0.3px;
}
.section-card p { font-size: 14px; color: #666; line-height: 1.55; }

/* Contenedor */
.container { max-width: 1280px; margin: 0 auto; padding: 20px; }
.page-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 40px;
  font-weight: 500;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.page-desc { color: #666; margin-bottom: 28px; font-size: 16px; max-width: 700px; }
@media (max-width: 600px) { .page-title { font-size: 30px; } }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 16px;
}
.stat .label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat .value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}
.stat .sub { font-size: 13px; color: #888; margin-top: 2px; }

/* Chart boxes */
.chart-box {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.chart-box h3 { font-size: 15px; margin-bottom: 12px; color: #333; }
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

/* Inputs */
.input, input[type=number], input[type=text], input[type=password], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.btn {
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid #d4d4d4;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
}
.btn:hover { background: #f5f5f5; }
.btn.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: #dc2626; color: #fff; border-color: #dc2626; }

/* Modal */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 28px;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; font-size: 22px; }
.modal textarea { font-family: ui-monospace, monospace; font-size: 12px; min-height: 320px; }

/* Mensajes */
.msg { padding: 10px 14px; border-radius: 6px; margin: 8px 0; font-size: 14px; }
.msg.ok { background: #dcfce7; color: #166534; }
.msg.err { background: #fee2e2; color: #991b1b; }
.msg.info { background: #eef6ff; color: #1e40af; border-left: 3px solid #2563eb; }

/* Footer */
.footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 13px;
  color: #666;
  border-top: 1px solid #e5e5e5;
  background: #fff;
  margin-top: 40px;
}
.footer nav { display: inline-block; }
.footer a { margin: 0 8px; }

/* Mapa */
#map { height: 500px; border: 1px solid #e5e5e5; border-radius: 8px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #e5e5e5; }
table th, table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
table th { background: #fafafa; font-weight: 600; font-size: 13px; color: #444; text-transform: uppercase; letter-spacing: 0.3px; }
table tr:last-child td { border-bottom: none; }
table tr:hover { background: #fafafa; }

/* Responsive */
@media (max-width: 768px) {
  .hero h1 { font-size: 28px; }
  .header { flex-direction: column; gap: 10px; padding: 12px; }
  .header nav { width: 100%; justify-content: center; }
  .charts-row { grid-template-columns: 1fr; }
}

/* Utils */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.muted { color: #888; font-size: 13px; }
.highlight { background: #fef3c7; padding: 2px 6px; border-radius: 4px; font-weight: 600; }

/* ──────────────────────────────────────────
   ACCESIBILIDAD: skip link
   ────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: #2563eb;
  color: #fff;
  padding: 10px 20px;
  z-index: 10000;
  border-radius: 0 0 6px 0;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0; outline: 2px solid #1a1a1a; outline-offset: 2px; }

:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 3px; }

/* ──────────────────────────────────────────
   RESPONSIVE DEFINITIVO — mobile-first
   ────────────────────────────────────────── */

/* Tablets y móviles: contenedor con padding reducido */
@media (max-width: 900px) {
  .container { padding: 16px; }
  .hero { padding: 60px 20px 40px; }
  .hero h1 { font-size: 48px; line-height: 1.1; }
  .hero p { font-size: 16px; }
  .sections-grid { gap: 14px; padding: 0 16px; margin: 24px auto; }
  .section-card { padding: 22px 18px; }
  .section-card h3 { font-size: 20px; }
  .charts-row, .grid-2 { grid-template-columns: 1fr !important; }
  .chart-box { padding: 16px; }
  .chart-box h3 { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat .value { font-size: 22px; }
  .page-title { font-size: 32px; line-height: 1.15; }
  table { font-size: 13px; }
  table th, table td { padding: 8px 10px; }
}

/* Móviles pequeños */
@media (max-width: 600px) {
  .container { padding: 12px; }
  .hero { padding: 40px 16px 30px; }
  .hero h1 { font-size: 36px; }
  .hero p { font-size: 15px; }
  .page-title { font-size: 28px; }
  .page-desc { font-size: 15px; margin-bottom: 20px; }
  .sections-grid { grid-template-columns: 1fr; gap: 12px; padding: 0 12px; }
  .section-card { padding: 20px 16px; }
  .chart-box { padding: 14px; margin-bottom: 12px; }
  .chart-box h3 { font-size: 15px; margin-bottom: 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 20px; }
  .stat .label { font-size: 11px; }

  /* Tablas con scroll horizontal */
  table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Inputs más grandes para touch */
  input, select, textarea, .input { padding: 12px 14px; font-size: 16px; min-height: 44px; }
  .btn { padding: 12px 18px; min-height: 44px; font-size: 14px; }

  /* Modales full-width */
  .modal { padding: 20px; border-radius: 8px; max-height: 90vh; }

  /* Quiz */
  .quiz-option { padding: 14px; font-size: 14px; min-height: 48px; }

  /* Landing h2 */
  h2 { font-size: 24px !important; }

  /* Footer */
  .footer { padding: 20px 16px; font-size: 12px; }
  .footer a { margin: 0 4px; }
}

/* Mejoras de touch para tablets */
@media (max-width: 1150px) {
  .site-header { padding: 14px 20px; }
  button, .btn, a.btn {
    min-height: 44px;
    min-width: 44px;
  }
  /* Evitar zoom en iOS al enfocar input */
  input[type="text"], input[type="number"], input[type="password"],
  select, textarea {
    font-size: 16px !important;
  }
}

/* Orientación landscape en móvil */
@media (max-width: 900px) and (orientation: landscape) {
  .hero { padding: 30px 20px 20px; }
  .hero h1 { font-size: 36px; }
  .site-header { padding: 10px 20px; }
}

/* Print */
@media print {
  .site-header, .site-drawer, .site-overlay, .site-burger,
  .footer, .modal-bg, .global-search, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .chart-box { page-break-inside: avoid; border: 1px solid #ccc; }
  a { color: #000; text-decoration: underline; }
  canvas { max-width: 100% !important; }
}

/* Alta densidad (retina) — más nítido */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
}

/* Reducir movimiento (accesibilidad) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Breadcrumb */
.breadcrumb {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}
.breadcrumb a { color: var(--text-muted, #888); text-decoration: none; }
.breadcrumb a:hover { color: var(--text, #1a1a1a); text-decoration: underline; }
.breadcrumb .sep { margin: 0 8px; opacity: 0.5; }

/* Botón volver arriba */
.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 900;
  transition: transform 0.2s;
}
.back-to-top:hover { transform: translateY(-3px); }
.back-to-top.visible { display: flex; }

/* ──────────────────────────────────────────
   CLASES UNIVERSALES para tarjetas auto-adaptables
   Úsalas en lugar de inline styles con backgrounds fijos
   ────────────────────────────────────────── */
.auto-card {
  padding: 14px 16px;
  background: var(--bg-subtle, #fafafa);
  border-radius: 6px;
  margin-bottom: 10px;
  color: var(--text, #1a1a1a);
}
.auto-chip {
  display: inline-block;
  background: var(--bg-elev, #fff);
  border: 1px solid var(--border, #ececec);
  color: var(--text-muted, #666);
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
}
.auto-chip-color { color: #fff; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 500; display: inline-block; }
.auto-code {
  background: var(--bg-subtle, #f5f5f5);
  color: var(--text, #1a1a1a);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

@media (max-width: 600px) {
  .back-to-top { bottom: 16px; right: 16px; }
}

/* ──────────────────────────────────────────
   DARK MODE — overrides para estilos inline
   Muchas páginas usan estilos inline con colores
   fijos que en modo oscuro quedan ilegibles.
   Aquí los rescatamos con !important.
   ────────────────────────────────────────── */
html[data-theme="dark"] [style*="background:#fafafa"],
html[data-theme="dark"] [style*="background: #fafafa"],
html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background: #f5f5f5"],
html[data-theme="dark"] [style*="background:#f7f7f7"],
html[data-theme="dark"] [style*="background: #f7f7f7"],
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"] {
  background: var(--bg-subtle) !important;
  color: var(--text) !important;
}

/* Cards temáticas con colores pastel — ajustamos a tonos oscuros */
html[data-theme="dark"] [style*="background:#fef3c7"],
html[data-theme="dark"] [style*="background: #fef3c7"] {
  background: rgba(234,179,8,0.15) !important;
  color: #fde68a !important;
}
html[data-theme="dark"] [style*="background:#fee2e2"],
html[data-theme="dark"] [style*="background: #fee2e2"],
html[data-theme="dark"] [style*="background:#fef2f2"],
html[data-theme="dark"] [style*="background: #fef2f2"] {
  background: rgba(220,38,38,0.15) !important;
  color: #fca5a5 !important;
}
html[data-theme="dark"] [style*="background:#dcfce7"],
html[data-theme="dark"] [style*="background: #dcfce7"],
html[data-theme="dark"] [style*="background:#f0fdf4"],
html[data-theme="dark"] [style*="background: #f0fdf4"] {
  background: rgba(22,163,74,0.15) !important;
  color: #86efac !important;
}
html[data-theme="dark"] [style*="background:#eef2ff"],
html[data-theme="dark"] [style*="background: #eef2ff"],
html[data-theme="dark"] [style*="background:#eff6ff"],
html[data-theme="dark"] [style*="background: #eff6ff"] {
  background: rgba(37,99,235,0.15) !important;
  color: #93c5fd !important;
}
html[data-theme="dark"] [style*="background:#fae8ff"],
html[data-theme="dark"] [style*="background: #fae8ff"] {
  background: rgba(147,51,234,0.15) !important;
  color: #d8b4fe !important;
}
html[data-theme="dark"] [style*="background:#fff7ed"],
html[data-theme="dark"] [style*="background: #fff7ed"] {
  background: rgba(234,88,12,0.15) !important;
  color: #fdba74 !important;
}

/* Textos con colores oscuros fijos que quedan ilegibles */
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#444"],
html[data-theme="dark"] [style*="color: #444"],
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#0a0a0a"],
html[data-theme="dark"] [style*="color: #0a0a0a"],
html[data-theme="dark"] [style*="color:#1a1a1a"],
html[data-theme="dark"] [style*="color: #1a1a1a"],
html[data-theme="dark"] [style*="color:#991b1b"],
html[data-theme="dark"] [style*="color: #991b1b"],
html[data-theme="dark"] [style*="color:#166534"],
html[data-theme="dark"] [style*="color: #166534"] {
  color: var(--text) !important;
}

/* Mensajes */
html[data-theme="dark"] .msg.ok { background: rgba(22,163,74,0.15) !important; color: #86efac !important; }
html[data-theme="dark"] .msg.err { background: rgba(220,38,38,0.15) !important; color: #fca5a5 !important; }
html[data-theme="dark"] .msg.info { background: rgba(37,99,235,0.15) !important; color: #93c5fd !important; }

/* Gráficas Chart.js — ticks + leyenda */
html[data-theme="dark"] canvas { filter: none; }

/* Selects y checkboxes */
html[data-theme="dark"] select option { background: var(--bg-elev); color: var(--text); }
