:root {
    /* Logo-based Palette (Maynas/Loreto Vibes) */
    --logo-green: #2e7d32;
    /* Forest Green */
    --logo-blue: #1565c0;
    /* River Blue */
    --logo-orange: #ef6c00;
    /* Earth/Sunset Orange */
    --logo-yellow: #fbc02d;
    /* Sun Yellow */

    /* Default Light Theme (using Logo Blue as Primary) */
    --primary-color: var(--logo-blue);
    --primary-dark: #0d47a1;
    --accent-color: var(--logo-orange);

    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --text-color: #334155;
    --text-light: #64748b;
    --text-on-primary: #ffffff;
    --background-color: #f1f5f9;
    --border-color: #e2e8f0;
    --hover-color: #f1f5f9;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    --font-family: 'Inter', sans-serif;
}

/* Dark Mode Overrides */
body.dark-mode {
    --primary-color: #64b5f6;
    /* Lighter Blue for Dark Mode */
    --primary-dark: #2196f3;
    --accent-color: #ffb74d;
    /* Lighter Orange */

    --sidebar-bg: #1e293b;
    /* Slate 800 */
    --sidebar-border: #334155;
    /* Slate 700 */
    --background-color: #0f172a;
    /* Slate 900 */

    --text-color: #f1f5f9;
    /* Slate 100 */
    --text-light: #94a3b8;
    /* Slate 400 */
    --text-on-primary: #0f172a;

    --border-color: #334155;
    /* Slate 700 */
    --hover-color: #334155;
    /* Slate 700 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

/* Apply background color to body variable */
body {
    background-color: var(--background-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Ensure components use variables correctly */
.app-header,
.sidebar-left,
.sidebar-right,
.group-content,
.search-container input,
.map-btn,
.form-group input,
.form-group select,
.form-group textarea,
.location-status,
.subgroup-header {
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

.app-header {
    background-color: var(--sidebar-bg);
}

.sidebar-header,
.search-container,
.group-content,
.active-layers-counter {
    background-color: var(--sidebar-bg);
    /* Match sidebar bg */
}

.map-btn {
    background-color: var(--sidebar-bg);
}

.subgroup-header {
    background-color: var(--hover-color);
    /* Slightly different in dark mode */
}

.form-group input,
.form-group select,
.form-group textarea {
    background-color: var(--background-color);
    /* Darker input bg in dark mode */
}

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

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    /* Prevent mobile scroll bounce */
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: #f1f5f9;
    /* Slate 100 */
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
}

/* Header */
.app-header {
    background-color: var(--sidebar-bg);
    color: var(--text-color);
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    flex-shrink: 0;
    /* Ensure header doesn't shrink */
}

/* Header Layout Fixes */
.header-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    /* Allow shrinking */
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    /* Space between logos and text */
    flex-wrap: nowrap;
    /* FORCE single line */
}

.logo {
    height: 40px;
    /* Optimal height for 60px header */
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
    /* Prevent logos from squishing */
}

.header-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: normal;
    /* Allow wrapping */
    margin-left: 10px;
    line-height: 1.1;
    /* Tight line height for wrapped text */
}

.header-text h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    letter-spacing: -0.01em;
    margin: 0;
}

/* Mobile/Tablet Header Adjustments */
@media (max-width: 1200px) {
    .header-text {
        display: none !important;
        /* Force hide text on smaller screens */
    }

    .logo {
        height: 36px;
        /* Slightly smaller logos */
    }
}

.header-right {
    display: flex;
    gap: 12px;
}

.btn-header {
    background: transparent;
    color: var(--text-color);
    border: 1px solid transparent;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-header:hover {
    background-color: var(--hover-color);
    color: var(--primary-color);
}

.btn-header.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    box-shadow: var(--shadow-sm);
}

/* Main Layout */
.main-container {
    display: flex;
    flex: 1;
    /* Fill remaining space */
    position: relative;
    height: auto;
    /* Let flex handle height */
    width: 100%;
    overflow: hidden;
    /* Prevent internal overflow */
}

/* Sidebars */
.sidebar-left,
.sidebar-right {
    background-color: var(--sidebar-bg);
    color: var(--text-color);
    width: 320px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 900;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: none;
}

.sidebar-right {
    width: 380px;
    border-left: 1px solid var(--sidebar-border);
    border-right: none;
}

.sidebar-header {
    padding: 24px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
}

/* Search */
.search-container {
    padding: 16px 24px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--background-color);
}

