/* Контейнер карты */
.mapContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
}

/* =====================================
   ИСПРАВЛЕНИЕ POPUP LEAFLET
===================================== */
.leaflet-popup-content {
    width: 900px !important;
    max-width: none !important;
    margin: 0 !important;
}

.leaflet-popup-content-wrapper {
    padding: 0 !important;
    width: 900px !important;
    max-width: none !important;
}

.leaflet-popup {
    max-width: none !important;
}

/* =====================================
   БАЛЛОН ТЕРРИТОРИИ
===================================== */
.territory-balloon {
    position: relative;
    width: 350px !important;
    max-width: none !important;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.20);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1e293b;
    overflow: visible;
}


/* =====================================================
   TERRITORY BALLOON
===================================================== */

.territory-balloon-wrapper {
    position: relative;
    transform: translate(-50%, -100%) scale(1);
    transform-origin: bottom center;
    pointer-events: auto;
    z-index: 1000;
}

.territory-balloon {
    position: relative;
    width: 320px;
    min-width: 280px;
    max-width: 360px;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(77, 139, 105, .15);
    border-radius: 18px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, .18);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    font-family: Arial, sans-serif;
    overflow: visible;
}

/* =====================================================
   СТРЕЛКА БАЛУНА
===================================================== */

/* Внешняя часть стрелки */

.territory-balloon::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -17px;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 17px solid transparent;
    border-right: 17px solid transparent;
    border-top: 17px solid rgba(77, 139, 105, .15);
    z-index: 1;
}

/* Внутренняя белая часть стрелки */

.territory-balloon::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -15px;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid rgba(255, 255, 255, .97);
    z-index: 2;
}

/* =====================================================
   HEADER
===================================================== */

.territory-balloon__header {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-right: 38px;
}

.territory-balloon__title-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

.territory-balloon__title {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 700;
    color: #26352d;
    overflow-wrap: anywhere;
}

.territory-balloon__zone {
    margin-top: 5px;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 600;
    color: #4d8b69;
}

.territory-balloon__close {
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(0, 0, 0, .05);
    color: #59645e;
    font-size: 21px;
    line-height: 30px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.territory-balloon__close:hover {
    background: rgba(77, 139, 105, .1);
    color: #4d8b69;
    transform: rotate(90deg);
}

/* =====================================================
   DIVIDER
===================================================== */

.territory-balloon__divider {
    width: 100%;
    height: 1px;
    margin: 10px 0;
    background: #ecefed;
}

/* =====================================================
   BODY
===================================================== */

.territory-balloon__body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.territory-balloon__section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.territory-balloon__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a958f;
}

.territory-balloon__value {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #33433a;
    overflow-wrap: anywhere;
}

.territory-balloon__value i {
    flex-shrink: 0;
    margin-top: 2px;
}

/* =====================================================
   FOOTER
===================================================== */

.territory-balloon__footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #ecefed;
}

.territory-balloon__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    padding: 8px 14px;
    box-sizing: border-box;
    border-radius: 10px;
    background: #4d8b69;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, transform .2s ease;
}

.territory-balloon__button:hover {
    background: #3f7558;
    color: #fff;
    transform: translateY(-1px);
}


/* =====================================================
   МУНИЦИПАЛЬНЫЕ ОКРУГА
===================================================== */

.districtSection {
    margin-top: 24px;
}

.districtList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 500px;
    overflow: hidden;
    opacity: 1;
    transition: max-height .35s ease, opacity .25s ease;
}

.districtList.collapsed {
    max-height: 0;
    opacity: 0;
}

.districtItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    transition: background .25s ease;
}

.districtItem:hover {
    background: rgba(220, 20, 60, .06);
}

.districtInfo {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 10px;
}

.districtIcon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(220, 20, 60, .12);
    color: #dc143c;
}

.districtName {
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    color: #25352d;
    overflow-wrap: anywhere;
}

.districtEmpty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #8b9690;
    font-size: 14px;
}

/* =====================================================
   DISTRICT BALLOON
===================================================== */

.district-balloon {
    position: relative;
    min-width: 280px;
    max-width: 360px;
    padding: 18px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(220, 20, 60, .15);
    border-radius: 18px;
    box-shadow: 0 15px 45px rgba(0, 0, 0, .18);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    overflow: visible;
}

.district-balloon__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.district-balloon__title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 700;
    color: #26352d;
    overflow-wrap: anywhere;
}

.district-balloon__close {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(0, 0, 0, .05);
    color: #59645e;
    font-size: 21px;
    line-height: 30px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.district-balloon__close:hover {
    background: rgba(220, 20, 60, .1);
    color: #dc143c;
    transform: rotate(90deg);
}

.district-balloon__divider {
    height: 1px;
    margin: 14px 0;
    background: #ecefed;
}

.district-balloon__body {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.district-balloon__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a958f;
}

.district-balloon__value {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #33433a;
    overflow-wrap: anywhere;
}

.district-balloon__footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #ecefed;
}

.district-balloon__points {
    font-size: 12px;
    line-height: 1.4;
    color: #8a958f;
}

/* =====================================
   МОБИЛЬНАЯ ВЕРСИЯ
===================================== */
@media (max-width: 700px) {
    .leaflet-popup-content {
        width: calc(100vw - 30px) !important;
    }

    .leaflet-popup-content-wrapper {
        width: calc(100vw - 30px) !important;
    }

    .territory-balloon {
        width: calc(100vw - 30px) !important;
    }

    .territory-balloon__header {
        padding: 16px 18px;
    }

    .territory-balloon__body {
        padding: 18px;
    }

    .territory-balloon__footer {
        padding: 0 18px 18px;
    }

    .territory-balloon__button {
        width: 100%;
    }
}


/* Инструменты */

/* =====================================
   LAYERS MENU
===================================== */

.layersMenu{
position:fixed;
width:220px;
background:#fff;
border:1px solid #e5e7eb;
border-radius:16px;
box-shadow:0 12px 35px rgba(0,0,0,.18);
padding:8px;
z-index:10000;
opacity:0;
visibility:hidden;
transform:translateY(-6px);
transition:opacity .2s ease,transform .2s ease,visibility .2s ease;
}

.layersMenu.active{
opacity:1;
visibility:visible;
transform:translateY(0);
}

.layersMenuHeader{
padding:10px 12px 8px;
font-size:13px;
font-weight:700;
color:#6b7280;
}

.layersMenuList{
display:flex;
flex-direction:column;
gap:3px;
}

.layersMenuItem{
width:100%;
display:flex;
align-items:center;
gap:10px;
border:none;
background:transparent;
border-radius:11px;
padding:10px;
cursor:pointer;
color:#1f2937;
text-align:left;
transition:background .2s ease;
}

.layersMenuItem:hover{
background:#f3f4f6;
}

.layersMenuItem.active{
background:#eef5ff;
color:#2563eb;
}

.layersMenuIcon{
width:30px;
height:30px;
display:flex;
align-items:center;
justify-content:center;
border-radius:8px;
background:#f3f4f6;
flex-shrink:0;
}

.layersMenuItem.active .layersMenuIcon{
background:#dbeafe;
}

