/* ==========================================================================
   estilos-moderno.css — Aspecto de España Data.
   Idea: un atlas moderno. Tinta azul marino, papel cálido, acento bermellón
   y gualda para los resaltes; cabecera con curvas de nivel.
   Todos los colores están aquí arriba como "fichas" (--nombre): cámbialos aquí.
   Los scripts leen algunas (--mar, --acento, --gualda, --superficie, --linea,
   --tinta-suave, --letra-texto) para pintar gráficos: no las renombres.
   ========================================================================== */

/* ===== FICHAS DE DISEÑO ===== */
:root {
  /* Colores de marca */
  --tinta: #14253a;          /* texto principal */
  --tinta-suave: #5d6b78;    /* texto secundario */
  --tinta-tenue: #8b97a2;    /* rótulos y ayudas */
  --papel: #f4f2ec;          /* fondo de la página */
  --superficie: #fffdf8;     /* paneles y tarjetas */
  --superficie-2: #efece4;   /* rellenos suaves */
  --superficie-3: #e5e1d6;   /* rellenos al pasar el ratón */
  --linea: #e2ddd1;          /* bordes */
  --linea-fuerte: #cdc6b6;
  --mar: #1f6f8b;            /* color principal (agua) */
  --acento: #d1462f;         /* bermellón: selección y detalles */
  --gualda: #f2b705;         /* amarillo: resaltes */
  --ok: #2e8b57;
  --aviso: #b7791f;
  --peligro: #c0392b;

  /* Cabecera (siempre oscura, en los dos temas) */
  --cabecera-fondo: #13293d;
  --cabecera-texto: #f4f2ec;
  --cabecera-tenue: rgba(244, 242, 236, .62);
  --cabecera-relleno: rgba(255, 255, 255, .08);
  --cabecera-borde: rgba(255, 255, 255, .14);

  /* Sombras */
  --sombra-sm: 0 1px 2px rgba(20, 37, 58, .06), 0 1px 1px rgba(20, 37, 58, .04);
  --sombra-md: 0 4px 14px -2px rgba(20, 37, 58, .12), 0 2px 4px rgba(20, 37, 58, .05);
  --sombra-lg: 0 18px 40px -12px rgba(20, 37, 58, .28), 0 4px 10px rgba(20, 37, 58, .06);
  --sombra: var(--sombra-lg);

  /* Tipografía */
  --letra-titulo: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --letra-texto: "Inter", "Segoe UI", system-ui, sans-serif;
  --letra-datos: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  /* Espaciado (también lo usa ui-utils.js) */
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem;

  /* Radios */
  --radio-sm: 6px; --radio-md: 10px; --radio-lg: 14px; --radio-xl: 20px;

  --rapido: 140ms cubic-bezier(.4, 0, .2, 1);
  --medio: 220ms cubic-bezier(.4, 0, .2, 1);

  /* Capas */
  --z-cabecera: 1020; --z-fijo: 1030; --z-modal: 1050; --z-overlay: 1060; --z-toast: 1080;

  /* Paneles flotantes con efecto cristal */
  --panel-ancho: 340px;
  --hueco: 12px;
  --cristal: color-mix(in srgb, var(--superficie) 80%, transparent);
  --cristal-borde: color-mix(in srgb, var(--tinta) 11%, transparent);
  --cristal-filtro: blur(18px) saturate(1.5);

  /* Nombres antiguos que aún usan algunos scripts */
  --primary: var(--mar);
  --danger: var(--peligro);
  --text-primary: var(--tinta);

  color-scheme: light;
}

/* ===== TEMA OSCURO ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tinta: #e6edf1; --tinta-suave: #9fb0bc; --tinta-tenue: #6f8291;
    --papel: #0b141b; --superficie: #111e28; --superficie-2: #182833; --superficie-3: #20333f;
    --linea: #22343f; --linea-fuerte: #2f4553;
    --mar: #5bb8d6; --acento: #ff7a5c; --gualda: #f6c945;
    --ok: #4cc38a; --aviso: #e0a33e; --peligro: #ff6b5b;
    --cabecera-fondo: #08111a;
    --sombra-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --sombra-md: 0 4px 14px -2px rgba(0, 0, 0, .5);
    --sombra-lg: 0 18px 40px -12px rgba(0, 0, 0, .7), 0 4px 10px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tinta: #e6edf1; --tinta-suave: #9fb0bc; --tinta-tenue: #6f8291;
  --papel: #0b141b; --superficie: #111e28; --superficie-2: #182833; --superficie-3: #20333f;
  --linea: #22343f; --linea-fuerte: #2f4553;
  --mar: #5bb8d6; --acento: #ff7a5c; --gualda: #f6c945;
  --ok: #4cc38a; --aviso: #e0a33e; --peligro: #ff6b5b;
  --cabecera-fondo: #08111a;
  --sombra-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --sombra-md: 0 4px 14px -2px rgba(0, 0, 0, .5);
  --sombra-lg: 0 18px 40px -12px rgba(0, 0, 0, .7), 0 4px 10px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--letra-texto);
  font-size: 15px;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--papel);
}

h1, h2, h3, h4 { font-family: var(--letra-titulo); line-height: 1.2; text-wrap: balance; letter-spacing: -.01em; }
p { margin: var(--space-2) 0; }
button { font: inherit; color: inherit; }
a { color: var(--mar); text-underline-offset: 2px; }
a:hover { color: var(--acento); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; text-align: center;
  font-family: var(--letra-datos); font-size: .72rem; line-height: 1.5;
  background: var(--superficie); border: 1px solid var(--linea-fuerte); border-bottom-width: 2px;
  border-radius: var(--radio-sm); color: var(--tinta);
}
:focus-visible { outline: 3px solid var(--gualda); outline-offset: 2px; border-radius: 4px; }
.cifra, .contador, .tabla td, .datos dd, .stat-value { font-variant-numeric: tabular-nums; }

/* Barras de desplazamiento finas */
* { scrollbar-width: thin; scrollbar-color: var(--linea-fuerte) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--linea-fuerte); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.hidden, [hidden] { display: none !important; }

