/* ================================================================
   GEOGUATAPÉ - ESTILOS COMPLETOS
   ================================================================ */

/* ===================== MODO OSCURO (por defecto) ===================== */
:root {
    --bg-deep: #080c14;
    --bg-primary: #0b1728;
    --bg-secondary: #102238;
    --bg-tertiary: #20364c;
    --bg-card: #15283d;
    --bg-card-hover: rgba(67,210,239,0.09);
    --bg-input: rgba(29,53,75,0.7);
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #acc0d1;
    --text-faint: #819cb2;
    --text-dim: #68869f;
    --accent: #43d2ef;
    --accent-hover: #20b7db;
    --accent-bg: rgba(67,210,239,0.13);
    --accent-border: rgba(67,210,239,0.38);
    --accent-glow: rgba(67,210,239,0.13);
    --border: #365269;
    --border-light: rgba(102,151,183,0.22);
    --border-accent: rgba(67,210,239,0.24);
    --shadow-sm: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-md: 0 12px 32px rgba(0,0,0,0.5);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.7);
    --danger: #ef4444;
    --danger-bg: rgba(239,68,68,0.15);
    --success: #22c55e;
    --warning: #eab308;
    --popup-bg: #1a2332;
    --popup-text: #e2e8f0;
    --map-bg: #1e293b;
    --shimmer-1: #43d2ef;
    --shimmer-2: #5eead4;
    --shimmer-3: #a78bfa;
    --coord-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7), 1px 1px 2px rgba(0,0,0,0.8);
    --coord-color: #ffffff;
    --scale-color: rgba(255,255,255,0.5);
    --overlay-bg: rgba(15,23,42,0.92);
    --overlay-border: #334155;
    --overlay-text: #38bdf8;
    --badge-urbano-bg: rgba(56,189,248,0.15);
    --badge-urbano-text: #38bdf8;
    --badge-rural-bg: rgba(34,197,94,0.15);
    --badge-rural-text: #86efac;
    --badge-expansion-bg: rgba(234,179,8,0.15);
    --badge-expansion-text: #fde047;
    --btn-text: #ffffff;
    --btn-shadow-color: rgba(0,0,0,0.3);
}

/* ===================== MODO CLARO — PREMIUM GIS ===================== */
body.light-mode {
    --bg-deep: #EAF3F7;
    --bg-primary: #F9FCFF;
    --bg-secondary: #EFF7FA;
    --bg-tertiary: #DCEBF1;
    --bg-card: #FFFFFF;
    --bg-card-hover: rgba(14,116,144,0.07);
    --bg-input: rgba(225,239,247,0.88);
    --text-primary: #123047;
    --text-secondary: #29465b;
    --text-muted: #48677c;
    --text-faint: #607d90;
    --text-dim: #7894a5;
    --accent: #087eaa;
    --accent-hover: #066b91;
    --accent-bg: #DDF3F8;
    --accent-border: rgba(8,126,170,0.28);
    --accent-glow: rgba(8,126,170,0.1);
    --border: #BCD5E1;
    --border-light: rgba(133,177,198,0.34);
    --border-accent: rgba(8,126,170,0.18);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-md: 0 2px 10px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --danger: #EF4444;
    --danger-bg: rgba(239,68,68,0.06);
    --success: #22C55E;
    --warning: #F59E0B;
    --popup-bg: #FFFFFF;
    --popup-text: #1F2937;
    --map-bg: #E8ECF0;
    --shimmer-1: #087eaa;
    --shimmer-2: #0fb8ad;
    --shimmer-3: #7c5ce5;
    --coord-shadow: -1px -1px 0 rgba(255,255,255,0.95), 1px -1px 0 rgba(255,255,255,0.95),
                    -1px 1px 0 rgba(255,255,255,0.95), 1px 1px 0 rgba(255,255,255,0.95),
                    0 0 8px rgba(255,255,255,0.85);
    --coord-color: #1F2937;
    --scale-color: rgba(31,41,55,0.45);
    --overlay-bg: rgba(255,255,255,0.92);
    --overlay-border: #DCE3EA;
    --overlay-text: #2563EB;
    --badge-urbano-bg: rgba(37,99,235,0.08);
    --badge-urbano-text: #2563EB;
    --badge-rural-bg: rgba(34,197,94,0.08);
    --badge-rural-text: #16A34A;
    --badge-expansion-bg: rgba(245,158,11,0.08);
    --badge-expansion-text: #D97706;
    --btn-text: #FFFFFF;
    --btn-shadow-color: rgba(37,99,235,0.2);
}

