* { box-sizing: border-box; }

:root {
    /* Brand — sage green spectrum */
    --green-50:  #ECF7F0;
    --green-100: #D5EDE0;
    --green-300: #6FB58A;
    --green-500: #2D7A4F;
    --green-700: #1E5A38;
    --green-900: #103D24;

    /* Accent — warm amber for emphasis (replaces orange) */
    --amber-50:  #FFF8EB;
    --amber-300: #F2C475;
    --amber-500: #E8A33E;
    --amber-700: #B47720;

    /* Status */
    --red-500: #DC2626; --red-50: #FEF2F2;
    --orange-500: #EA580C;
    --blue-500: #2563EB;

    /* Warm neutrals (stone) — менее холодные, чем gray */
    --stone-50:  #FAFAF9;
    --stone-100: #F5F5F4;
    --stone-150: #EFEEEC;
    --stone-200: #E7E5E4;
    --stone-300: #D6D3D1;
    --stone-400: #A8A29E;
    --stone-500: #78716C;
    --stone-600: #57534E;
    --stone-700: #44403C;
    --stone-800: #292524;
    --stone-900: #1C1917;

    /* Semantic tokens */
    --primary:        var(--green-500);
    --primary-hover:  var(--green-700);
    --primary-tint:   var(--green-50);
    --accent:         var(--amber-500);
    --accent-hover:   var(--amber-700);
    --accent-tint:    var(--amber-50);
    --bg:             #FFFFFF;
    --bg-2:           var(--stone-50);
    --bg-3:           var(--stone-100);
    --border:         var(--stone-200);
    --border-strong:  var(--stone-300);
    --text:           var(--stone-900);
    --text-2:         var(--stone-600);
    --text-3:         var(--stone-400);

    /* Legacy aliases — старые правила продолжают работать */
    --green:       var(--green-500);
    --green-dark:  var(--green-700);
    --green-light: var(--green-50);

    /* Spacing scale (4px base) */
    --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
    --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

    /* Radii */
    --radius-sm: 6px;
    --radius:    10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 22px;

    /* Elevation — двухслойные тени для глубины */
    --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.05);
    --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.08), 0 1px 2px rgba(28, 25, 23, 0.04);
    --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08), 0 2px 4px rgba(28, 25, 23, 0.04);
    --shadow-lg: 0 8px 28px rgba(28, 25, 23, 0.10), 0 4px 12px rgba(28, 25, 23, 0.06);
    --shadow-xl: 0 24px 64px rgba(28, 25, 23, 0.16), 0 8px 24px rgba(28, 25, 23, 0.08);

    --font: 'Inter', -apple-system, system-ui, sans-serif;
}

