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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    background: #e5e5e5;
}

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

.leaflet-control-attribution {
    display: none !important;
}

/* ── Stats Panel ── */

#stats-panel {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    padding: 8px 28px;
    text-align: center;
    min-width: 420px;
    transition: opacity 0.25s ease;
}

.stats-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #888;
    margin-bottom: 4px;
}

.stats-grid {
    display: flex;
    gap: 24px;
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #0a2540;
    line-height: 1.1;
    transition: opacity 0.2s ease;
}

.stat-name {
    font-size: 10px;
    color: #6b7280;
    margin-top: 2px;
    white-space: nowrap;
}

/* ── Filter Panel ── */

#filter-panel {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    padding: 10px 28px 8px;
    min-width: 400px;
}

.filter-label {
    font-size: 14px;
    font-weight: 700;
    color: #0a2540;
    text-align: center;
    margin-bottom: 6px;
}

.slider-track {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
}

.slider-highlight {
    position: absolute;
    height: 4px;
    background: #1e3a8a;
    border-radius: 2px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

.slider-track input[type="range"] {
    position: absolute;
    width: 100%;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    pointer-events: none;
}

.slider-track input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #1e3a8a;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slider-track input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 10px rgba(30, 58, 138, 0.3);
}

.slider-track input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 3px solid #1e3a8a;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.filter-years {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ── Detail Card ── */

#detail-card {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 2000;
    overflow-y: auto;
    padding: 20px 24px 24px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

#detail-card.card-hidden {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

#detail-card.card-visible {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

#card-close {
    position: sticky;
    top: 0;
    float: right;
    background: #f3f4f6;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    z-index: 1;
}

#card-close:hover {
    background: #e5e7eb;
    color: #111;
}

#card-content {
    padding-top: 8px;
}

.card-section {
    margin-bottom: 18px;
}

.card-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #9ca3af;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 5px 0;
    gap: 12px;
}

.card-label {
    font-size: 12px;
    color: #6b7280;
    flex-shrink: 0;
}

.card-value {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    text-align: right;
    word-break: break-word;
}

/* ── Overlap Badge ── */

.overlap-badge {
    background: #fff;
    color: #0a2540;
    font-size: 14px;
    font-weight: 700;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #1e3a8a;
    line-height: 1;
    pointer-events: none;
}

.overlap-badge span {
    margin-top: -1px;
}

/* ── Group Popup (Leaflet popup) ── */

.group-popup-wrapper .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.group-popup-wrapper .leaflet-popup-content {
    margin: 0;
    min-width: 220px;
    max-width: 320px;
}

.group-popup-wrapper .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: none;
}

.group-popup {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.group-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.group-popup-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
}

.group-popup-close:hover {
    color: #111;
}

.group-popup-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
}

.group-popup-item {
    display: flex;
    flex-direction: column;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.group-popup-item:hover {
    background: #f3f4f6;
}

.group-popup-name {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.group-popup-year {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 1px;
}

/* ── Responsive: bottom sheet for narrow screens ── */

@media (max-width: 768px) {
    #detail-card {
        width: 100%;
        height: 55vh;
        top: auto;
        bottom: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    #detail-card.card-hidden {
        transform: translateY(100%);
    }

    #detail-card.card-visible {
        transform: translateY(0);
    }

    #stats-panel {
        min-width: 300px;
        padding: 6px 16px;
    }

    .stat-value {
        font-size: 16px;
    }

    #filter-panel {
        min-width: 280px;
        padding: 8px 16px 6px;
    }
}
