* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    background-image: url('../images/Фон 1920х1080.png');
    background-size: cover;
    background-attachment: fixed;
    background-position: center right;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    overflow: hidden;
}

@media (min-width: 2560px) {
    body {
        background-image: url('../images/Фон 2880х1800.png');
    }
}

.user-desktop-wrap {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
}

.user-desktop-badge {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 123, 255, 0.25);
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.25s ease;
}

.user-desktop-badge:hover {
    background: rgba(0, 123, 255, 0.06);
    border-color: rgba(0, 123, 255, 0.4);
    color: #007bff;
}

.user-desktop-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 123, 255, 0.15);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.user-desktop-wrap.user-desktop-open .user-desktop-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-desktop-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.user-desktop-dropdown-item:hover {
    background: rgba(0, 123, 255, 0.08);
}

.user-desktop-logout {
    color: #dc3545;
}

.user-desktop-logout:hover {
    background: rgba(220, 53, 69, 0.08);
}

.user-panel-trigger {
    display: none;
}

.user-panel {
    display: none;
}

@media (min-width: 993px) {
    .user-desktop-wrap {
        display: block;
    }
}

@media (max-width: 992px) {
    .user-desktop-wrap {
        display: none;
    }

    .user-panel-trigger {
        display: flex;
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1001;
        align-items: center;
        gap: 8px;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(0, 123, 255, 0.35);
        border-radius: 14px;
        padding: 12px 18px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 4px 24px rgba(0, 123, 255, 0.15);
    }

    .user-panel-trigger:active {
        transform: scale(0.97);
    }

    .user-panel-trigger-icon {
        font-size: 20px;
        opacity: 0.95;
    }

    .user-panel {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        z-index: 2000;
        pointer-events: none;
    }

    .user-panel.user-panel-open {
        pointer-events: auto;
    }

    .user-panel-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        opacity: 0;
        transition: opacity 0.35s ease;
        backdrop-filter: blur(4px);
    }

    .user-panel-open .user-panel-backdrop {
        opacity: 1;
    }

    .user-panel-content {
        position: absolute;
        top: 0;
        right: 0;
        width: 100%;
        max-width: 320px;
        height: 100%;
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.2);
        transform: translateX(100%);
        transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .user-panel-open .user-panel-content {
        transform: translateX(0);
        animation: panelContentIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    @keyframes panelContentIn {
        0% { box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08); }
        100% { box-shadow: -12px 0 40px rgba(0, 0, 0, 0.2); }
    }
}

.user-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 2px solid rgba(0, 123, 255, 0.15);
    flex-shrink: 0;
}

.user-panel-title {
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}

.user-panel-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 123, 255, 0.08);
    border-radius: 10px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s ease;
}

.user-panel-close:hover {
    background: rgba(0, 123, 255, 0.15);
    color: #007bff;
}

.user-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.user-panel-open .user-panel-role-display,
.user-panel-open .user-panel-options .user-panel-option,
.user-panel-open .auth-form-container,
.user-panel-open .logout-container,
.user-panel-open .user-panel-territory {
    animation: panelItemFadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.user-panel-open .user-panel-role-display { animation-delay: 0.06s; opacity: 0; }
.user-panel-open .user-panel-options .user-panel-option:nth-child(1) { animation-delay: 0.12s; opacity: 0; }
.user-panel-open .user-panel-options .user-panel-option:nth-child(2) { animation-delay: 0.18s; opacity: 0; }
.user-panel-open .auth-form-container { animation-delay: 0.24s; opacity: 0; }
.user-panel-open .logout-container { animation-delay: 0.12s; opacity: 0; }
.user-panel-open .user-panel-territory { animation-delay: 0.2s; opacity: 0; }

@keyframes panelItemFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.user-panel-role-display {
    font-size: 14px;
    font-weight: 600;
    color: #007bff;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.08) 0%, rgba(0, 123, 255, 0.04) 100%);
    border-radius: 10px;
    border-left: 4px solid #007bff;
}

.user-panel-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-panel-option {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 10px;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: all 0.25s ease;
    font-size: 14px;
}

.user-panel-option:hover {
    background: rgba(0, 123, 255, 0.06);
    border-color: rgba(0, 123, 255, 0.4);
    transform: translateX(4px);
}

.auth-form-container {
    margin-top: 16px;
}

.auth-form-title {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 12px;
}

.auth-form-container .auth-form {
    margin: 0;
}

.auth-form-container .auth-form input {
    margin-bottom: 10px;
}

.logout-container {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 123, 255, 0.15);
}

