/* ==========================================================================
   SAS Ríos Uruguay · Paraná — Rediseño "SAS Rios" (dark monocromático / terminal)
   Importado desde Claude Design. Fondo #0a0a0a, Geist + Geist Mono, bordes finos,
   esquinas rectas, grillas con separadores de 1px, colores de estado semánticos.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
    --bg: #0a0a0a;
    --panel: #0a0a0a;

    --text: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --text-mute: rgba(255, 255, 255, 0.4);
    --text-faint: rgba(255, 255, 255, 0.35);

    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.24);
    --grid-line: rgba(255, 255, 255, 0.1);
    --grid-line-soft: rgba(255, 255, 255, 0.09);
    --hover: rgba(255, 255, 255, 0.03);

    --accent: #ffffff;

    /* Colores semánticos de estado (compartidos con app.js y Chart.js) */
    --color-normal: #10b981;
    --color-vigilancia: #f59e0b;
    --color-alerta: #f97316;
    --color-evacuacion: #ef4444;

    /* Tipografía */
    --font-sans: 'Geist', system-ui, -apple-system, sans-serif;
    --font-mono: 'Geist Mono', 'Courier New', monospace;

    /* Espaciados */
    --espacio-xs: 0.25rem;
    --espacio-sm: 0.5rem;
    --espacio-md: 1rem;
    --espacio-lg: 1.5rem;
    --espacio-xl: 2rem;

    /* Radios (el diseño es de esquinas rectas; sólo píldoras redondeadas) */
    --radio-sm: 0;
    --radio-md: 0;
    --radio-lg: 0;
    --pill: 9999px;

    --transicion-rapida: all 0.18s ease;
    --transicion-media: all 0.25s ease;
}

/* --------------------------------------------------------------------------
   2. RESET / BASE
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: rgba(255, 255, 255, 0.5); }

h1, h2, h3, h4 { font-weight: 400; }

@keyframes sasPulse { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes sasBlink { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   3. LEAFLET (mapa oscuro, popups y marcadores)
   -------------------------------------------------------------------------- */
.leaflet-container { background: #0a0a0a !important; font-family: var(--font-mono) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: #111111; color: #fff; border-radius: 0;
    border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: none;
}
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font-sans); }
.leaflet-control-zoom a {
    background: #111111 !important; color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important; border-radius: 0 !important;
}
.leaflet-bar { border: none !important; }

.marker-pin {
    width: 14px; height: 14px; border-radius: 50%;
    border: 1.5px solid #0a0a0a; background: var(--color-normal);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.marker-pin.NORMAL { background: var(--color-normal); }
.marker-pin.VIGILANCIA { background: var(--color-vigilancia); }
.marker-pin.ALERTA { background: var(--color-alerta); }
.marker-pin.EVACUACION { background: var(--color-evacuacion); }
.marker-pin.creciendo::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    border: 1px solid currentColor; animation: sasPulse 2.2s infinite ease-out;
}
.dam-pin {
    width: 12px; height: 12px; background: #fff; border: 2px solid #0a0a0a;
    transform: rotate(45deg); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3);
}
.trend-indicator-growing { color: var(--color-alerta); }
.trend-indicator-falling { color: var(--color-normal); }
.trend-indicator-stable { color: var(--text-mute); }

/* --------------------------------------------------------------------------
   4. LAYOUT PRINCIPAL
   -------------------------------------------------------------------------- */
.app-container {
    height: 100vh; width: 100vw;
    display: grid; grid-template-rows: 76px 1fr 40px;
    background: var(--bg); overflow: hidden;
}

/* --------------------------------------------------------------------------
   5. HEADER
   -------------------------------------------------------------------------- */
.main-header {
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 0 28px; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(249, 115, 22, 0.05), transparent), #0a0a0a;
}

.header-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
/* Logo de marca (RÍO VIGÍA): badge "RV" azul con reflejo de agua. Si falta el archivo,
   el onerror lo reemplaza por el punto pulsante (.pulse-logo) y queda solo el wordmark. */
