/* ==========================================================================
   MeteoPrecisa — Modern Technical Glassmorphism & High-Contrast Design System
   ========================================================================== */

:root {
    --bg-base: #060913;
    --glass-bg: rgba(11, 17, 32, 0.82);
    --glass-bg-subtle: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(56, 189, 248, 0.4);
    --glass-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
    --blur: blur(24px);

    /* Paleta Técnica OKLCH / RGB Accesible */
    --accent-cyan: #38bdf8;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-orange: #f97316;
    --accent-rose: #f43f5e;
    --accent-purple: #a855f7;
    --accent-indigo: #6366f1;

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-ui);
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* MAPA LEAFLET EN MÓDULO */
.map-module-card {
    padding: 16px;
}

.map-container-inner {
    position: relative;
    width: 100%;
    height: 450px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    margin-top: 16px;
    background: #020617;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.leaflet-layer, .leaflet-control-zoom-in, .leaflet-control-zoom-out, .leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* GLASS PANEL BASE */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* BUSCADOR SUPERIOR */
.search-nav {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 540px;
    border-radius: var(--radius-xl);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-container {
    display: flex;
    align-items: center;
    padding: 6px 14px;
    gap: 8px;
}

.search-icon { font-size: 1.1rem; opacity: 0.7; }

#search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    padding: 10px 6px;
    outline: none;
    font-family: inherit;
}

#search-input::placeholder { color: var(--text-muted); font-weight: 400; }

#btn-gps {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: transform 0.2s, background 0.2s;
}

#btn-gps:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.08); }

.search-results {
    list-style: none;
    border-top: 1px solid var(--glass-border);
    max-height: 280px;
    overflow-y: auto;
}

.search-results li {
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s;
}

.search-results li:hover { background: rgba(56, 189, 248, 0.12); }
.search-results li strong { display: block; font-size: 0.95rem; color: #fff; }
.search-results li span { font-size: 0.8rem; color: var(--text-muted); }

/* DASHBOARD PRINCIPAL */
.weather-panel {
    position: relative;
    margin: 90px auto 70px auto;
    width: 94%;
    max-width: 680px;
    border-radius: var(--radius-xl);
    padding: 24px;
    z-index: 10;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ENCABEZADO */
.weather-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--glass-border);
}

.header-main { text-align: left; }

.location-badge-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-badge-group h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.source-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-action {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 7px 13px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-action:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
}

.btn-sat { background: rgba(99, 102, 241, 0.18); border-color: rgba(99, 102, 241, 0.35); }
.btn-sat:hover { background: rgba(99, 102, 241, 0.35); border-color: #818cf8; }

.btn-trace { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); }
.btn-trace:hover { background: rgba(16, 185, 129, 0.28); border-color: #34d399; }

/* BANNERS DE ALERTA */
.alert-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    text-align: left;
    font-size: 0.85rem;
    line-height: 1.4;
    border-left: 4px solid;
    animation: fadeIn 0.3s ease-out;
}

.alert-icon { font-size: 1.3rem; flex-shrink: 0; }
.alert-text strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }

.alert-senapred {
    background: rgba(244, 63, 94, 0.18);
    border-left-color: var(--accent-rose);
    border-top: 1px solid rgba(244, 63, 94, 0.3);
    border-right: 1px solid rgba(244, 63, 94, 0.3);
    border-bottom: 1px solid rgba(244, 63, 94, 0.3);
}

.alert-agro-spray {
    background: rgba(16, 185, 129, 0.15);
    border-left-color: var(--accent-emerald);
    border-top: 1px solid rgba(16, 185, 129, 0.25);
    border-right: 1px solid rgba(16, 185, 129, 0.25);
    border-bottom: 1px solid rgba(16, 185, 129, 0.25);
}

.alert-purple {
    background: rgba(168, 85, 247, 0.18);
    border-left-color: var(--accent-purple);
    border-top: 1px solid rgba(168, 85, 247, 0.25);
    border-right: 1px solid rgba(168, 85, 247, 0.25);
    border-bottom: 1px solid rgba(168, 85, 247, 0.25);
}

.alert-oms {
    background: rgba(249, 115, 22, 0.18);
    border-left-color: var(--accent-orange);
    border-top: 1px solid rgba(249, 115, 22, 0.25);
    border-right: 1px solid rgba(249, 115, 22, 0.25);
    border-bottom: 1px solid rgba(249, 115, 22, 0.25);
}

