body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

:root {
    --bg: #f2f2f2;
    --panel-bg: #ffffff;
    --text: #222;
    --border: #cccccc;
    --shadow: rgba(0,0,0,0.15);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --panel-bg: #1f1f1f;
        --text: #eee;
        --border: #333;
        --shadow: rgba(0,0,0,0.5);
    }
}

/* Top bar */
#topBar {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}

/* Map */
#map {
    position: absolute;
    top: 80px;
    bottom: 0;
    left: 0;
    right: 0;
}

/* Side panel */
#sidePanel {
    position: absolute;
    right: 10px;
    top: 90px;
    width: 280px;
    height: calc(100vh - 110px);
    overflow-y: auto;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow);
    padding: 15px;
    z-index: 9999;
}

#sidePanel.collapsed {
    height: 45px;
    overflow: hidden;
}

#sidePanel h5 {
    margin: 0 0 10px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

/* Crime list */
#crimeList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#crimeList li {
    padding: 10px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    margin-bottom: 10px;
    cursor: pointer;
}

#crimeList li:hover {
    background: #ffffff35;
}

/* Time slider */
.timeline-box {
    display: flex;
    flex-direction: column;
    width: 240px;
}

#timeSlider {
    width: 100%;
}

#timeSliderLabels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    margin-top: 4px;
}

/* Layer switcher control */
.layer-switcher-control {
    position: relative;
}

.layer-toggle-btn {
    width: 40px;
    height: 40px;
    background: var(--panel-bg);
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px var(--shadow);
}

.layer-options {
    position: absolute;
    bottom: 48px;
    left: 0;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    overflow: hidden;
    min-width: 120px;
}

.layer-options.hidden {
    display: none;
}

.layer-options button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    color: var(--text);
}

.layer-options button:hover {
    background: var(--bg);
}

.layer-options button.active {
    font-weight: bold;
    color: #C41E1E;
}

/* MOBILE STYLES */
@media (max-width: 768px) {
    #topBar {
        flex-direction: column;
        gap: 10px;
        padding-bottom: 15px;
    }

    .filters-wrapper {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    #map {
        top: 260px !important;
    }

    #sidePanel {
        width: 100%;
        right: 0;
        left: 0;
        bottom: 0;
        top: auto;
        border-radius: 12px 12px 0 0;
        height: 40vh;
        z-index: 99999;
    }

    .timeline-box {
        width: 100%;
    }
}

/* Mobile: layer switcher */
@media (max-width: 768px) {
    .layer-toggle-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
    }

    .layer-toggle-btn svg {
        width: 28px;
        height: 28px;
    }

    .layer-options {
        bottom: 64px;
        min-width: 150px;
    }

    .layer-options button {
        font-size: 17px;
        padding: 14px 20px;
    }
}

/* Mobile popups */
.popup-mobile .leaflet-popup-content-wrapper {
    border-radius: 14px !important;
}

.popup-mobile .leaflet-popup-content {
    font-size: 15px !important;
    line-height: 1.8 !important;
    margin: 14px 16px !important;
}

.popup-mobile .leaflet-popup-content b {
    font-size: 17px !important;
    display: block;
    margin-bottom: 4px;
}

.popup-mobile .leaflet-popup-content a {
    font-size: 15px !important;
    display: inline-block;
    margin-top: 8px;
}