/* ===================== OVERRIDES ESPECÍFICOS MODO CLARO ===================== */
body.light-mode .sidebar {
    background: radial-gradient(circle at 8% 6%, rgba(99,216,216,0.2), transparent 35%), linear-gradient(170deg, #f2f9fc, #e5f0f6 52%, #f0f7fb);
    border-right: 1px solid var(--border-accent);
    box-shadow: 5px 0 24px rgba(21,78,103,0.1);
}
body.light-mode .sidebar-header {
    background: linear-gradient(115deg, #dceff6, #f7fbff 68%, #e9e5fc);
    border-bottom: 1px solid var(--border-accent);
}
body.light-mode .sidebar::before { opacity: 0.7; }
body.light-mode .section-divider {
    background: linear-gradient(90deg, transparent, rgba(8,126,170,0.3), transparent);
}
body.light-mode .layer-item:has(input:checked) { background: rgba(8,126,170,0.07); }
body.light-mode #btn-zoom {
    background: linear-gradient(135deg, #1D4ED8, #3B82F6);
    box-shadow: 0 2px 8px rgba(37,99,235,0.25), 0 1px 2px rgba(0,0,0,0.06);
}
body.light-mode #btn-zoom:hover {
    background: linear-gradient(135deg, #1E40AF, #2563EB);
    box-shadow: 0 4px 16px rgba(37,99,235,0.3), 0 2px 4px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
body.light-mode #btn-zona {
    background: linear-gradient(135deg, #6D28D9, #8B5CF6);
    box-shadow: 0 2px 8px rgba(109,40,217,0.2), 0 1px 2px rgba(0,0,0,0.06);
}
body.light-mode #btn-zona:hover {
    background: linear-gradient(135deg, #5B21B6, #7C3AED);
    box-shadow: 0 4px 16px rgba(109,40,217,0.25), 0 2px 4px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
body.light-mode #btn-earth {
    background: linear-gradient(135deg, #0891B2, #06B6D4);
    box-shadow: 0 2px 8px rgba(6,182,212,0.25), 0 1px 2px rgba(0,0,0,0.06);
}
body.light-mode #btn-earth:hover {
    background: linear-gradient(135deg, #0E7490, #0891B2);
    box-shadow: 0 4px 16px rgba(6,182,212,0.3), 0 2px 4px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
body.light-mode #geo-dashboard {
    background: #FFFFFF;
    border-left: 1px solid var(--border);
    box-shadow: -2px 0 20px rgba(0,0,0,0.06);
}
body.light-mode .dash-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
}
body.light-mode .dash-input-group button {
    background: linear-gradient(135deg, #1D4ED8, #3B82F6);
    box-shadow: 0 1px 4px rgba(37,99,235,0.2);
}
body.light-mode #attribute-panel {
    background: #FFFFFF;
    box-shadow: -4px 0 24px rgba(0,0,0,0.06);
}
body.light-mode .panel-header {
    border-bottom: 1px solid var(--border);
}
body.light-mode #table-container th {
    background: #F8FAFC;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
}
body.light-mode #table-container tr {
    background: #FFFFFF;
    transition: background 0.15s ease;
}
body.light-mode #table-container tr:nth-child(even) {
    background: #FAFBFC;
}
body.light-mode #table-container tr:hover {
    background: #E0EDFF;
}
body.light-mode #table-container td {
    border-bottom-color: #F0F2F5;
    color: var(--text-secondary);
}
body.light-mode .dark-popup .leaflet-popup-content-wrapper {
    background: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.08);
    padding: 0;
}
body.light-mode .dark-popup .leaflet-popup-tip {
    background: #FFFFFF;
    border: 1px solid var(--border);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
body.light-mode .dark-popup .leaflet-popup-content {
    margin: 14px 16px;
}
body.light-mode .popup-table-dark td:first-child {
    background: rgba(37,99,235,0.04);
    color: var(--text-muted);
    font-weight: 600;
}
body.light-mode .popup-table-dark td {
    border-bottom-color: #F0F2F5;
    color: var(--text-secondary);
}
body.light-mode .legend-panel {
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
body.light-mode .legend-header {
    border-bottom: 1px solid var(--border);
}
body.light-mode .toast {
    background: #FFFFFF;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.1);
}
body.light-mode .toast-info {
    border-color: rgba(37,99,235,0.15);
    color: var(--text-secondary);
}
body.light-mode .toast-success {
    border-color: rgba(34,197,94,0.15);
    color: #16A34A;
    background: rgba(34,197,94,0.04);
}
body.light-mode .toast-warning {
    border-color: rgba(245,158,11,0.15);
    color: #D97706;
    background: rgba(245,158,11,0.04);
}
body.light-mode .toast-error {
    border-color: rgba(239,68,68,0.15);
    color: #DC2626;
    background: rgba(239,68,68,0.04);
}
body.light-mode .leaflet-control-zoom a {
    background: rgba(255,255,255,0.95) !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04) !important;
    font-weight: 500 !important;
}
body.light-mode .leaflet-control-zoom a:hover {
    background: #2563EB !important;
    color: #FFFFFF !important;
    border-color: #2563EB !important;
    box-shadow: 0 2px 8px rgba(37,99,235,0.25) !important;
}
body.light-mode .leaflet-control-zoom {
    box-shadow: 0 1px 6px rgba(0,0,0,0.04) !important;
    border-radius: 10px !important;
    overflow: hidden;
}
body.light-mode .leaflet-control-separator { background: var(--border-light); }
body.light-mode .leaflet-control-clear {
    background: rgba(255,255,255,0.95) !important;
    color: #DC2626 !important;
    border-color: var(--border) !important;
    border-top: 1px solid var(--border-light) !important;
}
body.light-mode .leaflet-control-clear:hover {
    background: #DC2626 !important;
    color: #FFFFFF !important;
    border-color: #DC2626 !important;
}
body.light-mode #search-input {
    background: rgba(255,255,255,0.95);
    border-color: var(--border);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    border-radius: 10px;
    color: var(--text-primary);
}
body.light-mode #search-input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1), 0 2px 8px rgba(0,0,0,0.06);
    background: #FFFFFF;
}
body.light-mode #search-results {
    background: rgba(255,255,255,0.98);
    border-color: var(--border);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
