.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-combined-panel {
    position: absolute;
    z-index: 660;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 320px;
    padding: 12px;
    background: #f8f4ea;
    border: 1px solid rgba(156, 118, 55, 0.25);
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.12);
}

.statmap-combined-search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.statmap-search-svg {
    position: absolute;
    left: 10px;
    color: #7b7264;
    pointer-events: none;
}

.statmap-combined-search input {
    width: 100%;
    border: 1px solid #c2b9a7;
    border-radius: 2px;
    padding: 6px 30px 6px 32px;
    color: #23313f;
    font-size: 13px;
    outline: none;
    background: #ece8da;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.statmap-combined-search input::-webkit-search-cancel-button,
.statmap-combined-search input::-webkit-search-decoration,
.statmap-combined-search input::-webkit-search-results-button,
.statmap-combined-search input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.statmap-combined-search input:focus {
    border-color: #9c7637;
    background: #fff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(156, 118, 55, 0.15);
}

.statmap-combined-layer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.statmap-combined-label {
    font-size: 11px;
    color: #7b7264;
    font-weight: 500;
}

.statmap-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.statmap-select-wrapper select {
    width: 100%;
    border: 1px solid #c2b9a7;
    border-radius: 2px;
    padding: 6px 32px 6px 10px;
    background: #ece8da;
    color: #23313f;
    font-size: 13px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.statmap-select-wrapper select:focus {
    border-color: #9c7637;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(156, 118, 55, 0.15);
}

.statmap-select-svg {
    position: absolute;
    right: 10px;
    color: #7b7264;
    pointer-events: none;
}

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

.statmap-page .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    border-radius: 4px !important;
    overflow: hidden;
}

.statmap-page .leaflet-control-zoom-in,
.statmap-page .leaflet-control-zoom-out {
    background: #000000 !important;
    color: #ffffff !important;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    font-weight: bold;
    transition: background 0.2s, color 0.2s;
}

.statmap-page .leaflet-control-zoom-out {
    border-bottom: none !important;
}

.statmap-page .leaflet-control-zoom-in:hover,
.statmap-page .leaflet-control-zoom-out:hover {
    background: #222222 !important;
    color: #ffffff !important;
}

.statmap-layers-toggle {
    position: absolute;
    z-index: 1100;
    top: 10px;
    right: 10px;
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: #000000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s ease;
}

.statmap-layers-toggle:hover,
.statmap-layers-toggle:focus,
.statmap-layers-toggle.is-active {
    background: #222222;
    color: #ffffff;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

.statmap-layers-sidebar {
    position: absolute;
    z-index: 1110;
    top: 0;
    right: 0;
    display: flex;
    width: 25%;
    min-width: 320px;
    height: 100%;
    flex-direction: column;
    transform: translateX(100%);
    border-left: 1px solid rgba(156, 118, 55, 0.26);
    background: #f8f4ea;
    box-shadow: -10px 0 28px rgba(15, 23, 42, 0.22);
    color: #23313f;
    transition: transform 0.22s ease;
    pointer-events: none;
}

.statmap-layers-sidebar.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

.statmap-layers-sidebar-header {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(123, 118, 107, 0.18);
    padding: 8px 14px;
    background: #f6f0e1;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
    color: #2f5d3b;
    font-size: 15px;
    font-weight: 700;
}

.statmap-layers-sidebar-header span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}



.statmap-layers-close {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    border: 1px solid rgba(123, 118, 107, 0.18);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.42);
    color: #65758a;
    font-size: 22px;
    line-height: 1;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.statmap-layers-close:hover,
.statmap-layers-close:focus {
    border-color: rgba(123, 118, 107, 0.28);
    background: #fffaf0;
    color: #2f5d3b;
}

.statmap-layers-sidebar-body {
    flex: 1;
    overflow: auto;
    padding: 8px 14px 10px;
}

.statmap-info-sidebar {
    position: absolute;
    z-index: 1110;
    top: 0;
    right: 0;
    display: flex;
    width: 25%;
    min-width: 320px;
    height: 100%;
    flex-direction: column;
    transform: translateX(100%);
    border-left: 1px solid rgba(156, 118, 55, 0.26);
    background: #f8f4ea;
    box-shadow: -10px 0 28px rgba(15, 23, 42, 0.22);
    color: #23313f;
    transition: transform 0.22s ease;
    pointer-events: none;
}

.statmap-info-sidebar.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

.statmap-info-sidebar-header {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(123, 118, 107, 0.18);
    padding: 8px 14px;
    background: #f6f0e1;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
    color: #2f5d3b;
    font-size: 15px;
    font-weight: 700;
}

.statmap-info-sidebar-header span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.statmap-info-close {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    border: 1px solid rgba(123, 118, 107, 0.18);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.42);
    color: #65758a;
    font-size: 22px;
    line-height: 1;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    cursor: pointer;
}

.statmap-info-close:hover,
.statmap-info-close:focus {
    border-color: rgba(123, 118, 107, 0.28);
    background: #fffaf0;
    color: #2f5d3b;
}

.statmap-info-sidebar-body {
    flex: 1;
    overflow: auto;
    background: #fffaf3;
}

.statmap-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #65758a;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 5;
}

.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: 120px;
    left: 10px;
    width: 320px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid rgba(156, 118, 55, 0.25);
    border-radius: 4px;
    background: #fbf9f4;
    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-shell > .leaflet-control-container .leaflet-top.leaflet-right .leaflet-control-layers {
    display: none;
}