.layersMenuText{
flex:1;
font-size:14px;
font-weight:600;
}

.layersMenuCheck{
width:20px;
display:flex;
justify-content:center;
opacity:0;
}

.layersMenuItem.active .layersMenuCheck{
opacity:1;
}




.territoryChooserOverlay{
position:fixed;
inset:0;
z-index:99999;
display:flex;
align-items:center;
justify-content:center;
background:rgba(0,0,0,.18);
backdrop-filter:blur(3px);
}
.territoryChooser{
width:min(460px,calc(100vw - 40px));
max-height:min(600px,calc(100vh - 40px));
overflow:hidden;
background:#fff;
border-radius:18px;
box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.territoryChooserHeader{
display:flex;
align-items:center;
justify-content:space-between;
padding:18px 20px;
border-bottom:1px solid #e5e7eb;
}
.territoryChooserTitle{
font-size:18px;
font-weight:700;
color:#111827;
}
.territoryChooserClose{
width:34px;
height:34px;
display:flex;
align-items:center;
justify-content:center;
padding:0;
border:0;
border-radius:10px;
background:#f3f4f6;
color:#374151;
cursor:pointer;
font-size:16px;
}
.territoryChooserClose:hover{
background:#e5e7eb;
}
.territoryChooserList{
padding:10px;
max-height:500px;
overflow-y:auto;
}
.territoryChooserItem{
width:100%;
display:flex;
align-items:center;
gap:12px;
padding:12px;
border:0;
border-radius:12px;
background:transparent;
text-align:left;
cursor:pointer;
transition:background .15s ease;
}
.territoryChooserItem:hover{
background:#f3f4f6;
}
.territoryChooserIcon{
width:42px;
height:42px;
flex:0 0 42px;
display:flex;
align-items:center;
justify-content:center;
border-radius:12px;
color:#fff;
font-size:17px;
}
.territoryChooserContent{
min-width:0;
flex:1;
}
.territoryChooserName{
font-size:15px;
font-weight:700;
color:#111827;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.territoryChooserCategory{
margin-top:3px;
font-size:12px;
color:#6b7280;
}
.territoryChooserDescription{
margin-top:5px;
font-size:12px;
line-height:1.4;
color:#9ca3af;
display:-webkit-box;
-webkit-line-clamp:2;
-webkit-box-orient:vertical;
overflow:hidden;
}
.territoryChooserNumber{
font-size:12px;
font-weight:600;
color:#9ca3af;
}

/* Рисование */

/* ============================================
USER DRAWING
============================================ */

.drawingPanel{
    position:fixed;
    top:25px;
    right:25px;
    width:320px;
    z-index:20000;
    overflow:hidden;
    box-sizing:border-box;
    border:1px solid #e5e7eb;
    border-radius:18px;
    background:#fff;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
    font-family:inherit;
}

.drawingPanelHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:58px;
    padding:0 16px;
    box-sizing:border-box;
    border-bottom:1px solid #e5e7eb;
    background:#f8fafc;
}

.drawingPanelTitle{
    display:flex;
    align-items:center;
    gap:9px;
    color:#1f2937;
    font-size:15px;
    font-weight:700;
}

.drawingPanelTitle i{
    color:#2563eb;
    font-size:16px;
}

.drawingCloseButton{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#6b7280;
    font-size:14px;
    cursor:pointer;
    transition:background .18s ease,color .18s ease,transform .18s ease;
}

.drawingCloseButton:hover{
    background:#e5e7eb;
    color:#111827;
}

.drawingCloseButton:active{
    transform:scale(.94);
}

.drawingPanelContent{
    padding:17px;
    box-sizing:border-box;
}

.drawingInstruction{
    margin-bottom:16px;
    color:#6b7280;
    font-size:13px;
    line-height:1.55;
}

.drawingStats{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-bottom:15px;
}

.drawingStat{
    min-width:0;
    padding:13px 10px;
    box-sizing:border-box;
    border:1px solid #eef2f7;
    border-radius:12px;
    background:#f8fafc;
    text-align:center;
}

.drawingStatLabel{
    margin-bottom:5px;
    color:#6b7280;
    font-size:11px;
    font-weight:600;
}

.drawingStatValue{
    overflow:hidden;
    color:#1d4ed8;
    font-size:18px;
    font-weight:800;
    line-height:1.2;
    text-overflow:ellipsis;
    white-space:nowrap;
}

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

.drawingFinishButton,
.drawingCancelButton{
    width:100%;
    height:42px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    box-sizing:border-box;
    border:0;
    border-radius:10px;
    font-family:inherit;
    font-size:13px;
    font-weight:700;
    cursor:pointer;
    transition:background .18s ease,color .18s ease,transform .18s ease,box-shadow .18s ease;
}

.drawingFinishButton{
    background:#2563eb;
    color:#fff;
    box-shadow:0 3px 10px rgba(37,99,235,.18);
}

.drawingFinishButton:hover{
    background:#1d4ed8;
    box-shadow:0 5px 14px rgba(37,99,235,.24);
}

.drawingFinishButton:active,
.drawingCancelButton:active{
    transform:translateY(1px);
}

.drawingCancelButton{
    background:#f3f4f6;
    color:#374151;
}

.drawingCancelButton:hover{
    background:#e5e7eb;
    color:#111827;
}


/* ============================================
DRAWING BUTTON ACTIVE
============================================ */

.toolButton.active{
    background:#2563eb;
    color:#fff;
    box-shadow:0 4px 12px rgba(37,99,235,.2);
}

.toolButton.active:hover{
    background:#1d4ed8;
}


/* ============================================
POLYGON VERTICES
============================================ */

.drawingVertex{
    position:relative;
    width:11px;
    height:11px;
    box-sizing:border-box;
    border:2px solid #2563eb;
    border-radius:50%;
    background:#fff;
    transform:translate(-50%,-50%);
    box-shadow:0 2px 7px rgba(0,0,0,.28);
    cursor:grab;
    transition:width .12s ease,height .12s ease,border-color .12s ease,box-shadow .12s ease;
}

.drawingVertex:hover{
    width:15px;
    height:15px;
    border-color:#1d4ed8;
    box-shadow:0 3px 10px rgba(0,0,0,.35);
}

.drawingVertex:active{
    cursor:grabbing;
}


/* ============================================
POLYGON MIDPOINTS
============================================ */

.drawingMidpoint{
    position:relative;
    width:8px;
    height:8px;
    box-sizing:border-box;
    border:2px solid #fff;
    border-radius:50%;
    background:#2563eb;
    transform:translate(-50%,-50%);
    box-shadow:0 1px 5px rgba(0,0,0,.24);
    cursor:pointer;
    opacity:.72;
    transition:width .12s ease,height .12s ease,opacity .12s ease;
}

.drawingMidpoint:hover{
    width:12px;
    height:12px;
    opacity:1;
}


/* ============================================
Рисование, редактирование нарисованных полигонов и линейка при рисовании
============================================ */