.user-panel-logout {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.25);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.user-panel-logout:hover {
    background: rgba(220, 53, 69, 0.15);
    border-color: rgba(220, 53, 69, 0.4);
}

.user-panel-territory {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid rgba(0, 123, 255, 0.12);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-panel-territory-title {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.territories-nav-wrap {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 8px;
}

.territories-nav-btn {
    flex-shrink: 0;
    width: 40px;
    min-width: 40px;
    border: 2px solid rgba(0, 123, 255, 0.35);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 12px;
    font-size: 22px;
    font-weight: 600;
    color: #007bff;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.territories-nav-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(0, 123, 255, 0.08) 0%, rgba(0, 123, 255, 0.12) 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
}

.territories-nav-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.territories-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.polygons-list-mobile {
    flex: 1;
    min-width: 0;
    max-height: 200px;
    min-height: 120px;
    margin-bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.polygons-list-mobile {
    flex-wrap: nowrap;
}

.polygons-list-mobile .polygon-item-compact {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
}

.territories-page-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0;
    flex-shrink: 0;
}

.territories-page-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.territories-page-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 123, 255, 0.25);
    cursor: pointer;
    transition: all 0.25s ease;
}

.territories-page-dot:hover {
    background: rgba(0, 123, 255, 0.5);
    transform: scale(1.2);
}

.territories-page-dot.active {
    background: #007bff;
    transform: scale(1.3);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
}

.territory-card-mobile {
    flex: 1;
    min-height: 160px;
}

.territory-card-mobile .territory-card-content {
    max-height: 320px;
}

@media (max-width: 576px) {
    .polygons-list-mobile {
        max-height: 220px;
        min-height: 140px;
    }

    .territory-card-mobile .territory-card-content {
        max-height: 280px;
    }

    .territories-nav-btn {
        width: 36px;
        min-width: 36px;
        font-size: 20px;
    }
}

.polygon-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 30px);
    max-height: 850px;
    min-height: 600px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.98);
}

.control-panel {
    width: 320px;
    min-width: 320px;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    animation: slideInLeft 0.5s ease;
    scroll-behavior: smooth;
}

.panel-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #007bff;
    flex-shrink: 0;
}

.panel-header h2 {
    color: #333;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h2::before {
    content: '';
    width: 80px;
    height: 80px;
    background-image: url('../images/ЕПОЛИГОН лого.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.search-section {
    margin-bottom: 12px;
    background: rgba(248, 249, 250, 0.9);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
    flex-shrink: 0;
}

.search-section h3,
.polygon-controls h3,
.polygon-list h3,
.export-section h3,
.monitoring-section h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.search-section h3::before {
    content: '★';
    margin-right: 6px;
    color: #007bff;
}

.search-input-group {
    display: flex;
    gap: 8px;
}

.search-input-group input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    transition: all 0.2s ease;
}

.search-input-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
}

.search-results {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 6px;
    background: white;
    display: none;
    margin-top: 8px;
}

.search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 123, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 12px;
}

.search-result-item:hover {
    background: rgba(0, 123, 255, 0.05);
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-address {
    font-weight: 500;
    color: #333;
    margin-bottom: 3px;
}

.result-polygon {
    font-size: 11px;
    color: #007bff;
}

.polygon-controls {
    margin-bottom: 12px;
    background: rgba(248, 249, 250, 0.9);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
    flex-shrink: 0;
}

.polygon-controls h3::before {
    content: '⚙';
    margin-right: 6px;
    color: #007bff;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger,
.btn-info {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d, #545b62);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #545b62, #3d4142);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c82333, #a02622);
    transform: translateY(-1px);
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
}

.btn-info:hover {
    background: linear-gradient(135deg, #138496, #0f6674);
    transform: translateY(-1px);
}

#searchBtn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

#searchBtn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
}

.polygon-form {
    background: rgba(0, 123, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
}

.polygon-form input,
.polygon-form textarea,
.polygon-form select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 123, 255, 0.2);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    transition: all 0.2s ease;
}

.polygon-form input:focus,
.polygon-form textarea:focus,
.polygon-form select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
}

.polygon-form textarea {
    height: 60px;
    resize: vertical;
    font-family: inherit;
}

