/* ====================== ОСНОВНЫЕ СТИЛИ ====================== */
#map {
    height: 100vh;
    width: 100%;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    overflow: hidden;
    --leaflet-right-offset: 82px;
    --tools-sidebar-width: 280px;
    --tools-sidebar-gap: 18px;
}

body.layers-modal-open {
    overflow: hidden;
}

.map-center-links {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 9600;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
}

.map-center-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 12px;
    line-height: 1.2;
    letter-spacing: 0.01em;
    transition:
        color 0.18s ease,
        opacity 0.18s ease;
}

.map-center-link:hover {
    color: white;
}

.floating-doc-link {
    position: fixed;
    right: 18px;
    bottom: 92px;
    z-index: 9600;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(7, 39, 58, 0.72);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 20px rgba(5, 23, 35, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease;
}

.floating-doc-link:hover {
    transform: translateY(-1px);
    background: rgba(12, 60, 89, 0.82);
    border-color: rgba(255, 255, 255, 0.26);
}

body.layers-modal-open .map-center-links,
body.layers-modal-open .floating-doc-link {
    opacity: 0;
    pointer-events: none;
}

/* ====================== БОКОВАЯ ПАНЕЛЬ ====================== */
.sidebar {
    position: fixed;
    top: 0;

    height: 100vh;
    background: linear-gradient(135deg, #0b476a 0%, #79bd8f 100%);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-left {
    left: -380px;
    width: 380px;
    overflow: visible;
}

.sidebar-right {
    right: -280px;
    width: 280px;
    left: auto;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.3);
    overflow: visible;
}

.sidebar-left.open {
    left: 0;
}

.sidebar-right.open {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.sidebar-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3em;
    font-weight: 600;
    flex: 0 1 auto;
    min-width: 0;
}

.sidebar-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.prototype-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.sidebar-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

#contact {
    margin-top: auto;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
    line-height: 1.4;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    text-align: center;
}

.sidebar-contact-line + .sidebar-contact-line {
    margin-top: 8px;
}

#contact a {
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

#contact a:hover {
    border-bottom-color: rgba(255, 255, 255, 0.8);
}

.sidebar-doc-link {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 8px 18px rgba(6, 27, 39, 0.14);
    transition:
        transform 0.18s ease,
        background 0.18s ease,
        box-shadow 0.18s ease,
        border-color 0.18s ease;
}

.sidebar-doc-link:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 10px 22px rgba(6, 27, 39, 0.18);
}

/* Кнопка открытия боковой панели */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10000;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #0b476a 0%, #79bd8f 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.sidebar-toggle .toggle-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================== ЧАТ В БОКОВОЙ ПАНЕЛИ ====================== */
/* ====================== ПРАВАЯ ПАНЕЛЬ ИНСТРУМЕНТОВ ====================== */
#sidebar-toggle.sidebar-toggle {
    position: absolute;
    top: 20px;
    right: -56px;
    left: auto;
    width: 56px;
    height: 56px;
    border-radius: 0 22px 22px 0;
}