.drawingAreaPopup{
    min-width:220px;
    max-width:280px;
    display:flex;
    align-items:center;
    gap:10px;
    box-sizing:border-box;
    padding:10px 12px;
    border:1px solid #e5e7eb;
    border-radius:13px;
    background:#fff;
    box-shadow:0 7px 22px rgba(0,0,0,.2);
    font-family:inherit;
    white-space:nowrap;
}

.drawingAreaPopupIcon{
    width:36px;
    height:36px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:9px;
    background:#eff6ff;
    color:#2563eb;
    font-size:15px;
}

.drawingAreaPopupContent{
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:2px;
}

.drawingAreaPopupTitle{
    max-width:170px;
    overflow:hidden;
    color:#6b7280;
    font-size:11px;
    font-weight:600;
    line-height:1.3;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.drawingAreaPopupValue{
    color:#111827;
    font-size:17px;
    font-weight:800;
    line-height:1.2;
}

.drawingAreaPopupClose{
    width:26px;
    height:26px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    margin-left:auto;
    padding:0;
    border:0;
    border-radius:7px;
    background:transparent;
    color:#9ca3af;
    font-size:12px;
    cursor:pointer;
    transition:background .18s ease,color .18s ease;
}

.drawingAreaPopupClose:hover{
    background:#f3f4f6;
    color:#111827;
}


.drawingLoadingBlock{
    display:none;
    margin-bottom:15px;
    padding:13px;
    border:1px solid #e5e7eb;
    border-radius:12px;
    background:#f8fafc;
}
.drawingLoadingText{
    margin-bottom:9px;
    color:#6b7280;
    font-size:12px;
    font-weight:600;
}
.drawingLoadingTrack{
    width:100%;
    height:6px;
    overflow:hidden;
    border-radius:999px;
    background:#e5e7eb;
}
.drawingLoadingBar{
    width:35%;
    height:100%;
    border-radius:999px;
    background:#2563eb;
    animation:drawingLoading 1.1s ease-in-out infinite;
}
@keyframes drawingLoading{
    0%{transform:translateX(-130%)}
    50%{transform:translateX(180%)}
    100%{transform:translateX(320%)}
}
.drawingLoading{
    cursor:wait;
}
.drawingLoadError{
    opacity:.75;
}
.drawingPanel{
    position:fixed;
    top:25px;
    right:25px;
    width:330px;
    z-index:20000;
    overflow:hidden;
    box-sizing:border-box;
    border:1px solid #e5e7eb;
    border-radius:18px;
    background:#fff;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
}
.drawingPanelHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:58px;
    padding:0 16px;
    box-sizing:border-box;
    border-bottom:1px solid #e5e7eb;
    background:#f8fafc;
}
.drawingPanelTitle{
    display:flex;
    align-items:center;
    gap:9px;
    color:#1f2937;
    font-size:15px;
    font-weight:700;
}
.drawingPanelTitle i{
    color:#2563eb;
}
.drawingPanelTitleText{
    color:#1f2937;
}
.drawingCloseButton{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#6b7280;
    cursor:pointer;
}
.drawingCloseButton:hover{
    background:#e5e7eb;
    color:#111827;
}
.drawingPanelContent{
    padding:17px;
}
.drawingInstruction{
    margin-bottom:15px;
    color:#6b7280;
    font-size:13px;
    line-height:1.55;
}
.drawingRulerControl{
    display:flex;
    margin-bottom:15px;
}
.drawingRulerButton{
    width:100%;
    height:42px;
    display:flex;
    align-items:center;
    gap:9px;
    padding:0 11px;
    border:1px solid #e5e7eb;
    border-radius:11px;
    background:#fff;
    color:#374151;
    cursor:pointer;
    transition:background .18s ease,border-color .18s ease,color .18s ease;
}
.drawingRulerButton:hover{
    border-color:#cbd5e1;
    background:#f8fafc;
}
.drawingRulerButton.active{
    border-color:#2563eb;
    background:#eff6ff;
    color:#1d4ed8;
}
.drawingRulerIcon{
    width:30px;
    height:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:8px;
    background:#f3f4f6;
    color:#6b7280;
}
.drawingRulerButton.active .drawingRulerIcon{
    background:#2563eb;
    color:#fff;
}
.drawingRulerText{
    flex:1;
    text-align:left;
    font-size:13px;
    font-weight:700;
}
.drawingRulerStatus{
    color:#9ca3af;
    font-size:11px;
    font-weight:700;
}
.drawingRulerButton.active .drawingRulerStatus{
    color:#2563eb;
}
.drawingStats{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-bottom:15px;
}
.drawingStat{
    padding:13px 10px;
    border:1px solid #eef2f7;
    border-radius:12px;
    background:#f8fafc;
    text-align:center;
}
.drawingStatLabel{
    margin-bottom:5px;
    color:#6b7280;
    font-size:11px;
    font-weight:600;
}
.drawingStatValue{
    overflow:hidden;
    color:#1d4ed8;
    font-size:18px;
    font-weight:800;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.drawingActions{
    display:flex;
    flex-direction:column;
    gap:8px;
}
.drawingFinishButton,
.drawingCancelButton{
    width:100%;
    height:42px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    border:0;
    border-radius:10px;
    font-size:13px;
    font-weight:700;
    cursor:pointer;
}
.drawingFinishButton{
    background:#2563eb;
    color:#fff;
}
.drawingFinishButton:hover{
    background:#1d4ed8;
}
.drawingCancelButton{
    background:#f3f4f6;
    color:#374151;
}
.drawingCancelButton:hover{
    background:#e5e7eb;
}
.toolButton.active{
    background:#2563eb;
    color:#fff;
}
.drawingVertex{
    width:11px;
    height:11px;
    box-sizing:border-box;
    border:2px solid #2563eb;
    border-radius:50%;
    background:#fff;
    transform:translate(-50%,-50%);
    box-shadow:0 2px 7px rgba(0,0,0,.28);
    cursor:grab;
}
.drawingVertex:hover{
    width:15px;
    height:15px;
    border-width:3px;
}
.drawingVertex:active{
    cursor:grabbing;
}
.drawingMidpoint{
    width:8px;
    height:8px;
    box-sizing:border-box;
    border:2px solid #fff;
    border-radius:50%;
    background:#2563eb;
    transform:translate(-50%,-50%);
    box-shadow:0 1px 5px rgba(0,0,0,.24);
    cursor:pointer;
    opacity:.72;
}
.drawingMidpoint:hover{
    width:12px;
    height:12px;
    opacity:1;
}
.drawingAreaPopup{
    min-width:220px;
    max-width:280px;
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px 12px;
    box-sizing:border-box;
    border:1px solid #e5e7eb;
    border-radius:13px;
    background:#fff;
    box-shadow:0 7px 22px rgba(0,0,0,.2);
}
.drawingAreaPopupIcon{
    width:36px;
    height:36px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:9px;
    background:#eff6ff;
    color:#2563eb;
}
.drawingAreaPopupContent{
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:2px;
}
.drawingAreaPopupTitle{
    max-width:170px;
    overflow:hidden;
    color:#6b7280;
    font-size:11px;
    font-weight:600;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.drawingAreaPopupValue{
    color:#111827;
    font-size:17px;
    font-weight:800;
}
.drawingAreaPopupClose{
    width:26px;
    height:26px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    margin-left:auto;
    border:0;
    border-radius:7px;
    background:transparent;
    color:#9ca3af;
    cursor:pointer;
}
.drawingAreaPopupClose:hover{
    background:#f3f4f6;
    color:#111827;
}
.drawingEditorPanel{
    position:fixed;
    top:25px;
    right:25px;
    width:340px;
    z-index:30000;
    overflow:hidden;
    box-sizing:border-box;
    border:1px solid #e5e7eb;
    border-radius:18px;
    background:#fff;
    box-shadow:0 10px 35px rgba(0,0,0,.25);
}
.drawingEditorHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:58px;
    padding:0 16px;
    box-sizing:border-box;
    border-bottom:1px solid #e5e7eb;
    background:#f8fafc;
}
.drawingEditorTitle{
    display:flex;
    align-items:center;
    gap:9px;
    color:#1f2937;
    font-size:15px;
    font-weight:700;
}
.drawingEditorTitle i{
    color:#2563eb;
}
.drawingEditorClose{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#6b7280;
    cursor:pointer;
}
.drawingEditorClose:hover{
    background:#e5e7eb;
    color:#111827;
}
.drawingEditorBody{
    padding:17px;
}
.drawingEditorLabel{
    display:block;
    margin-bottom:7px;
    color:#374151;
    font-size:12px;
    font-weight:700;
}
.drawingEditorName{
    width:100%;
    height:42px;
    margin-bottom:17px;
    padding:0 12px;
    box-sizing:border-box;
    border:1px solid #d1d5db;
    border-radius:10px;
    outline:none;
    background:#fff;
    color:#111827;
    font-size:14px;
}
.drawingEditorName:focus{
    border-color:#2563eb;
    box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.drawingEditorColors{
    display:flex;
    gap:11px;
    margin-bottom:18px;
}
.drawingEditorColor{
    width:34px;
    height:34px;
    padding:0;
    box-sizing:border-box;
    border:3px solid transparent;
    border-radius:50%;
    background:var(--editor-color);
    cursor:pointer;
}
.drawingEditorColor:hover{
    transform:scale(1.08);
}
.drawingEditorColor.active{
    border-color:#fff;
    box-shadow:0 0 0 2px var(--editor-color),0 3px 8px rgba(0,0,0,.2);
}
.drawingEditorArea{
    margin-bottom:17px;
    padding:13px 12px;
    box-sizing:border-box;
    border:1px solid #eef2f7;
    border-radius:11px;
    background:#f8fafc;
    text-align:center;
}
.drawingEditorAreaLabel{
    margin-bottom:4px;
    color:#6b7280;
    font-size:11px;
}
.drawingEditorAreaValue{
    color:#111827;
    font-size:19px;
    font-weight:800;
}
.drawingEditorActions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:9px;
}
.drawingEditorCancel,
.drawingEditorSave{
    height:41px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    border:0;
    border-radius:10px;
    font-size:13px;
    font-weight:700;
    cursor:pointer;
}
.drawingEditorCancel{
    background:#f3f4f6;
    color:#374151;
}
.drawingEditorCancel:hover{
    background:#e5e7eb;
}
.drawingEditorSave{
    background:#2563eb;
    color:#fff;
}
.drawingEditorSave:hover{
    background:#1d4ed8;
}
.drawingRulerDistance{
    position:fixed;
    z-index:40000;
    display:none;
    padding:7px 10px;
    border:1px solid #dbeafe;
    border-radius:9px;
    background:#fff;
    color:#1d4ed8;
    box-shadow:0 5px 18px rgba(0,0,0,.2);
    font-size:13px;
    font-weight:800;
    pointer-events:none;
    white-space:nowrap;
}
body.drawingRulerCursor .mapContainer{
    cursor:crosshair!important;
}
.drawingRulerButton{
    position:relative;
}
.drawingRulerButton.active{
    border-color:#2563eb;
    background:#eff6ff;
    color:#1d4ed8;
}
.drawingRulerButton.active .drawingRulerIcon{
    background:#2563eb;
    color:#fff;
}
.drawingRulerStatus{
    margin-left:auto;
    color:#9ca3af;
    font-size:11px;
    font-weight:700;
}
.drawingRulerButton.active .drawingRulerStatus{
    color:#2563eb;
}
@media(max-width:600px){
    .drawingPanel,
    .drawingEditorPanel{
        top:15px;
        right:15px;
        left:15px;
        width:auto;
    }
}

/* Инструмент линейка */

.measurementPanel{
    position:fixed;
    top:25px;
    right:25px;
    width:300px;
    z-index:30000;
    overflow:hidden;
    border:1px solid rgba(255,255,255,.7);
    border-radius:18px;
    background:rgba(255,255,255,.96);
    box-shadow:0 15px 45px rgba(0,0,0,.18);
    backdrop-filter:blur(18px);
    -webkit-backdrop-filter:blur(18px);
}
.measurementPanelHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:15px 16px;
    border-bottom:1px solid #eef0f3;
}
.measurementPanelTitle{
    display:flex;
    align-items:center;
    gap:11px;
}
.measurementPanelIcon{
    width:38px;
    height:38px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:11px;
    background:#eff6ff;
    color:#2563eb;
    font-size:16px;
}
.measurementPanelTitleText{
    color:#111827;
    font-size:15px;
    font-weight:800;
}
.measurementPanelSubtitle{
    margin-top:2px;
    color:#9ca3af;
    font-size:11px;
}
.measurementPanelClose{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#9ca3af;
    cursor:pointer;
    transition:.18s;
}
.measurementPanelClose:hover{
    background:#f3f4f6;
    color:#374151;
}
.measurementPanelBody{
    padding:15px 16px 16px;
}
.measurementPanelStats{
    display:grid;
    grid-template-columns:1.4fr .8fr;
    gap:10px;
}
.measurementPanelStat{
    padding:12px;
    border:1px solid #eef0f3;
    border-radius:12px;
    background:#f8fafc;
}
.measurementPanelStatLabel{
    margin-bottom:5px;
    color:#9ca3af;
    font-size:10px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.04em;
}
.measurementPanelStatValue{
    color:#111827;
    font-size:18px;
    font-weight:800;
}
.measurementPanelHint{
    margin:13px 2px;
    color:#6b7280;
    font-size:12px;
    line-height:1.45;
}
.measurementFinishButton{
    width:100%;
    height:40px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    border:0;
    border-radius:10px;
    background:#2563eb;
    color:#fff;
    font-size:12px;
    font-weight:800;
    cursor:pointer;
    transition:.18s;
}
.measurementFinishButton:hover{
    background:#1d4ed8;
}
.measurementDistance{
    position:fixed;
    z-index:40000;
    display:none;
    padding:7px 10px;
    border:1px solid #dbeafe;
    border-radius:9px;
    background:#fff;
    color:#1d4ed8;
    box-shadow:0 5px 18px rgba(0,0,0,.2);
    font-size:13px;
    font-weight:800;
    pointer-events:none;
    white-space:nowrap;
}
.measurementDistance::before{
    content:'';
    display:inline-block;
    width:6px;
    height:6px;
    margin-right:6px;
    vertical-align:middle;
    border-radius:50%;
    background:#2563eb;
}
body.measurementCursor .mapContainer{
    cursor:crosshair!important;
}
.toolButton.active{
    background:#2563eb;
    color:#fff;
}