.statmap-layers-sidebar .leaflet-control-layers {
    display: block;
    width: 100%;
    float: none;
    clear: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.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-layers-sidebar .leaflet-control-layers-expanded::before {
    display: none;
}

.statmap-page .leaflet-control-layers label {
    display: flex;
    min-height: 30px;
    align-items: center;
    margin: 2px 0;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    color: #23313f;
    font-size: 14px;
    line-height: 1.35;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.statmap-page .leaflet-control-layers label > span {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
}

.statmap-layers-sidebar .leaflet-control-layers label:hover {
    background: rgba(156, 118, 55, 0.12);
}

.statmap-page .leaflet-control-layers-selector {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    margin: 0;
    border: 1px solid #9a9487;
    background-color: #fff;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    cursor: pointer;
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
}

.statmap-page .leaflet-control-layers-selector[type='radio'] {
    border-radius: 50%;
}

.statmap-page .leaflet-control-layers-selector[type='checkbox'] {
    border-radius: 4px;
}

.statmap-page .leaflet-control-layers-selector:checked {
    border-color: #7b766b;
    background-color: #7b766b;
}

.statmap-page .leaflet-control-layers-selector[type='radio']:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

.statmap-page .leaflet-control-layers-selector[type='checkbox']:checked {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

.statmap-page .leaflet-control-layers-selector:focus-visible {
    border-color: #7b766b;
    outline: 0;
    box-shadow: none;
}

.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: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(156, 118, 55, 0.16);
}

.statmap-layer-heatmap-section label {
    display: flex;
    min-height: 30px;
    align-items: center;
    margin: 2px 0;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    color: #23313f;
    font-size: 14px;
    line-height: 1.35;
}

.statmap-layer-heatmap-section label:hover {
    background: rgba(156, 118, 55, 0.12);
}

.statmap-layer-heatmap-section label > div {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
}

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

.statmap-year-wrap {
    margin-top: 2px;
    border: 0;
    border-radius: 0;
}

.statmap-year-wrap > label {
    margin: 2px 8px;
}

.statmap-year-header {
    display: flex;
    min-height: 24px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 2px;
    border: 0;
    padding: 2px 10px;
    background: transparent;
    border-radius: 0;
    color: #1a3a5c;
    font-weight: 600;
}

.statmap-year-title {
    color: #1a3a5c;
    font-size: 14px;
    font-weight: 600;
}

.statmap-year-value {
    font-size: 14px;
    font-weight: 700;
    color: #23313f;
}

.statmap-year-slider-wrap {
    display: flex;
    height: 24px;
    align-items: center;
    padding: 0 8px;
}

.statmap-year-slider {
    display: block;
    width: 100%;
    box-sizing: border-box;
    height: 24px;
    margin: 0;
    border: 0 !important;
    outline: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.statmap-year-slider:focus {
    outline: 0;
}

.statmap-year-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(123, 118, 107, 0.18);
}

.statmap-year-slider::-webkit-slider-runnable-track {
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(to right, #7b766b 0%, #7b766b var(--statmap-year-progress, 100%), #d8d0c0 var(--statmap-year-progress, 100%), #d8d0c0 100%);
    box-shadow: none;
}

.statmap-year-slider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -6px;
    border: 3px solid #f8f4ea;
    border-radius: 50%;
    background: #7b766b;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
    appearance: none;
    -webkit-appearance: none;
}

.statmap-year-slider::-moz-range-track {
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: #d8d0c0;
    box-shadow: none;
}

.statmap-year-slider::-moz-range-progress {
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: #7b766b;
    box-shadow: none;
}

.statmap-year-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 3px solid #f8f4ea;
    border-radius: 50%;
    background: #7b766b;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
}

.statmap-year-slider:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(123, 118, 107, 0.18);
}

.statmap-year-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    padding: 0 8px 6px;
    color: #65758a;
    font-size: 11px;
    line-height: 1.2;
}

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

.statmap-legend {
    position: absolute;
    z-index: 650;
    bottom: 12px;
    left: 12px;
    min-width: 170px;
    border: 1px solid rgba(156, 118, 55, 0.26);
    border-radius: 6px;
    padding: 10px 14px 10px;
    background: #f8f4ea;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.16);
    color: #23313f;
}

.statmap-legend-title {
    margin-bottom: 7px;
    color: #2f5d3b;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}



.statmap-legend-bar {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #fff3d9, #f4a020, #c0302a);
    margin-bottom: 4px;
    border: 1px solid rgba(156, 118, 55, 0.12);
}

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

.statmap-legend-total {
    margin-top: 6px;
    border-top: 1px solid rgba(156, 118, 55, 0.16);
    padding-top: 5px;
    color: #23313f;
    font-size: 11px;
}

.statmap-legend-total strong {
    color: #2f5d3b;
    font-weight: 700;
}

.statmap-legend-updated {
    margin-top: 4px;
    color: #7b8896;
    font-size: 9px;
    line-height: 1.1;
}


@media (max-width: 767.98px) {
    .statmap-combined-panel {
        top: 10px;
        left: 10px;
        width: calc(100% - 20px);
        max-width: 360px;
    }

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

    .statmap-search-results {
        top: 140px;
        left: 10px;
        width: calc(100% - 20px);
        max-width: 360px;
    }

    .statmap-page .leaflet-top.leaflet-left {
        top: 155px !important;
    }

    .statmap-layers-sidebar,
    .statmap-info-sidebar {
        width: min(88%, 360px);
        min-width: 0;
    }

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

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