#sidebar-toggle.sidebar-toggle:hover {
    transform: translateX(4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

#tools-toggle.tools-toggle {
    position: absolute;
    top: 20px;
    left: -56px;
    right: auto;
    width: 56px;
    height: 56px;
    border-radius: 22px 0 0 22px;
    background: linear-gradient(135deg, #0b476a 0%, #79bd8f 100%);
    z-index: 10000;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    color: white;
}

#tools-toggle.tools-toggle:hover {
    transform: translateX(-4px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.auth-trigger {
    position: relative;
    min-width: 136px;
    max-width: 156px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    color: #0b476a;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease,
        border-color 0.18s ease;
}

.auth-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.auth-trigger.is-authenticated {
    background: linear-gradient(135deg, #0b476a 0%, #79bd8f 100%);
    color: white;
}

#auth-trigger-label {
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}

.auth-trigger-user {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.2;
    opacity: 0.82;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tools-section {
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.geojson-upload {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.geojson-file-hidden {
    display: none;
}

.geojson-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #0b476a 0%, #66b18b 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.1;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 6px 14px rgba(4, 30, 44, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.geojson-btn-icon {
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.geojson-btn-main {
    display: inline-block;
    line-height: 1.1;
}

.geojson-btn:hover {
    transform: translateY(-1px);
    box-shadow:
        0 9px 18px rgba(4, 30, 44, 0.36),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    background: linear-gradient(135deg, #0a3b57 0%, #5aa47f 100%);
}

.geojson-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.geojson-btn:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.geojson-hint {
    margin: 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
}

.tools-section:last-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.tools-section h4 {
    margin: 0 0 12px 0;
    color: white;
    font-size: 1.02rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tools-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.tools-section-header h4 {
    margin: 0;
}

.tools-mini-btn {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.tools-mini-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.tools-mini-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.layers-launch-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    background: linear-gradient(
        135deg,
        rgba(11, 71, 106, 0.92),
        rgba(121, 189, 143, 0.88)
    );
    color: white;
    text-align: left;
    cursor: pointer;
    box-shadow:
        0 14px 26px rgba(6, 23, 34, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.layers-launch-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.26);
    box-shadow:
        0 18px 30px rgba(6, 23, 34, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.layers-launch-btn-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.layers-launch-btn-text {
    font-size: 12px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.82);
}

.db-layers-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.db-layers-open-btn {
    justify-content: flex-start;
}

.db-layers-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.db-layers-panel .db-layers-table-wrap {
    max-height: min(40vh, 380px);
    overflow: auto;
}

.db-layers-modal-panel {
    min-height: 0;
}

.layers-modal {
    position: fixed;
    inset: 0;
    z-index: 13200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4, 16, 24, 0.46);
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.layers-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.layers-modal-content {
    position: relative;
    width: min(760px, 94vw);
    max-height: min(78vh, 820px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px 26px 22px;
    border-radius: 24px;
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 255, 255, 0.98),
            rgba(244, 251, 249, 0.98) 56%
        ),
        linear-gradient(
            135deg,
            rgba(11, 71, 106, 0.08),
            rgba(121, 189, 143, 0.16)
        );
    border: 1px solid rgba(11, 71, 106, 0.12);
    box-shadow:
        0 28px 72px rgba(7, 25, 36, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.74);
    transform: translateY(14px) scale(0.98);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.layers-modal.show .layers-modal-content {
    transform: translateY(0) scale(1);
}

.layers-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(12, 54, 76, 0.08);
    color: rgba(12, 54, 76, 0.68);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.layers-modal-close:hover {
    background: rgba(12, 54, 76, 0.14);
    color: rgba(12, 54, 76, 0.96);
    transform: rotate(90deg);
}

.layers-modal-intro {
    padding-right: 52px;
}

.layers-modal-eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(11, 71, 106, 0.1);
    color: rgba(11, 71, 106, 0.82);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.layers-modal-intro h3 {
    margin: 12px 0 8px;
    color: #0c364c;
    font-size: clamp(1.55rem, 2vw, 2rem);
    line-height: 1.1;
}

.layers-modal-subtitle {
    margin: 0;
    color: rgba(12, 54, 76, 0.72);
    font-size: 14px;
    line-height: 1.55;
}

.layers-modal-panel.tools-section {
    margin: 0;
    padding: 0;
    border-bottom: none;
}

.layers-modal-panel .tools-section-header {
    margin-bottom: 14px;
}

.layers-modal-panel .tools-section-header h4 {
    color: #0c364c;
    font-size: 1rem;
}

.layers-modal-panel .tools-mini-btn {
    color: #0c364c;
    background: rgba(11, 71, 106, 0.08);
    border-color: rgba(11, 71, 106, 0.14);
}

.layers-modal-panel .tools-mini-btn:hover {
    background: rgba(11, 71, 106, 0.14);
    border-color: rgba(11, 71, 106, 0.22);
}

.layers-modal-panel .db-layers-table-wrap {
    background: rgba(10, 42, 58, 0.06);
    border-color: rgba(11, 71, 106, 0.12);
    max-height: min(52vh, 520px);
    overflow: auto;
}

.layers-modal-panel .db-layers-table thead {
    background: rgba(11, 71, 106, 0.08);
}

.layers-modal-panel .db-layers-table th {
    color: rgba(12, 54, 76, 0.68);
}

.layers-modal-panel .db-layer-title {
    color: #0e3247;
}

.layers-modal-panel .db-layer-load-btn,
.layers-modal-panel .db-layer-delete-btn {
    border-color: rgba(11, 71, 106, 0.14);
}

.layers-modal-panel .db-layer-load-btn {
    background: rgba(121, 189, 143, 0.18);
    color: #185d54;
}

.layers-modal-panel .db-layer-load-btn:hover {
    background: rgba(121, 189, 143, 0.26);
    border-color: rgba(11, 71, 106, 0.2);
}

.layers-modal-panel .db-layer-delete-btn {
    background: rgba(219, 96, 80, 0.12);
    color: #8d4038;
}

.layers-modal-panel .db-layer-delete-btn:hover {
    background: rgba(219, 96, 80, 0.18);
    border-color: rgba(11, 71, 106, 0.2);
}

.layers-modal-panel .db-layers-empty td {
    color: rgba(12, 54, 76, 0.7);
}

.db-layers-table-wrap {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(7, 32, 44, 0.18);
    overflow: hidden;
}

.db-layers-table {
    width: 100%;
    border-collapse: collapse;
}

.db-layers-table thead {
    background: rgba(255, 255, 255, 0.08);
}

.db-layers-table th,
.db-layers-table td {
    padding: 10px 12px;
    text-align: left;
}

.db-layers-table th {
    color: rgba(255, 255, 255, 0.78);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.db-layers-table th:last-child,
.db-layers-table td:last-child {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.db-layers-table tbody tr + tr {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.db-layer-title {
    color: white;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    word-break: break-word;
}

.db-layer-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.db-layer-load-btn,
.db-layer-delete-btn {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.db-layer-load-btn {
    background: rgba(114, 247, 197, 0.14);
    color: #d9fff0;
}

.db-layer-load-btn:hover {
    background: rgba(114, 247, 197, 0.22);
    border-color: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.db-layer-load-btn:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.db-layer-delete-btn {
    background: rgba(255, 107, 107, 0.14);
    color: #ffd9d9;
}

.db-layer-delete-btn:hover {
    background: rgba(255, 107, 107, 0.22);
    border-color: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.db-layer-delete-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.db-layers-empty td {
    color: rgba(255, 255, 255, 0.76);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.tool-btn {
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(3px);
}

.tool-btn:active {
    transform: translateX(1px);
}

.tool-btn:last-child {
    margin-bottom: 0;
}

/* ====================== ЧАТ В БОКОВОЙ ПАНЕЛИ ====================== */
.chat-messages-frame {
    flex: 1;
    position: relative;
    min-height: 0;
    margin-bottom: 15px;
}

.chat-messages {
    height: 100%;
    overflow-y: auto;
    padding: 15px 72px 52px 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-mode-selector {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
}

.chat-mode-selector label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 14px;
}

.chat-mode-selector select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
}

.chat-mode-selector select:focus {
    outline: none;
    border-color: #2c7be5;
    box-shadow: 0 0 0 3px rgba(44, 123, 229, 0.15);
}

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.chat-input {
    flex: 1;
    border: none;
    padding: 14px;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    font-size: 14px;
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chat-send {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e88 100%);
    color: white;
    border: none;
    padding: 14px 22px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.18s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    min-width: 50px;
}

.chat-send:hover,
.chat-send:active {
    transform: scale(1.18);
}

.chat-send:active {
    transform: scale(0.94);
}

.chat-status {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    margin: 0;
    padding: 4px 9px;
    background: rgba(11, 71, 106, 0.12);
    border: 1px solid rgba(11, 71, 106, 0.1);
    font-size: 10px;
    border-radius: 999px;
    color: rgba(11, 71, 106, 0.62);
    font-weight: 700;
    line-height: 1;
    text-align: center;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 12px rgba(12, 60, 89, 0.06);
    pointer-events: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* Сообщения в чате */
.message {
    display: flex;
    max-width: 85%;
    margin: 8px 0;
}

.message.user {
    align-self: flex-end;
    justify-content: flex-end;
}

.message.assistant,
.message.system {
    align-self: flex-start;
    justify-content: flex-start;
}

.message.assistant {
    padding-left: 48px;
    position: relative;
}

.bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    font-size: 15px;
    word-wrap: break-word;
    position: relative;
    max-width: 100%;
}

/* Пользователь */
.message.user .bubble {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Ассистент */
.message.assistant .bubble {
    background: #e9ecef;
    color: #212529;
    border-bottom-left-radius: 4px;
}

/* Системные */
.message.system .bubble {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    font-size: 0.9em;
    padding: 10px 14px;
    border-radius: 10px;
    align-self: center;
}

/* Аватары (dicebear) */
.bubble::before {
    content: "";
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
}

.message.assistant .bubble::before {
    left: -42px;
    background: #e4e3e3
        url("https://api.dicebear.com/9.x/bottts/svg?seed=assistant")
        center/cover;
}

.message.user .bubble::before {
    right: -42px;
    background: #0d6efd
        url("https://api.dicebear.com/9.x/personas/svg?seed=user") center/cover;
}

/* Thinking */
.message.thinking .bubble {
    background: #e9e9e9;
    color: #555;
}

.message.thinking .dot {
    display: inline-block;
    animation: blink 1.4s infinite;
    opacity: 0;
    margin: 0 1px;
}

.message.thinking .dot:nth-child(2) {
    animation-delay: 0.2s;
}
.message.thinking .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.cross-css {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    z-index: 10000;
    pointer-events: none;
    opacity: 0.95;
    user-select: none;
    background:
        linear-gradient(rgba(219, 96, 80, 0.82) 0 0) center top / 2px 14px
            no-repeat,
        linear-gradient(rgba(219, 96, 80, 0.82) 0 0) center bottom / 2px 14px
            no-repeat,
        linear-gradient(rgba(219, 96, 80, 0.82) 0 0) left center / 14px 2px
            no-repeat,
        linear-gradient(rgba(219, 96, 80, 0.82) 0 0) right center / 14px 2px
            no-repeat;
    filter: drop-shadow(0 1px 6px rgba(255, 255, 255, 0.7));
}

body.layers-modal-open .cross-css,
body.layers-modal-open .leaflet-control-coordinates,
body.layers-modal-open .leaflet-top,
body.layers-modal-open .leaflet-bottom {
    opacity: 0;
    pointer-events: none;
}

.cross-css::before {
    content: "";
    position: absolute;
    inset: 18px;
    border-radius: 50%;
    border: 2px solid rgba(219, 96, 80, 0.68);
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.78);
}

.cross-css::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: #db6050;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.95),
        0 0 12px rgba(219, 96, 80, 0.32);
}

/* ====================== LEAFLET ====================== */
.leaflet-top.leaflet-right,
.leaflet-bottom.leaflet-right {
    right: var(--leaflet-right-offset);
    transition:
        right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease;
}

body.tools-sidebar-open .leaflet-top.leaflet-right,
body.tools-sidebar-open .leaflet-bottom.leaflet-right {
    right: calc(
        var(--leaflet-right-offset) + var(--tools-sidebar-width) +
            var(--tools-sidebar-gap)
    );
}

.leaflet-control-layers {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-family: Arial, sans-serif;
    font-size: 14px;
    top: 30px;
}

.leaflet-control-layers label {
    color: #333;
    padding: 5px 10px;
}

.leaflet-control-layers input[type="checkbox"],
.leaflet-control-layers input[type="radio"] {
    margin-right: 8px;
}

.leaflet-control-layers-expanded {
    padding: 10px;
}

/* Попапы */
.custom-popup .leaflet-popup-content-wrapper {
    background-color: #f0f8ff;
    border-radius: 5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.custom-popup .leaflet-popup-content {
    font-family: "Verdana", sans-serif;
    font-size: 12px;
    color: #333;
    padding: 10px;
}

.custom-popup .leaflet-popup-tip {
    background-color: #f0f8ff;
}

/* Векторные слои */
.custom-vector path.leaflet-interactive {
    stroke: #0066cc;
    stroke-width: 3;
    fill: #99ccff;
    fill-opacity: 0.5;
    transition: fill-opacity 0.2s;
}

.custom-vector path.leaflet-interactive:hover {
    fill-opacity: 0.8;
}

/* Маркеры */
.custom-marker {
    transition: transform 0.2s;
}

.custom-marker:hover {
    transform: scale(1.2);
}

/* Тултипы */
.leaflet-tooltip {
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    padding: 5px;
}

/* ====================== МОБИЛЬНАЯ ВЕРСИЯ ====================== */
@media (min-width: 769px) and (max-width: 1199px) {
    body {
        --leaflet-right-offset: 56px;
        --tools-sidebar-width: 240px;
        --tools-sidebar-gap: 14px;
    }

    .sidebar-left {
        width: 320px;
        left: -320px;
    }

    .sidebar-right {
        width: 240px;
        right: -240px;
    }

    .sidebar-header {
        padding: 16px;
    }

    .sidebar-content {
        padding: 16px;
    }

    #sidebar-toggle.sidebar-toggle {
        top: 16px;
        right: -52px;
        width: 52px;
        height: 52px;
        border-radius: 0 20px 20px 0;
    }

    #tools-toggle.tools-toggle {
        top: 16px;
        left: -52px;
        width: 52px;
        height: 52px;
        border-radius: 20px 0 0 20px;
    }

    .auth-trigger {
        min-width: 122px;
        max-width: 140px;
        padding: 8px 10px;
    }

    .chat-messages {
        padding: 12px 68px 42px 12px;
    }

    .chat-input {
        padding: 12px 13px;
        font-size: 14px;
    }

    .chat-send {
        padding: 12px 18px;
        min-width: 46px;
    }

    .pdf-report-btn {
        width: calc(100% - 32px);
        margin: 14px 16px;
        padding: 11px 14px;
    }

    .tools-section {
        padding: 14px;
    }

    .db-layers-table th,
    .db-layers-table td {
        padding: 9px 10px;
    }

    .welcome-modal-content {
        width: min(680px, 94vw);
        padding: 28px 26px 24px;
    }

    .welcome-feature-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .leaflet-control-coordinates {
        max-width: 280px;
        font-size: 13px !important;
        padding: 8px 10px !important;
    }
}

@media (max-width: 768px) {
    body {
        --leaflet-right-offset: 12px;
        --tools-sidebar-width: 0px;
        --tools-sidebar-gap: 0px;
        --mobile-sheet-height: clamp(320px, 46vh, 390px);
        --mobile-toggle-offset: calc(env(safe-area-inset-bottom, 0px) + 14px);
    }

    .sidebar-left {
        top: auto;
        bottom: calc(-1 * var(--mobile-sheet-height) - 24px);
        width: 100%;
        height: var(--mobile-sheet-height);
        left: 0;
        right: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -16px 34px rgba(0, 0, 0, 0.34);
        overflow: hidden;
    }

    .sidebar-left.open {
        bottom: 0;
    }

    .sidebar-right {
        top: auto;
        bottom: calc(-1 * var(--mobile-sheet-height) - 24px);
        width: 100%;
        height: var(--mobile-sheet-height);
        right: 0;
        left: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -16px 34px rgba(0, 0, 0, 0.34);
        overflow: hidden;
    }

    .sidebar-right.open {
        bottom: 0;
    }

    .sidebar-left .sidebar-content,
    .sidebar-right .sidebar-content {
        overflow-y: auto;
        scrollbar-width: none;
    }

    .sidebar-left .sidebar-content::-webkit-scrollbar,
    .sidebar-right .sidebar-content::-webkit-scrollbar {
        display: none;
    }

    .sidebar-left .sidebar-content {
        gap: 10px;
        align-items: stretch;
    }

    .sidebar-right .sidebar-content {
        gap: 12px;
        justify-content: flex-start;
    }

    /* ====================== ПРАВАЯ ПАНЕЛЬ ИНСТРУМЕНТОВ ====================== */
    #sidebar-toggle.sidebar-toggle {
        position: fixed;
        top: auto;
        right: auto;
        bottom: var(--mobile-toggle-offset);
        left: 14px;
        width: 48px;
        height: 48px;
        border-radius: 14px;
    }

    #tools-toggle.tools-toggle {
        position: fixed;
        top: auto;
        left: auto;
        bottom: var(--mobile-toggle-offset);
        right: 14px;
        width: 48px;
        height: 48px;
        border-radius: 14px;
        background: linear-gradient(135deg, #0b476a 0%, #66b18b 100%);
    }

    body.chat-sidebar-open #sidebar-toggle.sidebar-toggle,
    body.chat-sidebar-open #tools-toggle.tools-toggle,
    body.tools-sidebar-open #sidebar-toggle.sidebar-toggle,
    body.tools-sidebar-open #tools-toggle.tools-toggle {
        bottom: calc(
            var(--mobile-sheet-height) + env(safe-area-inset-bottom, 0px) + 10px
        );
    }

    .auth-trigger {
        min-width: 108px;
        max-width: 122px;
        padding: 7px 8px;
        border-radius: 14px;
    }

    #auth-trigger-label {
        font-size: 13px;
    }

    .auth-trigger-user {
        font-size: 11px;
    }

    .geojson-upload {
        gap: 6px;
    }

    .geojson-btn {
        min-height: 42px;
        padding: 9px 10px;
        font-size: 13px;
        gap: 6px;
    }

    .geojson-btn-icon {
        font-size: 15px;
    }

    .geojson-hint {
        font-size: 10px;
    }

    .tools-section {
        padding: 14px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.14);
    }

    .tools-section:last-child {
        border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    }

    .tools-section h4 {
        margin: 0 0 10px 0;
        color: white;
        font-size: 1rem;
        font-weight: 600;
    }

    .layers-launch-btn {
        padding: 12px 14px;
        border-radius: 14px;
        gap: 6px;
    }

    .layers-launch-btn-title {
        font-size: 14px;
    }

    .layers-launch-btn-text {
        font-size: 11px;
    }

    .db-layers-summary {
        padding-right: 42px;
    }

    .db-layers-summary::after {
        right: 16px;
        width: 9px;
        height: 9px;
    }

    .tools-section-header {
        margin-bottom: 10px;
    }

    .tools-mini-btn {
        padding: 5px 8px;
        font-size: 10px;
    }

    .db-layers-table th,
    .db-layers-table td {
        padding: 8px 10px;
    }

    .db-layer-title {
        font-size: 12px;
    }

    .db-layers-panel {
        gap: 10px;
    }

    .db-layers-panel .db-layers-table-wrap {
        max-height: min(26vh, 240px);
    }

    .db-layer-delete-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .layers-modal {
        align-items: flex-end;
        padding: 0;
        background: rgba(4, 16, 24, 0.36);
    }

    .layers-modal-content {
        width: 100%;
        max-height: min(78vh, 640px);
        padding: 22px 16px calc(18px + env(safe-area-inset-bottom, 0px));
        border-radius: 24px 24px 0 0;
    }

    .layers-modal-intro {
        padding-right: 42px;
    }

    .layers-modal-intro h3 {
        font-size: 1.45rem;
    }

    .layers-modal-subtitle {
        font-size: 13px;
    }

    .layers-modal-panel .db-layers-table-wrap {
        max-height: min(48vh, 420px);
    }

    .tool-btn {
        width: 100%;
        padding: 10px 15px;
        margin-bottom: 8px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 6px;
        color: white;
        font-size: 14px;
        text-align: left;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 10px;
        transition: all 0.2s ease;
    }

    .tool-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateX(3px);
    }

    .tool-btn:active {
        transform: translateX(1px);
    }

    .tool-btn:last-child {
        margin-bottom: 0;
    }

    .sidebar-toggle {
        width: 44px;
        height: 44px;
        font-size: 20px;
        top: auto;
        left: auto;
    }

    .sidebar-header {
        padding: 12px 14px;
    }

    .sidebar-header-actions {
        gap: 6px;
    }

    .sidebar-header h3 {
        font-size: 1.08rem;
    }

    .sidebar-title-group {
        gap: 8px;
    }

    .prototype-badge {
        padding: 2px 6px;
        font-size: 9px;
    }

    .sidebar-content {
        padding: 15px 15px calc(15px + env(safe-area-inset-bottom, 0px));
    }

    .sidebar-close {
        display: none;
    }

    #contact {
        margin-top: 0;
        padding: 10px 12px;
        font-size: 12px;
    }

    .sidebar-doc-link {
        margin-top: 0;
        padding: 10px 12px;
        font-size: 12px;
    }

    .chat-messages {
        height: 100% !important;
        padding: 12px 64px 42px 12px;
    }

    .chat-messages-frame {
        flex: 1 1 140px;
        min-height: 140px;
        max-height: 28vh;
        margin-bottom: 0;
    }

    #chat-messages.is-empty {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #chat-messages.is-empty::before {
        content: "Диалог появится здесь";
        color: rgba(11, 71, 106, 0.56);
        font-size: 14px;
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    .chat-mode-selector,
    .chat-input-bar,
    .chat-status,
    .pdf-report-btn,
    #contact,
    .sidebar-doc-link,
    .tools-section {
        flex-shrink: 0;
    }

    .chat-mode-selector {
        margin-bottom: 0;
    }

    .chat-input-bar {
        margin-bottom: 0;
    }

    .chat-input {
        font-size: 16px !important; /* iOS zoom fix */
        padding: 12px 14px !important;
        border-radius: 30px !important;
        min-height: 48px !important;
    }

    .chat-send {
        padding: 12px 20px !important;
        font-size: 15px !important;
        min-width: 46px !important;
    }

    .chat-status {
        right: 10px;
        bottom: 10px;
        padding: 3px 8px;
        font-size: 10px;
    }

    .pdf-report-btn {
        width: 100%;
        margin: 0;
    }

    .message.assistant {
        padding-left: 42px !important;
    }

    .bubble {
        font-size: 15.5px !important;
        padding: 11px 15px !important;
        border-radius: 20px !important;
    }

    .cross-css {
        width: 46px;
        height: 46px;
        background:
            linear-gradient(rgba(219, 96, 80, 0.82) 0 0) center top / 2px 12px
                no-repeat,
            linear-gradient(rgba(219, 96, 80, 0.82) 0 0) center bottom / 2px
                12px no-repeat,
            linear-gradient(rgba(219, 96, 80, 0.82) 0 0) left center / 12px 2px
                no-repeat,
            linear-gradient(rgba(219, 96, 80, 0.82) 0 0) right center / 12px 2px
                no-repeat;
    }

    .cross-css::before {
        inset: 15px;
    }

    /* Safe-area для iPhone */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .sidebar {
            padding-bottom: env(safe-area-inset-bottom);
        }
    }

    @media (max-width: 360px) {
        .sidebar-content {
            padding: 12px;
        }

        .chat-messages {
            height: 100% !important;
        }

        .chat-messages-frame {
            min-height: 120px;
            max-height: 22vh;
        }
    }
}

@media (max-width: 768px) {
    .leaflet-control-coordinates {
        min-width: auto !important;
        width: auto !important;
        max-width: 85vw;
        font-size: 13px !important;
        padding: 6px 10px !important;
        line-height: 1.4;
        border-radius: 6px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
        background: rgba(255, 255, 255, 0.92);
        z-index: 1;
    }

    .leaflet-bottom.leaflet-right .leaflet-control-coordinates {
        margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 66px) !important;
    }

    body.chat-sidebar-open
        .leaflet-bottom.leaflet-right
        .leaflet-control-coordinates,
    body.tools-sidebar-open
        .leaflet-bottom.leaflet-right
        .leaflet-control-coordinates {
        margin-bottom: calc(
            var(--mobile-sheet-height, 46vh) +
                env(safe-area-inset-bottom, 0px) + 14px
        ) !important;
    }

    .leaflet-control-coordinates > div {
        margin: 2px 0 !important;
    }
}

/* ====================== КНОПКИ УПРАВЛЕНИЯ ====================== */
.pdf-report-btn {
    width: calc(100% - 40px);
    margin: 15px 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #0b476a 0%, #79bd8f 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pdf-report-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    background: linear-gradient(135deg, #0a3a5a 0%, #68ad7f 100%);
}

.pdf-report-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pdf-report-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Стили для кнопки postGeojson теперь в классе .geojson-btn выше */

#contack {
    position: fixed;
    bottom: 1px;
    left: 12%;
    transform: translateX(-50%);
    padding: 1px 12px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    color: rgb(0, 0, 0);
    font-size: 12px;
    z-index: 9999;
    opacity: 0.8;
    white-space: nowrap;
}

/* ====================== ПРИВЕТСТВЕННОЕ ОКНО ====================== */
.welcome-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(6, 28, 40, 0.3), rgba(6, 28, 40, 0.72)),
        rgba(7, 15, 22, 0.28);
    backdrop-filter: blur(10px);
    z-index: 12500;
    opacity: 0;
    transition: opacity 0.28s ease;
}

.welcome-modal.show {
    display: flex;
    opacity: 1;
}

.welcome-modal-content {
    position: relative;
    width: min(760px, 100%);
    padding: 34px 34px 30px;
    border-radius: 28px;
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 255, 255, 0.92),
            #ffffff 55%
        ),
        linear-gradient(
            135deg,
            rgba(11, 71, 106, 0.08),
            rgba(121, 189, 143, 0.12)
        );
    box-shadow:
        0 28px 80px rgba(5, 18, 27, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transform: translateY(18px) scale(0.98);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.welcome-modal.show .welcome-modal-content {
    transform: translateY(0) scale(1);
}

.welcome-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(12, 54, 76, 0.06);
    color: rgba(10, 49, 69, 0.48);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.welcome-close-btn:hover {
    background: rgba(12, 54, 76, 0.12);
    color: rgba(10, 49, 69, 0.88);
    transform: rotate(90deg);
}

.welcome-eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(11, 71, 106, 0.08);
    color: #0b476a;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.welcome-title {
    margin: 18px 0 12px;
    max-width: 620px;
    color: #091e2b;
    font-size: clamp(2rem, 4vw, 3.1rem);
    line-height: 1.02;
}