/* Инструмент загрузка координат для создания территории  */

.territoryImportOverlay{
    position:fixed;
    inset:0;
    z-index:50000;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    box-sizing:border-box;
    background:rgba(15,23,42,.28);
    backdrop-filter:blur(8px);
    -webkit-backdrop-filter:blur(8px);
}
.territoryImportModal{
    width:520px;
    max-width:100%;
    overflow:hidden;
    border:1px solid rgba(255,255,255,.8);
    border-radius:22px;
    background:rgba(255,255,255,.97);
    box-shadow:0 25px 70px rgba(0,0,0,.25);
}
.territoryImportHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:18px 20px;
    border-bottom:1px solid #eef0f3;
}
.territoryImportHeaderInfo{
    display:flex;
    align-items:center;
    gap:12px;
}
.territoryImportIcon{
    width:44px;
    height:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:13px;
    background:#ecfdf5;
    color:#059669;
    font-size:18px;
}
.territoryImportTitle{
    color:#111827;
    font-size:17px;
    font-weight:800;
}
.territoryImportSubtitle{
    margin-top:3px;
    color:#9ca3af;
    font-size:11px;
}
.territoryImportClose{
    width:34px;
    height:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:10px;
    background:transparent;
    color:#9ca3af;
    cursor:pointer;
    transition:.18s;
}
.territoryImportClose:hover{
    background:#f3f4f6;
    color:#374151;
}
.territoryImportOptions{
    display:flex;
    flex-direction:column;
    gap:10px;
    padding:20px;
}
.territoryImportOption{
    width:100%;
    display:flex;
    align-items:center;
    gap:13px;
    padding:14px;
    border:1px solid #e5e7eb;
    border-radius:15px;
    background:#fff;
    text-align:left;
    cursor:pointer;
    transition:
        border-color .18s ease,
        background .18s ease,
        transform .18s ease,
        box-shadow .18s ease;
}
.territoryImportOption:hover{
    border-color:#a7f3d0;
    background:#f0fdf4;
    box-shadow:0 7px 20px rgba(16,185,129,.08);
    transform:translateY(-1px);
}
.territoryImportOptionIcon{
    width:42px;
    height:42px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:11px;
    background:#f0fdf4;
    color:#059669;
    font-size:17px;
}
.territoryImportOptionContent{
    flex:1;
    min-width:0;
}
.territoryImportOptionTitle{
    color:#111827;
    font-size:13px;
    font-weight:800;
}
.territoryImportOptionText{
    margin-top:4px;
    color:#9ca3af;
    font-size:11px;
    line-height:1.4;
}
.territoryImportOptionArrow{
    color:#c4cbd3;
    font-size:12px;
}
.territoryImportSecurity{
    display:flex;
    align-items:flex-start;
    gap:9px;
    margin:0 20px 20px;
    padding:11px 12px;
    border:1px solid #d1fae5;
    border-radius:11px;
    background:#f0fdf4;
    color:#047857;
    font-size:11px;
    line-height:1.45;
}
.territoryImportSecurity i{
    margin-top:2px;
    flex-shrink:0;
}
.territoryImportFileInput{
    display:none;
}
.territoryImportPreview{
    padding:5px 0;
    text-align:center;
}
.territoryImportPreviewIcon{
    width:58px;
    height:58px;
    display:flex;
    align-items:center;
    justify-content:center;
    margin:0 auto 12px;
    border-radius:17px;
    background:#ecfdf5;
    color:#059669;
    font-size:25px;
}
.territoryImportPreviewTitle{
    color:#111827;
    font-size:16px;
    font-weight:800;
}
.territoryImportPreviewSource{
    margin-top:5px;
    color:#9ca3af;
    font-size:11px;
    word-break:break-word;
}
.territoryImportPreviewStats{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-top:18px;
}
.territoryImportPreviewStat{
    padding:13px;
    border:1px solid #eef0f3;
    border-radius:12px;
    background:#f8fafc;
}
.territoryImportPreviewStat span{
    display:block;
    margin-bottom:4px;
    color:#9ca3af;
    font-size:10px;
    font-weight:700;
    text-transform:uppercase;
}
.territoryImportPreviewStat strong{
    color:#111827;
    font-size:17px;
}
.territoryImportPreviewButtons{
    display:flex;
    gap:10px;
    margin-top:16px;
}
.territoryImportSecondary,
.territoryImportPrimary{
    flex:1;
    height:42px;
    border-radius:10px;
    font-size:12px;
    font-weight:800;
    cursor:pointer;
}
.territoryImportSecondary{
    border:1px solid #e5e7eb;
    background:#fff;
    color:#374151;
}
.territoryImportPrimary{
    border:0;
    background:#059669;
    color:#fff;
}
.territoryImportError{
    display:flex;
    align-items:flex-start;
    gap:10px;
    padding:12px;
    margin-bottom:2px;
    border:1px solid #fecaca;
    border-radius:12px;
    background:#fef2f2;
}
.territoryImportErrorIcon{
    width:32px;
    height:32px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:9px;
    background:#fee2e2;
    color:#dc2626;
}
.territoryImportErrorTitle{
    color:#991b1b;
    font-size:12px;
    font-weight:800;
}
.territoryImportErrorText{
    margin-top:3px;
    color:#b91c1c;
    font-size:11px;
    line-height:1.4;
}