.brand-logo { height: 36px; width: auto; flex-shrink: 0; display: block; border-radius: 6px; }
.pulse-logo { position: relative; width: 9px; height: 9px; flex-shrink: 0; border-radius: 50%; background: #fff; }
.pulse-logo::after {
    content: ""; position: absolute; inset: -3px; border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.6); animation: sasPulse 2.6s infinite ease-out;
}
.header-brand h1 {
    display: flex; flex-direction: column; gap: 2px;
    font-family: var(--font-mono); font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
}
.header-brand h1 span {
    font-family: var(--font-mono); font-size: 9px; font-weight: 400;
    letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-mute);
}

/* Nav (píldoras) */
.desktop-nav { display: flex; gap: 6px; align-items: center; }
.nav-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
    padding: 8px 16px; border-radius: var(--pill);
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
    transition: var(--transicion-rapida);
}
.nav-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.04); }
.nav-btn.active { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; transition: var(--transicion-rapida); }
.nav-btn.active .nav-icon { stroke: #fff; }

/* Pestañas aún no habilitadas ("Pronto") */
.nav-btn-soon { opacity: 0.55; cursor: not-allowed; }
.nav-btn-soon:hover { color: var(--text-secondary); border-color: var(--border); }
.nav-btn-soon.active { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.soon-badge {
    font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--color-vigilancia); border: 1px solid var(--color-vigilancia);
    border-radius: var(--pill); padding: 1px 6px; margin-left: 2px;
}
.bottom-nav-btn.nav-btn-soon { opacity: 0.55; cursor: not-allowed; }

.coming-soon-panel {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: 14px; padding: 60px 20px; color: var(--text-secondary);
}
.coming-soon-panel h2 { color: #fff; margin: 0; }
.coming-soon-panel .section-desc { margin: 0; max-width: 440px; }

/* Estado global de la cuenca */
.basin-state-container {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 16px; border: 1px solid var(--border); min-width: 300px;
}
.state-indicator {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--color-normal); box-shadow: 0 0 10px var(--color-normal);
}
.state-indicator.NORMAL { background: var(--color-normal); box-shadow: 0 0 10px var(--color-normal); }
.state-indicator.VIGILANCIA { background: var(--color-vigilancia); box-shadow: 0 0 10px var(--color-vigilancia); }
.state-indicator.ALERTA { background: var(--color-alerta); box-shadow: 0 0 10px var(--color-alerta); }
.state-indicator.EVACUACION { background: var(--color-evacuacion); box-shadow: 0 0 10px var(--color-evacuacion); animation: sasBlink 1.2s infinite; }
.state-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.state-label {
    font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--text-mute);
}
.state-value {
    font-family: var(--font-mono); font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
    color: var(--color-normal);
}
.basin-state-container.NORMAL .state-value { color: var(--color-normal); }
.basin-state-container.VIGILANCIA .state-value { color: var(--color-vigilancia); }
.basin-state-container.ALERTA .state-value { color: var(--color-alerta); }
.basin-state-container.EVACUACION .state-value { color: var(--color-evacuacion); }
.state-desc {
    font-size: 11px; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}

/* --------------------------------------------------------------------------
   6. TABS (contenedor)
   -------------------------------------------------------------------------- */
.main-content-wrapper { position: relative; overflow: hidden; }
.tab-content { display: none; height: 100%; }
.tab-content.active-tab { display: block; animation: fadeInUp 0.25s ease; }
#tab-map.active-tab { display: block; overflow: hidden; }
#tab-dashboard.active-tab,
#tab-forecasts.active-tab,
#tab-alerts.active-tab,
#tab-settings.active-tab { display: block; overflow-y: auto; padding: 32px 40px; }

.tab-content h1 { font-size: 40px; font-weight: 300; letter-spacing: -0.035em; line-height: 1; }
.tab-content h2 { font-size: 40px; font-weight: 300; letter-spacing: -0.035em; line-height: 1; }
.tab-content h4 {
    font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--text-mute); font-weight: 400;
}

/* --------------------------------------------------------------------------
   7. TAB MAPA
   -------------------------------------------------------------------------- */
.map-grid-layout { display: grid; grid-template-columns: 1fr 400px; height: 100%; }
.map-section { position: relative; border-right: 1px solid var(--border); height: 100%; }
#map { position: absolute; inset: 0; }