body.light-mode #measure-panel {
    background: rgba(255,255,255,0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
body.light-mode #minimap-container {
    border-color: var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
body.light-mode #btn-toggle {
    background: rgba(255,255,255,0.95);
    border-color: var(--border);
    color: var(--text-muted);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
body.light-mode #btn-toggle:hover {
    background: #2563EB;
    color: #FFFFFF;
    border-color: #2563EB;
    box-shadow: 0 2px 10px rgba(37,99,235,0.25);
}
body.light-mode #btn-open-dashboard {
    background: rgba(255,255,255,0.95);
    border-color: var(--border);
    color: var(--text-muted);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    border-radius: 10px;
}
body.light-mode #btn-open-dashboard:hover {
    background: #2563EB;
    color: #FFFFFF;
    border-color: #2563EB;
    box-shadow: 0 2px 10px rgba(37,99,235,0.25);
}
body.light-mode #coord-toggle {
    background: rgba(255,255,255,0.92);
    border-color: var(--border);
    color: var(--text-dim);
    border-radius: 6px;
}
body.light-mode #coord-toggle:hover {
    color: #2563EB;
    border-color: #2563EB;
}
body.light-mode .theme-slider {
    background: var(--bg-tertiary);
    border-color: var(--border);
}
body.light-mode .dash-summary-card {
    background: var(--bg-secondary);
    border-color: var(--border-light);
}
body.light-mode .pot-section-header {
    background: var(--bg-secondary);
}
body.light-mode .pot-section.open .pot-section-header {
    background: var(--accent-bg);
}
body.light-mode .dropdown-menu {
    background: rgba(255,255,255,0.98);
    border-color: var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
body.light-mode .btn-cerrar {
    background: rgba(239,68,68,0.06);
    border-color: rgba(239,68,68,0.12);
    border-radius: 8px;
}
body.light-mode #basemaps button {
    background: var(--bg-secondary);
    border-color: var(--border-light);
    border-radius: 8px;
    color: var(--text-faint);
}
body.light-mode #basemaps button:hover {
    background: var(--accent-bg);
    color: var(--text-secondary);
    border-color: rgba(37,99,235,0.15);
}
body.light-mode #basemaps button.activo {
    background: var(--accent-bg);
    color: #2563EB;
    border-color: rgba(37,99,235,0.2);
    font-weight: 700;
}
body.light-mode .tool-btn {
    background: linear-gradient(145deg, #ffffff, #eaf5fa);
    border-color: var(--border-accent);
    border-radius: 10px;
    box-shadow: 0 3px 9px rgba(21,78,103,0.05);
}
body.light-mode .tool-btn:hover {
    background: linear-gradient(145deg, #e3f9fb, #eaf0ff);
    border-color: var(--accent-border);
}
body.light-mode .tool-btn.active {
    background: linear-gradient(145deg, #c9eff5, #e6eeff);
    color: var(--accent);
    border-color: var(--accent-border);
}
body.light-mode .sidebar-body::-webkit-scrollbar-thumb { background: #D1D5DB; }
body.light-mode #table-container::-webkit-scrollbar-thumb { background: #D1D5DB; }
body.light-mode .legend-body::-webkit-scrollbar-thumb { background: #D1D5DB; }
body.light-mode #dash-detail::-webkit-scrollbar-thumb,
body.light-mode #dash-results::-webkit-scrollbar-thumb { background: #D1D5DB; }
body.light-mode .legend-overlay {
    background: rgba(15,23,42,0.2);
    backdrop-filter: blur(4px);
}

/* ===================== RESET ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg-deep); color: var(--text-secondary); transition: background 0.35s, color 0.35s; }
.container { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ===================== MAPA ===================== */
#map { flex: 1; height: 100vh; background: var(--map-bg); position: relative; z-index: 1; overflow: hidden; transition: background 0.35s; }
.leaflet-control-layers, .leaflet-control-attribution { display: none !important; }

/* ===================== PANTALLA DE CARGA ===================== */
#loading-screen { position: fixed; inset: 0; background: var(--bg-deep); z-index: 999999; display: flex; align-items: center; justify-content: center; transition: opacity 0.8s, visibility 0.8s; }
#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-content { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader-escudo { width: 56px; height: 56px; object-fit: contain; animation: pulse-icon 2s ease-in-out infinite; }
.loader-content h1 { font-size: 32px; font-weight: 800; color: var(--text-primary); letter-spacing: -1px; }
.loader-name { color: var(--accent) !important; }
#loading-text { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 3px; font-weight: 600; }
#loading-text.error { color: var(--danger); }
.loader-spinner { width: 32px; height: 32px; border: 3px solid var(--accent-bg); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin-top: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-icon { 0%,100%{transform:scale(1);opacity:.8} 50%{transform:scale(1.08);opacity:1} }

/* ===================== CONTROLES DEL MAPA ===================== */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-sm) !important; }
.leaflet-control-zoom a { background: var(--overlay-bg) !important; color: var(--overlay-text) !important; border: 1px solid var(--overlay-border) !important; width: 34px !important; height: 34px !important; line-height: 34px !important; font-size: 18px !important; font-weight: 700 !important; transition: all 0.2s !important; display: flex !important; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
.leaflet-control-zoom a:hover { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.leaflet-control-zoom-in { border-radius: 8px 8px 0 0 !important; }
.leaflet-control-zoom-out { border-radius: 0 !important; border-top: none !important; }
.leaflet-control-separator { height: 1px; margin: 0 7px; background: var(--border-light); opacity: 0.5; }
.leaflet-control-clear {
    background: var(--overlay-bg) !important;
    color: var(--danger) !important;
    border: 1px solid var(--overlay-border) !important;
    border-top: 1px solid var(--border-light) !important;
    width: 34px !important;
    height: 34px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 8px 8px !important;
    cursor: pointer;
    transition: all 0.2s !important;
    backdrop-filter: blur(8px);
    font-size: 14px !important;
}
.leaflet-control-clear:hover {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: var(--danger) !important;
}

/* ===================== BUSCADOR ===================== */
#search-container { position: absolute; top: 16px; left: 60px; z-index: 1000; width: 300px; display: flex; flex-direction: column; }
#search-input { background: var(--overlay-bg); backdrop-filter: blur(8px); color: var(--text-secondary); border: 1px solid var(--overlay-border); border-radius: 8px 8px 0 0; padding: 10px 14px 10px 36px; font-size: 13px; outline: none; transition: all 0.2s; width: 100%; box-shadow: var(--shadow-sm); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolygon points='16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 12px center; }
#search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg), var(--shadow-md); }
#search-input::placeholder { color: var(--text-faint); }
#search-results { list-style: none; margin: 0; padding: 0; position: absolute; top: 100%; left: 0; right: 0; background: var(--overlay-bg); backdrop-filter: blur(12px); border: 1px solid var(--overlay-border); border-radius: 0 0 8px 8px; box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; display: none; z-index: 9999; }
#search-results.activo { display: block; }
#search-results li { padding: 10px 14px; color: var(--text-muted); font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border-light); transition: background 0.15s; }
#search-results li:last-child { border-bottom: none; }
#search-results li:hover { background: var(--accent-bg); color: var(--accent); }
#search-results li small { display: block; color: var(--text-faint); font-size: 10px; margin-top: 2px; }
#search-results .poi-category { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; background: var(--accent-bg); color: var(--accent); margin-right: 6px; vertical-align: middle; }
.search-cargando { padding: 12px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ===================== COORDENADAS / ESCALA ===================== */
.leaflet-control-scale-line { background: transparent !important; border: none !important; color: var(--coord-color) !important; font-family: 'Courier New', monospace !important; font-size: 11px !important; font-weight: 600 !important; padding: 0 !important; margin-bottom: 2px !important; box-shadow: none !important; text-shadow: var(--coord-shadow) !important; border-bottom-color: var(--scale-color) !important; border-top-color: var(--scale-color) !important; }
.leaflet-control-scale { border: none !important; box-shadow: none !important; background: transparent !important; }
#coord-display { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; pointer-events: none; font-family: 'Courier New', monospace; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; color: var(--coord-color); text-shadow: var(--coord-shadow); transition: color 0.3s, text-shadow 0.3s; }
#coord-toggle { position: absolute; bottom: 10px; left: calc(50% + 140px); z-index: 1000; background: var(--overlay-bg); color: var(--text-faint); border: 1px solid var(--overlay-border); border-radius: 4px; padding: 2px 8px; font-size: 10px; font-family: 'Courier New', monospace; font-weight: 700; cursor: pointer; transition: all 0.2s; backdrop-filter: blur(8px); }
#coord-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ===================== MEDICIÓN ===================== */
#measure-panel { position: absolute; top: 16px; right: 16px; z-index: 1000; background: var(--overlay-bg); backdrop-filter: blur(12px); border: 1px solid var(--overlay-border); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 12px; transition: all 0.3s cubic-bezier(0.22,1,0.36,1); min-width: 180px; }
#measure-panel.hidden { opacity: 0; transform: translateY(-10px) scale(0.95); pointer-events: none; visibility: hidden; }
.measure-icon { color: var(--accent); flex-shrink: 0; }
.measure-value { font-size: 16px; font-weight: 800; color: var(--accent); font-family: 'Courier New', monospace; line-height: 1.2; }
.measure-label { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-top: 2px; }

/* ===================== MINIMAP ===================== */
#minimap-container { position: absolute; bottom: 12px; right: 12px; width: 150px; height: 150px; border: 2px solid var(--overlay-border); border-radius: 8px; overflow: hidden; z-index: 1000; box-shadow: var(--shadow-sm); transition: all 0.2s; cursor: pointer; }
#minimap-container:hover { border-color: var(--accent); transform: scale(1.05); }
#minimap { width: 100%; height: 100%; background: var(--map-bg); }
#minimap .leaflet-control-zoom, #minimap .leaflet-control-attribution { display: none !important; }

/* ===================== SWITCH TEMA ===================== */
.theme-switch { position: relative; display: inline-block; width: 42px; height: 22px; flex-shrink: 0; cursor: pointer; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.theme-slider { position: absolute; inset: 0; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 22px; transition: all 0.3s; display: flex; align-items: center; justify-content: flex-end; padding: 0 5px; }
.theme-slider::before { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); left: 2px; top: 2px; transition: transform 0.3s; box-shadow: 0 0 6px var(--accent-glow); }
.theme-switch input:checked + .theme-slider::before { transform: translateX(20px); }
.theme-switch input:checked + .theme-slider { justify-content: flex-start; }
.icon-moon { color: var(--text-faint); }
.icon-sun { color: var(--warning); display: none; }
.theme-switch input:checked ~ .theme-slider .icon-moon { display: none; }
.theme-switch input:checked ~ .theme-slider .icon-sun { display: block; }

/* ===================== SIDEBAR ===================== */
#btn-toggle { position: absolute; top: 20px; left: 190px; z-index: 1000; background: var(--bg-tertiary); color: var(--accent); border: 1px solid var(--border); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all 0.3s; box-shadow: var(--shadow-sm); }
#btn-toggle:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
#btn-toggle.movido { top: 125px; left: 15px; }

.sidebar { width: 300px; flex-shrink: 0; height: 100vh; background: radial-gradient(circle at 6% 10%, rgba(27,147,171,0.2), transparent 34%), radial-gradient(circle at 90% 66%, rgba(100,83,177,0.12), transparent 38%), linear-gradient(180deg, var(--bg-primary), var(--bg-secondary) 52%, var(--bg-primary)); color: var(--text-secondary); position: relative; z-index: 10; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); border-right: 1px solid var(--border-accent); transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1), background 0.35s; }
.sidebar.oculta { margin-left: -300px; }
.sidebar::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, var(--shimmer-1), var(--shimmer-2), var(--shimmer-3), var(--shimmer-1)); background-size: 200% 100%; animation: shimmer-bar 4s ease infinite; z-index: 20; }
@keyframes shimmer-bar { 0%{background-position:0% 0%} 100%{background-position:200% 0%} }

.sidebar-header { padding: 18px 20px; border-bottom: 1px solid var(--border-accent); background: linear-gradient(110deg, rgba(17,76,100,0.38), rgba(63,53,108,0.22)); display: flex; justify-content: space-between; align-items: center; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-escudo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.sidebar-header h1 { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; line-height: 1.1; }
.sidebar-header h2 { font-size: 11px; color: var(--text-faint); margin-top: 2px; font-weight: 500; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 16px 0 22px; }
.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.section-block { padding: 0; }
.section-title { display: flex; align-items: center; gap: 8px; padding: 14px 20px 8px; font-size: 9.5px; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); font-weight: 700; user-select: none; }
.section-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border); flex-shrink: 0; transition: all 0.3s; }
.section-divider { height: 1px; margin: 6px 20px; background: linear-gradient(90deg, transparent, var(--border-accent), transparent); }

/* --- BASEMAPS --- */
#basemaps { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px 20px 14px; }
#basemaps button { background: var(--bg-input); color: var(--text-faint); border: 1px solid var(--border-light); padding: 7px 0; border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 600; transition: all 0.25s; text-align: center; flex: 1 0 45%; position: relative; overflow: hidden; }
#basemaps button::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 0; height: 2px; background: var(--accent); border-radius: 2px; transition: width 0.25s; }
#basemaps button:hover { background: var(--accent-bg); color: var(--text-muted); border-color: var(--border); }
#basemaps button.activo { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-border); box-shadow: 0 0 12px var(--accent-glow); }
#basemaps button.activo::after { width: 60%; }
.basemap-selector { display:block; width:calc(100% - 40px); margin:0 20px 10px; padding:9px 10px; border:1px solid var(--border-light); border-radius:7px; background:var(--bg-input); color:var(--text-muted); font-size:12px; }
.swipe-controls { padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border-light); border-radius: 8px; margin: 8px 12px; background: var(--bg-card); }
.swipe-controls.hidden, .swipe-divider.hidden { display:none !important; }
.swipe-controls { grid-column:1 / -1; }
.swipe-controls label { color: var(--text-faint); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.swipe-controls select { min-width: 0; background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border-light); border-radius: 6px; padding: 7px; font-size: 11px; }
.tool-btn.active { border-color: var(--accent-border); background: var(--accent-bg); color: var(--accent); }
#swipe-position { width: 100%; accent-color: var(--accent); }
.basemap-selector:focus, .swipe-controls select:focus { outline:2px solid var(--accent); outline-offset:1px; }
.swipe-controls small { color: var(--text-faint); font-size: 10px; line-height: 1.4; }
.swipe-divider { position: absolute; z-index: 760; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #f8fafc; box-shadow: 0 0 5px rgba(0,0,0,.8); pointer-events: none; }
.swipe-divider span { position: absolute; left: 50%; top: 50%; width: 28px; height: 42px; transform: translate(-50%,-50%); border-radius: 9px; border: 2px solid #fff; background: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.45); pointer-events: auto; cursor: ew-resize; }
.swipe-divider span::before { content: '‹ ›'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800; white-space: nowrap; }
.coverage-layer-item { display: block; padding: 0 12px; }
.coverage-row-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; }
.coverage-layer-item .eye-toggle { flex: 1; min-width: 0; }
.coverage-layer-item .opacity-control { width: 100%; box-sizing: border-box; padding-left: 8px; padding-right: 8px; }
.coverage-legend { border: 1px solid var(--border-light); border-radius: 5px; background: var(--bg-input); color: var(--text-faint); padding: 4px 6px; font-size: 9px; cursor: pointer; }
.coverage-mini-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 8px; margin-top: 10px; padding: 9px; border: 1px solid var(--border-light); border-radius: 7px; font-size: 10px; }
.coverage-mini-legend strong { grid-column: 1 / -1; color: var(--accent); font-size: 10px; }
.coverage-mini-legend span { display: flex; align-items: center; gap: 5px; color: var(--text-muted); line-height: 1.25; }
.coverage-mini-legend i { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 2px; }

