:root {
    --who-blue: #009EDB;
    --espen-navy: #263371;
    --red: #ef4444;
    --orange: #f59e0b;
    --teal: #0d9488;
    --green: #16a34a;
    --bg: #f0f4f8;
    --border: #e2e8f0;
    --card-bg: #ffffff;
    --text: #0f172a;
    --text-dim: #64748b;
    --radius: 12px;
    --shadow: 0 1px 8px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.10);
}

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

html,
body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

/* ─── LAYOUT ─── */
#app {
    display: flex;
    height: 100vh;
}

/* ─── MAP POPUPS & TOOLTIPS ─── */
.leaflet-tooltip.hover-tooltip {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.leaflet-tooltip.hover-tooltip::before {
    display: none;
}

.popup-box {
    min-width: 250px;
    background: #0f172a;
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    font-family: 'Inter', sans-serif;
    color: #f8fafc;
    border: 1px solid #1e293b;
}

.popup-title {
    font-size: 15px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 2px;
}

.popup-state {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #334155;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 11.5px;
    border-bottom: 1px solid #1e293b;
}

.popup-row span {
    color: #94a3b8;
}

.popup-row strong {
    font-weight: 700;
    color: #f8fafc;
}

.popup-endemic {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.popup-endemic.High {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.popup-endemic.Moderate {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fcd34d;
}

.popup-endemic.Low {
    background: rgba(13, 148, 136, 0.2);
    border: 1px solid rgba(13, 148, 136, 0.4);
    color: #5eead4;
}

.popup-endemic.None {
    background: #1e293b;
    color: #94a3b8;
    border: 1px solid #334155;
}


/* ─── SIDEBAR ─── */
#sidebar {
    width: 238px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--who-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.who-dot {
    color: white;
    font-weight: 800;
    font-size: 15px;
}

.brand-main {
    font-size: 13.5px;
    font-weight: 700;
}

.brand-main span {
    color: var(--who-blue);
}

.brand-sub {
    font-size: 10px;
    color: var(--text-dim);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 0 14px 8px;
}

#sidebarNav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--who-blue);
}

.nav-link.active {
    background: #e0f2fe;
    color: var(--who-blue);
    border-left-color: var(--who-blue);
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

.nav-badge {
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    color: var(--text-dim);
    font-weight: 600;
}

.nav-badge.urgent {
    background: #fee2e2;
    color: #dc2626;
}

.nav-link.active .nav-badge {
    background: #bae6fd;
    color: var(--who-blue);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 18px;
    font-size: 10px;
    color: var(--text-dim);
}

/* ─── MAIN ─── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 0;
}

/* ─── TOPBAR (2-row) ─── */
#topbar {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.topbar-row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px 10px;
    border-bottom: 1px solid #f1f5f9;
    background: #fafbfc;
    gap: 16px;
}

.topbar-tags {
    display: flex;
    gap: 8px;
    align-items: center;
}

.scope-tag {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.scope-tag.blue {
    background: #e0f2fe;
    color: var(--who-blue);
}

.scope-tag.green {
    background: #dcfce7;
    color: var(--green);
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 14px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-label {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-sel {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 6px 32px 6px 10px;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.filter-sel:focus {
    border-color: var(--who-blue);
    box-shadow: 0 0 0 3px rgba(0, 158, 219, 0.12);
}

/* Multi-select styling */
.multi-select {
    position: relative;
    width: 190px;
}

.multi-select-value {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    padding: 6px 32px 6px 10px;
    font-size: 12.5px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.multi-select-value:hover {
    border-color: var(--who-blue);
}

.multi-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 220px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    z-index: 100;
    padding: 8px 0;
}

.multi-select.open .multi-dropdown {
    display: block;
}

.multi-select.open .multi-select-value {
    border-color: var(--who-blue);
    box-shadow: 0 0 0 3px rgba(0, 158, 219, 0.12);
}

.multi-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.15s;
}

.multi-opt:hover {
    background: #f8fafc;
}

.multi-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.multi-scroll {
    max-height: 200px;
    overflow-y: auto;
}

.topbar-row2 {
    padding: 9px 24px 9px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-row2-left {
    flex: 1;
}

.page-breadcrumb {
    font-size: 16px;
    font-weight: 800;
    color: var(--espen-navy);
}

.data-hint {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 3px;
}

.active-context-tag {
    font-size: 11px;
    background: var(--espen-navy);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    white-space: nowrap;
}

/* ─── PAGES ─── */
.page {
    display: none;
    padding: 18px 24px 32px;
    flex-direction: column;
    gap: 16px;
}

.page.active {
    display: flex;
    animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── KPI STRIP ─── */
.kpi-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.kpi-card {
    flex: 1 0 170px;
    min-width: 0;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px 16px 13px;
    display: flex;
    align-items: flex-start;
    gap: 13px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: white;
    flex-shrink: 0;
}

.kpi-icon.blue {
    background: linear-gradient(135deg, #009EDB, #0284c7);
}

.kpi-icon.navy {
    background: linear-gradient(135deg, #263371, #1e3a8a);
}

.kpi-icon.red {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.kpi-icon.orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.kpi-icon.teal {
    background: linear-gradient(135deg, #0d9488, #0f766e);
}

.kpi-icon.green {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.kpi-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    margin-top: 5px;
    line-height: 1;
}

.kpi-sub {
    font-size: 10.5px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ─── VIZ ROW ─── */
.viz-row {
    display: flex;
    gap: 16px;
    min-height: 400px;
}

.viz-panel {
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: white;
}

.map-panel {
    flex: 2;
    min-height: 400px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-title {
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 7px;
}

.panel-title i {
    color: var(--who-blue);
}

.panel-sub {
    font-size: 10.5px;
    color: var(--text-dim);
    font-style: italic;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-dim);
    transition: all 0.15s;
    font-family: inherit;
}

.pill-btn.active,
.pill-btn:hover {
    background: var(--who-blue);
    color: white;
}

.back-btn {
    background: #fef3c7 !important;
    color: #92400e !important;
}

.back-btn:hover {
    background: var(--orange) !important;
    color: white !important;
}

/* ─── MAP ─── */
#map {
    flex: 1;
    min-height: 0;
}

.map-legend {
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 10.5px;
    align-items: center;
    color: var(--text-dim);
    flex-shrink: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 11px;
    height: 11px;
    border-radius: 3px;
}

/* ─── CHART AREAS ─── */
.chart-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    min-height: 0;
}

.chart-wrap canvas {
    max-height: 300px;
}

.chart-wrap.tall canvas {
    max-height: 330px;
}

/* ─── RANK PANEL (scrollable, all 37 states) ─── */
.rank-panel {
    flex: 1;
}

.rank-scroll {
    overflow-y: auto;
    padding: 8px 12px 12px;
    flex: 1;
    min-height: 0;
}

.rank-scroll canvas {
    width: 100% !important;
}

/* ─── TABLES ─── */
.table-scroll {
    overflow-y: auto;
    max-height: 320px;
}

.table-search {
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    width: 220px;
}

.table-search:focus {
    border-color: var(--who-blue);
}

.icon-btn {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 12px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: var(--who-blue);
    color: white;
    border-color: var(--who-blue);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead th {
    background: #f8fafc;
    padding: 9px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table thead th:hover {
    color: var(--who-blue);
}

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.table-footer {
    padding: 7px 14px;
    font-size: 11px;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* ─── BADGES ─── */
.badge-high {
    color: #dc2626;
    font-weight: 600;
    background: #fef2f2;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
}

.badge-mod {
    color: #d97706;
    font-weight: 600;
    background: #fffbeb;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
}

.badge-low {
    color: #0d9488;
    font-weight: 600;
    background: #f0fdfa;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
}

.badge-none {
    color: var(--text-dim);
    background: #f1f5f9;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
}

.badge-delivered {
    color: var(--green);
    font-weight: 600;
    background: #dcfce7;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
}

.badge-shipped {
    color: var(--who-blue);
    font-weight: 600;
    background: #e0f2fe;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 11px;
}

.cov-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cov-bar-bg {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: #e2e8f0;
    min-width: 60px;
}

.cov-bar-inner {
    height: 5px;
    border-radius: 3px;
    background: var(--who-blue);
}

/* ─── LOGISTICS ─── */
.model-note {
    font-size: 11px;
    color: var(--text-dim);
    padding: 6px 14px 10px;
    flex-shrink: 0;
}

/* ─── DECISION PAGE ─── */
.decision-header {
    padding: 2px 0 6px;
}

.decision-header h2 {
    font-size: 17px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--espen-navy);
}

.decision-header h2 i {
    color: var(--who-blue);
}

.decision-header p {
    font-size: 11.5px;
    color: var(--text-dim);
    margin-top: 4px;
}

.alert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 12px;
}

.alert-card {
    border-radius: var(--radius);
    padding: 14px 16px;
    border-left: 4px solid;
    box-shadow: var(--shadow);
}

.alert-card.critical {
    background: #fef2f2;
    border-color: var(--red);
}

.alert-card.warning {
    background: #fffbeb;
    border-color: var(--orange);
}

.alert-card.info {
    background: #eff6ff;
    border-color: var(--who-blue);
}

.alert-card.success {
    background: #f0fdf4;
    border-color: var(--green);
}

.alert-title {
    font-size: 12.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 6px;
}

.alert-card.critical .alert-title {
    color: #dc2626;
}

.alert-card.warning .alert-title {
    color: #d97706;
}

.alert-card.info .alert-title {
    color: var(--who-blue);
}

.alert-card.success .alert-title {
    color: var(--green);
}

.alert-body {
    font-size: 11.5px;
    color: var(--text);
    line-height: 1.55;
}

.alert-meta {
    font-size: 10.5px;
    color: var(--text-dim);
    margin-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 6px;
}

.p-critical {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
}

.p-high {
    background: #fffbeb;
    color: #d97706;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
}

.p-medium {
    background: #eff6ff;
    color: var(--who-blue);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
}

.p-low {
    background: #f0fdf4;
    color: var(--green);
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
}

/* ─── LEAFLET POPUP ─── */
.leaflet-popup-content-wrapper {
    background: #1e3a5f !important;
    color: white !important;
    border: none;
    border-radius: 10px !important;
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.leaflet-popup-tip {
    background: #1e3a5f !important;
}

.popup-box {
    padding: 14px 16px;
    min-width: 220px;
}

.popup-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #7dd3fc;
}

.popup-state {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.55);
    margin: 3px 0 10px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.popup-row:last-of-type {
    border: none;
}

.popup-row span {
    color: rgba(255, 255, 255, 0.65);
}

.popup-row strong {
    color: #bae6fd;
}

.popup-endemic {
    margin-top: 9px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 5px;
    display: inline-block;
}

.popup-endemic.High {
    background: rgba(239, 68, 68, 0.22);
    color: #fca5a5;
}

.popup-endemic.Moderate {
    background: rgba(245, 158, 11, 0.22);
    color: #fcd34d;
}

.popup-endemic.Low {
    background: rgba(13, 148, 136, 0.22);
    color: #5eead4;
}

.popup-endemic.None,
.popup-endemic.Unknown {
    background: rgba(100, 116, 139, 0.18);
    color: #cbd5e1;
}

@media (max-width:900px) {
    #sidebar {
        display: none;
    }

    .viz-row {
        flex-direction: column;
    }

    .kpi-strip {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ─── CORRELATION DASHBOARD ─── */
.correlation-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-item label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-sep {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    margin-top: 14px;
}

.correlation-stats {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    justify-content: center;
}

.corr-score-card {
    background: rgba(0, 158, 219, 0.05);
    border: 1px solid rgba(0, 158, 219, 0.15);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.corr-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.corr-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--who-blue);
    margin-bottom: 4px;
    font-family: 'Inter', sans-serif;
}

.corr-interpret {
    font-size: 13px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

.corr-description {
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.6;
    text-align: center;
}