.map-legend {
    position: absolute; bottom: 20px; left: 20px; z-index: 500;
    padding: 14px 16px; background: rgba(10, 10, 10, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px);
    display: flex; flex-direction: column; gap: 9px;
}
.legend-title {
    font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--text-mute);
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 12px; color: rgba(255, 255, 255, 0.75); }
.legend-color { width: 8px; height: 8px; border-radius: 50%; }
.legend-color.normal { background: var(--color-normal); }
.legend-color.vigilancia { background: var(--color-vigilancia); }
.legend-color.alerta { background: var(--color-alerta); }
.legend-color.evacuacion { background: var(--color-evacuacion); }
.legend-color.pulse { animation: sasBlink 1.2s infinite; }

/* Sidebar de detalle */
.sidebar-section { height: 100%; overflow-y: auto; padding: 28px; }

.sidebar-empty {
    height: 100%; display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; gap: 14px; color: var(--text-secondary);
}
.sidebar-empty h2 { font-size: 22px; font-weight: 400; color: #fff; }
.sidebar-empty p { font-size: 13px; max-width: 34ch; line-height: 1.5; }
.welcome-icon { opacity: 0.5; }

.sidebar-data.fading { animation: fadeInUp 0.4s ease; }

.station-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    padding-bottom: 22px; border-bottom: 1px solid var(--border);
}
.station-header h2 { font-size: 26px; font-weight: 400; letter-spacing: -0.03em; line-height: 1; }
.station-meta {
    display: block; margin-top: 8px; font-family: var(--font-mono);
    font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute);
}

/* Píldora de estado reutilizable */
.status-badge {
    font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
    padding: 6px 12px; border-radius: var(--pill); border: 1px solid var(--text-mute);
    color: var(--text-secondary); white-space: nowrap; text-transform: uppercase;
}
.status-badge.NORMAL { border-color: var(--color-normal); color: var(--color-normal); }
.status-badge.VIGILANCIA { border-color: var(--color-vigilancia); color: var(--color-vigilancia); }
.status-badge.ALERTA { border-color: var(--color-alerta); color: var(--color-alerta); }
.status-badge.EVACUACION { border-color: var(--color-evacuacion); color: var(--color-evacuacion); }

/* Grilla de lecturas (con separadores de 1px) */
.readings-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 24px;
    background: var(--grid-line); border: 1px solid var(--grid-line);
}
.reading-card { background: var(--panel); padding: 18px; }
.card-label {
    font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--text-mute);
}
.card-value-container { display: flex; align-items: baseline; gap: 4px; margin-top: 12px; }
.card-value { font-family: var(--font-mono); font-size: 34px; font-weight: 500; line-height: 1; }
.reading-card .card-value { color: #fff; }
.card-unit { font-size: 13px; color: var(--text-secondary); }
.card-subtext { display: block; font-size: 11px; color: var(--text-secondary); margin-top: 10px; }
#val-edad-dato { margin-top: 4px; }
#val-edad-dato:empty { display: none; }

/* Dato de nivel medido hace demasiado tiempo: se resalta en amber (color de vigilancia)
   para que una lectura vieja no se lea como nivel vigente. */
.dato-viejo { color: var(--color-vigilancia); }

/* Alerta temprana / propagación */
.forecast-card {
    margin-top: 20px; border: 1px solid rgba(249, 115, 22, 0.4); border-left: 2px solid var(--color-alerta);
    padding: 18px; background: rgba(249, 115, 22, 0.05);
}
.forecast-header { display: flex; align-items: center; gap: 9px; color: var(--color-alerta); }
.forecast-header::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: var(--color-alerta); animation: sasBlink 1.2s infinite;
}
.forecast-icon { display: none; }
.forecast-header h4 {
    font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--color-alerta);
}
.forecast-text { margin: 12px 0 16px; font-size: 12.5px; line-height: 1.5; color: rgba(255, 255, 255, 0.72); }
.forecast-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
    padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.f-label {
    font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-mute);
}
.f-value { display: block; font-family: var(--font-mono); font-size: 14px; font-weight: 600; margin-top: 6px; }
.f-value.highlighting { color: var(--color-alerta); }