.form-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.form-buttons button {
    flex: 1;
}

.polygon-list {
    background: rgba(248, 249, 250, 0.9);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
    flex: 1;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.polygon-list h3::before {
    content: '📋';
    margin-right: 6px;
}

.polygons-list-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    max-height: 140px;
    min-height: 60px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    flex-shrink: 0;
}

.polygons-list-quick .polygon-item-compact {
    padding: 5px 10px;
    font-size: 11px;
    flex: 0 0 auto;
    margin-bottom: 0;
}

.polygons-list-quick .polygon-item-compact .polygon-name {
    margin-bottom: 0;
    font-size: 11px;
    cursor: pointer;
}

.polygons-list-quick .polygon-item-compact .polygon-name:hover {
    color: #007bff;
}

.polygons-list-quick .polygon-item-compact .polygon-actions {
    margin-top: 4px;
}

.territory-card {
    flex: 1;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.territory-card-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.04) 0%, rgba(0, 123, 255, 0.08) 100%);
    border-radius: 10px;
    border: 1px dashed rgba(0, 123, 255, 0.25);
    transition: all 0.3s ease;
}

.territory-card-empty:hover {
    border-color: rgba(0, 123, 255, 0.4);
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.06) 0%, rgba(0, 123, 255, 0.1) 100%);
}

.territory-card-empty-icon {
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.6;
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.territory-card-content {
    flex: 1;
    min-height: 160px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    padding: 0;
    background: transparent;
    border: none;
    padding-right: 4px;
}

.territory-card-content.territory-card-content-visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: cardSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardSlideIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.territory-card-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 12px 14px;
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.25);
}

.territory-card-badge {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.territory-card-title {
    font-weight: 600;
    font-size: 15px;
    margin: 0;
    line-height: 1.3;
}

.territory-card-body {
    background: white;
    border: 1px solid rgba(0, 123, 255, 0.15);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.territory-card-item {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 123, 255, 0.08);
    transition: background 0.2s ease;
}

.territory-card-item:last-child {
    border-bottom: none;
}

.territory-card-item:hover {
    background: rgba(0, 123, 255, 0.03);
}

.territory-card-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.territory-card-item-content {
    flex: 1;
    min-width: 0;
}

.territory-card-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #007bff;
    font-weight: 600;
    margin-bottom: 2px;
}

.territory-card-value {
    font-size: 12px;
    color: #333;
    line-height: 1.4;
}

.territory-card-desc {
    font-size: 11px;
    color: #555;
    line-height: 1.5;
    margin: 4px 0 0 0;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.polygon-list-empty {
    text-align: center;
    color: #666;
    padding: 15px;
    font-size: 12px;
    width: 100%;
}

.polygons-list-quick:has(.polygon-list-empty) {
    max-height: none;
}

.polygon-item-compact {
    padding: 6px 8px;
}

.polygon-item-compact .polygon-description {
    display: none;
}

.polygons-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.polygon-item {
    background: white;
    border: 1px solid rgba(0, 123, 255, 0.15);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid #007bff;
}

.polygon-item:hover {
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
}

.polygon-item.active {
    border-color: #007bff;
    background: rgba(0, 123, 255, 0.05);
}

.polygon-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
    font-size: 13px;
}

.polygon-description {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
}

.polygon-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.polygon-actions button {
    padding: 4px 8px;
    font-size: 10px;
}

.export-section,
.monitoring-section {
    margin-top: 12px;
    padding: 12px;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 10px;
    border: 1px solid rgba(0, 123, 255, 0.15);
    flex-shrink: 0;
}

.export-section h3::before {
    content: '📤';
    margin-right: 6px;
}

.monitoring-section h3::before {
    content: '📊';
    margin-right: 6px;
}

.monitoring-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.monitoring-controls button {
    font-size: 11px;
    padding: 8px 12px;
}

.law-updates-container {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid rgba(0, 123, 255, 0.15);
    border-radius: 6px;
    background: white;
    padding: 8px;
}

.law-update-item {
    padding: 8px;
    border-bottom: 1px solid rgba(0, 123, 255, 0.1);
    font-size: 11px;
}

.law-update-item:last-child {
    border-bottom: none;
}

.law-update-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 3px;
}

.law-update-date,
.law-update-status {
    font-size: 10px;
    color: #007bff;
}

.map-container {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
    overflow: hidden;
    animation: slideInRight 0.5s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(0, 123, 255, 0.12);
}