/* SECCIONES Y BADGES */
.dashboard-section {
    background: var(--glass-bg-subtle);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 18px;
    text-align: left;
}

.section-badge-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.badge-urbano { background: rgba(56, 189, 248, 0.15); color: var(--accent-cyan); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-agricola { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-gee { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-emergencia { background: rgba(244, 63, 94, 0.15); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-firms { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-model { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-neutral { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); border: 1px solid rgba(255, 255, 255, 0.12); }

.sync-pill {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* HERO TEMP CARD */
.hero-temp-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.temp-primary {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hero-degrees {
    font-family: var(--font-mono);
    font-size: 3.4rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    letter-spacing: -0.04em;
}

.temp-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.condition-tag {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.feels-like-text {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.hero-sun-moon {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* GRILLAS DE MÉTRICAS */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.metric-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, border-color 0.2s;
}

.metric-card:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
}

.metric-icon { font-size: 1.3rem; flex-shrink: 0; }

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.metric-val {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.text-cyan { color: var(--accent-cyan); }
.text-amber { color: var(--accent-amber); }

/* CALIDAD DEL AIRE */
.air-quality-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-top: 12px;
}

.aqi-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.aqi-status-pill {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-aqi { font-size: 1.5rem; }
.sub-label { font-size: 0.72rem; color: var(--text-muted); display: block; }
.aqi-title { font-size: 1.1rem; font-weight: 700; color: #fff; }

.aqi-pm-metrics {
    display: flex;
    gap: 8px;
}

.pm-badge {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pm-badge strong { color: #fff; font-size: 0.9rem; }
.sensor-caption { font-size: 0.72rem; color: var(--text-dim); margin-top: 8px; }

/* TELEDETECCIÓN SATELITAL Y SUELO GEE */
.satellite-agro-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 14px;
}

.card-subtitle {
    font-size: 0.88rem;
    font-weight: 700;
    color: #c7d2fe;
    margin-bottom: 14px;
}

.gauge-block {
    margin-bottom: 14px;
}

.gauge-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.gauge-name { color: var(--text-secondary); }
.gauge-score { font-family: var(--font-mono); color: #fff; font-weight: 700; }

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 20px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.ndvi-gradient {
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 35%, #10b981 70%, #059669 100%);
}

.smap-fill {
    background: linear-gradient(90deg, #38bdf8 0%, #0284c7 100%);
}

.gauge-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.diag-label { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }

.smap-bars-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.smap-sub-bar {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.smap-label {
    font-size: 0.74rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.smap-track { height: 7px; }

.topo-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.topo-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.topo-badge strong { color: #fff; }

/* ENTORNO Y EMERGENCIAS */
.env-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.env-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.env-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.env-icon { font-size: 1.4rem; }
.env-title { font-size: 0.85rem; font-weight: 700; color: #fff; }
.env-caption { font-size: 0.7rem; color: var(--text-muted); }

.env-metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sub-cota { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }

.status-pill {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.pill-ok { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.pill-danger { background: rgba(244, 63, 94, 0.18); color: #fda4af; }

/* PRONÓSTICO Y GRÁFICOS */
.model-summary-container {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.min-max {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expand-icon { font-size: 0.78rem; color: var(--accent-cyan); font-weight: 600; }

.hourly-chart-container {
    height: 180px;
    width: 100%;
    margin-bottom: 18px;
}

.forecast-section {
    margin-top: 14px;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.forecast-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.forecast-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.forecast-day { font-weight: 600; width: 110px; }
.forecast-icon-temp { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); }

/* MODALES */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-xl);
    padding: 24px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-modal:hover { background: rgba(255, 255, 255, 0.25); }

/* MODAL SATÉLITE */
.modal-sat-content { max-width: 760px; }
.modal-sat-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.modal-sat-header h2 { font-size: 1.25rem; font-weight: 700; color: #fff; }
.sat-badge { background: rgba(99, 102, 241, 0.2); color: #a5b4fc; font-size: 0.72rem; padding: 3px 8px; border-radius: 12px; }
.sat-desc { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 14px; }

.satellite-player-container {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--glass-border);
    margin-bottom: 14px;
}

.sat-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.sat-controls-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* TABLA DE TRAZABILIDAD METROLÓGICA */
.modal-trace-content { max-width: 820px; }
.trace-intro { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 14px; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}

.trace-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.trace-table th {
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 12px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid var(--glass-border);
}

.trace-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.trace-table tr:hover { background: rgba(56, 189, 248, 0.06); }
.trace-val { font-family: var(--font-mono); font-weight: 700; color: #fff; }
.trace-tag { background: rgba(255, 255, 255, 0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.72rem; }

/* ACERCA DE */
.acerca-body {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-buttons-row {
    text-align: center;
    margin-top: 10px;
}

.btn-action-small {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action-small:hover { color: #fff; border-color: #fff; }

/* FOOTER FLOTANTE */
.system-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(6, 9, 19, 0.85);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    z-index: 999;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-emerald);
}

.live-pulse {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.net-pill {
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.net-pill.online { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.net-pill.offline { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* SPINNER */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 9, 19, 0.85);
    backdrop-filter: blur(16px);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(56, 189, 248, 0.15);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* TOOLTIPS */
.tooltip {
    cursor: help;
    color: var(--accent-cyan);
    font-weight: bold;
    font-size: 0.75rem;
}

/* MAPA INTERACTIVO MULTIRED Y POPUPS */
.map-legend-box {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    max-width: 220px;
}

.map-legend-title {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.8rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-dmc { background: #3b82f6; box-shadow: 0 0 8px #3b82f688; }
.dot-agromet { background: #10b981; box-shadow: 0 0 8px #10b98188; }
.dot-redmeteo { background: #a855f7; box-shadow: 0 0 8px #a855f788; }
.dot-sinca { background: #ef4444; box-shadow: 0 0 8px #ef444488; }
.dot-user { background: #38bdf8; border: 2px solid #ffffff; box-shadow: 0 0 10px #38bdf8; }

/* Custom Leaflet Popups */
.leaflet-popup-content-wrapper {
    background: rgba(11, 17, 32, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(20px) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8) !important;
    color: #f8fafc !important;
    padding: 4px !important;
}

.leaflet-popup-tip {
    background: rgba(11, 17, 32, 0.95) !important;
}

.station-popup-content {
    font-family: var(--font-ui);
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
}

.popup-station-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.popup-station-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #f8fafc;
    line-height: 1.2;
}

.popup-station-badge {
    display: inline-block;
    align-self: flex-start;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 4px;
}

.popup-badge-dmc { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.popup-badge-agromet { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.popup-badge-redmeteo { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }
.popup-badge-sinca { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

.popup-metrics-row {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.popup-dist-tag {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 600;
}

.btn-select-station {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-select-station:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: scale(1.02);
}

/* User Location Beacon Animation */
@keyframes userPulse {
    0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
    70% { box-shadow: 0 0 0 14px rgba(56, 189, 248, 0); }
    100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.user-pulse-marker {
    border-radius: 50%;
    animation: userPulse 2s infinite;
}

/* Floating Switcher between Map and Dashboard */
.floating-panel-toggle {
    position: fixed;
    top: 85px;
    right: 20px;
    z-index: 1500;
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 10px 18px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(16px);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.floating-panel-toggle:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7);
}

.btn-map-toggle {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-cyan);
}

.btn-map-toggle:hover {
    background: rgba(56, 189, 248, 0.25);
}

/* RESPONSIVE */
@media (max-width: 640px) {
    .weather-panel {
        width: 96%;
        margin-top: 80px;
        padding: 16px;
    }
    
    .hero-degrees { font-size: 2.8rem; }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .btn-action { font-size: 0.75rem; padding: 6px 10px; }

    .map-legend-box {
        bottom: 12px;
        left: 12px;
        padding: 8px 12px;
        font-size: 0.72rem;
        max-width: 170px;
    }
}

/* Modal de Estación */
.station-modal {
    border: none;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 500px;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    margin: auto;
}

.station-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-subheader {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal-sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.sensor-card {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border-color);
}

.sensor-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.sensor-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sensor-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    text-align: center;
    color: var(--text-secondary);
}

/* Iconos DGA - Mitad Blanco, Mitad Tipo */
.dga-marker-icon {
    border-radius: 50%;
    border: 2px solid #333;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.dga-fluviometrica { background: linear-gradient(135deg, #ffffff 50%, #2196F3 50%); }
.dga-nivometrica { background: linear-gradient(135deg, #ffffff 50%, #00BCD4 50%); }
.dga-piezometrica { background: linear-gradient(135deg, #ffffff 50%, #8D6E63 50%); }
.dga-lago { background: linear-gradient(135deg, #ffffff 50%, #1565C0 50%); }
.dga-meteorologica { background: linear-gradient(135deg, #ffffff 50%, #4CAF50 50%); }
.dga-default { background: linear-gradient(135deg, #ffffff 50%, #9E9E9E 50%); }