/* Avisos vigentes (SMN/SHN) */
.advisories-section { margin-top: 24px; }
.advisories-list { display: flex; flex-direction: column; gap: 1px; margin-top: 12px; background: var(--grid-line); border: 1px solid var(--grid-line); }
.advisory-item {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--panel);
    border-left: 2px solid var(--text-mute);
}
.advisory-item.VIGILANCIA { border-left-color: var(--color-vigilancia); }
.advisory-item.ALERTA { border-left-color: var(--color-alerta); }
.advisory-item.EVACUACION { border-left-color: var(--color-evacuacion); }
.advisory-tag {
    font-family: var(--font-mono); font-size: 8.5px; font-weight: 600; letter-spacing: 0.1em;
    color: var(--text-secondary); border: 1px solid var(--border); padding: 3px 7px; flex-shrink: 0;
}
.advisory-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.advisory-title { font-size: 12.5px; color: rgba(255, 255, 255, 0.85); }
.advisory-detail { font-size: 10.5px; color: var(--text-secondary); }

/* Cotas */
.cotas-section { margin-top: 26px; }
.cotas-section h4 { margin-bottom: 12px; }
.cotas-list { display: flex; flex-direction: column; gap: 1px; background: var(--grid-line); border: 1px solid var(--grid-line); }
.cota-item { display: flex; justify-content: space-between; padding: 11px 14px; background: var(--panel); font-size: 12.5px; }
.cota-name { color: var(--text-secondary); }
.cota-val { font-family: var(--font-mono); font-weight: 600; }
.cota-val.color-evac { color: var(--color-evacuacion); }
.cota-val.color-alert { color: var(--color-alerta); }
.cota-val.color-vig { color: var(--color-vigilancia); }

/* Chart histórico */
.chart-container { margin-top: 26px; }
.chart-container h4 { margin-bottom: 14px; }
.canvas-wrapper { position: relative; height: 160px; width: 100%; }

/* Fuentes de datos */
.station-sources { margin-top: 26px; padding-bottom: 20px; }
.station-sources h4 { margin-bottom: 12px; }
.sources-list { display: flex; flex-direction: column; gap: 1px; background: var(--grid-line); border: 1px solid var(--grid-line); }
.source-pill {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; background: var(--panel);
}
.source-name {
    font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
    text-transform: uppercase; color: rgba(255, 255, 255, 0.8);
}
.source-indicator {
    display: flex; align-items: center; gap: 7px; font-family: var(--font-mono);
    font-size: 9px; letter-spacing: 0.1em; color: var(--text-secondary);
}
.indicator-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute); }
.indicator-dot.active, .indicator-dot.stable { background: var(--color-normal); }
.indicator-dot.degraded { background: var(--color-vigilancia); }
.indicator-dot.down { background: var(--color-evacuacion); }

/* --------------------------------------------------------------------------
   8. TAB DASHBOARD
   -------------------------------------------------------------------------- */
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; }
.dashboard-header h2 { font-size: 40px; font-weight: 300; letter-spacing: -0.035em; }
.dashboard-header .status-badge { border-color: var(--border); color: var(--text-secondary); border-radius: 0; }

