.moscow-map-page {
    max-width: 1800px;
    margin: 0 auto;
}

.moscow-map-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

.map-filters {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.map-filter-label {
    display: block;
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
    color: #4b5563;
    margin: 14px 0 6px;
}

.map-filter-control {
    display: block;
    width: 100%;
    min-width: 0;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    line-height: 18px;
    padding: 7px 9px;
    outline: none;
}

.map-filter-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgb(59 130 246 / 12%);
}

.map-level-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background: #f3f4f6;
}

.map-level-control button {
    border-radius: 7px;
    padding: 7px 5px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

.map-level-control button[aria-pressed="true"] {
    color: #1d4ed8;
    background: #fff;
    box-shadow: 0 1px 3px rgb(15 23 42 / 12%);
}

.map-card {
    min-width: 0;
}

.map-canvas-wrap {
    position: relative;
    background: #f8fafc;
}

.moscow-map-canvas {
    height: 640px;
    width: 100%;
    background: #f8fafc;
}

.moscow-map-canvas .leaflet-interactive {
    cursor: pointer;
    transition: fill-opacity 120ms ease, stroke 120ms ease;
    outline: none;
}

.map-loading {
    position: absolute;
    z-index: 500;
    left: 50%;
    top: 16px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: rgb(255 255 255 / 94%);
    box-shadow: 0 4px 16px rgb(15 23 42 / 8%);
    color: #4b5563;
    font-size: 12px;
    padding: 8px 13px;
    pointer-events: none;
}

.map-loading.hidden {
    display: none;
}

.map-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: moscow-map-spin 700ms linear infinite;
}

@keyframes moscow-map-spin {
    to { transform: rotate(360deg); }
}

.map-hover-card {
    position: absolute;
    z-index: 500;
    left: 12px;
    top: 12px;
    width: min(260px, calc(100% - 24px));
    padding: 14px;
    border: 1px solid rgb(226 232 240 / 90%);
    border-radius: 12px;
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 12px 30px rgb(15 23 42 / 13%);
    pointer-events: none;
}

.map-hover-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.map-hover-metrics div {
    min-width: 0;
}

.map-hover-metrics div:last-child {
    grid-column: 1 / -1;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.map-hover-metrics span,
.map-detail-metric span {
    display: block;
    color: #6b7280;
    font-size: 11px;
    margin-bottom: 3px;
}

.map-hover-metrics strong {
    display: block;
    color: #111827;
    font-size: 13px;
    white-space: nowrap;
}

.map-legend-gradient {
    height: 9px;
    border-radius: 999px;
    background: #e5e7eb;
}

.map-legend-empty {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 1px solid #d1d5db;
    border-radius: 2px;
    background: #e5e7eb;
    vertical-align: -1px;
}

.map-detail-panel {
    position: sticky;
    top: 80px;
    min-height: 260px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.map-detail-metric {
    min-width: 0;
    padding: 10px;
    border-radius: 9px;
    background: #f8fafc;
}

.map-detail-metric strong {
    display: block;
    color: #111827;
    font-size: 13px;
    line-height: 18px;
    white-space: nowrap;
}

.map-histogram {
    display: flex;
    align-items: end;
    gap: 3px;
    height: 92px;
    margin-top: 12px;
}

.map-histogram-bar {
    flex: 1;
    min-width: 2px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: #60a5fa;
}

.map-histogram-bar:hover {
    background: #2563eb;
}

.map-filter-toggle {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
}

.leaflet-control-attribution {
    font-size: 9px !important;
    background: rgb(255 255 255 / 82%) !important;
}

@media (max-width: 1279px) {
    .moscow-map-layout {
        grid-template-columns: 230px minmax(0, 1fr);
    }

    .map-detail-panel {
        position: static;
        grid-column: 1 / -1;
        min-height: 0;
        max-height: none;
    }

    #map-detail-content .grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .moscow-map-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .map-filter-toggle {
        display: flex;
    }

    .map-filters {
        display: none;
        position: static;
        max-height: none;
    }

    .map-filters.open {
        display: block;
    }

    .moscow-map-canvas {
        height: min(560px, 64vh);
        min-height: 420px;
    }

    .map-detail-panel {
        grid-column: auto;
    }

    #map-detail-content .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-hover-card {
        display: none !important;
    }

    .leaflet-control-attribution {
        max-width: 85%;
        white-space: normal;
    }
}

@media (max-width: 380px) {
    .moscow-map-canvas {
        min-height: 380px;
    }
}