/* ===== BOTONES ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 7px 14px; font-size: .85rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--radio-md); cursor: pointer;
  transition: background var(--rapido), border-color var(--rapido), color var(--rapido), transform var(--rapido);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--tinta); color: var(--papel); }
.btn-primary:hover { background: var(--mar); }
.btn-secondary { background: var(--superficie); color: var(--tinta); border-color: var(--linea-fuerte); }
.btn-secondary:hover { border-color: var(--tinta); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 1px solid transparent; border-radius: var(--radio-md);
  background: transparent; color: var(--tinta-suave); cursor: pointer;
  transition: background var(--rapido), color var(--rapido);
}
.btn-icon:hover { background: var(--superficie-2); color: var(--tinta); }

.btn-icon-sm {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 28px; height: 28px; font-size: 1.15rem; line-height: 1;
  border: 0; border-radius: var(--radio-sm); background: transparent; color: var(--tinta-suave); cursor: pointer;
  transition: background var(--rapido), color var(--rapido);
}
.btn-icon-sm:hover { background: var(--superficie-2); color: var(--tinta); }

.btn-mini {
  padding: 3px 10px; font-size: .74rem; font-weight: 600;
  background: transparent; color: var(--tinta-suave);
  border: 1px solid var(--linea-fuerte); border-radius: 999px; cursor: pointer;
  transition: all var(--rapido);
}
.btn-mini:hover { color: var(--tinta); border-color: var(--tinta); }

/* ===== FORMULARIOS ===== */
input[type="text"], input[type="search"], input[type="date"], select {
  width: 100%; padding: 9px 12px; font: inherit; font-size: .9rem; color: var(--tinta);
  background: var(--superficie); border: 1px solid var(--linea-fuerte); border-radius: var(--radio-md);
  transition: border-color var(--rapido), box-shadow var(--rapido);
}
input:focus, select:focus {
  outline: none; border-color: var(--mar);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mar) 22%, transparent);
}
select {
  appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b97a2' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.select-full { width: 100%; }

/* ===== CABECERA ===== */
#cabecera {
  position: relative;
  z-index: var(--z-cabecera);
  display: flex; align-items: center; gap: var(--space-4);
  height: 60px; flex-shrink: 0; padding: 0 var(--space-5);
  color: var(--cabecera-texto);
  background-color: var(--cabecera-fondo);
  /* Curvas de nivel */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='120' viewBox='0 0 420 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.06' stroke-width='1.2'%3E%3Cpath d='M-10 90 C60 60 120 110 200 80 S330 40 430 70'/%3E%3Cpath d='M-10 70 C70 40 130 90 210 60 S340 20 430 50'/%3E%3Cpath d='M-10 50 C80 20 140 70 220 40 S350 0 430 30'/%3E%3Cpath d='M-10 110 C50 80 110 130 190 100 S320 60 430 90'/%3E%3Cellipse cx='330' cy='38' rx='34' ry='14'/%3E%3Cellipse cx='330' cy='38' rx='18' ry='7'/%3E%3C/g%3E%3C/svg%3E");
  box-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
/* Fina franja roja y gualda bajo la cabecera */
#cabecera::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px;
  background: linear-gradient(90deg, var(--acento) 0 25%, var(--gualda) 25% 75%, var(--acento) 75%);
  opacity: .9;
}

#cabecera .btn-icon { color: var(--cabecera-tenue); }
#cabecera .btn-icon:hover { color: var(--cabecera-texto); background: var(--cabecera-relleno); }
#boton-panel { display: none; }

.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo h1 {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.22rem; font-weight: 500; letter-spacing: -.02em; color: var(--cabecera-texto);
}
.logo h1 b { font-weight: 800; }
.logo-icon { flex-shrink: 0; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35)); }

/* Selector de modo */
.tabs {
  display: flex; gap: 2px; padding: 3px; margin-left: var(--space-4);
  background: var(--cabecera-relleno); border: 1px solid var(--cabecera-borde); border-radius: 999px;
}
.tab {
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 6px 14px; font-size: .85rem; font-weight: 600;
  color: var(--cabecera-tenue); background: transparent; border: 0; border-radius: 999px; cursor: pointer;
  transition: background var(--rapido), color var(--rapido);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--cabecera-texto); }
.tab.activo { background: var(--cabecera-texto); color: var(--cabecera-fondo); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }

/* Fecha */
.fecha-controls { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.fecha-picker {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--cabecera-relleno); border: 1px solid var(--cabecera-borde); border-radius: var(--radio-md);
}
.input-fecha, #cabecera input[type="date"] {
  width: auto; min-width: 0; padding: 4px 8px; font-family: var(--letra-datos); font-size: .82rem;
  color: var(--cabecera-texto); background: transparent; border: 0; border-radius: var(--radio-sm);
  color-scheme: dark;
}
#cabecera input[type="date"]:focus { box-shadow: none; background: var(--cabecera-relleno); }
#boton-hoy {
  padding: 4px 12px; font-size: .8rem; border: 0;
  background: var(--cabecera-texto); color: var(--cabecera-fondo); border-radius: var(--radio-sm);
}
#boton-hoy:hover { background: var(--gualda); }

.estado-badge {
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: .76rem; color: var(--cabecera-tenue);
}
.estado-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #4cc38a;
  box-shadow: 0 0 0 0 rgba(76, 195, 138, .6); animation: latido 2.4s ease-out infinite;
}
@keyframes latido {
  0% { box-shadow: 0 0 0 0 rgba(76, 195, 138, .55); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(76, 195, 138, 0); }
}

.header-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0; }
.fecha-controls + .header-actions { margin-left: var(--space-2); }
body.modo-enciclopedia .header-actions { margin-left: auto; }

/* ===== DISTRIBUCIÓN ===== */
#contenedor { flex: 1; display: flex; min-height: 0; position: relative; }

/* ===== PANEL LATERAL ===== */

.panel-scroll { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-5) var(--space-8); }
.panel-scroll > section { padding: var(--space-5) 0; border-bottom: 1px solid var(--linea); }
.panel-scroll > section:last-child { border-bottom: 0; }

.section-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 var(--space-3);
  font-family: var(--letra-datos); font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em; color: var(--tinta-suave);
}
.section-title svg { width: 14px; height: 14px; color: var(--acento); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-3); }
.section-header .section-title { margin: 0; }
.capas-actions { display: flex; gap: 4px; }

/* Navegación rápida: píldoras */
.zonas-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.zonas-grid button {
  padding: 5px 12px; font-size: .82rem; font-weight: 500; color: var(--tinta);
  background: var(--superficie-2); border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  transition: all var(--rapido);
}
.zonas-grid button:hover { background: var(--superficie); border-color: var(--tinta); }

/* Filtros */
.filtros-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 12px; font-size: .8rem; font-weight: 500; color: var(--tinta-suave);
  background: transparent; border: 1px solid var(--linea-fuerte); border-radius: 999px; cursor: pointer;
  transition: all var(--rapido);
}
.chip:hover { color: var(--tinta); border-color: var(--tinta); }
.chip.activo { background: var(--tinta); border-color: var(--tinta); color: var(--papel); }

/* Estadísticas */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card {
  padding: 12px 10px; text-align: left; border-radius: var(--radio-md);
  background: var(--superficie-2);
}
.stat-value { display: block; font-family: var(--letra-titulo); font-size: 1.6rem; font-weight: 800; line-height: 1.1; color: var(--tinta); }
#stat-urgentes { color: var(--acento); }
.stat-label { display: block; margin-top: 2px; font-size: .72rem; color: var(--tinta-suave); }

/* Verificación */
.verificacion-lista { list-style: none; display: grid; gap: 5px; }
.verificacion-lista li { padding: 6px 10px; font-size: .78rem; border-radius: var(--radio-sm); background: var(--superficie-2); }

/* Buscador del panel */
.search-box { position: relative; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--tinta-tenue); pointer-events: none; }
.search-box input { padding-left: 38px; background: var(--superficie-2); border-color: transparent; }
.search-box input:focus { background: var(--superficie); }
.resultados-lista { display: grid; gap: 2px; margin-top: 6px; }

#resultados-busqueda button, #resultados-globales button, #lista-zonas .zona {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left;
  font-size: .88rem; border: 0; border-radius: var(--radio-sm); background: none; cursor: pointer;
  transition: background var(--rapido);
}
#resultados-busqueda button:hover, #resultados-globales button:hover, #lista-zonas .zona:hover { background: var(--superficie-2); }
.tipo-resultado {
  flex-shrink: 0; padding: 2px 6px; font-family: var(--letra-datos); font-size: .6rem;
  text-transform: uppercase; letter-spacing: .06em; border-radius: 4px;
  background: var(--superficie-3); color: var(--tinta-suave);
}
.muestra { width: 12px; height: 12px; flex-shrink: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.zonas-lista { display: grid; gap: 1px; }
#lista-zonas .zona .estado { margin-left: auto; font-family: var(--letra-datos); font-size: .64rem; color: var(--tinta-tenue); }

/* Interruptor */
.switch-label { display: flex; align-items: center; gap: 10px; font-size: .88rem; font-weight: 500; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative; flex-shrink: 0; width: 38px; height: 22px; border-radius: 999px;
  background: var(--superficie-3); transition: background var(--rapido);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--rapido);
}
.switch-label input:checked + .switch { background: var(--mar); }
.switch-label input:checked + .switch::after { transform: translateX(16px); }
.switch-label input:focus-visible + .switch { outline: 3px solid var(--gualda); outline-offset: 2px; }
.hint { margin-top: var(--space-3); font-size: .76rem; color: var(--tinta-suave); line-height: 1.45; }

/* Herramientas */
.tools-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tool-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left;
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio-md); cursor: pointer;
  transition: border-color var(--rapido), box-shadow var(--rapido), transform var(--rapido);
}
.tool-btn:hover { border-color: var(--tinta); box-shadow: var(--sombra-md); transform: translateY(-1px); }
.tool-icon {
  width: 30px; height: 30px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; border-radius: 8px; background: var(--superficie-2);
}
.tool-label { font-size: .85rem; font-weight: 600; }