.stations-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px;
    background: var(--grid-line-soft); border: 1px solid var(--grid-line-soft);
}
.river-group-header {
    grid-column: 1 / -1; background: var(--bg) !important;
    font-family: var(--font-mono); font-size: 11px !important; letter-spacing: 0.2em !important;
    text-transform: uppercase; color: var(--text-faint) !important;
    border-bottom: none !important; padding: 22px 0 8px !important; margin: 0 !important;
}
.station-dashboard-card {
    background: var(--panel); border-left: 2px solid var(--color-normal);
    padding: 20px; cursor: pointer; display: flex; flex-direction: column; gap: 16px;
    transition: var(--transicion-rapida);
}
.station-dashboard-card:hover { background: var(--hover); }
.station-dashboard-card.NORMAL { border-left-color: var(--color-normal); }
.station-dashboard-card.VIGILANCIA { border-left-color: var(--color-vigilancia); }
.station-dashboard-card.ALERTA { border-left-color: var(--color-alerta); }
.station-dashboard-card.EVACUACION { border-left-color: var(--color-evacuacion); }
.card-top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.card-station-name { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.card-country-flag, .country-badge {
    font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.1em;
    padding: 3px 7px; border: 1px solid rgba(255, 255, 255, 0.14); color: var(--text-secondary);
}
.card-main-level { display: flex; align-items: baseline; gap: 6px; }
.card-level-num { font-family: var(--font-mono); font-size: 30px; font-weight: 500; line-height: 1; }
.card-level-unit { font-size: 13px; color: var(--text-secondary); }
.card-bottom-row {
    display: flex; justify-content: space-between; align-items: center;
    padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-mute);
}
.card-bottom-row .status-badge { border: none; padding: 0; font-size: 9px; }
.dashboard-trend { font-family: var(--font-mono); font-size: 12px; margin-left: 6px; }
.dashboard-trend.growing { color: var(--color-alerta); }
.dashboard-trend.falling { color: var(--color-normal); }
.dashboard-trend.stable { color: var(--text-mute); }
/* colorear el nº por estado de la tarjeta */
.station-dashboard-card.NORMAL .card-level-num { color: var(--color-normal); }
.station-dashboard-card.VIGILANCIA .card-level-num { color: var(--color-vigilancia); }
.station-dashboard-card.ALERTA .card-level-num { color: var(--color-alerta); }
.station-dashboard-card.EVACUACION .card-level-num { color: var(--color-evacuacion); }

/* --------------------------------------------------------------------------
   9. TAB CLIMA
   -------------------------------------------------------------------------- */
.forecasts-tab-layout { max-width: 1100px; margin: 0 auto; }

.weather-advisories { margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; }
.weather-advisories-title {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--text-faint);
}
.weather-advisories-list { display: flex; flex-direction: column; gap: 1px; background: var(--grid-line); border: 1px solid var(--grid-line); }

.weather-current-card { border: 1px solid var(--border); padding: 32px; margin-bottom: 0; }
.weather-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.weather-header-row h3 { font-size: 24px; font-weight: 300; letter-spacing: -0.02em; }
.weather-selector-container { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); }
.custom-select {
    background: #0a0a0a; color: #fff; border: 1px solid var(--border); border-radius: 0;
    padding: 8px 12px; font-family: var(--font-mono); font-size: 11px; cursor: pointer;
}
.custom-select:focus { outline: none; border-color: var(--border-strong); }

.weather-current-main { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.weather-icon-large { width: 84px; height: 84px; }
.weather-svg { width: 100%; height: 100%; }
.weather-temp-container { display: flex; flex-direction: column; gap: 6px; }
.weather-temp { font-family: var(--font-mono); font-size: 60px; font-weight: 300; line-height: 1; }
.weather-cond { font-size: 16px; color: rgba(255, 255, 255, 0.85); }
.weather-feels { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--text-mute); }
.weather-outlook {
    display: inline-flex; align-items: center; gap: 7px; margin-top: 4px;
    font-size: 12px; font-weight: 500; color: var(--color-vigilancia);
}
.weather-outlook::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--color-vigilancia); }

.weather-metrics-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px;
    background: var(--grid-line-soft); border: 1px solid var(--grid-line-soft); border-top: none;
}
.metric-tile { background: var(--panel); padding: 20px; }
.metric-icon { display: block; width: 18px; height: 18px; color: var(--text-mute); margin-bottom: 8px; }
.metric-icon svg { width: 100%; height: 100%; }
.metric-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); }
.metric-value { display: block; font-family: var(--font-mono); font-size: 22px; font-weight: 500; margin-top: 12px; }