.welcome-subtitle {
    margin: 0;
    max-width: 620px;
    color: #476172;
    font-size: 17px;
    line-height: 1.6;
}

.welcome-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 26px 0 20px;
}

.welcome-feature-card {
    min-height: 112px;
    padding: 18px 18px 16px;
    border-radius: 18px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.96),
        rgba(242, 247, 250, 0.98)
    );
    border: 1px solid rgba(11, 71, 106, 0.08);
    box-shadow: 0 10px 26px rgba(11, 71, 106, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.welcome-feature-card strong {
    color: #0d3850;
    font-size: 16px;
}

.welcome-feature-card span {
    color: #587181;
    font-size: 14px;
    line-height: 1.5;
}

.welcome-note {
    margin: 0;
    max-width: 640px;
    color: #5b7281;
    font-size: 14px;
    line-height: 1.6;
}

.welcome-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 26px;
}

.welcome-btn {
    min-width: 168px;
    padding: 14px 18px;
    border-radius: 14px;
    border: none;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.welcome-btn:hover {
    transform: translateY(-1px);
}

.welcome-btn-primary {
    background: linear-gradient(135deg, #0b476a 0%, #4f9f93 100%);
    color: white;
    box-shadow: 0 16px 34px rgba(11, 71, 106, 0.24);
}

.welcome-btn-primary:hover {
    box-shadow: 0 20px 38px rgba(11, 71, 106, 0.3);
}

.welcome-btn-secondary {
    background: rgba(11, 71, 106, 0.08);
    color: #0b476a;
    border: 1px solid rgba(11, 71, 106, 0.12);
}

.welcome-btn-secondary:hover {
    background: rgba(11, 71, 106, 0.12);
}

/* ====================== МОДАЛКА АВТОРИЗАЦИИ ====================== */
.auth-modal {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(6, 28, 40, 0.34), rgba(6, 28, 40, 0.76)),
        rgba(7, 15, 22, 0.34);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 13000;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.auth-modal.show {
    display: flex;
    opacity: 1;
}

.auth-modal-content {
    background:
        radial-gradient(
            circle at top left,
            rgba(255, 255, 255, 0.98),
            rgba(246, 252, 250, 0.98) 56%
        ),
        linear-gradient(
            135deg,
            rgba(11, 71, 106, 0.08),
            rgba(121, 189, 143, 0.14)
        );
    padding: 30px;
    border-radius: 18px;
    width: 380px;
    max-width: 92vw;
    border: 1px solid rgba(11, 71, 106, 0.12);
    box-shadow:
        0 20px 46px rgba(8, 27, 38, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-modal.show .auth-modal-content {
    transform: scale(1);
}

.auth-input {
    width: 100%;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid rgba(11, 71, 106, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.88);
    color: #0e3247;
    font-size: 16px;
    box-sizing: border-box;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}

.auth-input::placeholder {
    color: rgba(14, 50, 71, 0.56);
}

.auth-input:focus {
    outline: none;
    border-color: rgba(11, 71, 106, 0.52);
    box-shadow: 0 0 0 3px rgba(79, 159, 147, 0.2);
    background: rgba(255, 255, 255, 0.96);
}

.auth-panel-hidden {
    display: none !important;
}

.auth-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #0b476a 0%, #4f9f93 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    box-shadow: 0 10px 24px rgba(11, 71, 106, 0.26);
    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.auth-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(11, 71, 106, 0.32);
    background: linear-gradient(135deg, #0a3b57 0%, #438b81 100%);
}

.auth-submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 5px 12px rgba(11, 71, 106, 0.2);
}

.auth-submit-btn:disabled {
    opacity: 0.62;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 3px 10px rgba(11, 71, 106, 0.18);
}

.auth-submit-btn-secondary {
    background: rgba(11, 71, 106, 0.08);
    color: #0b476a;
    box-shadow: none;
    border: 1px solid rgba(11, 71, 106, 0.14);
}

.auth-submit-btn-secondary:hover {
    background: rgba(11, 71, 106, 0.12);
    box-shadow: none;
}

.auth-close-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(11, 71, 106, 0.06);
    border: none;
    font-size: 28px;
    color: rgba(11, 71, 106, 0.44);
    cursor: pointer;
    line-height: 1;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.auth-close-btn:hover {
    color: rgba(11, 71, 106, 0.9);
    background: rgba(11, 71, 106, 0.12);
    transform: rotate(90deg);
}

.auth-title {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 1.4em;
    color: #0d3850;
}

.auth-switch {
    text-align: center;
    margin-top: 18px;
    font-size: 14px;
    color: #366476;
}

.auth-verify-panel {
    margin-top: 4px;
    padding: 18px 16px 14px;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(243, 249, 247, 0.92)),
        rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(11, 71, 106, 0.12);
}

.auth-verify-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(79, 159, 147, 0.14);
    color: #155b6e;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.auth-verify-message {
    margin: 12px 0 10px;
    color: #1c475c;
    line-height: 1.55;
    font-size: 14px;
}

.auth-verify-email {
    margin: 0 0 14px;
    color: #0d3850;
    font-weight: 700;
    word-break: break-word;
}

.auth-verify-actions {
    display: grid;
    gap: 10px;
}

#switch-to-register {
    color: #0b476a;
    font-weight: 600;
    cursor: pointer;
}