.search-container input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-container input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-container i {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Layers List */
.layers-container {
    flex: 1;
    overflow-y: auto;
}

.layer-group {
    border-bottom: 1px solid var(--border-color);
}

.group-header {
    padding: 12px 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    transition: background 0.2s;
    color: var(--text-color);
}

.group-header:hover {
    background-color: var(--hover-color);
}

.group-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.subgroup-header {
    padding: 8px 24px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    background-color: var(--hover-color);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.indicator {
    width: 6px;
    height: 6px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
}

.group-content {
    display: none;
    background-color: var(--sidebar-bg);
    padding-bottom: 8px;
}

.group-content.open {
    display: block;
}

.layer-item {
    padding: 8px 24px 8px 40px;
    display: flex;
    align-items: flex-start;
    transition: background-color 0.2s;
}

.layer-item:hover {
    background-color: var(--hover-color);
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    width: 100%;
}

.layer-toggle {
    margin-top: 3px;
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
}

.layer-info {
    display: flex;
    flex-direction: column;
}

.layer-name {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 400;
}

.layer-desc {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
    line-height: 1.3;
}

/* Active Layers Counter */
.active-layers-counter {
    padding: 16px 24px;
    background-color: var(--background-color);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-light);
    font-weight: 500;
}

/* Map Area */
.map-container {
    flex: 1;
    position: relative;
    background-color: var(--background-color);
}

#map {
    width: 100%;
    height: 100%;
}

.map-controls {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 500;
}

.map-btn {
    width: 40px;
    height: 40px;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    transition: all 0.2s;
}

.map-btn:hover {
    background-color: var(--hover-color);
    color: var(--accent-color);
    transform: translateY(-1px);
}

/* Right Panel Forms */
.panel-section {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
}

.panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-primary {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.location-status {
    background-color: var(--background-color);
    padding: 12px;
    border-radius: 6px;
    border: 1px dashed var(--border-color);
    margin-bottom: 20px;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Dashboard Stats */
.stats-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-color);
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

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

.dot-green {
    background-color: #10b981;
}

.dot-yellow {
    background-color: #f59e0b;
}

.dot-blue {
    background-color: #3b82f6;
}

.dot-red {
    background-color: #ef4444;
}

/* Responsive adjustments */
/* Responsive adjustments */
@media (max-width: 1024px) {
    .sidebar-left {
        position: absolute;
        left: -320px;
        /* Width of sidebar */
        top: 0;
        height: 100%;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
        z-index: 2000;
        /* Higher than map controls */
    }

    .sidebar-left.open {
        left: 0;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1500;
        /* Below sidebar, above everything else */
    }

    .sidebar-overlay.active {
        display: block;
    }

    .sidebar-right {
        display: none;
        /* Hide right panel on mobile for now, or make it toggleable too */
    }

    .map-controls {
        top: 12px;
        right: 12px;
    }
}

/* Mobile Toggle Button */
#sidebar-toggle-btn {
    display: none;
}

@media (max-width: 1024px) {

    #sidebar-toggle-btn {
        display: flex;
        position: absolute;
        top: 12px;
        left: 12px;
        z-index: 1000;
        background: var(--sidebar-bg);
        border: 1px solid var(--border-color);
        padding: 10px;
        border-radius: 8px;
        box-shadow: var(--shadow-md);
        color: var(--text-color);
        cursor: pointer;
    }

    #btn-participation-toggle {
        display: flex !important;
        position: static;
        right: auto;
        top: auto;
        /* Inherit map-btn styles but override colors */
        width: 40px;
        height: 40px;
        background: #67B685;
        /* Solicitado: Verde #67B685 */
        border: 1px solid #5da577;
        /* Slightly darker border */
        border-radius: 8px;
        box-shadow: var(--shadow-md);
        color: white;
        /* Solicitado: Icono blanco */
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: auto;
        margin-top: 8px;
    }

    #btn-participation-toggle:hover {
        background: #5da577;
        /* Darker green on hover */
    }

    /* Right Sidebar Mobile Styles */
    .sidebar-right {
        position: absolute;
        right: -380px;
        top: 0;
        height: 100%;
        transition: right 0.3s ease-in-out;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
        z-index: 2000;
        display: flex;
        /* Override display: none */
    }

    .sidebar-right.open {
        right: 0;
    }

    .sidebar-right.open {
        right: 0;
    }
}

/* Header Responsiveness for Mobile (< 700px) */
@media (max-width: 700px) {
    .header-right .btn-header {
        display: none;
    }

    /* Keep Admin button or Theme toggle? User said "ocultarlos porque no cabe". 
       Usually nice to keep at least one, but user said hide the rest.
       If I hide .btn-header, all of them go.
       Let's follow instruction: "el resto de texto y botones ocultarlos".
    */

    /* Reset width to auto or specific for logo container so it doesn't break */
    .header-left .logo-container {
        gap: 8px;
    }

    .logo {
        height: 32px;
        /* Slightly smaller logo */
    }

    .header-text h1 {
        font-size: 0.6rem;
        /* AJUSTAR AQUÍ TAMAÑO DE TEXTO PLAN */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 280px;
        /* Limit width */
    }

    .header-text p {
        display: none;
        /* Hide subtitle */
    }
}

