:root {
    color-scheme: dark;
    --background: #071016;
    --surface: rgba(12, 25, 33, 0.96);
    --surface-soft: rgba(18, 39, 50, 0.94);
    --border: rgba(137, 203, 220, 0.18);
    --text: #ecf7f9;
    --muted: #91aab1;
    --accent: #5de0c1;
    --warning: #f6c96d;
    --danger: #ff7474;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 18px;
    background:
        linear-gradient(
            90deg,
            rgba(7, 16, 22, 0.98),
            rgba(12, 38, 46, 0.96)
        );
    border-bottom: 1px solid var(--border);
    z-index: 1000;
}

.topbar h1 {
    margin: 0;
    font-size: 19px;
    letter-spacing: 0.08em;
}

.eyebrow {
    margin-bottom: 3px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.status-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.status.waiting {
    color: var(--warning);
}

.status.online {
    color: var(--accent);
}

.status.error {
    color: var(--danger);
}

.status.isolated {
    color: #b8d8ff;
}

main {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
}

.panel {
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 900;
}

.panel section {
    margin-bottom: 24px;
}

.panel h2,
.panel h3 {
    margin: 0 0 12px;
}

.panel h2 {
    font-size: 17px;
}

.panel h3 {
    font-size: 13px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.scientific-warning {
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(246, 201, 109, 0.28);
    border-radius: 10px;
    background: rgba(246, 201, 109, 0.06);
    color: #e8d6aa;
    font-size: 12px;
    line-height: 1.5;
}

.controls {
    display: grid;
    gap: 10px;
}

.controls label {
    color: var(--muted);
    font-size: 12px;
}

.controls select,
.controls button {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
}

.controls button {
    cursor: pointer;
    background:
        linear-gradient(
            135deg,
            rgba(41, 130, 126, 0.72),
            rgba(32, 87, 110, 0.72)
        );
    font-weight: 700;
}

.controls button:hover {
    filter: brightness(1.12);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.metric {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 18px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 9px 0;
    color: var(--muted);
    font-size: 12px;
}

.dot {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 50%;
}

.level-1 {
    background: #6ec8ff;
}

.level-2 {
    background: #ffe071;
}

.level-3 {
    background: #ff9f43;
}

.level-4 {
    background: #ff5f6d;
}

.scientific-stages {
    margin: 0;
    padding-left: 22px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.8;
}

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

#map {
    position: absolute;
    inset: 0;
    background: #0b1820;
}

.panel-toggle {
    display: none;
    position: absolute;
    z-index: 1100;
    top: 12px;
    left: 12px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
}

.map-message {
    position: absolute;
    z-index: 800;
    right: 12px;
    bottom: 12px;
    max-width: 310px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(7, 16, 22, 0.92);
    color: var(--muted);
    font-size: 11px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #10232d;
    color: var(--text);
}

.popup-title {
    margin-bottom: 8px;
    color: var(--accent);
    font-weight: 800;
}

.popup-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 9px;
    min-width: 230px;
    font-size: 11px;
}

.popup-grid dt {
    color: var(--muted);
}

.popup-grid dd {
    margin: 0;
}

.popup-warning {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: #e8d6aa;
    font-size: 10px;
}

@media (max-width: 760px) {
    .topbar {
        min-height: 62px;
        padding: 8px 11px;
    }

    .topbar h1 {
        font-size: 15px;
    }

    .status.isolated {
        display: none;
    }

    main {
        display: block;
        position: relative;
    }

    .panel {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(88vw, 340px);
        transform: translateX(-105%);
        transition: transform 180ms ease;
        box-shadow: 8px 0 28px rgba(0, 0, 0, 0.38);
    }

    .panel.open {
        transform: translateX(0);
    }

    .map-wrapper {
        position: absolute;
        inset: 0;
    }

    .panel-toggle {
        display: block;
    }
}