body {
    margin:0; padding:0;
    font-family: var(--font);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
#map { position:absolute; top:0; bottom:0; left:0; right:0; }

/* Чёткие границы зон на оверлее/тайлах: nearest-neighbor вместо bilinear.
   Применяется к imageOverlay И к плиткам нашего тайл-слоя
   (но не к OSM-плиткам — они в другом контейнере).
   Селекторы намеренно избыточные — в разных версиях Leaflet класс
   попадает то на контейнер слоя, то на отдельные тайлы. */
body.sharp-overlay .leaflet-image-layer,
body.sharp-overlay .genplan-tiles,
body.sharp-overlay .genplan-tiles img,
body.sharp-overlay .genplan-tiles .leaflet-tile,
body.sharp-overlay img.genplan-tiles {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* ========== ПАНЕЛЬ ========== */
.controls {
    position: absolute; top: 20px; right: 20px;
    background: #FFFFFF;
    border: none;
    border-radius: 24px;
    box-shadow:
        0 4px 12px rgba(28, 25, 23, 0.04),
        0 16px 40px rgba(28, 25, 23, 0.08);
    padding: 20px;
    z-index: 1000;
    width: 360px;
    transition: transform 0.35s cubic-bezier(.16,.84,.34,1), opacity 0.35s ease;
    display: flex; flex-direction: column; gap: 14px;
}
.controls.hidden { transform: translateX(calc(100% + 32px)); opacity: 0; pointer-events:none; }

/* Шапка */
.panel-header {
    display: flex; align-items: center; gap: 12px;
    margin: 0; padding: 0;
    border-bottom: none;
}
.panel-logo {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--green-500);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.panel-logo svg { width: 20px; height: 20px; fill: white; }
.panel-title {
    font-size: 16px; font-weight: 700; color: var(--text);
    line-height: 1.2; letter-spacing: -0.02em;
}
.panel-sub   {
    font-size: 12px; color: var(--text-2);
    margin-top: 2px; font-weight: 500;
}
.panel-sub-sep { color: var(--text-3); margin: 0 3px; }

.close-panel-btn {
    width: 30px; height: 30px; padding: 0; margin: 0 0 0 auto;
    background: transparent; border: none; border-radius: var(--radius-sm);
    color: var(--text-3); font-size: 16px; flex-shrink: 0; box-shadow: none; min-height: auto;
    transition: background 0.15s, color 0.15s;
}
.close-panel-btn:hover { background: var(--bg-3); color: var(--text); transform: none; }

/* Поиск — pill-стиль */
.search-wrap { position: relative; margin: 0; }
.search-wrap > svg {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; stroke: var(--text-3); fill: none; stroke-width: 2;
    pointer-events: none;
    transition: stroke 0.15s;
}
.search-wrap:focus-within > svg { stroke: var(--primary); }
input[type="text"] {
    width: 100%; padding: 14px 16px 14px 46px;
    border: none; border-radius: 14px;
    background: var(--bg-2); color: var(--text);
    font-size: 14px; font-family: inherit; outline: none;
    font-weight: 500;
    transition: box-shadow 0.2s, background 0.2s;
}
input[type="text"]:focus {
    background: #fff;
    box-shadow: 0 0 0 4px rgba(45, 122, 79, 0.12);
}
input[type="text"]::placeholder { color: var(--text-3); font-weight: 400; }

/* Автоподсказки */
.suggest {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 280px; overflow-y: auto; z-index: 10;
    display: none;
    overflow: hidden;
}
.suggest.open { display: block; }
.suggest-item {
    padding: 9px 12px; cursor: pointer;
    border-bottom: 1px solid var(--bg-2);
    line-height: 1.3;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item.active, .suggest-item:hover { background: var(--green-light); }
.suggest-item .s-main { font-size: 13px; color: var(--text); font-weight: 500; }
.suggest-item .s-sub  { font-size: 11px; color: var(--text-2); margin-top: 1px; }
.suggest-empty { padding: 10px 12px; font-size: 12px; color: var(--text-2); text-align:center; }

/* Кнопки — flat solid, без градиентов, pill-стиль */
button {
    width: 100%; padding: 13px 18px;
    border: none; border-radius: 14px;
    font-size: 14px; font-weight: 600; font-family: inherit;
    cursor: pointer; display: inline-flex; align-items: center;
    justify-content: center; gap: 8px;
    transition: background 0.18s, transform 0.12s, color 0.15s, border-color 0.15s;
    background: var(--primary); color: #fff;
    box-shadow: none;
    margin: 0;
    letter-spacing: -0.005em;
}
button:hover  { background: var(--primary-hover); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-row { display: flex; gap: 10px; }
.btn-row > button { flex: 1; }
.btn-icon {
    width: 48px; height: 48px; flex: 0 0 48px;
    background: var(--bg-2); color: var(--text-2); border: none;
    padding: 0; box-shadow: none;
    border-radius: 14px;
}
.btn-icon:hover {
    background: var(--primary-tint);
    color: var(--primary); transform: none;
}
.btn-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

.divider { border: none; border-top: 1px solid var(--border); margin: var(--s-2) 0; }

/* Настройки карты — сгруппированы в визуальный блок */
.map-settings {
    background: var(--bg-2);
    border: none;
    border-radius: 18px;
    padding: 16px;
    display: flex; flex-direction: column; gap: 14px;
}
.map-settings-heading {
    font-size: 10px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.8px;
    margin: 0;
}

/* Прозрачность */
.opacity-label {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 13px; color: var(--text); margin-bottom: 6px;
    font-weight: 500;
}
.opacity-label span {
    font-weight: 700; color: var(--primary);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}
input[type="range"] {
    width: 100%; height: 4px; border-radius: 4px;
    accent-color: var(--primary); cursor: pointer;
}

/* Тоггл-строка (свич + подпись) */
.toggle-row {
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: 0;
    cursor: pointer;
    font-size: 13px; color: var(--text);
    font-weight: 500;
}
.toggle-row > span { flex: 1; line-height: 1.35; }
.toggle-row .toggle-hint {
    display: block;
    font-size: 11px; color: var(--text-2);
    font-weight: 400; margin-top: 3px;
    line-height: 1.4;
}
.toggle-row input[type="checkbox"] {
    width: 38px; height: 22px;
    appearance: none; -webkit-appearance: none;
    background: var(--stone-300); border-radius: 12px;
    position: relative; cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0; margin: 1px 0 0;
    outline: none;
}
.toggle-row input[type="checkbox"]::after {
    content: ''; position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: #fff; border-radius: 50%;
    transition: left 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-row input[type="checkbox"]:checked { background: var(--primary); }
.toggle-row input[type="checkbox"]:checked::after { left: 18px; }
.toggle-row input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(45,122,79,0.22);
}

.btn-legend {
    background: var(--bg-2);
    color: var(--text);
    border: none;
    font-weight: 500;
    margin: 0;
    padding: 13px 16px;
    border-radius: 14px;
}
.btn-legend:hover {
    background: var(--primary-tint);
    color: var(--primary);
}

input[type="range"] { -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--green);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    margin-top: -7px;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px; border-radius: 4px;
    background: linear-gradient(to right, var(--green) 0%, var(--green) var(--val, 70%), #E5E7EB var(--val, 70%));
}
input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--green); cursor: pointer;
    border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Карточка результата — flat card */
.result-card {
    display: none;
    margin: 0;
    background: var(--bg-2);
    border: none;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: none;
}
.result-card.visible { display: block; }

/* Адрес — eyebrow + main */
.result-addr {
    padding: 14px 16px 12px;
    background: transparent;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}
.result-addr::before {
    content: 'Найденный участок';
    display: block;
    font-size: 10px; color: var(--text-3);
    font-weight: 700; letter-spacing: 0.7px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.result-addr .addr-main {
    font-size: 15px; font-weight: 600; color: var(--text);
    letter-spacing: -0.01em;
}
.result-addr .addr-sub {
    font-size: 12px; color: var(--text-2); margin-top: 3px;
}

/* Зона — большой блок с эмблемой */
.result-zone {
    padding: 16px;
    display: flex; align-items: flex-start; gap: 14px;
}
.result-swatch {
    width: 52px; height: 52px; border-radius: 14px;
    flex-shrink: 0;
    border: none;
    box-shadow: 0 0 0 4px #fff;
}
.result-info { flex: 1; min-width: 0; }
.result-zone-name {
    font-size: 11px; color: var(--text-2); margin-bottom: 6px;
    font-weight: 600;
    line-height: 1.35;
    /* Полное название зоны — без uppercase, чтобы читалось */
}
.result-floors {
    font-size: 26px; font-weight: 700; line-height: 1;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
}
.result-floors-label {
    font-size: 12px; color: var(--text-2); margin-top: 5px;
    line-height: 1.4;
}
.result-warn {
    font-size: 11px; color: var(--amber-700);
    background: var(--amber-50);
    border: 1px solid var(--amber-300);
    border-radius: 8px;
    padding: 5px 9px;
    margin-top: 8px;
    display: inline-flex; align-items: center; gap: 5px;
    font-weight: 500;
}

/* Actions внутри карточки */
.result-actions {
    padding: 0 16px 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.result-actions > div { display: flex; gap: 8px; }
.result-actions > div > button { flex: 1; }

.result-actions {
    display: flex; gap: 6px;
    padding: 0 12px 12px;
    border-top: 1px dashed var(--border); padding-top: 10px;
}
.result-actions button {
    flex: 1; min-height: 0; padding: 7px 10px; font-size: 11px;
    background: var(--bg-2); color: var(--text-2);
    border: 1px solid var(--border);
}
.result-actions button:hover { background: var(--green-light); color: var(--green); border-color: var(--green); }

/* Статус загрузки зон */
.zones-status {
    padding: 8px 12px; font-size: 12px; border-radius: var(--radius-sm);
    margin: 0; text-align: center;
    background: var(--amber-50); color: var(--amber-700);
    border: 1px solid var(--amber-300);
    display: none;
    font-weight: 500;
}
.zones-status.visible { display: block; }
.zones-status.error {
    color: var(--red-500); border-color: #FECACA; background: var(--red-50);
}

.toggle-btn {
    position: absolute; top: 12px; right: 12px; z-index: 1001;
    width: 40px; height: 40px;
    background: #fff; color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px; font-size: 18px;
    cursor: pointer; display: none;
    align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.toggle-btn.visible { display: flex; }

.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--text); color: #fff; padding: 10px 18px;
    border-radius: 8px; font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 3000; opacity: 0; pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* Бейдж оффлайн-режима — слева снизу */
.offline-badge {
    position: fixed; bottom: 16px; left: 16px; z-index: 1500;
    background: #FEF3C7; color: #92400E;
    border: 1px solid #FDE68A;
    padding: 6px 10px; border-radius: 8px;
    font-size: 12px; font-weight: 600;
    display: none; align-items: center; gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.offline-badge.visible { display: inline-flex; }
.offline-badge svg { stroke: currentColor; flex-shrink: 0; }
@media (max-width: 640px) {
    .offline-badge { bottom: auto; top: 12px; left: 12px; }
}

/* ========== МОБИЛЬНАЯ АДАПТАЦИЯ ========== */
@media (max-width: 640px) {
    .controls {
        top: auto !important;
        bottom: 0; left: 0; right: 0;
        width: 100% !important;
        border-radius: 20px 20px 0 0;
        border: 1px solid var(--border);
        border-bottom: none;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
        padding: 0 16px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        max-height: 85vh;
        overflow-y: auto;
        transform: translateY(calc(100% - 130px));
        transition: transform 0.38s cubic-bezier(0.32,0.72,0,1);
    }
    .controls.expanded  { transform: translateY(0); }
    .controls.hidden    { transform: translateY(100%); }

    .drag-handle {
        width: 36px; height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 10px auto 14px;
        cursor: grab; flex-shrink: 0;
    }

    .panel-header { margin-bottom: 10px; padding-bottom: 10px; }
    .close-panel-btn { display: none !important; }

    button { min-height: 48px; padding: 12px 14px; font-size: 14px; }
    .btn-icon { width: 48px; flex: 0 0 48px; }

    input[type="text"] { font-size: 16px; padding: 12px 12px 12px 38px; }
    .search-wrap > svg { top: 22px; }

    .toggle-btn {
        top: 12px; left: auto; right: 12px;
        display: flex !important;
    }
    .toggle-btn.visible { display: flex; }

    .leaflet-top.leaflet-right { top: auto; bottom: 150px; }
    .leaflet-control-zoom { margin-right: 12px !important; }

    .result-floors { font-size: 26px; }
}

.drag-handle { display: none; }
@media (max-width: 640px) { .drag-handle { display: block; } }

/* Индикатор уровня зума рядом с +/- */
.zoom-level-label {
    background: #fff;
    padding: 4px 8px;
    font: 600 12px/1 system-ui, -apple-system, sans-serif;
    color: #333;
    text-align: center;
    min-width: 30px;
}

/* ========== AI HUB ATTRIBUTION ========== */
.brand-credit {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 12px; color: var(--text-2);
    letter-spacing: 0;
}
.brand-credit .aihub-logo {
    height: 14px; width: auto;
    opacity: 0.9;
}
.brand-credit strong {
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.5px;
    font-size: 13px;
}

/* ========== UI POLISH ========== */
/* Микро-анимация подъёма для CTA-кнопок */
.btn-cta {
    box-shadow: 0 2px 8px rgba(234, 88, 12, 0.22);
    transition: background 0.2s, transform 0.15s ease, box-shadow 0.2s;
}
.btn-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.32);
}
.btn-cta:active { transform: translateY(0); }

/* Общая полировка обычных кнопок */
button:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}
.btn-icon:focus-visible { outline-offset: 1px; }

/* Плавное появление модалок */
.modal {
    opacity: 0;
    transition: opacity 0.18s ease;
}
.modal.open {
    opacity: 1;
}
.modal-box {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
    transition: transform 0.22s cubic-bezier(.16,.84,.34,1), opacity 0.18s ease;
}
.modal.open .modal-box {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Подсветка фокуса инпутов */
.form-field input:focus,
.form-field select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(45, 122, 79, 0.12);
    outline: none;
}

/* Подсветка suggest-item */
.suggest-item {
    transition: background 0.12s, padding-left 0.15s;
}
.suggest-item:hover, .suggest-item.active {
    padding-left: 16px;
}

/* Карточка результата — лёгкое появление */
.result-card.visible {
    animation: cardIn 0.22s cubic-bezier(.16,.84,.34,1);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ========== МОДАЛЬНАЯ ЛЕГЕНДА ========== */
.legend-modal {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background: rgba(28, 25, 23, 0.55);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    align-items: center; justify-content: center;
}
.legend-modal.open { display: flex; }
.legend-box {
    background: var(--bg); border-radius: var(--radius-lg);
    max-width: 520px; width: 92vw;
    max-height: 88vh; overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    padding: var(--s-6); position: relative;
}
.legend-box h2 {
    font-size: 19px; font-weight: 700; color: var(--text);
    margin: 0 0 var(--s-1); text-align: left;
    letter-spacing: -0.015em;
}
.legend-box .sub {
    font-size: 13px; color: var(--text-2);
    text-align: left; margin-bottom: var(--s-5);
}
.legend-close {
    position: absolute; top: var(--s-3); right: var(--s-3);
    background: transparent; border: none;
    border-radius: var(--radius-sm); width: 32px; height: 32px; padding: 0; margin: 0;
    font-size: 17px; cursor: pointer; color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    box-shadow: none; font-weight: 400;
    transition: background 0.15s, color 0.15s;
}
.legend-close:hover { color: var(--text); background: var(--bg-3); transform: none; box-shadow: none; }
.legend-section {
    font-size: 11px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.8px;
    margin: var(--s-5) 0 var(--s-2); padding-bottom: var(--s-1);
    border-bottom: 1px solid var(--border);
}
.legend-section:first-child { margin-top: 0; }
.legend-row {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 8px 0; border-bottom: 1px solid var(--bg-2);
}
.legend-row:last-child { border-bottom: none; }
.legend-swatch {
    width: 28px; height: 20px; border-radius: var(--radius-sm); flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
}
.legend-name  { font-size: 13px; color: var(--text); flex: 1; line-height: 1.4; }
.legend-floors {
    font-size: 12px; font-weight: 700; color: var(--primary); white-space: nowrap;
    font-variant-numeric: tabular-nums;
    background: var(--primary-tint);
    padding: 2px 7px; border-radius: var(--radius-sm);
}
.legend-img-wrap { text-align: center; margin-top: var(--s-5); }
.legend-img-wrap img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.legend-note {
    font-size: 12px; color: var(--text-2); line-height: 1.5;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px;
    margin-top: var(--s-3);
}

/* ========== УНИВЕРСАЛЬНАЯ МОДАЛКА (Подробнее / Аудит) ========== */
.modal {
    display: none; position: fixed; inset: 0; z-index: 2000;
    background: rgba(28, 25, 23, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center; justify-content: center;
    padding: var(--s-4);
}
.modal.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 24px;
    max-width: 480px; width: 100%;
    max-height: 88vh; overflow-y: auto;
    box-shadow:
        0 8px 24px rgba(28, 25, 23, 0.10),
        0 32px 80px rgba(28, 25, 23, 0.20);
    padding: 28px;
    position: relative;
    border: none;
}
.modal-box--wide { max-width: 580px; }
.modal-box h2 {
    font-size: 22px; font-weight: 700; color: var(--text);
    margin: 0 0 4px; padding-right: 40px;
    letter-spacing: -0.022em; line-height: 1.2;
}
.modal-sub {
    font-size: 13px; color: var(--text-2);
    margin-bottom: 20px; line-height: 1.5;
}
.modal-close {
    position: absolute; top: 14px; right: 14px;
    background: var(--bg-2); border: 1px solid var(--border);
    border-radius: 50%; width: 36px; height: 36px; padding: 0; margin: 0;
    font-size: 15px; cursor: pointer; color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
    box-shadow: none; font-weight: 400; min-height: auto;
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.modal-close:hover {
    color: var(--text); background: var(--bg-3);
    transform: rotate(90deg);
}
.modal-body { margin-top: var(--s-2); }
.modal-actions {
    margin-top: var(--s-5);
    display: flex; gap: var(--s-3);
    align-items: center;
}
.modal-actions > button { flex: 1; }

/* «← Назад + Сформировать PDF» — назад как текстовая ghost-кнопка слева, CTA шире справа */
.modal-actions--split .btn-back { flex: 0 0 auto; }
.modal-actions--split .btn-cta  { flex: 1; }

/* Текстовая «назад» кнопка */
.btn-back {
    background: transparent;
    color: var(--text-2);
    border: none;
    box-shadow: none;
    padding: 10px 14px;
    width: auto;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}
.btn-back:hover { background: var(--bg-3); color: var(--text); transform: none; }
.btn-back svg { stroke: currentColor; }

/* Блоки внутри Подробнее */
.det-section { margin-top: 18px; }
.det-section:first-child { margin-top: 0; }
.det-section h3 {
    font-size: 10px; font-weight: 700; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.8px;
    margin: 0 0 10px; padding-bottom: 0;
    border-bottom: none;
}
.det-addr-main {
    font-size: 16px; font-weight: 600; color: var(--text);
    letter-spacing: -0.005em;
}
.det-addr-sub  { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.det-zone-card {
    display: flex; align-items: center; gap: 14px;
    padding: 16px;
    background: var(--bg-2);
    border-radius: 16px;
    border: none;
    box-shadow: none;
}
.det-zone-swatch {
    width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
    border: none;
    box-shadow: 0 0 0 4px #fff;
}
.det-zone-name {
    font-size: 14px; font-weight: 600; color: var(--text);
    letter-spacing: -0.005em;
}
.det-zone-meta { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.det-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); line-height: 1.6; }
.det-list li { margin: 4px 0; }
.det-text { font-size: 14px; color: var(--text); line-height: 1.55; margin: 0; }

/* CTA-кнопка — flat solid pill */
.btn-cta {
    background: var(--green-500);
    color: #fff; font-weight: 600; font-size: 14px;
    padding: 14px 20px; min-height: 50px;
    border-radius: 14px;
    box-shadow: none;
    letter-spacing: -0.005em;
}
.btn-cta:hover { background: var(--green-700); }
.btn-cta svg { stroke: currentColor; }

/* Кнопка «Подробнее» в карточке/попапе */
.btn-details {
    background: var(--primary-tint); color: var(--primary);
    border: none; font-weight: 600;
    padding: 11px 14px; min-height: auto; font-size: 13px;
    box-shadow: none;
    width: 100%;
    border-radius: 12px;
}
.btn-details:hover {
    background: var(--primary); color: #fff;
}

/* ========== БАННЕР РЕЖИМА РИСОВАНИЯ ========== */
.draw-banner {
    display: none;
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    background: var(--text); color: #fff;
    padding: 10px 14px; border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    z-index: 1500;
    align-items: center; gap: 14px;
    max-width: calc(100vw - 24px);
}
.draw-banner.active { display: flex; }
.draw-banner__text { display: flex; flex-direction: column; gap: 2px; font-size: 12px; line-height: 1.3; }
.draw-banner__text strong { font-size: 13px; font-weight: 700; }
.draw-banner__text span { color: #cbd5e1; }
.draw-banner__cancel {
    width: auto; padding: 6px 12px; min-height: auto; font-size: 12px;
    background: transparent; color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
}
.draw-banner__cancel:hover { background: rgba(255,255,255,0.1); }

/* Полигон Leaflet.Draw — тёмно-зелёный */
.leaflet-draw-tooltip { font-family: 'Inter', sans-serif; font-size: 12px; }

.muted { color: var(--text-2); font-size: 13px; }

/* ========== ЛИД-ФОРМА ========== */
.lead-form { display: flex; flex-direction: column; gap: 14px; }

/* PDF-отчёт по участку: in-modal форма (alias лид-формы + кастомы для слайдера) */
.report-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.report-form[hidden] { display: none; }
#detailsInfoView[hidden] { display: none; }
.report-summary { background: var(--bg-2); border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.report-summary:empty { display: none; }
.report-summary .ls-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
.report-summary .ls-row:first-child { margin-top: 0; }
.report-summary .ls-key { color: var(--text-2); flex-shrink: 0; }
.report-summary .ls-val { font-weight: 600; text-align: right; }

.slider-row {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-2); border-radius: 8px; padding: 10px 12px;
}
.slider-row input[type="range"] { flex: 1; accent-color: var(--green); }
.slider-value { font-size: 13px; font-weight: 600; color: var(--text); min-width: 110px; text-align: right; }
.slider-sub { color: var(--text-2); font-weight: 400; font-size: 11px; display: inline-block; margin-left: 2px; }

.btn-secondary {
    background: var(--bg-2); color: var(--text);
    border: none; font-weight: 500;
    padding: 12px 16px; min-height: auto; font-size: 13px;
    border-radius: 12px; cursor: pointer;
}
.btn-secondary:hover { background: var(--border); }

.lead-summary {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
}
.lead-summary:empty { display: none; }
.lead-summary strong { font-weight: 600; }
.lead-summary .ls-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
.lead-summary .ls-row:first-child { margin-top: 0; }
.lead-summary .ls-key { color: var(--text-2); flex-shrink: 0; }
.lead-summary .ls-val { font-weight: 600; text-align: right; }

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label {
    font-size: 12px; font-weight: 600; color: var(--text);
}
.form-field label .req { color: #dc2626; }
.form-field label .opt { color: var(--text-2); font-weight: 400; }

.form-field input,
.form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.form-field select { appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-field input:focus,
.form-field select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(45,122,79,0.12);
}
.form-field input.invalid,
.form-field select.invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220,38,38,0.10);
}

.form-hint { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.form-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    display: none;
}
.form-error.visible { display: block; }

.form-consent {
    font-size: 10px; color: var(--text-2);
    text-align: center; line-height: 1.5;
    margin-top: -4px;
}

/* Success state */
.lead-success { text-align: center; padding: 16px 0 8px; }
.lead-success__icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--green-light); color: var(--green);
    font-size: 32px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.lead-success h3 { margin: 0 0 8px; font-size: 16px; color: var(--text); }
.lead-success p { margin: 0 0 18px; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.lead-success button {
    width: auto; min-height: auto; padding: 9px 18px;
    background: var(--bg-2); color: var(--text);
    border: 1px solid var(--border);
    margin: 0 auto;
}

/* iOS не зумит инпуты при font-size >= 16px */
@media (max-width: 640px) {
    .form-field input,
    .form-field select { font-size: 16px; padding: 12px; }
}

@media (max-width: 640px) {
    .modal-box { padding: 20px 16px; }
    .modal-box h2 { font-size: 16px; }
    .draw-banner { top: 8px; padding: 10px 12px; gap: 10px; }
    .draw-banner__text strong { font-size: 12px; }
    .draw-banner__text span { font-size: 11px; }
}

/* ========== LEAFLET — попап и зум-контрол ========== */
/* Сглаживаем стандартный белый попап под наш стиль */
.leaflet-popup-content-wrapper {
    background: var(--bg) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border) !important;
    padding: 0 !important;
}
.leaflet-popup-content {
    margin: 14px 16px !important;
    font-family: var(--font) !important;
    line-height: 1.5 !important;
}
.leaflet-popup-tip {
    background: var(--bg) !important;
    box-shadow: var(--shadow-sm) !important;
}
.leaflet-popup-close-button {
    color: var(--text-3) !important;
    font-size: 18px !important;
    padding: 6px 8px 0 0 !important;
    transition: color 0.15s;
}
.leaflet-popup-close-button:hover { color: var(--text) !important; }

/* Кнопка «Подробнее» внутри попапа — в стиль */
.popup-details-btn {
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.12s !important;
}
.popup-details-btn:hover {
    background: var(--primary) !important;
    color: #fff !important;
}
.popup-details-btn:active { transform: translateY(0.5px); }

/* Зум-контрол Leaflet — современнее */
.leaflet-touch .leaflet-bar a,
.leaflet-bar a {
    background: var(--bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    font-weight: 600 !important;
    transition: background 0.15s, color 0.15s !important;
}
.leaflet-bar a:hover {
    background: var(--primary-tint) !important;
    color: var(--primary) !important;
}
.leaflet-bar {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    border: none !important;
    overflow: hidden !important;
}
.leaflet-bar a:first-child { border-top-left-radius: var(--radius) !important; border-top-right-radius: var(--radius) !important; }
.leaflet-bar a:last-child  { border-bottom-left-radius: var(--radius) !important; border-bottom-right-radius: var(--radius) !important; }

/* Наша zoom-level-label — приведём в один стиль с +/- */
.zoom-level-label {
    background: var(--bg) !important;
    border: none !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 6px 10px !important;
    font: 600 12px/1 var(--font) !important;
    color: var(--text-2) !important;
    text-align: center;
    min-width: 36px;
    margin-top: 6px !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

/* Атрибуция Leaflet — поскромнее */
.leaflet-control-attribution {
    background: rgba(255,255,255,0.85) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--radius-sm) 0 0 0 !important;
    font-size: 10px !important;
    color: var(--text-2) !important;
}
.leaflet-control-attribution a { color: var(--text-2) !important; }

/* Ghost-кнопка — тёртичный action (share/close в карточке и др.) */
.btn-ghost {
    background: var(--bg);
    color: var(--text-2);
    border: none;
    font-weight: 500;
    font-size: 13px;
    padding: 9px 12px;
    box-shadow: none;
}
.btn-ghost:hover {
    background: var(--bg-2);
    color: var(--text);
}
.btn-ghost svg { stroke: currentColor; width: 14px; height: 14px; }

/* Подгон padding/radius для ghost под общую систему */
.btn-ghost { padding: 11px 14px; border-radius: 12px; }

/* ========== ПРЕЛОАДЕР (Elite Invest × AI HUB) ========== */
/* Этапы (управляется через JS через классы phase-1..6):
   phase-1: рисуется контур Elite Invest    (~1.4с)
   phase-2: рисуется контур AI HUB           (~1.4с)
   phase-3: оба заливаются цветом            (~0.5с)
   phase-4: появляется «×»                   (~0.4с)
   phase-5: появляется caption               (~0.5с)
   phase-6: всё уходит fade-out              (~0.5с)
*/
.splash {
    position: fixed; inset: 0;
    z-index: 9999;
    background: #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    opacity: 1;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}
.splash--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-row {
    display: flex;
    align-items: center;
    gap: 36px;
    min-height: 110px;
}

.splash-svg {
    height: auto;
    overflow: visible;
}
.splash-svg--ei    { width: 200px; }
.splash-svg--aihub { width: 78px;  }

/* Пути изначально: только контур, без заливки.
   JS подставит stroke-dasharray/offset через --len. */
.splash-svg path {
    fill: transparent;
    stroke: currentColor;
    stroke-width: 0.6;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-dasharray: var(--len, 1000);
    stroke-dashoffset: var(--len, 1000);
    transition:
        stroke-dashoffset 1.4s cubic-bezier(.55,.08,.45,1),
        fill 0.5s ease,
        stroke 0.5s ease;
}
.splash-svg--ei    { color: #282828; }
.splash-svg--aihub { color: #152235; }

/* AI HUB шире-stroke для крупных путей */
.splash-svg--aihub path { stroke-width: 2; }

/* phase-1: ei stroke draws */
.splash.phase-1 .splash-svg--ei path,
.splash.phase-2 .splash-svg--ei path,
.splash.phase-3 .splash-svg--ei path,
.splash.phase-4 .splash-svg--ei path,
.splash.phase-5 .splash-svg--ei path,
.splash.phase-6 .splash-svg--ei path { stroke-dashoffset: 0; }

/* phase-2: aihub stroke draws */
.splash.phase-2 .splash-svg--aihub path,
.splash.phase-3 .splash-svg--aihub path,
.splash.phase-4 .splash-svg--aihub path,
.splash.phase-5 .splash-svg--aihub path,
.splash.phase-6 .splash-svg--aihub path { stroke-dashoffset: 0; }

/* phase-3: оба заливаются (через data-fill, выставленное JS) */
.splash.phase-3 .splash-svg path,
.splash.phase-4 .splash-svg path,
.splash.phase-5 .splash-svg path,
.splash.phase-6 .splash-svg path {
    fill: var(--target-fill, currentColor);
    stroke: transparent;
}

/* Разделитель «×» */
.splash-sep {
    font-size: 34px;
    font-weight: 200;
    color: var(--stone-300);
    line-height: 1;
    opacity: 0;
    transform: scale(0.6) rotate(-90deg);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(.16,.84,.34,1);
    user-select: none;
    align-self: center;
}
.splash.phase-4 .splash-sep,
.splash.phase-5 .splash-sep,
.splash.phase-6 .splash-sep {
    opacity: 1;
    transform: scale(1) rotate(0);
}

/* Caption */
.splash-caption {
    font-size: 13px;
    color: var(--text-3);
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.16,.84,.34,1);
}
.splash.phase-5 .splash-caption,
.splash.phase-6 .splash-caption {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 640px) {
    .splash-row { gap: 24px; min-height: 90px; }
    .splash-svg--ei    { width: 160px; }
    .splash-svg--aihub { width: 60px; }
    .splash-sep { font-size: 26px; }
    .splash-caption { font-size: 11px; letter-spacing: 0.9px; }
}

@media (prefers-reduced-motion: reduce) {
    .splash-svg path {
        stroke-dashoffset: 0 !important;
        fill: var(--target-fill, currentColor) !important;
        stroke: transparent !important;
        transition: none !important;
    }
    .splash-sep, .splash-caption {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}