/* --- ACORDEÓN --- */
.layer-group { margin-bottom: 6px; }
.group-header-left { display: flex; align-items: center; gap: 8px; }
.group-header-left svg { opacity: 0.5; transition: opacity 0.2s; }
.layer-group-header:hover .group-header-left svg { opacity: 0.8; }
body.light-mode .thematic-zonas { --group-accent: #694ac9; --group-soft: #e9e2fc; --group-border: rgba(105,74,201,0.34); }
body.light-mode .thematic-drenaje { --group-accent: #087ca8; --group-soft: #d8f0f9; --group-border: rgba(8,124,168,0.34); }
body.light-mode .thematic-unidades { --group-accent: #178267; --group-soft: #daf3e9; --group-border: rgba(23,130,103,0.34); }
body.light-mode .thematic-vias { --group-accent: #a45b0d; --group-soft: #faead2; --group-border: rgba(164,91,13,0.36); }
body.light-mode .thematic-group.open .layer-group-inner { background: #ffffff; border-color: var(--group-border); box-shadow: 0 7px 17px rgba(32,77,103,0.08); }
body.light-mode .thematic-group .layer-name { color: #48677c; }
body:not(.light-mode) .thematic-zonas { --group-accent: #b49aff; --group-tint: rgba(123,91,202,0.3); --group-border: rgba(180,154,255,0.4); }
body:not(.light-mode) .thematic-drenaje { --group-accent: #54d7ef; --group-tint: rgba(35,151,183,0.3); --group-border: rgba(84,215,239,0.4); }
body:not(.light-mode) .thematic-unidades { --group-accent: #65dfb6; --group-tint: rgba(35,148,117,0.28); --group-border: rgba(101,223,182,0.4); }
body:not(.light-mode) .thematic-vias { --group-accent: #f3bf76; --group-tint: rgba(178,113,38,0.27); --group-border: rgba(243,191,118,0.4); }
body:not(.light-mode) .thematic-group.open .layer-group-inner { background: rgba(10,24,40,0.82); border-color: var(--group-border); box-shadow: 0 8px 20px rgba(0,0,0,0.22); }
.layer-group-content { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease-out; }
.layer-group.open .layer-group-content { grid-template-rows: 1fr; }
.layer-group-inner { overflow: hidden; border: 1px solid transparent; border-top: none; border-radius: 0 0 8px 8px; transition: border-color 0.2s; }
.layer-group.open .layer-group-inner { border-color: var(--border-light); }

/* --- LAYER ITEMS --- */
.layer-item { display: flex; justify-content: space-between; align-items: center; padding: 0 12px; position: relative; border-bottom: 1px solid var(--border-light); transition: background 0.2s; }
.layer-group.open .layer-group-inner { margin: 0 12px; }
#local-basemaps .layer-item, #coverage-layers .layer-item { display: block; padding: 7px 12px 10px; }
#local-basemaps .eye-toggle, #coverage-layers .eye-toggle { min-width: 0; padding: 7px 6px; }
#local-basemaps .opacity-control, #coverage-layers .opacity-control { width: 100%; box-sizing: border-box; min-width: 0; padding: 9px 6px 3px; margin: 2px 0 0; gap: 10px; }
.layer-item:last-child { border-bottom: none; }
.layer-item:hover { background: var(--bg-card-hover); }
.eye-toggle { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 9px 8px; border-radius: 6px; transition: background 0.2s; user-select: none; }
.eye-toggle:hover { background: var(--accent-bg); }
.eye-toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.eye-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.25s; }
.eye-icon svg { width: 18px; height: 18px; }
.eye-open { display: none; color: var(--accent); }
.eye-closed { display: block; color: var(--text-dim); }
.eye-toggle input:checked ~ .eye-icon .eye-open { display: block; }
.eye-toggle input:checked ~ .eye-icon .eye-closed { display: none; }
.eye-toggle input:checked ~ .eye-icon { filter: drop-shadow(0 0 4px var(--accent-glow)); transform: scale(1.05); }
.layer-name { font-size: 12.5px; color: var(--text-faint); font-weight: 500; transition: all 0.25s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eye-toggle input:checked ~ .layer-name { color: var(--text-secondary); font-weight: 600; }
.layer-item::before { content: ''; position: absolute; left: 0; top: 15%; bottom: 15%; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); opacity: 0; transform: scaleY(0); transition: all 0.3s cubic-bezier(0.4,0,0.2,1); }
.layer-item:has(input:checked)::before { opacity: 1; transform: scaleY(1); }

.menu-container { min-width: 32px; flex-shrink: 0; position: relative; }
.btn-dots { background: transparent; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: all 0.2s; line-height: 1; width: 100%; text-align: center; }
.btn-dots:hover { color: var(--accent); background: var(--accent-bg); }

/* --- DROPDOWN MENU --- */
.dropdown-menu { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; position: fixed; background: var(--bg-card); border: 1px solid var(--border-accent); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 190px; z-index: 99999; padding: 5px; opacity: 0; visibility: hidden; transform: translateX(-6px) scale(0.96); transition: all 0.2s cubic-bezier(0.22,1,0.36,1); backdrop-filter: blur(12px); }
.dropdown-menu.show-menu { opacity: 1; visibility: visible; transform: translateX(0) scale(1); }
.dropdown-menu a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; color: var(--text-muted); text-decoration: none; font-size: 12px; transition: all 0.15s; white-space: nowrap; border-radius: 6px; font-weight: 500; }
.dropdown-menu a:hover { background: var(--accent-bg); color: var(--accent); }
.opacity-control { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border-light); margin-top: 2px; }
.opacity-control span:first-child { font-size: 10px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.opacity-control input[type="range"] { flex: 1 1 auto; min-width: 0; height: 6px; margin: 0 8px; -webkit-appearance: none; appearance: none; background: var(--bg-tertiary); border-radius: 999px; outline: none; cursor: pointer; accent-color: var(--accent); }
.opacity-control input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-primary); box-shadow: 0 0 0 1px var(--accent-border), 0 2px 7px rgba(0,0,0,0.25); cursor: grab; }
.opacity-control input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg-primary); box-shadow: 0 0 0 1px var(--accent-border), 0 2px 7px rgba(0,0,0,0.25); cursor: grab; }
.opacity-control input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 7px; }
.opacity-control input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.1); }
.opacity-control input[type="range"]:active::-moz-range-thumb { cursor: grabbing; transform: scale(1.1); }
.opacity-val { font-size: 10px; color: var(--accent); font-weight: 700; min-width: 30px; text-align: right; font-family: 'Courier New', monospace; }

/* --- COLOR PICKER FIXES --- */
.opacity-control input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.opacity-control input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border);
    border-radius: 4px;
}
.opacity-control input[type="color"]::-moz-color-swatch {
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* --- HERRAMIENTAS --- */
.tools-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 20px 14px; }
.tool-btn { background: var(--bg-input); color: var(--text-faint); border: 1px solid var(--border-light); border-radius: 8px; padding: 10px 6px; cursor: pointer; font-size: 10px; font-weight: 600; transition: all 0.25s; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tool-btn svg { color: var(--text-dim); transition: color 0.2s; }
.tool-btn:hover { background: var(--accent-bg); color: var(--text-muted); border-color: var(--border-accent); }
.tool-btn:hover svg { color: var(--accent); }
.tool-btn.active { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-border); box-shadow: 0 0 12px var(--accent-glow); }
.tool-btn.active svg { color: var(--accent); }

