/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background-color: #1a1a1a;
}

/* Map container */
#map {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Controls overlay */
.controls-container {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 320px;
    width: calc(100% - 40px);
    max-height: calc(100vh - 40px);
    backdrop-filter: blur(10px);
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ===== Compact Header ===== */
.controls-header-compact {
    margin-bottom: 10px;
}

.controls-header-compact h1 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.year-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
}

.year-slider-row .year-value {
    font-size: 20px;
    font-weight: 700;
    color: white;
    min-width: 45px;
    font-variant-numeric: tabular-nums;
}

.step-btn,
.play-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.step-btn {
    font-size: 10px;
}

.step-btn:hover,
.play-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.step-btn:active {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0.95);
}

.play-btn.playing {
    background: rgba(255, 255, 255, 0.4);
}

.year-slider-row .year-slider {
    flex: 1;
    height: 4px;
}

/* ===== Minimal Layer Toggles ===== */
.layer-toggles {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.layer-toggle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.layer-toggle:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.layer-toggle.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.layer-toggle .toggle-icon {
    font-size: 16px;
}

.layer-toggle .toggle-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Scrollable Filter Sections (legacy, keep for compatibility) ===== */
.filter-sections {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===== Filter Section (legacy) ===== */
.filter-section {
    margin-bottom: 2px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.filter-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.filter-section-header:hover {
    background: #e9ecef;
}

.filter-section-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    flex: 1;
}

.section-icon {
    font-size: 10px;
    color: #6c757d;
    transition: transform 0.2s ease;
}

.filter-section.collapsed .section-icon {
    transform: rotate(0);
}

.filter-section:not(.collapsed) .section-icon {
    transform: rotate(0);
}

.filter-section-content {
    padding: 0 12px 10px 12px;
}

.filter-section.collapsed .filter-section-content {
    display: none;
}

/* ===== Filter Mode Button ===== */
.filter-mode-btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #495057;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-mode-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.filter-mode-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.source-filter-panel {
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px dashed #dee2e6;
}

/* ===== Source Chips ===== */
.source-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.source-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s ease;
}

.source-chip:hover {
    border-color: #667eea;
}

.source-chip:has(input:checked) {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.source-chip:has(input:checked) .chip-color {
    border-color: white;
}

.source-chip input[type="checkbox"] {
    display: none;
}

.chip-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.chip-label {
    font-weight: 500;
}

.source-chip.snapshot {
    background: #faf8f5;
    border-color: #d4c4b0;
}

.source-chip.snapshot:has(input:checked) {
    background: #8b4513;
    border-color: #8b4513;
}

/* ===== Subsection Header ===== */
.subsection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 6px 0;
    padding-top: 6px;
    border-top: 1px solid #dee2e6;
}

/* ===== Mini Buttons ===== */
.mini-btn {
    padding: 4px 8px;
    background: #e9ecef;
    border: none;
    border-radius: 12px;
    color: #495057;
    font-size: 11px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
}

.mini-btn:hover {
    background: #667eea;
    color: white;
}

/* ===== Controls Footer ===== */
.controls-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid #e9ecef;
    font-size: 10px;
}

.about-link-mini {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.about-link-mini:hover {
    text-decoration: underline;
}

.data-credit {
    color: #6c757d;
}

/* ===== Legacy styles (kept for compatibility) ===== */
.controls-header {
    margin-bottom: 20px;
}

.controls-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
}

.year-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
}