.territoryImportDetectedOrder{
    display:flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    margin-top:12px;
    padding:9px 11px;
    border:1px solid #dbeafe;
    border-radius:10px;
    background:#eff6ff;
    color:#1d4ed8;
    font-size:11px;
}
.territoryImportDetectedOrder strong{
    font-weight:800;
}
.territoryImportPreviewStats{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
    margin-top:12px;
}
.territoryImportFilesList{
    display:flex;
    flex-direction:column;
    gap:8px;
}
.territoryImportFileRow{
    display:flex;
    align-items:center;
    gap:10px;
    padding:10px;
    border:1px solid #e5e7eb;
    border-radius:12px;
    background:#f8fafc;
}
.territoryImportFileRowIcon{
    width:34px;
    height:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border-radius:9px;
    background:#ecfdf5;
    color:#059669;
}
.territoryImportFileRowContent{
    flex:1;
    min-width:0;
}
.territoryImportFileRowName{
    overflow:hidden;
    color:#111827;
    font-size:12px;
    font-weight:800;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.territoryImportFileRowMeta{
    margin-top:3px;
    color:#9ca3af;
    font-size:10px;
}
.territoryImportFileRemove{
    width:30px;
    height:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    border:0;
    border-radius:8px;
    background:#fff;
    color:#9ca3af;
    cursor:pointer;
}
.territoryImportFileRemove:hover{
    background:#fef2f2;
    color:#dc2626;
}
.territoryImportManual{
    padding:2px 0;
}
.territoryImportManualTitle{
    color:#111827;
    font-size:15px;
    font-weight:800;
}
.territoryImportManualSubtitle{
    margin-top:5px;
    color:#9ca3af;
    font-size:11px;
    line-height:1.45;
}
.territoryImportTextarea{
    width:100%;
    height:220px;
    margin-top:14px;
    padding:12px;
    box-sizing:border-box;
    resize:vertical;
    border:1px solid #e5e7eb;
    border-radius:12px;
    outline:none;
    background:#f8fafc;
    color:#111827;
    font-family:Consolas,Monaco,monospace;
    font-size:12px;
    line-height:1.55;
}
.territoryImportTextarea:focus{
    border-color:#93c5fd;
    background:#fff;
    box-shadow:0 0 0 3px rgba(37,99,235,.08);
}
.territoryImportManualFormat{
    display:flex;
    align-items:center;
    gap:7px;
    margin-top:9px;
    color:#6b7280;
    font-size:10px;
}
.territoryImportManualFormat i{
    color:#2563eb;
}
.territoryImportManualActions{
    display:flex;
    gap:10px;
    margin-top:15px;
}
.territoryImportManualActions .territoryImportSecondary,
.territoryImportManualActions .territoryImportPrimary{
    flex:1;
}

/* Окно информации у загруженной территории */

.importedTerritoryPopup{
    width:280px;
    padding:14px;
    box-sizing:border-box;
    border:1px solid #e5e7eb;
    border-radius:16px;
    background:#fff;
    box-shadow:0 8px 28px rgba(0,0,0,.22);
}
.importedTerritoryPopupHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
}
.importedTerritoryPopupIcon{
    width:34px;
    height:34px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:10px;
    background:#ecfdf5;
    color:#059669;
}
.importedTerritoryPopupClose{
    width:30px;
    height:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:8px;
    background:transparent;
    color:#9ca3af;
    cursor:pointer;
}
.importedTerritoryPopupClose:hover{
    background:#f3f4f6;
    color:#374151;
}
.importedTerritoryPopupTitle{
    margin-top:12px;
    color:#111827;
    font-size:15px;
    font-weight:800;
    line-height:1.35;
}
.importedTerritoryPopupMeta{
    margin-top:3px;
    color:#9ca3af;
    font-size:10px;
}
.importedTerritoryPopupGrid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:7px;
    margin-top:12px;
}
.importedTerritoryPopupStat{
    padding:9px;
    border:1px solid #eef0f3;
    border-radius:10px;
    background:#f8fafc;
}
.importedTerritoryPopupStat span{
    display:block;
    margin-bottom:3px;
    color:#9ca3af;
    font-size:9px;
    font-weight:700;
    text-transform:uppercase;
}
.importedTerritoryPopupStat strong{
    display:block;
    overflow:hidden;
    color:#111827;
    font-size:12px;
    font-weight:800;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.importedTerritoryPopupActions{
    margin-top:10px;
}
.importedTerritoryEditButton{
    width:100%;
    height:36px;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    border:0;
    border-radius:9px;
    background:#059669;
    color:#fff;
    font-size:11px;
    font-weight:800;
    cursor:pointer;
}
.importedTerritoryEditButton:hover{
    background:#047857;
}

/* Булун */

.userMarkerWrapper{
    position:relative;
    display:flex;
    align-items:center;
    justify-content:center;
    width:max-content;
    transform:translate(-50%,-100%);
    cursor:pointer;
    pointer-events:auto;
}
.userMarker{
    width:38px;
    height:38px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    background:var(--marker-color,#2563eb);
    color:#fff;
    border:3px solid #fff;
    box-shadow:0 5px 18px rgba(0,0,0,.3);
    font-size:17px;
    transition:transform .18s ease,box-shadow .18s ease;
    position:relative;
    z-index:2;
}
.userMarker::after{
    content:'';
    position:absolute;
    left:50%;
    bottom:-7px;
    width:13px;
    height:13px;
    background:var(--marker-color,#2563eb);
    transform:translateX(-50%) rotate(45deg);
    border-right:2px solid #fff;
    border-bottom:2px solid #fff;
    z-index:-1;
}
.userMarkerWrapper:hover .userMarker{
    transform:scale(1.08);
    box-shadow:0 7px 24px rgba(0,0,0,.38);
}
.userMarkerLabel{
    position:absolute;
    left:50%;
    bottom:44px;
    transform:translateX(-50%);
    white-space:nowrap;
    max-width:240px;
    overflow:hidden;
    text-overflow:ellipsis;
    padding:6px 11px;
    border-radius:10px;
    background:rgba(255,255,255,.97);
    color:#0f172a;
    border:1px solid rgba(15,23,42,.08);
    box-shadow:0 5px 18px rgba(0,0,0,.18);
    font-size:12px;
    font-weight:700;
    z-index:3;
    pointer-events:none;
}
.userMarkerPopup{
    width:280px;
    box-sizing:border-box;
    padding: 15px 15px 25px 15px;
    border-radius:16px;
    background:#fff;
}
.userMarkerPopupHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
}
.userMarkerPopupIcon{
    width:38px;
    height:38px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:11px;
    color:#fff;
    font-size:17px;
}
.userMarkerPopupClose{
    width:30px;
    height:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:8px;
    background:transparent;
    color:#64748b;
    cursor:pointer;
    font-size:15px;
}
.userMarkerPopupClose:hover{
    background:#f1f5f9;
    color:#0f172a;
}
.userMarkerPopupTitle{
    margin-top:12px;
    font-size:17px;
    line-height:1.3;
    font-weight:800;
    color:#0f172a;
}
.userMarkerPopupDescription{
    margin-top:8px;
    font-size:13px;
    line-height:1.5;
    color:#475569;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
}
.userMarkerPopupCoordinates{
    margin-top:12px;
    padding:9px 11px;
    border-radius:10px;
    background:#f8fafc;
    color:#2563eb;
    font-size:12px;
    font-weight:700;
    font-variant-numeric:tabular-nums;
}
.userMarkerPopupLabelState{
    margin-top:8px;
    font-size:11px;
    color:#64748b;
}
.markerEditorOverlay{
    position:fixed;
    inset:0;
    z-index:30000;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    box-sizing:border-box;
    background:rgba(15,23,42,.42);
    backdrop-filter:blur(8px);
}
.markerEditorWindow{
    width:min(500px,100%);
    max-height:min(760px,calc(100vh - 40px));
    overflow:auto;
    border-radius:22px;
    background:#fff;
    border:1px solid rgba(15,23,42,.08);
    box-shadow:0 25px 70px rgba(15,23,42,.28);
}
.markerEditorHeader{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:15px;
    padding:18px 20px;
    border-bottom:1px solid #e2e8f0;
}
.markerEditorHeaderInfo{
    display:flex;
    align-items:center;
    gap:12px;
    min-width:0;
}
.markerEditorHeaderIcon{
    width:42px;
    height:42px;
    flex:none;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:12px;
    background:#2563eb;
    color:#fff;
    font-size:17px;
}
.markerEditorTitle{
    font-size:17px;
    font-weight:800;
    color:#0f172a;
}
.markerEditorSubtitle{
    margin-top:3px;
    font-size:11px;
    color:#64748b;
}
.markerEditorClose{
    width:34px;
    height:34px;
    flex:none;
    display:flex;
    align-items:center;
    justify-content:center;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#64748b;
    cursor:pointer;
    font-size:16px;
}
.markerEditorClose:hover{
    background:#f1f5f9;
    color:#0f172a;
}
.markerEditorBody{
    padding:20px;
}
.markerEditorLabel{
    display:block;
    margin-bottom:7px;
    font-size:13px;
    font-weight:700;
    color:#334155;
}
.markerEditorInput,
.markerEditorTextarea{
    width:100%;
    box-sizing:border-box;
    border:1px solid #cbd5e1;
    outline:none;
    border-radius:12px;
    background:#f8fafc;
    color:#0f172a;
    font:inherit;
    transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;
}
.markerEditorInput{
    height:44px;
    padding:0 13px;
    margin-bottom:16px;
}
.markerEditorTextarea{
    min-height:110px;
    resize:vertical;
    padding:12px 13px;
    margin-bottom:16px;
}
.markerEditorInput:focus,
.markerEditorTextarea:focus{
    background:#fff;
    border-color:#2563eb;
    box-shadow:0 0 0 3px rgba(37,99,235,.12);
}
.markerEditorColors{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-bottom:18px;
}
.markerEditorColor{
    width:38px;
    height:38px;
    border:3px solid #fff;
    border-radius:50%;
    background:var(--marker-editor-color);
    box-shadow:0 0 0 1px #cbd5e1;
    cursor:pointer;
    transition:transform .18s ease,box-shadow .18s ease;
}
.markerEditorColor:hover{
    transform:scale(1.08);
}
.markerEditorColor.active{
    box-shadow:0 0 0 2px #0f172a,0 3px 10px rgba(0,0,0,.18);
}
.markerEditorIcons{
    display:grid;
    grid-template-columns:repeat(5,1fr);
    gap:9px;
    margin-bottom:18px;
}
.markerEditorIcon{
    height:46px;
    border:1px solid #cbd5e1;
    border-radius:11px;
    background:#f8fafc;
    color:#475569;
    font-size:17px;
    cursor:pointer;
    transition:background .18s ease,border-color .18s ease,color .18s ease,transform .18s ease;
}
.markerEditorIcon:hover{
    background:#fff;
    transform:translateY(-1px);
}
.markerEditorIcon.active{
    background:#eff6ff;
    border-color:#2563eb;
    color:#2563eb;
    box-shadow:0 0 0 3px rgba(37,99,235,.1);
}
.markerEditorCheckbox{
    display:flex;
    align-items:center;
    gap:10px;
    margin:4px 0 18px;
    cursor:pointer;
    user-select:none;
}
.markerEditorCheckbox input{
    position:absolute;
    opacity:0;
    pointer-events:none;
}
.markerEditorCheckboxBox{
    width:20px;
    height:20px;
    flex:none;
    box-sizing:border-box;
    display:flex;
    align-items:center;
    justify-content:center;
    border:2px solid #cbd5e1;
    border-radius:6px;
    background:#fff;
}
.markerEditorCheckbox input:checked+
.markerEditorCheckboxBox{
    border-color:#2563eb;
    background:#2563eb;
}
.markerEditorCheckbox input:checked+
.markerEditorCheckboxBox::after{
    content:'✓';
    color:#fff;
    font-size:13px;
    font-weight:800;
}
.markerEditorCheckboxText{
    font-size:13px;
    font-weight:600;
    color:#334155;
}
.markerEditorSecurity{
    display:flex;
    align-items:flex-start;
    gap:9px;
    padding:11px 12px;
    margin-bottom:18px;
    border-radius:11px;
    background:#f8fafc;
    color:#64748b;
    font-size:11px;
    line-height:1.45;
}
.markerEditorSecurity i{
    color:#16a34a;
    margin-top:2px;
}
.markerEditorActions{
    display:flex;
    justify-content:flex-end;
    gap:10px;
}
.markerEditorCancel,
.markerEditorSave{
    height:42px;
    padding:0 18px;
    border:0;
    border-radius:11px;
    font-size:13px;
    font-weight:700;
    cursor:pointer;
}
.markerEditorCancel{
    background:#f1f5f9;
    color:#475569;
}
.markerEditorCancel:hover{
    background:#e2e8f0;
}
.markerEditorSave{
    display:flex;
    align-items:center;
    gap:8px;
    background:#2563eb;
    color:#fff;
}
.markerEditorSave:hover{
    background:#1d4ed8;
}
@media(max-width:600px){
    .markerEditorOverlay{
        padding:12px;
    }
    .markerEditorWindow{
        max-height:calc(100vh - 24px);
        border-radius:18px;
    }
    .markerEditorBody{
        padding:16px;
    }
    .markerEditorIcons{
        grid-template-columns:repeat(5,1fr);
    }
    .userMarkerPopup{
        width:250px;
    }
}




.markerEditorTemporaryWrapper{
    margin-top:12px;
}
.markerEditorTemporaryHint{
    display:flex;
    align-items:flex-start;
    gap:8px;
    margin-top:7px;
    padding:9px 11px;
    border-radius:10px;
    background:#fff7ed;
    color:#9a3412;
    font-size:11px;
    line-height:1.4;
}
.markerEditorTemporaryHint i{
    margin-top:2px;
    flex-shrink:0;
}
.markerEditorError{
    display:none;
    margin-top:12px;
    padding:10px 12px;
    border-radius:10px;
    background:#fef2f2;
    color:#b91c1c;
    font-size:12px;
    line-height:1.4;
}
.markerEditorError.active{
    display:block;
}
.markerEditorCategoryNotice{
    display:flex;
    align-items:center;
    gap:8px;
    margin-top:12px;
    padding:10px 12px;
    border-radius:10px;
    background:#f8fafc;
    color:#64748b;
    font-size:12px;
}

/* Скриншот */

.screenshotOverlay{
    position:fixed;
    inset:0;
    z-index:40000;
    cursor:crosshair;
    background:rgba(15,23,42,.20);
}
.screenshotHint{
    position:absolute;
    top:22px;
    left:50%;
    transform:translateX(-50%);
    display:flex;
    align-items:center;
    gap:12px;
    min-width:360px;
    box-sizing:border-box;
    padding:12px 14px;
    border-radius:15px;
    background:rgba(255,255,255,.96);
    border:1px solid rgba(15,23,42,.08);
    box-shadow:0 10px 35px rgba(15,23,42,.2);
    backdrop-filter:blur(12px);
    cursor:default;
}
.screenshotHintIcon{
    width:38px;
    height:38px;
    flex:none;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:11px;
    background:#2563eb;
    color:#fff;
}
.screenshotHintTitle{
    font-size:14px;
    font-weight:800;
    color:#0f172a;
}
.screenshotHintText{
    margin-top:2px;
    font-size:11px;
    color:#64748b;
}
.screenshotCancelButton{
    width:32px;
    height:32px;
    margin-left:auto;
    flex:none;
    border:0;
    border-radius:9px;
    background:#f1f5f9;
    color:#64748b;
    cursor:pointer;
}
.screenshotCancelButton:hover{
    background:#e2e8f0;
    color:#0f172a;
}
.screenshotSelection{
    position:fixed;
    display:none;
    box-sizing:border-box;
    border:2px solid #2563eb;
    background:rgba(37,99,235,.10);
    box-shadow:0 0 0 99999px rgba(15,23,42,.28);
    pointer-events:none;
}
.screenshotOverlay.selecting .screenshotSelection{
    display:block;
}
.screenshotSize{
    position:fixed;
    display:none;
    padding:5px 8px;
    border-radius:7px;
    background:#0f172a;
    color:#fff;
    font-size:11px;
    font-weight:700;
    font-variant-numeric:tabular-nums;
    pointer-events:none;
}
.screenshotOverlay.selecting .screenshotSize{
    display:block;
}
.screenshotStatus{
    position:absolute;
    left:50%;
    bottom:25px;
    transform:translateX(-50%);
    display:flex;
    align-items:center;
    gap:9px;
    padding:10px 15px;
    border-radius:11px;
    background:#0f172a;
    color:#fff;
    font-size:13px;
    font-weight:600;
    box-shadow:0 8px 25px rgba(0,0,0,.25);
    cursor:default;
}

/* Печать */

@media print{
    @page{
        size:auto;
        margin:10mm;
    }
    html,
    body{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        overflow:visible;
        background:#fff;
    }
    body *{
        visibility:hidden;
    }
    body.mapPrintMode .mapContainer,
    body.mapPrintMode .mapContainer *{
        visibility:visible;
    }
    body.mapPrintMode .mapContainer{
        position:absolute!important;
        top:0!important;
        left:0!important;
        width:100vw!important;
        height:100vh!important;
        margin:0!important;
        padding:0!important;
        overflow:hidden!important;
    }
    body.mapPrintMode .menuButton{
        display:none!important;
    }
    body.mapPrintMode .mapMenu{
        display:none!important;
    }
    body.mapPrintMode .layersMenu{
        display:none!important;
    }
    body.mapPrintMode .drawingPanel{
        display:block!important;
    }
    body.mapPrintMode .territory-balloon-wrapper{
        display:block!important;
    }
    body.mapPrintMode .drawingAreaPopup{
        display:flex!important;
    }
    body.mapPrintMode .userMarkerPopup{
        display:block!important;
    }
    body.mapPrintMode .screenshotOverlay{
        display:none!important;
    }
}

/* Чтобы не нарушать авторские права подложек */

.mapAttribution{
    position:fixed;
    left:12px;
    bottom:10px;
    z-index:20000;
    display:none;
    align-items:center;
    gap:8px;
    max-width:75vw;
    padding:5px 8px;
    border-radius:6px;
    background:rgba(255,255,255,.9);
    box-shadow:0 1px 5px rgba(0,0,0,.2);
    font-size:11px;
    line-height:1.3;
    color:#333;
}
.mapAttributionVisible{
    display:flex;
}
.mapAttributionText{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:6px;
}
.mapAttribution a{
    color:#333;
    text-decoration:none;
}
.mapAttribution a:hover{
    text-decoration:underline;
}
.mapAttributionDivider{
    color:#777;
}
.mapTilerLogo{
    display:flex;
    align-items:center;
    flex-shrink:0;
}
.mapTilerLogo img{
    display:block;
    width:70px;
    height:auto;
}


/* Меню выбора территории на карте */

.territory-context-menu{
    position:absolute;
    width:370px;
    max-width:calc(100vw - 30px);
    padding:7px;
    border:1px solid rgba(0,0,0,.09);
    border-radius:18px;
    background:rgba(255,255,255,.96);
    box-shadow:0 20px 50px rgba(0,0,0,.20),0 4px 12px rgba(0,0,0,.08);
    backdrop-filter:blur(22px);
    -webkit-backdrop-filter:blur(22px);
    overflow:hidden;
    opacity:0;
    transform:translateY(8px) scale(.96);
    transform-origin:bottom center;
    transition:opacity .18s ease,transform .18s ease;
    z-index:10000;
}

.territory-context-menu--visible{
    opacity:1;
    transform:translateY(0) scale(1);
}

.territory-context-menu__header{
    height:42px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 5px 0 10px;
}

.territory-context-menu__header-title{
    color:#202020;
    font-size:14px;
    font-weight:700;
    line-height:1;
    letter-spacing:-.15px;
}

.territory-context-menu__close{
    width:30px;
    height:30px;
    min-width:30px;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:0;
    border:0;
    border-radius:9px;
    background:transparent;
    color:#999;
    font-size:16px;
    cursor:pointer;
    transition:background .15s ease,color .15s ease,transform .15s ease;
}

.territory-context-menu__close:hover{
    background:rgba(0,0,0,.07);
    color:#333;
    transform:rotate(90deg);
}

.territory-context-menu__list{
    display:flex;
    flex-direction:column;
    gap:3px;
}

.territory-context-menu__item{
    width:100%;
    min-height:78px;
    display:flex;
    align-items:center;
    gap:12px;
    padding:10px;
    border:0;
    border-radius:13px;
    background:transparent;
    color:#222;
    text-align:left;
    cursor:pointer;
    transition:background .16s ease,transform .16s ease;
}

.territory-context-menu__item:hover{
    background:rgba(0,0,0,.045);
    transform:translateX(2px);
}

.territory-context-menu__item:active{
    transform:scale(.985);
}

.territory-context-menu__icon{
    width:44px;
    height:44px;
    min-width:44px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:12px;
    color:#fff;
    font-size:18px;
    box-shadow:0 5px 12px rgba(0,0,0,.18);
}

.territory-context-menu__content{
    min-width:0;
    flex:1;
    display:flex;
    flex-direction:column;
    gap:4px;
}

.territory-context-menu__title{
    overflow:hidden;
    color:#202020;
    font-size:14px;
    font-weight:700;
    line-height:1.3;
    letter-spacing:-.1px;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.territory-context-menu__category{
    display:flex;
    align-items:center;
    gap:6px;
    min-width:0;
    overflow:hidden;
    color:#777;
    font-size:11px;
    font-weight:500;
    line-height:1.2;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.territory-context-menu__category-dot{
    width:7px;
    height:7px;
    min-width:7px;
    border-radius:50%;
    box-shadow:0 0 0 2px rgba(0,0,0,.04);
}

.territory-context-menu__info{
    display:flex;
    align-items:center;
    flex-wrap:wrap;
    gap:5px;
    margin-top:2px;
}

.territory-context-menu__badge{
    height:22px;
    display:inline-flex;
    align-items:center;
    gap:5px;
    padding:0 8px;
    border:1px solid rgba(0,0,0,.06);
    border-radius:7px;
    background:rgba(0,0,0,.045);
    color:#5f5f5f;
    font-size:10px;
    font-weight:600;
    line-height:1;
}

.territory-context-menu__badge i{
    font-size:9px;
    color:#777;
}

@media(max-width:500px){
    .territory-context-menu{
        width:calc(100vw - 24px);
    }
    .territory-context-menu__item{
        min-height:74px;
    }
}