/* Close button in sidebar */
#sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
}

@media (max-width: 1024px) {
    #sidebar-close-btn {
        display: block;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* Mapa Tematico Section */
.mapa-tematico-container .section-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--sidebar-bg);
}

.mapa-tematico-container .section-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mapa-tematico-container .group-title,
.mapa-tematico-container .layer-name {
    text-transform: uppercase;
    font-size: 0.8rem;
    /* Adjustment for uppercase readability */
    letter-spacing: 0.03em;
}

#layers-list {
    display: none;
}

/* Sidebar Layout Refactoring */
.sidebar-left {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll, use internal scroll */
}

/* Header is naturally at top */

/* Scrollable Content */
.sidebar-scroll-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Legend Items Styles */
.legend-category-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.7rem;
    /* Smaller font for elegance */
    color: var(--text-color);
}

.legend-color-box {
    width: 12px;
    height: 12px;
    display: inline-block;
}

.legend-icon-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.legend-category-label {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* Elegant spacing */
    font-weight: 500;
}

/* Footer (Counter + Legend) */
.sidebar-footer {
    flex-shrink: 0;
    background-color: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    max-height: 50%;
    /* Limit height so it doesn't take over screen */
}

.active-layers-counter {
    border-top: none;
    /* Handled by footer */
    padding: 12px 24px;
    background-color: transparent;
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Legend Panel Styles */
.legend-panel {
    position: absolute;
    /* Changed from fixed to be relative to map-container */
    bottom: 20px;
    /*left: 20px;*/
    left: 1rem;
    width: 300px;
    /* Fixed width */
    max-height: 50vh;
    /* Max height relative to viewport */
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    /* Above map */
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.legend-panel.collapsed {
    /* When collapsed, only header shows effectively, or we minimize it? */
    /* Implementation choice: Keep header visible, hide content. Auto-size height. */
    height: auto;
}

.legend-header {
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.legend-header h4 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
}

.btn-icon-small {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.btn-icon-small:hover {
    color: var(--primary-color);
}

.legend-content {
    padding: 0;
    overflow-y: auto;
    max-height: 250px;
    /* Default max height */
    transition: max-height 0.3s;
}

.legend-panel.collapsed .legend-content {
    display: none;
}

.legend-item {
    padding: 12px 24px;
    background-color: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.legend-layer-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Styles for dynamically added category rows */
.legend-category-row {
    display: flex;
    /* layout fix */
    align-items: center;
    /* layout fix */
    gap: 8px;
    /* layout fix */
    margin-bottom: 4px;
    /* spacing */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    color: var(--text-color);
}

.legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background-color: #ccc;
    display: inline-block;
}

.legend-controls {
    display: flex;
    gap: 8px;
}

.legend-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.legend-btn:hover {
    color: var(--primary-color);
    background-color: var(--hover-color);
}

.legend-btn.active {
    color: var(--primary-color);
}

/* Opacity Slider */
.opacity-control {
    display: none;
    /* Hidden by default */
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    animation: fadeIn 0.2s ease-in-out;
}

.opacity-control.show {
    display: flex;
}

.opacity-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.opacity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.opacity-value {
    font-size: 0.75rem;
    color: var(--text-light);
    min-width: 32px;
    text-align: right;
}

.empty-legend {
    padding: 24px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    font-style: italic;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Basemap Switcher */
.basemap-menu {
    position: absolute;
    right: 50px;
    top: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 0;
    width: 180px;
    z-index: 1000;
}

body.dark-mode .basemap-menu {
    background: #1e293b;
    /* Manual Dark Mode color since var might fail in some contexts */
}

.basemap-option {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.basemap-option:hover {
    background-color: var(--hover-color);
}

.basemap-option.active {
    background-color: var(--hover-color);
    color: var(--primary-color);
    font-weight: 500;
}

.basemap-option i {
    width: 16px;
    text-align: center;
}

/* Mobile Legend Styles */
#mobile-legend-toggle {
    display: none;
    /* Default hidden on desktop */
}

@media (max-width: 768px) {

    /* Adjust Legend Panel for Mobile */
    .legend-panel {
        left: 1rem !important;
        right: auto;
        bottom: 1rem;
        width: calc(100% - 2rem);
        max-width: 400px;
        max-height: 40vh;
    }

    /* Show Mobile Toggle Button */
    #mobile-legend-toggle {
        display: flex !important;
        /* No absolute positioning - let it flow in .map-controls */
        /* No circular border - inherit square from .map-btn */
        z-index: 500;
    }

    /* When hidden via mobile toggle */
    .legend-panel.mobile-hidden {
        display: none !important;
    }
}