.year-label {
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.year-value {
    font-size: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Slider container */
.slider-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.slider-label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.year-min,
.year-max {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    min-width: 40px;
}

.year-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #667eea 0%, #764ba2 100%);
    outline: none;
    cursor: pointer;
}

/* Slider thumb styles */
.year-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.year-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

.year-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.year-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

/* Era Indicator */
.era-indicator {
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.era-indicator h3 {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.era-info {
    font-size: 14px;
    color: #495057;
    margin-bottom: 5px;
}

.era-info strong {
    font-weight: 600;
    color: #2c3e50;
}

/* Animation Controls */
.animation-controls {
    margin: 15px 0;
    display: flex;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* Layer Toggles */
.layer-toggles {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.layer-toggles h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.toggle-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.toggle-btn {
    padding: 8px 12px;
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.toggle-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
}

.toggle-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Slider Markers */
.slider-markers {
    position: relative;
    height: 20px;
    margin-top: 5px;
}

.slider-marker {
    position: absolute;
    width: 2px;
    height: 10px;
    background: #6c757d;
    transform: translateX(-50%);
}

.slider-marker.key-date {
    height: 15px;
    width: 3px;
    background: #667eea;
}

.slider-marker-label {
    position: absolute;
    font-size: 10px;
    color: #6c757d;
    transform: translateX(-50%);
    top: 12px;
    white-space: nowrap;
}

/* Info panel */
.info-panel {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
}

.info-text {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.6;
    margin-bottom: 15px;
}

.about-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #667eea;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid #dee2e6;
}

.about-link:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Legend */
.legend {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

.legend h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #495057;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Historical color variations for legend */
.legend-color.historical {
    opacity: 0.8;
    filter: sepia(0.3);
}

.legend-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #dee2e6;
}

.legend-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.legend-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #495057;
    font-size: 14px;
    font-weight: 500;
}

/* Error message */
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #dc3545;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    z-index: 1001;
    max-width: 500px;
    text-align: center;
}

.error-message p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

/* MapLibre controls customization */
.maplibregl-ctrl-bottom-right {
    bottom: 20px;
    right: 20px;
}

.maplibregl-ctrl-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    z-index: 10;
}

.loading-overlay .spinner {
    width: 30px;
    height: 30px;
    margin: 0;
}

.updating-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1000;
    animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Responsive design */
@media (max-width: 768px) {
    .controls-container {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        max-width: 100%;
        width: 100%;
        border-radius: 12px 12px 0 0;
        max-height: 60vh;
        overflow-y: auto;
        padding: 15px;
    }

    .controls-header h1 {
        font-size: 20px;
    }

    .year-value {
        font-size: 28px;
    }

    .era-indicator {
        margin: 10px 0;
        padding: 12px;
    }

    .layer-toggles {
        margin: 10px 0;
    }

    .toggle-buttons {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .toggle-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .about-link {
        display: block;
        text-align: center;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .controls-container {
        padding: 12px;
        max-height: 65vh;
    }

    .controls-header h1 {
        font-size: 18px;
        margin-bottom: 8px;
    }

    .year-value {
        font-size: 24px;
    }

    .year-label {
        font-size: 12px;
    }

    .slider-container {
        margin: 15px 0;
        padding: 12px;
    }

    .era-indicator {
        padding: 10px;
    }

    .era-indicator h3 {
        font-size: 11px;
    }

    .era-info {
        font-size: 12px;
    }

    .animation-controls .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .layer-toggles {
        padding: 10px;
    }

    .legend {
        padding: 10px;
    }

    .legend h3 {
        font-size: 13px;
    }

    .legend-item {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .legend-color {
        width: 16px;
        height: 16px;
    }
}

/* Tablet landscape and desktop improvements */
@media (min-width: 769px) and (max-width: 1024px) {
    .controls-container {
        max-width: 420px;
    }
}

@media (min-width: 1025px) {
    .controls-container {
        max-width: 450px;
    }
}

/* Source Filter */
.source-filter {
    margin: 15px 0;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.source-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.source-filter-header:hover {
    background: #e9ecef;
}

.source-filter-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.collapse-icon {
    font-size: 10px;
    color: #6c757d;
    transition: transform 0.2s ease;
}

.source-filter.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.source-filter-content {
    padding: 0 12px 12px 12px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.source-filter.collapsed .source-filter-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.source-filter-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.source-action-btn {
    flex: 1;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-action-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.source-group {
    margin-bottom: 10px;
}

.source-group:last-child {
    margin-bottom: 0;
}

.source-group-title {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #dee2e6;
}

.source-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 2px 0;
    background: #ffffff;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.source-checkbox:hover {
    background: #e9ecef;
}

.source-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #667eea;
}

.source-checkbox .source-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.source-checkbox .source-label {
    flex: 1;
    font-size: 12px;
    color: #495057;
}

.source-checkbox .source-count {
    font-size: 11px;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 24px;
    text-align: center;
}

.source-checkbox.sub {
    margin-left: 22px;
    padding: 4px 8px;
    background: #f8f9fa;
}

.source-checkbox.sub .source-label {
    font-size: 11px;
}

.source-subsources {
    margin-top: 4px;
}

/* Source filter help text */
.source-filter-help {
    font-size: 11px;
    color: #6c757d;
    margin: 0 0 10px 0;
    font-style: italic;
    line-height: 1.4;
}

/* Date Sources panel styling */
.date-sources-filter {
    border-left: 3px solid #667eea;
}

.date-sources-filter .source-filter-header h3::before {
    content: "📅 ";
    font-size: 12px;
}

/* Snapshot Sources panel styling */
.snapshot-sources-filter {
    border-left: 3px solid #8b4513;
    background: linear-gradient(135deg, #faf8f5 0%, #f5f0eb 100%);
}

.snapshot-sources-filter .source-filter-header h3::before {
    content: "📷 ";
    font-size: 12px;
}

.snapshot-sources-filter .source-filter-header {
    background: rgba(139, 69, 19, 0.05);
}

.snapshot-sources-filter .source-filter-header:hover {
    background: rgba(139, 69, 19, 0.1);
}

/* Source checkbox row with details link */
.source-checkbox-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.source-checkbox-row .source-checkbox {
    flex: 1;
}

.source-details-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: #e9ecef;
    color: #6c757d;
    text-decoration: none;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.source-details-link:hover {
    background: #667eea;
    color: white;
}

/* Inspect button styling */
.source-action-btn.inspect-btn {
    background: linear-gradient(135deg, #8b4513 0%, #5a3d2b 100%);
    color: white;
    border-color: #8b4513;
}

.source-action-btn.inspect-btn:hover {
    background: linear-gradient(135deg, #a05a2c 0%, #6b4423 100%);
    border-color: #a05a2c;
}

/* ===== Feature Tabs ===== */
.feature-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #dee2e6;
}

.feature-tab {
    flex: 1;
    padding: 10px 16px;
    background: #ffffff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feature-tab:first-child {
    border-right: 1px solid #dee2e6;
}

.feature-tab:hover {
    background: #f8f9fa;
}

.feature-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.feature-tab:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* Feature Panels */
.feature-panel {
    display: none;
}

.feature-panel.active {
    display: block;
}

/* ===== Road Type Filter ===== */
.road-type-filter {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.road-type-filter h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.road-type-filter .toggle-buttons {
    grid-template-columns: repeat(3, 1fr);
}

/* ===== Date Range Filter ===== */
.date-range-filter {
    margin: 15px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.date-range-filter h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.range-inputs {
    display: flex;
    gap: 15px;
}

.range-inputs label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.range-inputs span {
    font-size: 12px;
    color: #6c757d;
}

.range-inputs input[type="number"] {
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    background: #ffffff;
}

.range-inputs input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.filter-help {
    font-size: 11px;
    color: #6c757d;
    margin-top: 8px;
    font-style: italic;
}

/* ===== Road Statistics ===== */
.road-stats {
    margin: 15px 0;
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.road-stats h3 {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.road-stats .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.road-stats .stat-label {
    font-size: 13px;
    color: #495057;
}

.road-stats .stat-value {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

/* Print styles */
@media print {
    .controls-container,
    .maplibregl-ctrl-bottom-right,
    .maplibregl-ctrl-bottom-left {
        display: none;
    }

    #map {
        position: relative;
        width: 100%;
        height: 80vh;
    }
}

/* Accessibility improvements */
.year-slider:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Smooth transitions */
.year-display,
.slider-container,
.info-panel {
    transition: all 0.3s ease;
}

/* ===== Rebuild Button and Status ===== */
.rebuild-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
    transition: all 0.2s ease;
    margin: 10px 0;
    width: 100%;
}

.rebuild-btn:hover {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.4);
}

.rebuild-btn:active {
    transform: translateY(0);
}

.rebuild-status {
    display: none;
    padding: 10px;
    margin: 10px 0;
    background: #f0f2ff;
    border: 1px solid #667eea;
    border-radius: 6px;
    color: #667eea;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Road change type indicator styles */
.maplibregl-popup-content .change-type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.maplibregl-popup-content .change-type-same { color: #888888; }
.maplibregl-popup-content .change-type-widened { color: #4a90d9; }
.maplibregl-popup-content .change-type-rerouted { color: #d97706; }
.maplibregl-popup-content .change-type-replaced { color: #7c3aed; }
.maplibregl-popup-content .change-type-removed { color: #dc2626; }
.maplibregl-popup-content .change-type-new { color: #16a34a; }

/* ===== Source Inspection Mode ===== */

/* Mini inspection button */
.inspection-selector-mini {
    position: fixed;
    bottom: 100px;
    left: 20px;
    z-index: 100;
}

.inspect-ml-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.inspect-ml-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.inspection-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-width: 150px;
}

.inspection-selector-mini:hover .inspection-dropdown,
.inspection-dropdown:hover {
    display: block;
}

.inspection-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inspection-loading {
    color: #6c757d;
    font-size: 11px;
    font-style: italic;
    padding: 5px;
    text-align: center;
}

.inspection-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.inspection-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.inspection-btn:hover .btn-year,
.inspection-btn:hover .btn-name {
    color: white;
}

.inspection-btn .btn-year {
    font-size: 14px;
    font-weight: 700;
    color: #2c3e50;
}

.inspection-btn .btn-name {
    font-size: 10px;
    color: #6c757d;
}

/* Inspection overlay (shown when active) */
.inspection-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 200;
    width: 280px;
    display: none;
    overflow: hidden;
}

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

.inspection-overlay.active ~ .inspection-selector {
    display: none;
}

.inspection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.inspection-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.inspection-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.inspection-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.inspection-content {
    padding: 20px;
}

.inspection-source {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.inspection-source .label {
    font-size: 12px;
    color: #6c757d;
}

.inspection-source .source-name {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
}

.inspection-stats {
    margin-bottom: 15px;
}

.inspection-stats .stat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.inspection-stats .stat-row:last-child {
    border-bottom: none;
}

.inspection-stats .stat-label {
    font-size: 12px;
    color: #6c757d;
    width: 70px;
}

.inspection-stats .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    min-width: 40px;
}

.inspection-stats .stat-conf {
    font-size: 11px;
    color: #667eea;
    background: #f0f2ff;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Confidence legend */
.confidence-legend {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
}

.confidence-legend h4 {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 10px 0;
}

.confidence-scale {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confidence-scale .conf-low,
.confidence-scale .conf-high {
    font-size: 10px;
    color: #6c757d;
}

.conf-gradient {
    flex: 1;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right,
        #ff0000 0%,
        #ffaa00 35%,
        #ffff00 50%,
        #88ff00 75%,
        #00ff00 100%
    );
}

.conf-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    margin-top: 5px;
    padding: 0 20px;
}

/* Inspection controls */
.inspection-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.opacity-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opacity-control span {
    font-size: 12px;
    color: #6c757d;
}

.opacity-control input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e9ecef;
    appearance: none;
    cursor: pointer;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

/* Hide inspection selector when overlay is active */
body:has(.inspection-overlay.active) .inspection-selector {
    display: none;
}

/* Mobile adjustments for inspection mode */
@media (max-width: 768px) {
    .inspection-selector {
        top: auto;
        bottom: 20px;
        right: 20px;
        max-width: 180px;
        padding: 12px;
    }

    .inspection-overlay {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

/* ===== Edit Popup ===== */
.edit-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 0;
}

.edit-popup h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
}

.edit-popup .current-values {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 12px;
}

.edit-popup .current-values div {
    margin: 4px 0;
    color: #495057;
}

.edit-popup .current-values strong {
    color: #2c3e50;
    font-weight: 600;
}

.edit-popup .edit-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.edit-popup label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #495057;
    font-weight: 500;
}

.edit-popup input[type="number"] {
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    background: #ffffff;
}

.edit-popup input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.edit-popup .edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.edit-popup .save-btn,
.edit-popup .cancel-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-popup .save-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.edit-popup .save-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.edit-popup .cancel-btn {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.edit-popup .cancel-btn:hover {
    background: #e9ecef;
}

/* ===== Debug Popup ===== */
.debug-popup {
    padding: 8px;
}

.debug-popup .debug-info {
    font-size: 13px;
    line-height: 1.6;
}

.debug-popup .debug-info div {
    margin-bottom: 4px;
}

.debug-popup .donor-info {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
    color: #27ae60;
}

/* ===== Debug Legend ===== */
.debug-legend {
    position: fixed;
    bottom: 40px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    font-size: 12px;
    min-width: 140px;
}

.debug-legend-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e9ecef;
}

.debug-legend-section {
    margin-bottom: 8px;
}

.debug-legend-section:last-child {
    margin-bottom: 0;
}

.debug-legend-subtitle {
    font-size: 10px;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.debug-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: #495057;
}

.debug-legend-item.filter-checkbox {
    cursor: pointer;
    padding: 4px 6px;
    margin: 1px 0;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.debug-legend-item.filter-checkbox:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.debug-legend-item.filter-checkbox input[type="checkbox"] {
    cursor: pointer;
    width: 14px;
    height: 14px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}