#switch-to-register:hover {
    text-decoration: underline;
    color: #0a3b57;
}

@media (max-width: 768px) {
    .welcome-modal {
        padding: 18px 14px;
    }

    .welcome-modal-content {
        padding: 24px 20px 22px;
        border-radius: 22px;
    }

    .welcome-title {
        margin-top: 16px;
        font-size: 2rem;
    }

    .welcome-subtitle {
        font-size: 15px;
    }

    .welcome-feature-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin: 20px 0 16px;
    }

    .welcome-feature-card {
        min-height: auto;
        padding: 14px 14px 13px;
    }

    .welcome-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 20px;
    }

    .welcome-btn {
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 12px;
    }

    .sidebar-content {
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .sidebar-title-group {
        gap: 6px;
    }

    .sidebar-header h3 {
        font-size: 1.1rem;
    }

    .auth-trigger {
        min-width: 102px;
        max-width: 118px;
        padding: 7px 8px;
    }

    #auth-trigger-label {
        font-size: 13px;
    }

    .auth-trigger-user {
        font-size: 11px;
    }

    .chat-input-bar {
        gap: 8px;
    }

    .chat-send {
        padding: 11px 16px !important;
        min-width: 42px !important;
    }

    .pdf-report-btn {
        width: calc(100% - 24px);
        margin: 10px 12px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .tools-section {
        padding: 12px;
    }

    .layers-launch-btn {
        padding: 11px 12px;
    }

    .layers-launch-btn-title {
        font-size: 13px;
    }

    .layers-launch-btn-text {
        font-size: 10px;
    }

    .geojson-btn {
        min-height: 40px;
        padding: 8px 10px;
    }

    .layers-modal-content {
        padding: 20px 14px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 20px 20px 0 0;
    }

    .layers-modal-close {
        top: 12px;
        right: 12px;
        width: 34px;
        height: 34px;
        font-size: 24px;
    }

    .layers-modal-intro {
        padding-right: 34px;
    }

    .layers-modal-intro h3 {
        font-size: 1.28rem;
    }

    .layers-modal-subtitle {
        font-size: 12px;
    }

    .auth-modal-content {
        padding: 22px 18px;
        border-radius: 16px;
    }

    .welcome-modal {
        padding: 12px;
    }

    .welcome-modal-content {
        padding: 20px 16px 18px;
        border-radius: 18px;
    }

    .welcome-title {
        font-size: 1.7rem;
    }
}