/* --- BOTONES ACCIÓN --- */
.sidebar-actions { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 6px; }
#btn-zoom, #btn-zona, #btn-earth { width: 100%; padding: 10px 14px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12px; color: var(--btn-text); transition: all 0.25s; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px var(--btn-shadow-color), 0 1px 3px rgba(0,0,0,0.1); }
#btn-zoom { background: linear-gradient(135deg, #0c4a6e, #0369a1); }
#btn-zona { background: linear-gradient(135deg, #5B21B6, #7C3AED); }
#btn-earth { background: linear-gradient(135deg, #064e3b, #047857); }
#btn-zoom:hover, #btn-zona:hover, #btn-earth:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--btn-shadow-color), 0 2px 6px rgba(0,0,0,0.15); }

/* ===================== PANEL TABLA ===================== */
#attribute-panel { position: fixed; top: 0; right: 0; width: 450px; height: 100vh; background: var(--bg-card); color: var(--text-secondary); z-index: 10000; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transition: right 0.4s cubic-bezier(0.22,1,0.36,1); }
#attribute-panel.closed { right: -460px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
.panel-header h3 { margin: 0; font-size: 15px; color: var(--accent); }
.btn-cerrar { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239,68,68,0.15); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 13px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-cerrar:hover { background: var(--danger); color: white; border-color: var(--danger); }
#table-container { flex: 1; overflow-y: auto; padding: 20px; }
#table-container::-webkit-scrollbar { width: 5px; }
#table-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
#table-container table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow-sm); }
#table-container th, #table-container td { padding: 10px; text-align: left; border-bottom: 1px solid var(--border-light); }
#table-container th { background: var(--bg-tertiary); color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 9px; letter-spacing: 0.5px; position: sticky; top: 0; z-index: 10; }
#table-container tr { background: var(--bg-secondary); transition: background 0.2s; }
#table-container tr:nth-child(even) { background: var(--bg-card-hover); }
#table-container tr:hover { background: var(--accent-bg); }
.table-count { font-size: 11px; color: var(--text-faint); margin-bottom: 12px; padding: 6px 10px; background: var(--bg-input); border-radius: 6px; display: flex; justify-content: space-between; }
.table-count strong { color: var(--accent); }