/* Panel para navegantes */
.nav-panel-card { border: 1px solid var(--border); padding: 24px; margin-top: 24px; }
.nav-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.nav-panel-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; }
.nav-anchor { display: inline-flex; width: 16px; height: 16px; color: var(--text-secondary); }
.nav-anchor svg { width: 100%; height: 100%; }
.nav-advisory-badge {
    font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; padding: 5px 12px; border-radius: var(--pill); border: 1px solid currentColor;
    color: var(--color-normal);
}
.nav-advisory-badge.nav-favorable { color: var(--color-normal); }
.nav-advisory-badge.nav-precaucion { color: var(--color-vigilancia); }
.nav-advisory-badge.nav-riesgoso { color: var(--color-alerta); }
.nav-advisory-badge.nav-peligroso { color: var(--color-evacuacion); animation: sasBlink 1.4s infinite; }
.nav-panel-body { display: flex; gap: 32px; align-items: center; flex-wrap: wrap; }
.wind-compass { width: 120px; height: 120px; flex-shrink: 0; }
.compass-svg { width: 100%; height: 100%; }
.compass-ring { fill: none; stroke: var(--border); stroke-width: 1.5; }
.compass-cardinals { fill: var(--text-mute); }
.compass-needle-from { fill: rgba(255, 255, 255, 0.25); }
.compass-needle-to { fill: var(--color-alerta); }
.compass-hub { fill: #fff; }
.compass-dir { fill: #fff; }
.nav-details { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 1px; flex: 1; background: var(--grid-line); border: 1px solid var(--grid-line); }
.nav-detail { background: var(--panel); padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; }
.nav-detail-label { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-mute); }
.nav-detail-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.nav-advisory-text { margin-top: 16px; font-size: 12.5px; line-height: 1.5; color: rgba(255, 255, 255, 0.72); }

/* Próximas horas */
.weather-hourly-section { margin-top: 40px; }
.weather-hourly-section h4 {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--text-faint); margin-bottom: 16px;
}
.weather-hourly-scroll { display: flex; gap: 1px; background: var(--grid-line-soft); border: 1px solid var(--grid-line-soft); overflow-x: auto; }
.hourly-card { background: var(--panel); padding: 18px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 90px; }
.hourly-card .hour { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text-mute); }
.hourly-card .icon { width: 30px; height: 30px; }
.hourly-card .icon svg { width: 100%; height: 100%; }
.hourly-card .temp { font-family: var(--font-mono); font-size: 18px; font-weight: 500; }

/* Pronóstico de nivel 5 días */
.water-forecast-section { margin-top: 40px; }
.water-forecast-section h4 {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--text-faint); margin-bottom: 16px;
}
.forecast-chart-container { position: relative; height: 260px; border: 1px solid var(--border); padding: 24px; }
.forecast-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px;
}
.forecast-empty-title { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); }
.forecast-empty-sub { font-size: 12px; color: var(--text-mute); max-width: 42ch; line-height: 1.5; }
.forecast-chart-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; color: var(--text-mute); flex-wrap: wrap; }
.peak-label { color: var(--color-alerta); }

/* Precipitación por subcuenca */
.rainfall-outlook-section { margin-top: 40px; padding-bottom: 40px; }
.rainfall-outlook-section h4 {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--text-faint); margin-bottom: 16px;
}
.basin-grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--grid-line-soft); border: 1px solid var(--grid-line-soft); }
.basin-column { background: var(--panel); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rainfall-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px; width: 100%; max-width: 150px; }
.rain-block { aspect-ratio: 1; background: rgba(255, 255, 255, 0.05); }
.rain-block.val-0 { background: rgba(255, 255, 255, 0.05); }
.rain-block.val-1 { background: rgba(125, 211, 252, 0.3); }
.rain-block.val-2 { background: rgba(125, 211, 252, 0.6); }
.rain-block.val-3 { background: rgba(125, 211, 252, 0.95); }
.basin-label { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); }
.basin-mm { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--color-vigilancia); }
.basin-mm.mm-0 { color: var(--text-secondary); }
.rainfall-outlook-desc { grid-column: 1 / -1; margin-top: 16px; font-size: 12.5px; color: var(--text-secondary); text-align: center; }

/* --------------------------------------------------------------------------
   10. TAB ALERTAS
   -------------------------------------------------------------------------- */
.alerts-tab-layout { max-width: 720px; margin: 0 auto; }
.alerts-tab-layout h2 { margin-bottom: 30px; }
.alert-config-card { border: 1px solid var(--border); padding: 28px; display: flex; flex-direction: column; gap: 32px; }
.form-section:not(:first-child) { border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 28px; }
.form-section h4 {
    font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--text-secondary); margin-bottom: 18px;
}

