:root {
    --bg-dark: #0a0c10;
    --panel-bg: rgba(18, 22, 28, 0.95);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #f97316;
    --radius: 12px;
    --c-lytkarino: #ff8c00;
    --c-arzamas: #059669;
    --c-batyrevo: #7c3aed;
    --c-roes: #dc2626;
    --c-mvd: #3b82f6;
    --c-gov: #fbbf24;
    --c-neutral: #ffffff;
    --c-smi: #ff5722;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    font-family: 'Inter', sans-serif;
}

body, html {
    height: 100%;
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #000;
}

.leaflet-container {
    background: #000 !important;
}

.leaflet-pane [stroke-dasharray] {
    stroke-dasharray: 10, 10;
    stroke-linecap: round;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.nav-btn:hover {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

.nav-btn:active {
    transform: scale(0.9);
}

.mil-panel {
    position: absolute;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    text-transform: uppercase;
    backdrop-filter: blur(15px);
}

.panel-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--panel-border);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius) var(--radius) 0 0;
}

.panel-header.danger-header {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 0;
    border-top: 1px solid var(--panel-border);
}

#control-panel {
    top: 20px;
    left: 20px;
    width: 320px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    display: none;
}

.section-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mil-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-main);
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    transition: 0.2s;
    text-align: left;
    border-radius: 6px;
}

.mil-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.mil-btn.active {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.marker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
}

.marker-btn {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    padding: 10px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 10px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    border-radius: 6px;
}

.marker-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.marker-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.marker-btn.active img {
    filter: brightness(0) invert(1);
}

#timeline-panel {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 800px;
    padding: 16px 24px;
    display: none;
    align-items: center;
    border-radius: 12px;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    width: 100%;
}

#date-display {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: #334155;
    border-radius: 3px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: -6px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(249, 115, 22, 0.4);
}

#auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.auth-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 40px;
    width: 400px;
    text-align: center;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.auth-box h2 {
    margin-bottom: 10px;
    color: #fff;
}

.auth-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    background: #000;
    border: 1px solid var(--panel-border);
    color: #fff;
    border-radius: 8px;
    text-align: center;
    letter-spacing: 3px;
}

.auth-btn-admin {
    background: var(--accent);
    color: #000;
    width: 100%;
    justify-content: center;
    margin-bottom: 10px;
}

.auth-btn-viewer {
    width: 100%;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid #444;
}

.custom-map-marker {
    background: #ffffff;
    border: 2px solid;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    overflow: visible;
}

.custom-map-marker img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.unit-label {
    position: absolute;
    top: -26px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    border: 1px solid;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.leaflet-popup-content-wrapper {
    background: #ffffff !important;
    color: #1f2937 !important;
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 15px !important;
}

.popup-mil-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.popup-input {
    width: 100%;
    background: #f9fafb;
    border: 1px solid #ddd;
    padding: 8px;
    margin: 4px 0;
    border-radius: 6px;
    font-size: 12px;
}

.btn-save-pop {
    background: var(--accent);
    color: #000;
    border: none;
    width: 100%;
    padding: 10px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    border-radius: 6px;
    text-transform: uppercase;
}

#news-btn {
    position: absolute;
    top: 20px;
    right: 210px;
    z-index: 1000;
    display: none;
    background: var(--panel-bg);
    border: 1px solid var(--c-smi);
    color: var(--c-smi);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 15px rgba(255, 87, 34, 0.2);
}

#news-btn:hover {
    background: var(--c-smi);
    color: #fff;
}

#catalog-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: none;
    background: var(--panel-bg);
    border: 1px solid var(--c-roes);
    color: var(--c-roes);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2);
}

#catalog-btn:hover {
    background: var(--c-roes);
    color: #fff;
}

#catalog-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    width: 360px;
    max-height: calc(100vh - 180px);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

#cat-breadcrumb {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--panel-border);
    font-size: 10px;
    color: #94a3b8;
    cursor: pointer;
    text-transform: uppercase;
}

#cat-content {
    padding: 12px;
    overflow-y: auto;
    flex-grow: 1;
}

.cat-nav-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 6px;
}

.cat-nav-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #555;
}

.cat-nav-card .title {
    font-weight: 800;
    font-size: 13px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cat-nav-card .desc {
    font-size: 10px;
    color: #94a3b8;
    text-transform: none;
}

details.cat-det {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    margin-bottom: 5px;
}

summary.cat-sum {
    padding: 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

summary.cat-sum::-webkit-details-marker {
    display: none;
}

summary.cat-sum::before {
    content: '\f0da';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    width: 12px;
    transition: 0.2s;
}

details.cat-det[open] > summary.cat-sum::before {
    transform: rotate(90deg);
}

.cat-children {
    padding: 5px 10px 10px 20px;
    border-top: 1px solid var(--panel-border);
}

.cat-unit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1e293b;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s;
}

.cat-unit-item:hover:not(.deployed) {
    background: #334155;
    border-color: #475569;
}

.cat-unit-item.deployed {
    background: rgba(220, 38, 38, 0.1);
    border-color: #ef4444;
    color: #ef4444;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-sys-clone {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    color: #10b981;
    justify-content: center;
}

.btn-sys-zone {
    background: rgba(14, 165, 233, 0.1);
    border-color: #0ea5e9;
    color: #0ea5e9;
    justify-content: center;
    margin-top: 5px;
}

.btn-sys-clear {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: #f59e0b;
    justify-content: center;
    margin-top: 5px;
}

.btn-sys-reset {
    background: rgba(220, 38, 38, 0.1);
    border-color: #ef4444;
    color: #ef4444;
    justify-content: center;
    margin-top: 5px;
}

#img-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(5px);
}

#img-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
}

#chrono-btn {
    position: absolute;
    top: 20px;
    right: 390px;
    z-index: 1000;
    display: none;
    background: var(--panel-bg);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.2);
}

#chrono-btn:hover {
    background: var(--accent);
    color: #000;
}