/* ====================== DEVICE-TUNED BREAKPOINTS ====================== */
@media (max-width: 430px) and (min-height: 780px) {
    #sidebar-toggle.sidebar-toggle,
    #tools-toggle.tools-toggle {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    }

    body.chat-sidebar-open #sidebar-toggle.sidebar-toggle,
    body.chat-sidebar-open #tools-toggle.tools-toggle,
    body.tools-sidebar-open #sidebar-toggle.sidebar-toggle,
    body.tools-sidebar-open #tools-toggle.tools-toggle {
        bottom: calc(
            var(--mobile-sheet-height) + env(safe-area-inset-bottom, 0px) + 8px
        );
    }

    .chat-messages-frame {
        min-height: 132px;
        max-height: 24vh;
    }

    .auth-modal-content {
        width: min(360px, 95vw);
    }

    .welcome-modal-content {
        width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    body {
        --leaflet-right-offset: 40px;
        --tools-sidebar-width: 250px;
        --tools-sidebar-gap: 12px;
    }

    .sidebar-left {
        width: 340px;
        left: -340px;
    }

    .sidebar-right {
        width: 250px;
        right: -250px;
    }

    .sidebar-header {
        padding: 18px;
    }

    .sidebar-content {
        padding: 18px;
    }

    #sidebar-toggle.sidebar-toggle {
        top: 16px;
        right: -54px;
        width: 54px;
        height: 54px;
    }

    #tools-toggle.tools-toggle {
        top: 16px;
        left: -54px;
        width: 54px;
        height: 54px;
    }

    body.tools-sidebar-open .leaflet-top.leaflet-right,
    body.tools-sidebar-open .leaflet-bottom.leaflet-right {
        opacity: 1;
        pointer-events: auto;
    }

    .leaflet-bottom.leaflet-right .leaflet-control-coordinates {
        margin-bottom: 0 !important;
    }

    .chat-messages {
        padding: 14px 70px 44px 14px;
    }

    .chat-messages-frame {
        margin-bottom: 14px;
    }

    .welcome-modal-content {
        width: min(720px, 92vw);
    }

    .auth-modal-content {
        width: min(440px, 88vw);
    }
}

@media (min-width: 1000px) and (max-width: 1100px) and (min-height: 1300px) and (orientation: portrait) {
    body {
        --leaflet-right-offset: 62px;
        --tools-sidebar-width: 260px;
        --tools-sidebar-gap: 14px;
    }

    .sidebar-left {
        width: 360px;
        left: -360px;
    }

    .sidebar-right {
        width: 260px;
        right: -260px;
    }

    .sidebar-header {
        padding: 18px 20px;
    }

    .sidebar-content {
        padding: 18px 20px;
    }

    .tools-section {
        padding: 15px;
    }

    .chat-messages {
        padding: 14px 70px 44px 14px;
    }
}

@media (max-width: 768px) {
    .map-center-links {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        gap: 10px;
    }

    .map-center-link {
        font-size: 11px;
    }

    .floating-doc-link {
        right: 12px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
        font-size: 11px;
        padding: 8px 10px;
    }

    body.chat-sidebar-open .map-center-links,
    body.tools-sidebar-open .map-center-links,
    body.chat-sidebar-open .floating-doc-link,
    body.tools-sidebar-open .floating-doc-link {
        opacity: 0;
        pointer-events: none;
    }
}
