.statmap-page {
    width: 100%;
    min-height: calc(100vh - 220px);
}

.statmap-shell {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 220px);
    overflow: hidden;
    background: #eef2f5;
}

.statmap-canvas {
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 460px;
}

.statmap-map-controls {
    position: absolute;
    z-index: 650;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 20px);
    border-radius: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.24);
    color: #1a3a5c;
}

.statmap-control-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.statmap-layer-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 12px;
}

.statmap-layer-control span,
.statmap-map-controls small {
    color: #65758a;
    white-space: nowrap;
}

.statmap-layer-control select {
    min-width: 210px;
    border: 1px solid #cfd6df;
    border-radius: 4px;
    padding: 4px 28px 4px 8px;
    background-color: #fff;
    color: #23313f;
    font-size: 13px;
    line-height: 1.25;
}

.statmap-page .leaflet-top.leaflet-left {
    top: 48px;
}

.statmap-map-search {
    position: absolute;
    z-index: 660;
    top: 10px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 6px;
    width: min(420px, calc(100% - 28px));
    transform: translateX(-50%);
    border-radius: 6px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.24);
}

.statmap-map-search input {
    flex: 1;
    min-width: 0;
    border: 1px solid #cfd6df;
    border-radius: 4px;
    padding: 5px 8px;
    color: #23313f;
    font-size: 13px;
    outline: none;
}

.statmap-map-search input:focus {
    border-color: #1a3a5c;
}

.statmap-search-clear {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #65758a;
    font-size: 20px;
    line-height: 1;
}

.statmap-search-clear:hover,
.statmap-search-clear:focus {
    background: #eef2f5;
    color: #23313f;
}

.statmap-status {
    position: absolute;
    z-index: 670;
    right: 18px;
    bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: min(420px, calc(100% - 36px));
    border-radius: 6px;
    padding: 8px 12px;
    background: rgba(26, 58, 92, 0.94);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.24);
    color: #fff;
    font-size: 13px;
    pointer-events: none;
}

.statmap-status::before {
    content: "";
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    background: #e6c689;
    border-radius: 50%;
    animation: statmap-pulse 1s ease-in-out infinite;
}

.statmap-status[data-statmap-state="error"]::before {
    display: none;
}

@keyframes statmap-pulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scale(0.85);
    }

    50% {
        opacity: 1;
        transform: scale(1.15);
    }
}

.statmap-search-results {
    position: absolute;
    z-index: 650;
    top: 60px;
    left: 50%;
    width: min(420px, calc(100% - 28px));
    max-height: 360px;
    overflow: auto;
    transform: translateX(-50%);
    border-radius: 8px;
    background: var(--bs-body-bg);
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.24);
}

.statmap-search-item {
    display: flex;
    width: 100%;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--bs-border-color);
    padding: 10px 12px;
    background: transparent;
    text-align: left;
}

.statmap-search-item:hover,
.statmap-search-item:focus {
    background: var(--bs-tertiary-bg);
}

.statmap-search-item strong {
    font-size: 13px;
    line-height: 1.25;
}

.statmap-search-item span {
    color: var(--bs-secondary-color);
    font-size: 12px;
    white-space: nowrap;
}

.statmap-search-empty {
    padding: 12px;
    color: var(--bs-secondary-color);
    font-size: 13px;
}

.statmap-popup {
    min-width: 230px;
    max-width: 350px;
}

.statmap-popup h3 {
    margin: 0 0 8px;
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 6px;
    color: #17324d;
    font-size: 15px;
    line-height: 1.25;
}

.statmap-popup-missing {
    color: #c00 !important;
}

.statmap-popup-row {
    display: flex;
    gap: 10px;
    margin: 4px 0;
    font-size: 12px;
}

.statmap-popup-row span {
    min-width: 82px;
    color: var(--bs-secondary-color);
}

.statmap-popup-row strong {
    font-weight: 600;
}