/* ===================== POPUP ===================== */
.dark-popup .leaflet-popup-content-wrapper { background: var(--popup-bg); color: var(--popup-text); border: 1px solid var(--border-accent); border-radius: 12px; box-shadow: var(--shadow-md); }
.dark-popup .leaflet-popup-tip { background: var(--popup-bg); }
.dark-popup .leaflet-popup-close-button { color: var(--text-faint) !important; font-size: 18px !important; }
.dark-popup .leaflet-popup-close-button:hover { color: var(--danger) !important; }
.popup-nav { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.popup-layer-name { font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; flex: 1; text-align: center; }
.popup-count { font-size: 9px; color: var(--text-faint); font-weight: 600; margin-right: 6px; }
.popup-arrows { display: flex; gap: 4px; }
.popup-arrow-btn { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--border); width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.popup-arrow-btn:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.popup-arrow-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.popup-table-dark { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 11px; }
.popup-table-dark td { padding: 4px 6px; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); white-space: nowrap; }
.popup-table-dark td:first-child { font-weight: 700; color: var(--accent); width: 40%; background: var(--accent-glow); }
.popup-table-dark tr:last-child td { border-bottom: none; }
.dark-popup .leaflet-popup-content { margin: 12px 14px; max-height: 220px; overflow: auto; }

/* ===================== LEYENDA ===================== */
.legend-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s; backdrop-filter: blur(4px); }
.legend-overlay.visible { opacity: 1; visibility: visible; }
.legend-panel { background: var(--bg-card); border: 1px solid var(--border-accent); border-radius: 14px; box-shadow: var(--shadow-lg); width: 320px; max-height: 80vh; display: flex; flex-direction: column; transform: scale(0.9) translateY(20px); transition: transform 0.3s cubic-bezier(0.22,1,0.36,1); overflow: hidden; }
.legend-overlay.visible .legend-panel { transform: scale(1) translateY(0); }
.legend-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.legend-header h3 { margin: 0; font-size: 14px; color: var(--accent); font-weight: 700; }
.legend-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; }
.legend-body::-webkit-scrollbar { width: 4px; }
.legend-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.legend-loading { color: var(--text-faint); font-size: 12px; padding: 30px 0; text-align: center; }
.legend-loading.error { color: var(--danger); }
.legend-body img { max-width: 100%; border-radius: 6px; }

/* ===================== TOASTS ===================== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999999; display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); box-shadow: var(--shadow-md); transform: translateX(120%); transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), opacity 0.3; opacity: 0; pointer-events: auto; max-width: 340px; border: 1px solid transparent; backdrop-filter: blur(10px); }
.toast.toast-show { transform: translateX(0); opacity: 1; }
.toast-info { background: var(--bg-card); border-color: var(--border-accent); }
.toast-success { background: var(--bg-card); border-color: rgba(34,197,94,0.3); color: var(--success); }
.toast-warning { background: var(--bg-card); border-color: rgba(234,179,8,0.3); color: var(--warning); }
.toast-error { background: var(--bg-card); border-color: rgba(239,68,68,0.3); color: var(--danger); }

/* ===================== BACKDROP MÓVIL ===================== */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9; }
.sidebar-backdrop.visible { display: block; }