.skeleton {
  height: 36px; margin-bottom: 4px; border-radius: var(--radio-sm);
  background: linear-gradient(90deg, var(--superficie-2) 25%, var(--superficie-3) 50%, var(--superficie-2) 75%);
  background-size: 200% 100%; animation: brillo 1.5s infinite;
}
@keyframes brillo { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===== ZONA DEL MAPA ===== */
#zona-mapa { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#mapa { flex: 1; min-height: 300px; z-index: 1; background: var(--superficie-2); }

/* Barra de contexto: flota sobre el mapa, arriba a la derecha */
.context-bar {
  position: absolute; z-index: 900; top: var(--hueco); left: calc(var(--panel-ancho) + var(--hueco) * 2);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 5px 5px 5px 14px; font-size: .8rem;
  background: var(--cristal); backdrop-filter: var(--cristal-filtro); -webkit-backdrop-filter: var(--cristal-filtro);
  border: 1px solid var(--cristal-borde); border-radius: 999px; box-shadow: var(--sombra-md);
}
.context-info { display: flex; align-items: baseline; gap: 10px; }
.context-fecha { font-weight: 600; }
.context-fecha::first-letter { text-transform: uppercase; }
.context-hora { font-family: var(--letra-datos); font-size: .76rem; color: var(--tinta-suave); }
.context-bar .btn { border-radius: 999px; background: var(--tinta); color: var(--papel); }
.context-bar .btn:hover { background: var(--mar); }

/* Panel de avisos */
.avisos-panel {
  position: absolute; z-index: 900; top: 62px; left: calc(var(--panel-ancho) + var(--hueco) * 2);
  width: 380px; max-width: calc(100% - var(--panel-ancho) - 90px); max-height: min(340px, 45%);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cristal); backdrop-filter: var(--cristal-filtro); -webkit-backdrop-filter: var(--cristal-filtro);
  border: 1px solid var(--cristal-borde); border-radius: var(--radio-lg); box-shadow: var(--sombra-lg);
}
.avisos-header {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--linea);
}
.avisos-header h3 {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--letra-datos); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--tinta-suave);
}
#avisos { flex: 1; overflow-y: auto; padding: 10px; font-size: .84rem; }
#avisos > div, #avisos > details { padding: 10px 12px; border-radius: var(--radio-md); }
#avisos summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 6px; }
#avisos summary::-webkit-details-marker { display: none; }
#avisos summary::before { content: "▸"; color: var(--tinta-tenue); transition: transform var(--rapido); }
#avisos details[open] summary::before { transform: rotate(90deg); }
#avisos ul { list-style: none; margin: 8px 0; display: grid; gap: 6px; }
#avisos li { padding: 6px 8px; line-height: 1.4; background: var(--superficie); border-radius: var(--radio-sm); }
#avisos li small { color: var(--tinta-suave); font-family: var(--letra-datos); font-size: .68rem; }
#avisos details > small { display: block; font-size: .72rem; color: var(--tinta-suave); }
.aviso-ok { background: color-mix(in srgb, var(--ok) 12%, var(--superficie)); }
.aviso-info { background: var(--superficie-2); color: var(--tinta-suave); }
.aviso-error, #avisos details { background: color-mix(in srgb, var(--gualda) 14%, var(--superficie)); }
[class^="nivel-"] {
  display: inline-block; padding: 0 7px; margin-right: 2px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #fff;
}
.nivel-Minor { background: #6b7d89; }
.nivel-Moderate { background: #d4a106; color: #1d1600; }
.nivel-Severe { background: #e0670f; }
.nivel-Extreme { background: #c0392b; }

/* Botón flotante que aparece al ocultar los avisos */
#zona-mapa > .btn.btn-primary { left: calc(var(--panel-ancho) + var(--hueco) * 2) !important; top: 62px !important; border-radius: 999px; box-shadow: var(--sombra-md); background: var(--acento); }

/* Leyenda del mapa de calor */
.leyenda-calor {
  position: absolute; z-index: 900; left: calc(var(--panel-ancho) + var(--hueco) * 2); bottom: 30px; max-width: 250px;
  padding: 12px 14px; font-size: .78rem;
  background: var(--cristal); backdrop-filter: var(--cristal-filtro); -webkit-backdrop-filter: var(--cristal-filtro);
  border: 1px solid var(--cristal-borde); border-radius: var(--radio-lg); box-shadow: var(--sombra-md);
}
.leyenda-calor b { font-family: var(--letra-titulo); font-size: .92rem; }
.leyenda-calor small { color: var(--tinta-suave); }
.leyenda-calor ul { list-style: none; margin-top: 8px; display: grid; gap: 4px; font-family: var(--letra-datos); font-size: .72rem; }
.leyenda-calor li { display: flex; align-items: center; gap: 8px; }
.leyenda-calor .muestra { width: 22px; height: 12px; border-radius: 3px; }
.leyenda-header { display: flex; justify-content: space-between; align-items: center; }
.leyenda-header h4 { font-size: .9rem; }

/* ===== LEAFLET ===== */
.leaflet-container { font-family: var(--letra-texto); background: var(--superficie-2); }
.leaflet-bar, .leaflet-control-layers {
  border: 1px solid var(--linea) !important; border-radius: var(--radio-md) !important;
  box-shadow: var(--sombra-md) !important; overflow: hidden;
}
.leaflet-bar a {
  width: 34px !important; height: 34px !important; line-height: 34px !important;
  background: var(--superficie); color: var(--tinta); border-bottom-color: var(--linea);
  font-weight: 400;
}
.leaflet-bar a:hover { background: var(--superficie-2); color: var(--tinta); }
.leaflet-control-layers { background: var(--superficie); color: var(--tinta); }
.leaflet-control-layers-toggle { width: 38px !important; height: 38px !important; background-size: 20px; }
.leaflet-control-layers-expanded { padding: 10px 12px; font-size: .84rem; }
.leaflet-control-layers-separator { border-top-color: var(--linea); }
.leaflet-control-scale-line {
  background: color-mix(in srgb, var(--superficie) 80%, transparent);
  border-color: var(--tinta-suave); color: var(--tinta); font-family: var(--letra-datos); font-size: .66rem;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--superficie) 75%, transparent) !important;
  color: var(--tinta-suave); font-size: .66rem; border-top-left-radius: 6px;
}
.leaflet-control-attribution a { color: var(--tinta-suave); }

/* Marcadores */
.leaflet-div-icon { background: transparent; border: 0; }
.marcador {
  position: relative; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(10, 20, 30, .35), 0 0 0 1px rgba(10, 20, 30, .08);
  transition: transform var(--rapido);
}
.marcador:hover { transform: scale(1.15); }
.marcador .insignia {
  position: absolute; top: -5px; right: -5px; width: 15px; height: 15px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff; background: var(--peligro); border: 1.5px solid #fff;
}
.marcador.dudoso { border: 2px dashed #d68910; opacity: .8; }
.marcador .insignia.aprox { background: #4b5a66; }
.flecha { font-size: 20px; line-height: 1; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.avion { font-size: 16px; line-height: 1; text-shadow: 0 0 2px #fff; }

/* Ventanas emergentes */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--superficie); color: var(--tinta); }
.leaflet-popup-content-wrapper { border-radius: var(--radio-lg); box-shadow: var(--sombra-lg); border: 1px solid var(--linea); }
.leaflet-popup-content { margin: 14px 16px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { top: 6px; right: 6px; color: var(--tinta-suave); font-size: 20px; }
.tarjeta { font-size: .84rem; max-height: 420px; overflow-y: auto; }
.tarjeta h3 { margin: 4px 0 6px; font-size: 1.05rem; font-weight: 700; }
.t-cat { font-family: var(--letra-datos); font-size: .64rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.t-meta { color: var(--tinta-suave); margin-bottom: 6px; font-size: .8rem; }
.t-desc { margin: 8px 0; }
.t-ver { font-size: .76rem; padding: 5px 9px; border-radius: var(--radio-sm); margin: 8px 0; }
.t-fuente { font-size: .76rem; color: var(--tinta-suave); padding-top: 6px; border-top: 1px solid var(--linea); }
.v-confirmado { background: color-mix(in srgb, var(--ok) 14%, var(--superficie)); }
.v-probable { background: color-mix(in srgb, var(--mar) 13%, var(--superficie)); }
.v-dato { background: var(--superficie-2); }
.v-sin_confirmar { background: color-mix(in srgb, var(--gualda) 16%, var(--superficie)); outline: 1px dashed #d68910; outline-offset: -1px; }
.caja-aviso { background: color-mix(in srgb, var(--peligro) 11%, var(--superficie)); border-left: 3px solid var(--peligro); padding: 7px 10px; margin-bottom: 8px; border-radius: var(--radio-sm); }
.caja-aviso.gris { background: color-mix(in srgb, var(--gualda) 14%, var(--superficie)); border-left-color: #d68910; }
.tabla { border-collapse: collapse; width: 100%; margin-top: 6px; font-size: .82rem; }
.tabla th, .tabla td { border-bottom: 1px solid var(--linea); padding: 6px 8px; text-align: left; }
.tabla th { position: sticky; top: 0; background: var(--superficie-2); font-weight: 600; font-size: .74rem; }
.tabla tbody tr:hover td { background: color-mix(in srgb, var(--superficie-2) 60%, transparent); }
.tabla-scroll { max-height: 320px; overflow: auto; border-radius: var(--radio-md); border: 1px solid var(--linea); }
.tarjeta .tabla-scroll { max-height: 200px; }
.etq { display: inline-block; padding: 1px 8px; border-radius: 999px; color: #fff; font-weight: 700; font-size: .76rem; }
.etq-flojo { background: #95a5a6; } .etq-regular { background: #c9a10b; } .etq-bueno { background: #27ae60; }
.etq-fuerte { background: #c0392b; } .etq-sindatos { background: #999; }
details.como { margin-top: 6px; font-size: .76rem; color: var(--tinta-suave); }

/* Etiqueta al pasar por una zona (enciclopedia) */
.etiqueta-zona {
  padding: 5px 10px; font-family: var(--letra-titulo); font-weight: 700; font-size: .88rem;
  background: var(--tinta); color: var(--papel); border: 0; border-radius: var(--radio-sm); box-shadow: var(--sombra-md);
}
.etiqueta-zona small { font-family: var(--letra-datos); font-weight: 400; opacity: .8; }
.etiqueta-zona::before { border-top-color: var(--tinta) !important; }
body.quiz-mapa .etiqueta-zona { display: none; }

/* ===== FICHA (enciclopedia, rankings, comparar y quiz) ===== */
#ficha {
  display: none; position: absolute; z-index: 1000; top: 12px; right: 12px; bottom: 12px;
  width: min(560px, calc(100% - var(--panel-ancho) - var(--hueco) * 3)); flex-direction: column; overflow: hidden;
  background: color-mix(in srgb, var(--superficie) 92%, transparent); backdrop-filter: var(--cristal-filtro); -webkit-backdrop-filter: var(--cristal-filtro);
  border: 1px solid var(--cristal-borde); border-radius: var(--radio-xl);
  box-shadow: var(--sombra-lg);
}
#ficha.abierta { display: flex; animation: entrar .28s cubic-bezier(.2, .8, .2, 1); }
#ficha.compacta { width: min(390px, calc(100% - 24px)); bottom: auto; max-height: calc(100% - 24px); }
@keyframes entrar { from { opacity: 0; transform: translateX(20px); } }

.portada {
  position: relative; flex-shrink: 0; overflow: hidden; padding: 20px 22px 18px; color: #fff;
  background: var(--color-zona, var(--cabecera-fondo));
}
.portada::after {   /* oscurece el color de la zona para que el texto se lea siempre */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, rgba(8, 17, 26, .6) 0%, rgba(8, 17, 26, .25) 60%, rgba(8, 17, 26, .05) 100%);
}
.portada > * { position: relative; z-index: 1; }
.portada .silueta { position: absolute; z-index: 0; right: -6px; top: 50%; transform: translateY(-50%); width: 44%; height: 140%; opacity: .3; }
.portada .silueta path { fill: #fff; }
.portada .ficha-tipo {
  display: inline-block; padding: 2px 8px; font-family: var(--letra-datos); font-size: .64rem;
  text-transform: uppercase; letter-spacing: .12em; background: rgba(255, 255, 255, .16); border-radius: 999px;
}
.portada h2 { margin: 8px 0 6px; max-width: 78%; font-size: 2.1rem; font-weight: 800; line-height: 1.02; letter-spacing: -.03em; color: #fff; overflow-wrap: anywhere; }
.portada .ficha-lema { margin: 0; max-width: 72%; font-size: .88rem; line-height: 1.45; opacity: .92; }
.portada .cerrar {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 32px; height: 32px; border-radius: 50%;
  border: 0; cursor: pointer; font-size: .95rem; color: #fff; background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(6px); transition: background var(--rapido);
}
.portada .cerrar:hover { background: rgba(0, 0, 0, .5); }
.aviso-ficha { margin: 0; padding: 9px 22px; font-size: .82rem; background: color-mix(in srgb, var(--gualda) 16%, var(--superficie)); }

.cifras { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex-shrink: 0; border-bottom: 1px solid var(--linea); }
.cifras > div { min-width: 0; padding: 12px 14px; border-right: 1px solid var(--linea); }
.cifras > div:last-child { border-right: 0; }
.cifras .cifra { display: block; font-family: var(--letra-titulo); font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cifras .rotulo { display: block; font-size: .7rem; color: var(--tinta-suave); line-height: 1.3; }
.cifras .comparacion { display: inline-block; margin-top: 4px; padding: 0 6px; font-family: var(--letra-datos); font-size: .62rem; border-radius: 999px; background: var(--superficie-2); }
.mejor { color: var(--ok); } .peor { color: var(--acento); }

.pestanas {
  display: flex; gap: 4px; flex-shrink: 0; overflow-x: auto; padding: 10px 14px;
  background: var(--superficie); border-bottom: 1px solid var(--linea);
}
.pestanas button {
  white-space: nowrap; padding: 6px 13px; font-size: .8rem; font-weight: 600; color: var(--tinta-suave);
  background: none; border: 0; border-radius: 999px; cursor: pointer; transition: all var(--rapido);
}
.pestanas button:hover { background: var(--superficie-2); color: var(--tinta); }
.pestanas button.activa { background: var(--tinta); color: var(--papel); }

.sector { flex: 1; overflow-y: auto; padding: 8px 22px 24px; line-height: 1.6; font-size: .9rem; }
.sector h4 { display: flex; align-items: center; gap: 9px; margin: 22px 0 8px; font-size: 1.02rem; font-weight: 700; }
.sector h4::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; border-radius: 2px; background: var(--color-zona, var(--mar)); }
.sector p { margin: 6px 0; max-width: 65ch; }
.sector ul { padding-left: 18px; margin: 4px 0; }
.sector li { margin: 4px 0; }
.sector li::marker { color: var(--color-zona, var(--mar)); }
.datos { display: grid; grid-template-columns: minmax(130px, 38%) minmax(0, 1fr); margin: 8px 0; }
.datos dt, .datos dd { padding: 8px 4px; border-bottom: 1px solid var(--linea); }
.datos dt { color: var(--tinta-suave); font-size: .84rem; }
.datos dd { font-weight: 600; }
.etapas { list-style: none; padding: 0 !important; margin: 10px 0 0 6px !important; border-left: 2px solid var(--linea); }
.etapas li { position: relative; padding: 0 0 14px 20px; }
.etapas li::before {
  content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--superficie); border: 3px solid var(--color-zona, var(--mar));
}
.etapas b { font-family: var(--letra-titulo); }
.etapas p { margin: 2px 0 0; }
.grafico { position: relative; height: 280px; margin: 8px 0 14px; padding: 10px; border: 1px solid var(--linea); border-radius: var(--radio-md); }
.grafico.alto { height: 360px; }
.nota-ficha { font-size: .78rem; color: var(--tinta-suave); background: var(--superficie-2); padding: 8px 12px; border-radius: var(--radio-sm); }
.pendiente {
  font-size: .8rem; padding: 8px 12px; border-radius: var(--radio-sm);
  background: color-mix(in srgb, var(--gualda) 12%, var(--superficie)); border: 1px dashed var(--aviso);
}
.fuentes-sector {
  margin-top: 24px; padding: 12px 14px; font-size: .78rem;
  background: var(--superficie-2); border-radius: var(--radio-md);
}
.fuentes-sector b { font-family: var(--letra-datos); font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; color: var(--tinta-suave); }
.fuentes-sector ul { margin: 6px 0 0; padding-left: 16px; }
.fuentes-sector .anio { color: var(--tinta-suave); font-family: var(--letra-datos); font-size: .7rem; }
.ficha-vacia { padding: 32px 20px; text-align: center; color: var(--tinta-suave); }
.revisado { flex-shrink: 0; margin: 0; padding: 8px 22px; font-family: var(--letra-datos); font-size: .64rem; color: var(--tinta-tenue); border-top: 1px solid var(--linea); }

/* Rankings y comparar */
.rotulo-campo { display: block; font-size: .82rem; margin-bottom: 4px; }
.controles-herramienta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.controles-herramienta label { display: grid; gap: 4px; min-width: 0; font-size: .74rem; font-weight: 600; color: var(--tinta-suave); }
.controles-herramienta select { padding: 7px 30px 7px 10px; font-size: .84rem; }
.referencia-es { font-size: .84rem; margin: 6px 0; color: var(--tinta-suave); }
.ranking { list-style: none; margin: 8px 0 !important; padding: 0 !important; }
.ranking li { margin: 0 !important; }
.ranking button {
  display: grid; grid-template-columns: 24px minmax(90px, 34%) minmax(30px, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; padding: 7px 6px; font-size: .84rem; text-align: left; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--linea); background: none; border-radius: 0;
  transition: background var(--rapido);
}
.ranking button:hover { background: var(--superficie-2); }
.ranking .pos { font-family: var(--letra-datos); font-size: .7rem; color: var(--tinta-tenue); text-align: right; }
.ranking li:nth-child(-n+3) .pos { color: var(--acento); font-weight: 600; }
.ranking .barra { height: 8px; background: var(--superficie-2); border-radius: 999px; overflow: hidden; }
.ranking .barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--mar), color-mix(in srgb, var(--mar) 70%, var(--gualda))); border-radius: 999px; }
.ranking .val { font-family: var(--letra-datos); font-size: .74rem; white-space: nowrap; }
.comparar { max-height: none; }
.comparar th[scope="row"] { position: static; background: none; font-weight: 400; color: var(--tinta-suave); }
.comparar td.mayor { font-weight: 700; color: var(--tinta); }
.comparar td.sin { color: var(--tinta-tenue); }
.comparar small { font-weight: 400; color: var(--tinta-suave); }

/* Quiz */
.progreso-quiz { font-family: var(--letra-datos); font-size: .7rem; color: var(--tinta-suave); text-transform: uppercase; letter-spacing: .08em; }
.opciones-quiz { display: grid; gap: 8px; margin: 12px 0; }
.opciones-quiz button {
  padding: 11px 14px; text-align: left; font-size: .9rem; cursor: pointer;
  background: var(--superficie); border: 1px solid var(--linea-fuerte); border-radius: var(--radio-md);
  transition: all var(--rapido);
}
.opciones-quiz button:not(:disabled):hover { border-color: var(--tinta); background: var(--superficie-2); transform: translateX(2px); }
.opciones-quiz button.correcta { border: 2px solid var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--superficie)); font-weight: 700; }
.opciones-quiz button.correcta::before { content: "✓ "; color: var(--ok); }
.opciones-quiz button.fallo { border: 2px solid var(--acento); background: color-mix(in srgb, var(--acento) 8%, var(--superficie)); }
.opciones-quiz button.fallo::before { content: "✗ "; color: var(--acento); }
.respuesta { margin: 10px 0 2px; font-size: .98rem; }
.boton-principal {
  margin-top: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer; border: 0; border-radius: var(--radio-md);
  background: var(--tinta); color: var(--papel); transition: background var(--rapido);
}
.boton-principal:hover { background: var(--mar); }

/* ===== VENTANAS (ayuda y buscador) ===== */
.modal {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; max-width: 100vw; max-height: 100vh; padding: var(--space-4);
  border: 0; color: var(--tinta);
  background: rgba(8, 17, 26, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
/* Un <dialog> cerrado debe ocultarse: sin esto, display:flex lo deja siempre visible */
.modal:not([open]) { display: none; }
.modal::backdrop { background: transparent; }
.modal[open] .modal-content { animation: aparecer .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.modal-content {
  max-width: 92vw; max-height: 88vh; overflow: auto;
  background: var(--superficie); border: 1px solid var(--linea); border-radius: var(--radio-xl);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
}
.modal-search { width: 600px; padding: 10px; align-self: flex-start; margin-top: 12vh; }
.search-global { display: flex; align-items: center; gap: 12px; padding: 6px 10px; color: var(--tinta-tenue); }
.search-global input { flex: 1; padding: 8px 0; font-size: 1.05rem; background: transparent; border: 0; }
.search-global input:focus { box-shadow: none; }
.resultados-globales { max-height: 400px; overflow-y: auto; }
.resultados-globales:not(:empty) { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--linea); }

.modal-ayuda { position: relative; width: 540px; padding: 28px 30px 26px; }
.modal-ayuda h2 { font-size: 1.5rem; font-weight: 800; padding-right: 40px; }
.modal-cerrar { position: absolute; top: 16px; right: 16px; }
.ayuda-section { margin: 18px 0; padding-top: 16px; border-top: 1px solid var(--linea); }
.ayuda-section h3 { margin-bottom: 4px; font-size: 1rem; font-weight: 700; }
.ayuda-section p { margin: 0; font-size: .88rem; color: var(--tinta-suave); }
.atajos-lista { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 8px; }
.atajo { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.atajo span { margin-left: 4px; color: var(--tinta-suave); }
.modal-ayuda > .btn-primary { width: 100%; padding: 11px; margin-top: 4px; font-size: .9rem; }

/* ===== AVISOS EMERGENTES (toasts) ===== */
.toast-container {
  position: fixed; z-index: var(--z-toast); bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 8px 8px 8px 16px;
  font-size: .84rem; font-weight: 500; pointer-events: auto;
  background: var(--tinta); color: var(--papel); border-radius: 999px; box-shadow: var(--sombra-lg);
  animation: toastEntra .25s cubic-bezier(.2, .8, .2, 1); transition: opacity .3s;
}
.toast::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--mar); }
.toast-success::before { background: #4cc38a; }
.toast-error::before { background: var(--acento); }
.toast-warning::before { background: var(--gualda); }
.toast .btn-icon-sm { color: inherit; opacity: .6; width: 24px; height: 24px; }
.toast .btn-icon-sm:hover { opacity: 1; background: rgba(255, 255, 255, .12); }
@keyframes toastEntra { from { opacity: 0; transform: translateY(10px); } }

/* ===== FONDO OSCURO DEL MENÚ EN MÓVIL ===== */
.overlay { position: fixed; inset: 0; z-index: var(--z-overlay); display: none; background: rgba(8, 17, 26, .5); }
.overlay.visible { display: block; }

/* ===== MODOS ===== */
.solo-enciclopedia { display: none; }
body.modo-enciclopedia .solo-dia { display: none !important; }
body.modo-enciclopedia .solo-enciclopedia { display: block; }

/* ===== PANTALLAS MEDIANAS ===== */
@media (max-width: 1280px) {
  .estado-badge { display: none; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  /* Pestañas solo con icono; el nombre queda como etiqueta accesible */
  .tabs .tab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tab { padding: 7px 11px; }
  .context-info .context-hora { display: none; }
}

@media (max-width: 1024px) {
  #cabecera { gap: var(--space-3); padding: 0 var(--space-4); }
  :root { --panel-ancho: 300px; }
  .cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cifras > div:nth-child(2n) { border-right: 0; }
  .cifras > div { border-bottom: 1px solid var(--linea); }
  .context-bar { display: none; }
}

/* ===== MÓVIL ===== */
@media (max-width: 768px) {
  #cabecera { height: 56px; padding: 0 var(--space-3); gap: var(--space-2); }
  .logo h1 { font-size: 1.05rem; }
  .logo-icon { width: 28px; height: 28px; }
  #controles-fecha { display: none; }
  #boton-compartir { display: none; }
  .header-actions, .fecha-controls + .header-actions { margin-left: auto; }

  /* Selector de modo: barra fija abajo */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-fijo);
    margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; border-radius: 0; border: 0;
    background: var(--cabecera-fondo); box-shadow: 0 -4px 16px rgba(0, 0, 0, .2);
  }
  .tab { flex: 1; flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; border-radius: var(--radio-md); justify-content: center; }
  .tab span { display: block; }

  :root { --panel-ancho: 0px; }
  #contenedor { margin-bottom: 58px; }
  .overlay.visible { display: none; }

  .avisos-panel { left: 8px; right: 8px; top: 8px; width: auto; max-width: none; max-height: 32%; }
  #zona-mapa > .btn.btn-primary { left: 8px !important; top: 8px !important; }
  .leaflet-top.leaflet-right { top: 50px; }

  #ficha { top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 84%; border-radius: 20px 20px 0 0; overflow-y: auto; }
  #ficha.abierta { display: block; animation: subir .28s cubic-bezier(.2, .8, .2, 1); }
  #ficha.compacta { width: 100%; height: auto; max-height: 50%; bottom: 0; }
  @keyframes subir { from { transform: translateY(30px); opacity: 0; } }
  .portada h2 { font-size: 1.6rem; max-width: 85%; }
  .portada .ficha-lema { max-width: 100%; }
  .pestanas { position: sticky; top: 0; z-index: 3; }
  .sector { overflow: visible; padding: 6px 16px 20px; }
  .datos { grid-template-columns: 1fr; }
  .datos dt { border-bottom: 0; padding-bottom: 0; }
  .ranking button { grid-template-columns: 22px minmax(84px, 38%) minmax(16px, 1fr) auto; }
  .leyenda-calor { bottom: 24px; left: 8px; font-size: .72rem; }
  .atajos-lista { grid-template-columns: 1fr; }
  .modal-ayuda { padding: 22px 20px; }
  .toast-container { bottom: 72px; }
}

@media (max-width: 420px) {
  .logo-text { display: none; }
}

/* ===== MOVIMIENTO REDUCIDO ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