.map-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    border-bottom: 1px solid rgba(0, 123, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.map-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.map-panel-icon {
    font-size: 18px;
    opacity: 0.9;
}

.map-wrapper {
    flex: 1;
    min-height: 0;
    position: relative;
}

.yandex-map {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px;
}

.map-controls {
    position: absolute;
    top: 70px;
    left: 15px;
    right: 15px;
    z-index: 1000;
}

.drawing-hint {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.95), rgba(0, 86, 179, 0.95));
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    animation: bounceIn 0.4s ease, pulse 2s infinite 0.5s;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}

.modal-content p {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    min-width: 90px;
}

.modal[style*="flex"] {
    display: flex !important;
}

#authModal.modal {
    display: none;
}

#authModal.modal[style*="flex"] {
    display: flex !important;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 15px 0;
}

.auth-form input {
    padding: 12px 14px;
    border: 1px solid rgba(0, 123, 255, 0.3);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
}

.auth-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.auth-status {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    display: none;
    font-size: 13px;
}

.auth-status.success {
    background: rgba(40, 167, 69, 0.15);
    color: #28a745;
    display: block;
}

.auth-status.error {
    background: rgba(220, 53, 69, 0.15);
    color: #dc3545;
    display: block;
}

.role-user .polygon-controls,
.role-user .export-section,
.role-user .monitoring-section {
    display: none;
}

.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@media (max-width: 992px) {
    .polygon-container {
        flex-direction: column;
        height: auto;
        max-height: none;
        min-height: 100vh;
    }

    .control-panel {
        width: 100%;
        min-width: auto;
        max-height: 50vh;
        overflow-y: auto;
        order: 1;
    }

    .map-container {
        height: 50vh;
        min-height: 300px;
        order: 2;
        border-left: none;
        border-top: 1px solid rgba(0, 123, 255, 0.12);
    }

    .map-panel-header {
        padding: 10px 14px;
    }

    .map-panel-title {
        font-size: 13px;
    }

    .map-controls {
        top: 55px;
    }

    .territory-card-content {
        max-height: 220px;
        min-height: 120px;
    }

    .polygons-list-quick {
        max-height: 100px;
        min-height: 50px;
    }

    .polygon-list {
        min-height: 180px;
    }

    .control-panel .polygon-list {
        display: none;
    }

    .control-panel {
        max-height: 55vh;
    }
}

@media (max-width: 576px) {
    body {
        padding: 8px;
    }

    .polygon-container {
        border-radius: 12px;
        min-height: 100vh;
    }

    .control-panel {
        padding: 10px;
        max-height: 50vh;
    }

    .panel-header h2 {
        font-size: 12px;
    }

    .panel-header h2::before {
        width: 40px;
        height: 40px;
    }

    .search-section,
    .polygon-controls,
    .polygon-list {
        padding: 10px;
    }

    .territory-card-title {
        font-size: 13px;
    }

    .territory-card-label {
        font-size: 9px;
    }

    .territory-card-value {
        font-size: 11px;
    }

    .territory-card-desc {
        font-size: 10px;
        max-height: 60px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-danger,
    .btn-info {
        padding: 8px 12px;
        font-size: 11px;
    }

    .user-panel-trigger {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .user-panel-content {
        max-width: 100%;
    }

    .map-container {
        min-height: 250px;
    }

    .map-panel-header {
        padding: 8px 12px;
    }

    .map-panel-title {
        font-size: 12px;
    }

    .map-panel-icon {
        font-size: 16px;
    }

    .map-controls {
        top: 50px;
    }

    .territory-card-desc {
        max-height: 100px;
    }

    .polygons-list-quick {
        max-height: 80px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 123, 255, 0.06);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 123, 255, 0.25);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 123, 255, 0.4);
}

.polygons-list-quick::-webkit-scrollbar,
.territory-card-content::-webkit-scrollbar,
.territory-card-desc::-webkit-scrollbar {
    width: 6px;
}

.polygons-list-mobile::-webkit-scrollbar {
    width: 8px;
}

.polygons-list-mobile::-webkit-scrollbar-thumb {
    background: rgba(0, 123, 255, 0.35);
    border-radius: 4px;
}

.polygons-list-mobile::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 123, 255, 0.5);
}

.polygons-list-quick,
.territory-card-content,
.polygons-list-mobile {
    scroll-behavior: smooth;
}