/* ===================== BOTÓN DASHBOARD ===================== */
#btn-open-dashboard { position: fixed; top: 16px; right: 16px; z-index: 1000; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--overlay-border); cursor: pointer; background: var(--overlay-bg); color: var(--accent); box-shadow: var(--shadow-sm); transition: all 0.25s; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
#btn-open-dashboard:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: scale(1.08); box-shadow: var(--shadow-md); }

/* ===================== DASHBOARD ===================== */
#geo-dashboard { position: fixed; top: 0; right: 0; width: 440px; height: 100vh; background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 40%, var(--bg-primary) 100%); color: var(--text-secondary); z-index: 10001; box-shadow: var(--shadow-lg); border-left: 1px solid var(--border-accent); display: flex; flex-direction: column; transition: right 0.4s cubic-bezier(0.22,1,0.36,1); }
#geo-dashboard.closed { right: -450px; }
.dash-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border-accent); background: var(--accent-glow); }
.dash-brand { display: flex; align-items: center; gap: 10px; }
.dash-escudo { width: 36px; height: 36px; object-fit: contain; }
.dash-brand h3 { margin: 0; font-size: 16px; color: var(--text-primary); font-weight: 800; }
.dash-brand p { margin: 2px 0 0; font-size: 11px; color: var(--text-faint); font-weight: 500; }
.dash-search { border-bottom: 1px solid var(--border); }
.dash-tabs { display: flex; border-bottom: 1px solid var(--border-light); }
.dash-tab { flex: 1; padding: 12px 14px; background: transparent; border: none; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--text-faint); display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.2s; border-bottom: 2px solid transparent; }
.dash-tab:hover { color: var(--text-muted); background: var(--accent-glow); }
.dash-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-glow); }
.dash-tab-pane { display: none; padding: 14px 18px; }
.dash-tab-pane.active { display: block; }
.dash-input-group { display: flex; gap: 6px; align-items: center; }
.dash-input-group input { flex: 1; background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; outline: none; transition: all 0.2s; }
.dash-input-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.dash-input-group input::placeholder { color: var(--text-faint); }
.dash-input-group button { background: linear-gradient(135deg, #0c4a6e, #0369a1); color: white; border: none; border-radius: 8px; width: 38px; height: 38px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; }
.dash-input-group button:hover { background: linear-gradient(135deg, #0369a1, #0284c7); transform: scale(1.05); }
.dash-suggestions { margin-top: 8px; max-height: 200px; overflow-y: auto; display: none; border: 1px solid var(--border-light); border-radius: 6px; }
.dash-suggestions.activo { display: block; }
.dash-sug-item { padding: 8px 12px; font-size: 12px; color: var(--text-muted); cursor: pointer; border-bottom: 1px solid var(--border-light); transition: background 0.15px; }
.dash-sug-item:last-child { border-bottom: none; }
.dash-sug-item:hover { background: var(--accent-bg); color: var(--accent); }
.dash-sug-item small { display: block; color: var(--text-faint); font-size: 10px; margin-top: 2px; }
#dash-results { overflow-y: auto; flex-shrink: 0; max-height: 0; transition: max-height 0.3s; }
#dash-results.has-results { max-height: 300px; border-bottom: 1px solid var(--border); }
#dash-results::-webkit-scrollbar { width: 4px; }
#dash-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.dash-result-item { padding: 12px 18px; border-bottom: 1px solid var(--border-light); cursor: pointer; transition: background 0.15s; display: flex; justify-content: space-between; align-items: center; }
.dash-result-item:hover { background: var(--accent-bg); }
.dash-result-main { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.dash-result-sub { font-size: 10px; color: var(--text-faint); margin-top: 2px; }
.dash-result-arrow { color: var(--text-dim); font-size: 14px; flex-shrink: 0; }
.dash-result-header { padding: 10px 18px; font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; background: var(--accent-glow); border-bottom: 1px solid var(--border-light); }
#dash-detail { flex: 1; overflow-y: auto; }
#dash-detail::-webkit-scrollbar { width: 4px; }
#dash-detail::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.dash-summary { padding: 16px 18px; background: var(--accent-glow); border-bottom: 1px solid var(--border); }
.dash-summary-row { display: flex; gap: 10px; margin-bottom: 10px; }
.dash-summary-row:last-child { margin-bottom: 0; }
.dash-summary-card { flex: 1; background: var(--bg-input); border: 1px solid var(--border-light); border-radius: 8px; padding: 12px; text-align: center; box-shadow: var(--shadow-sm); }
.dash-summary-card .card-value { font-size: 15px; font-weight: 800; color: var(--accent); }
.dash-summary-card .card-label { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════
   SECCIONES ACORDEÓN DEL DASHBOARD — FLECHAS FIJAS EN LÍNEA
   ══════════════════════════════════════════════════════════════════ */
.pot-section { border-bottom: 1px solid var(--border-light); }
.pot-section:last-child { border-bottom: none; }
.pot-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-input);
    transition: background 0.2s;
}
.pot-section-header:hover { background: var(--accent-glow); }
.pot-section-header svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.pot-section-header span:not(.pot-section-arrow) {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pot-section-arrow {
    font-size: 10px;
    color: var(--text-dim);
    transition: transform 0.3s;
    flex: none;
    flex-shrink: 0;
    margin-left: auto;
    width: 14px;
    text-align: center;
    line-height: 1;
}
.pot-section.open .pot-section-arrow {
    transform: rotate(90deg);
    color: var(--accent);
}
.pot-section.open .pot-section-header {
    background: var(--accent-glow);
}
.pot-section.open .pot-section-header span:not(.pot-section-arrow) {
    color: var(--text-secondary);
}
.pot-section-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; }
.pot-section.open .pot-section-body { grid-template-rows: 1fr; }
.pot-section-inner { overflow: hidden; }
.pot-data-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 18px; border-bottom: 1px solid var(--border-light); transition: background 0.15s; }
.pot-data-row:last-child { border-bottom: none; }
.pot-data-row:hover { background: var(--accent-glow); }
.pot-data-key { font-size: 11px; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0; max-width: 45%; }
.pot-data-value { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-align: right; word-break: break-word; max-width: 55%; line-height: 1.4; }
.pot-data-value.highlight { color: var(--accent); font-weight: 700; font-size: 13px; }
.pot-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.pot-badge-urbano { background: var(--badge-urbano-bg); color: var(--badge-urbano-text); }
.pot-badge-rural { background: var(--badge-rural-bg); color: var(--badge-rural-text); }
.pot-badge-expansion { background: var(--badge-expansion-bg); color: var(--badge-expansion-text); }
.pot-badge-default { background: var(--bg-input); color: var(--text-muted); }
.pot-empty { padding: 30px 18px; text-align: center; color: var(--text-dim); font-size: 12px; }

.leaflet-draw { display: none !important; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 10000; }
    #btn-toggle { left: 15px !important; z-index: 10001; top: 16px; }
    #btn-toggle:not(.movido) { left: 305px !important; }
    #attribute-panel, #geo-dashboard { width: 100%; }
    #attribute-panel.closed { right: -110%; }
    #geo-dashboard.closed { right: -110%; }
    #minimap-container { width: 100px; height: 100px; bottom: 8px; right: 8px; }
    #search-container { left: 55px; width: calc(100% - 75px); max-width: 260px; }
    #coord-display { font-size: 10px; bottom: 8px; }
    #coord-toggle { display: none; }
    .legend-panel { width: calc(100% - 32px); max-width: 320px; }
    #toast-container { bottom: 16px; right: 16px; left: 16px; }
    .toast { max-width: 100%; }
    .dash-summary-row { flex-direction: column; }
    #btn-open-dashboard { top: auto; bottom: 80px; right: 16px; }
    #measure-panel { top: auto; bottom: 50px; right: 80px; left: 16px; min-width: unset; }
}
@media (max-width: 480px) {
    .sidebar { width: 280px; }
    #btn-toggle:not(.movido) { left: 184px !important; }
    .sidebar.oculta { margin-left: -280px; }
    #minimap-container { width: 80px; height: 80px; }
}

/* ===================== TUTORIAL INTERACTIVO ===================== */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(3px);
    z-index: 100000;
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}
#tutorial-overlay.active {
    opacity: 1;
    visibility: visible;
}