.statmap-members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 4px 0;
    table-layout: fixed;
}
.statmap-members-table th:first-child,
.statmap-members-table td:first-child {
    width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.statmap-members-table th:not(:first-child),
.statmap-members-table td:not(:first-child) {
    width: 20%;
    white-space: nowrap;
}
.statmap-members-table th,
.statmap-members-table td {
    padding: 3px 6px;
    border-bottom: 1px solid #e5e5e5;
}
.statmap-members-table thead th {
    font-weight: 600;
    font-size: 11px;
    color: #666;
    border-bottom: 2px solid #ccc;
}
.statmap-members-table tfoot tr {
    border-top: 2px solid #ccc;
}
.statmap-members-table tfoot th {
    font-weight: 700;
}
.statmap-members-table .text-end {
    text-align: right;
}

.statmap-popup-badge {
    display: inline-block;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
}

.statmap-popup-badge-ok {
    background: #e3f3e3;
    color: #176;
}

.statmap-popup-badge-unc {
    background: #fdf0d5;
    color: #a60;
}

.statmap-popup-notice {
    margin-top: 8px;
    border-left: 3px solid #d06b39;
    border-radius: 4px;
    padding: 6px 8px;
    background: #fff3ec;
    color: #8a3b13;
    font-size: 12px;
}

.statmap-popup-notice-alert {
    border-left-color: #e05a3a;
    background: #fff3f0;
    color: #a33;
}

.statmap-popup-notice-restored {
    border-left-color: #3a9a4a;
    background: #eef7ee;
    color: #276;
}

.statmap-page .leaflet-control-layers {
    border: 0;
    border-radius: 6px;
    padding: 6px 10px 8px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.24);
    color: #23313f;
    font-size: 12px;
}

.statmap-page .leaflet-control-layers-expanded::before {
    content: 'Шари карти';
    display: block;
    margin-bottom: 5px;
    border-bottom: 1px solid #e5e9ef;
    padding-bottom: 4px;
    color: #1a3a5c;
    font-size: 12px;
    font-weight: 600;
}

.statmap-page .leaflet-control-layers label {
    margin: 2px 0;
    cursor: pointer;
}

.statmap-page .leaflet-control-layers-selector {
    margin-top: 0;
}

.statmap-label-icon {
    width: 0 !important;
    height: 0 !important;
    overflow: visible;
    border: 0;
    background: transparent;
}

.statmap-label-oblast,
.statmap-label-rayon {
    position: absolute;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 0 2px #fff, 0 0 4px #fff, 0 0 4px #fff;
}

.statmap-label-oblast {
    color: #3f3320;
    font: 600 12px/1 "Segoe UI", Arial, sans-serif;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.statmap-label-rayon {
    color: #544326;
    font: 400 10.5px/1 "Segoe UI", Arial, sans-serif;
}

/* ── Heatmap toggle — appended to Leaflet layer control container ────────── */

.statmap-layer-heatmap-section {
    margin-top: 3px;
    padding-top: 5px;
    border-top: 1px solid #ddd;
}

.statmap-layer-heatmap-section label {
    display: block;
    margin: 2px 0;
    cursor: pointer;
}

/* ── Year slider (inside Leaflet layer control) ───────────────────────────── */

.statmap-year-wrap {
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px solid #eee;
}

.statmap-year-header {
    margin-bottom: 2px;
}

.statmap-year-value {
    font-size: 13px;
    font-weight: 700;
    color: #1a3a5c;
}

.statmap-year-slider {
    display: block;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    accent-color: #1a3a5c;
}

/* ── Heatmap legend ──────────────────────────────────────────────────────── */

.statmap-legend {
    position: absolute;
    z-index: 650;
    bottom: 56px;
    left: 10px;
    min-width: 160px;
    border-radius: 6px;
    padding: 9px 12px 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.24);
}

.statmap-legend-title {
    margin-bottom: 6px;
    color: #1a3a5c;
    font-size: 12px;
    font-weight: 600;
}

.statmap-legend-bar {
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(to right, #fff3d9, #f4a020, #c0302a);
    margin-bottom: 3px;
}

.statmap-legend-scale {
    display: flex;
    justify-content: space-between;
    color: #65758a;
    font-size: 10px;
}

.statmap-legend-total {
    margin-top: 5px;
    border-top: 1px solid #e5e9ef;
    padding-top: 4px;
    color: #65758a;
    font-size: 11px;
}

.statmap-legend-total strong {
    color: #23313f;
}


@media (max-width: 767.98px) {
    .statmap-map-controls {
        right: 10px;
        flex-wrap: wrap;
        gap: 6px 8px;
    }

    .statmap-control-title {
        width: 100%;
    }

    .statmap-layer-control {
        width: 100%;
    }

    .statmap-layer-control select {
        flex: 1;
        min-width: 0;
    }

    .statmap-map-controls small {
        display: none;
    }

    .statmap-legend {
        bottom: auto;
        top: 112px;
        left: 10px;
        min-width: 140px;
    }

    .statmap-map-search {
        top: 64px;
    }

    .statmap-search-results {
        top: 114px;
    }

    .statmap-shell,
    .statmap-canvas {
        min-height: 520px;
    }

    .statmap-canvas {
        height: 68vh;
    }
}