.stations-switches-list { display: flex; flex-direction: column; }
.toggle-row, .input-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px; color: rgba(255, 255, 255, 0.85);
}
.station-sel-name { font-size: 14px; }

/* Toggle (switch) estilo diseño */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; cursor: pointer; border-radius: var(--pill);
    border: 1px solid var(--border-strong); background: transparent; transition: var(--transicion-rapida);
}
.slider::before {
    content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
    border-radius: 50%; background: rgba(255, 255, 255, 0.6); transition: var(--transicion-rapida);
}
.switch input:checked + .slider { background: #fff; border-color: #fff; }
.switch input:checked + .slider::before { left: 22px; background: #0a0a0a; }

/* Sliders de nivel */
.range-group { display: flex; flex-direction: column; gap: 14px; }
.range-group + .range-group { margin-top: 26px; }
.range-header { display: flex; justify-content: space-between; font-size: 13px; color: rgba(255, 255, 255, 0.75); }
.highlight-val { font-family: var(--font-mono); font-weight: 600; color: var(--color-alerta); }
.range-input-wrapper { display: flex; align-items: center; gap: 14px; }
input[type=range] {
    -webkit-appearance: none; appearance: none; flex: 1; height: 2px;
    background: rgba(255, 255, 255, 0.18); outline: none;
}
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; cursor: pointer; }
.numeric-input, .text-input {
    width: 90px; background: #0a0a0a; color: #fff; border: 1px solid var(--border);
    padding: 8px 10px; font-family: var(--font-mono); font-size: 13px; border-radius: 0;
}
.text-input { width: 220px; }
.numeric-input:focus, .text-input:focus, .custom-select:focus { outline: none; border-color: var(--border-strong); }
.input-row .text-input { max-width: 55%; }

/* Segmented control de frecuencia */
.segmented-control { display: inline-flex; border: 1px solid var(--border-strong); }
.segment-btn {
    background: transparent; color: var(--text-secondary); border: none;
    padding: 10px 18px; font-family: var(--font-mono); font-size: 10px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; transition: var(--transicion-rapida);
}
.segment-btn.active { background: #fff; color: #0a0a0a; }

.btn-save-config {
    align-self: flex-start; margin-top: 4px; background: #fff; color: #0a0a0a; border: none;
    border-radius: var(--pill); padding: 13px 28px; font-family: var(--font-mono);
    font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer;
    transition: var(--transicion-rapida);
}
.btn-save-config:hover { background: rgba(255, 255, 255, 0.75); }

/* --------------------------------------------------------------------------
   11. TAB DIAGNÓSTICO
   -------------------------------------------------------------------------- */
.settings-tab-layout { max-width: 1000px; margin: 0 auto; }
.settings-tab-layout h2 { margin-bottom: 8px; }
.section-desc { font-size: 14px; color: var(--text-secondary); margin-bottom: 30px; }
.health-table-wrapper { border: 1px solid var(--border); overflow-x: auto; margin-bottom: 20px; }
.health-table { width: 100%; border-collapse: collapse; }
.health-table thead th {
    text-align: left; font-family: var(--font-mono); font-size: 9px; font-weight: 400;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute);
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.health-table tbody td {
    padding: 15px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px; color: var(--text-secondary); vertical-align: middle;
}
.health-table tbody tr:last-child td { border-bottom: none; }
.health-table tbody td:first-child { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.04em; color: #fff; }
.health-status-cell { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
.health-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute); flex-shrink: 0; }
.health-dot.stable { background: var(--color-normal); }
.health-dot.degraded { background: var(--color-vigilancia); }
.health-dot.down { background: var(--color-evacuacion); animation: sasBlink 1.4s infinite; }

.notif-section-header { display: flex; align-items: center; gap: 14px; margin-top: 20px; }
.notif-section-header h2 { font-size: 26px; font-weight: 300; }
.notif-mode-badge {
    font-family: var(--font-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; padding: 4px 10px; border: 1px solid var(--border); color: var(--text-secondary);
}
.notif-mode-badge.modo-real { border-color: var(--color-normal); color: var(--color-normal); }
.notif-mode-badge.modo-dry { border-color: var(--color-vigilancia); color: var(--color-vigilancia); }

/* --------------------------------------------------------------------------
   12. FOOTER
   -------------------------------------------------------------------------- */
.main-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; border-top: 1px solid var(--border);
}
.footer-left, .health-summary-btn {
    display: flex; align-items: center; gap: 12px; font-family: var(--font-mono);
    font-size: 10px; letter-spacing: 0.08em; color: var(--text-mute); text-transform: uppercase;
}
.footer-left .separator { color: rgba(255, 255, 255, 0.2); }
.health-summary-btn { background: transparent; border: none; cursor: pointer; color: rgba(255, 255, 255, 0.55); }
.health-summary-btn:hover { color: #fff; }
.footer-left { flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   13. BOTTOM NAV (móvil)
   -------------------------------------------------------------------------- */
.bottom-nav { display: none; }

/* --------------------------------------------------------------------------
   14. TOASTS
   -------------------------------------------------------------------------- */
.toast-container { position: fixed; bottom: 60px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast-notification {
    display: flex; align-items: center; gap: 12px; min-width: 260px; max-width: 380px;
    padding: 14px 16px; background: #111111; border: 1px solid var(--border); border-left: 2px solid var(--text-mute);
    font-size: 13px; color: #fff; opacity: 0; transform: translateX(20px); transition: var(--transicion-media);
}
.toast-notification.visible { opacity: 1; transform: none; }
.toast-notification.dismissing { opacity: 0; transform: translateX(20px); }
.toast-notification.success { border-left-color: var(--color-normal); }
.toast-notification.error { border-left-color: var(--color-evacuacion); }
.toast-notification.warning { border-left-color: var(--color-vigilancia); }
.toast-notification.info { border-left-color: #7dd3fc; }
.toast-icon { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; }
.toast-svg { width: 100%; height: 100%; }
.toast-svg.success { color: var(--color-normal); }
.toast-svg.error { color: var(--color-evacuacion); }
.toast-svg.warning { color: var(--color-vigilancia); }
.toast-svg.info { color: #7dd3fc; }
.toast-message { line-height: 1.4; }

/* --------------------------------------------------------------------------
   15. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .app-container { grid-template-rows: 64px 1fr 56px; }
    .main-header { padding: 0 16px; gap: 12px; }
    .desktop-nav { display: none; }
    .basin-state-container { min-width: 0; padding: 8px 12px; }
    .state-desc { display: none; }
    .main-footer { display: none; }

    .map-grid-layout { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
    .map-section { border-right: none; border-bottom: 1px solid var(--border); }

    #tab-dashboard.active-tab,
    #tab-forecasts.active-tab,
    #tab-alerts.active-tab,
    #tab-settings.active-tab { padding: 20px 16px; }
    .tab-content h1, .tab-content h2, .dashboard-header h2 { font-size: 28px; }
    .weather-current-main { gap: 20px; }
    .weather-temp { font-size: 44px; }

    /* Bottom nav visible en móvil */
    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; z-index: 800;
        background: rgba(10, 10, 10, 0.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .bottom-nav-btn {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
        background: transparent; border: none; color: var(--text-mute); cursor: pointer; position: relative;
        font-family: var(--font-mono); font-size: 8.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
        transition: var(--transicion-rapida); padding: 6px 0;
    }
    .bottom-nav-btn::before {
        content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px;
        background: transparent; transition: var(--transicion-rapida);
    }
    .bottom-nav-btn:hover { color: rgba(255, 255, 255, 0.8); }
    .bottom-nav-btn.active { color: #fff; font-weight: 600; }
    .bottom-nav-btn.active::before { background: #fff; }
    .bottom-icon {
        display: inline-flex; align-items: center; justify-content: center;
        width: 20px; height: 20px; color: currentColor; transition: var(--transicion-rapida);
    }
    .bottom-icon svg { width: 100%; height: 100%; stroke: currentColor; transition: var(--transicion-rapida); }
    .bottom-nav-btn.active .bottom-icon { transform: translateY(-1px); }