#tutorial-content {
    position: absolute;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    max-width: 480px;
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    transform: scale(0.9);
}
#tutorial-overlay.active #tutorial-content {
    transform: scale(1);
}

/* Imagen de la mascota */
#tutorial-mascot {
    width: 100px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
    animation: float-mascot 3s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes float-mascot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Burbuja de texto */
.tutorial-bubble {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 20px var(--accent-glow);
    position: relative;
    color: var(--text-secondary);
}
.tutorial-bubble::before {
    content: '';
    position: absolute;
    bottom: 25px;
    left: -10px;
    width: 20px;
    height: 20px;
    background: var(--bg-card);
    border-left: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(45deg);
}

.tutorial-bubble h3 {
    margin: 0 0 12px 0;
    color: var(--accent);
    font-size: 18px;
    font-weight: 800;
}
.tutorial-bubble p {
    font-size: 13.5px;
    line-height: 1.6;
    margin: 0 0 20px 0;
}

/* Controles del footer */
.tutorial-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
}
.tut-dots {
    display: flex;
    gap: 6px;
}
.tut-dot {
    width: 8px;
    height: 8px;
    background: var(--border);
    border-radius: 50%;
    transition: all 0.3s;
}
.tut-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

.tut-buttons {
    display: flex;
    gap: 10px;
}
#btn-tut-skip {
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
}
#btn-tut-skip:hover { color: var(--text-muted); }

#btn-tut-next {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56,189,248,0.3);
    transition: all 0.2s;
}
#btn-tut-next:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}
#btn-tut-prev {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
#btn-tut-prev:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

/* --- Posiciones dinámicas en pantalla --- */
.tut-pos-center { top: 50%; left: 50%; transform: translate(-50%, -50%) !important; }
.tut-pos-left-top { top: 120px; left: 320px; }
.tut-pos-left-bottom { bottom: 100px; left: 320px; }
.tut-pos-map { bottom: 100px; left: 50%; transform: translateX(-50%) !important; }
.tut-pos-dashboard { top: 70px; right: 70px; flex-direction: row-reverse; }
.tut-pos-dashboard .tutorial-bubble::before { left: auto; right: -10px; border-left: none; border-bottom: none; border-right: 2px solid var(--accent); border-top: 2px solid var(--accent); }

/* Móviles */
@media (max-width: 768px) {
    #tutorial-content { flex-direction: column !important; align-items: center; width: 90%; text-align: center; top: 50% !important; left: 50% !important; right: auto !important; bottom: auto !important; transform: translate(-50%, -50%) !important; }
    .tutorial-bubble::before { display: none; }
    .tut-pos-dashboard .tutorial-bubble::before { display: none; }
}

/* ===================== WIDGET DE INFORMACIÓN ===================== */
#info-widget {
    position: fixed;
    top: 16px;
    right: 65px; /* Se ubica justo al lado del botón del Dashboard */
    z-index: 10000;
    transition: right 0.4s cubic-bezier(0.22,1,0.36,1);
}

/* Cuando el dashboard se abre, empujamos el widget hacia la izquierda */
body.dash-open #info-widget {
    right: 460px; /* 440px del dashboard + 20px de margen */
}

#info-content {
    background: var(--overlay-bg);
    color: var(--text-secondary);
    border: 1px solid var(--overlay-border);
    border-radius: 12px;
    padding: 16px 20px;
    width: 280px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

#info-content.hidden {
    display: none;
}

#info-content h4 {
    margin: 0;
    color: var(--accent);
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 800;
}

#info-content p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

#info-content p strong {
    color: var(--text-secondary);
}

.btn-close-info {
    background: transparent;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
}

.btn-close-info:hover {
    color: var(--danger);
}

#info-icon {
    width: 40px;
    height: 40px;
    background: var(--overlay-bg);
    border: 1px solid var(--overlay-border);
    border-radius: 10px;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    font-weight: 800;
    font-size: 18px;
    font-family: 'Courier New', Courier, monospace;
    transition: all 0.25s;
    backdrop-filter: blur(8px);
}

#info-icon:hover {
    transform: scale(1.08);
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

#info-icon.hidden {
    display: none;
}

/* Responsivo para móviles */
@media (max-width: 768px) {
    #info-widget { top: 65px; right: 16px; }
    body.dash-open #info-widget { display: none; /* Se oculta en móviles si se abre el dashboard para no saturar */ }
}

/* Controles operables mediante teclado en ambos temas. */
.layer-group-header:focus-visible, .sidebar button:focus-visible, .dropdown-menu a:focus-visible, #search-results li:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
