:root {
    --bg: #070f1d;
    --bg-elev: #0d1a2b;
    --bg-card: #102039;
    --bg-soft: #152a47;
    --border: #1f3657;
    --text: #e5eefc;
    --muted: #93a8c5;
    --blue: #3f86ff;
    --teal: #2ec4b6;
    --red: #ff5d66;
    --orange: #ffb347;
    --green: #3cd48f;
    --yellow: #f5d365;
    --font-ui: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    background: radial-gradient(circle at top left, #122545 0%, var(--bg) 60%);
    color: var(--text);
}

body[data-theme="light"] {
    --bg: #eff3fb;
    --bg-elev: #ffffff;
    --bg-card: #ffffff;
    --bg-soft: #f2f6fd;
    --border: #d8e1f0;
    --text: #10213a;
    --muted: #5f738e;
    background: radial-gradient(circle at top left, #ffffff 0%, #eff3fb 65%);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    gap: 18px;
    padding: 16px;
}

.sidebar {
    background: rgba(6, 14, 28, 0.9);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(145deg, #33e0cc, #2d6bff);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.brand-text {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-item {
    color: var(--muted);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    transition: 0.2s ease;
    font-size: 14px;
}

.nav-item:hover {
    color: var(--text);
    border-color: var(--border);
    background: rgba(63, 134, 255, 0.08);
}

.nav-item.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(63, 134, 255, 0.22), rgba(63, 134, 255, 0.08));
    border-color: rgba(63, 134, 255, 0.45);
}

.panel {
    background: linear-gradient(180deg, rgba(16, 32, 57, 0.98), rgba(11, 23, 41, 0.96));
    border: 1px solid var(--border);
    border-radius: 12px;
}

.filter-panel {
    padding: 14px;
}

.filter-panel h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.filter-panel label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin: 10px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input {
    width: 100%;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    font-size: 13px;
}

.main {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.topbar {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 11px;
    margin: 0;
    letter-spacing: 0.6px;
}

h1, h2, h3, h4, p {
    margin: 0;
}

h1 {
    font-size: 20px;
}

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

.btn {
    border: 1px solid rgba(63, 134, 255, 0.4);
    background: linear-gradient(180deg, #2c6cea, #1a4cb7);
    color: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
}

.status-chip {
    font-size: 12px;
    border-radius: 999px;
    padding: 5px 10px;
    border: 1px solid;
}

.critical {
    color: #ff9da3;
    border-color: rgba(255, 93, 102, 0.45);
    background: rgba(255, 93, 102, 0.1);
}

.content-grid {
    display: grid;
    gap: 14px;
}

.dashboard-layout {
    grid-template-columns: 2.2fr 1fr;
}

.card {
    padding: 14px;
}

.kpi-stack {
    display: grid;
    gap: 10px;
}

.kpi {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(14, 30, 52, 0.88);
}

.kpi .label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
}

.kpi .value {
    font-size: 30px;
    margin: 6px 0;
    font-weight: 700;
}

.kpi .trend {
    color: var(--green);
    font-size: 12px;
}

.value-danger {
    color: var(--red);
}

.value-success {
    color: var(--green);
}

.map-placeholder {
    height: 430px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: radial-gradient(circle at center, #20406b 0%, #0f2039 58%, #0a172a 100%);
    position: relative;
    overflow: hidden;
}

.zone-badge {
    position: absolute;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid;
    text-decoration: none;
}

.badge-a12 {
    left: 40%;
    top: 22%;
    color: #ffd9d6;
    background: rgba(255, 93, 102, 0.2);
    border-color: rgba(255, 93, 102, 0.6);
}

.badge-c04 {
    left: 25%;
    top: 40%;
    color: #d6fbe9;
    background: rgba(60, 212, 143, 0.2);
    border-color: rgba(60, 212, 143, 0.5);
}

.badge-e09 {
    left: 44%;
    top: 60%;
    color: #ffe5be;
    background: rgba(255, 179, 71, 0.22);
    border-color: rgba(255, 179, 71, 0.56);
}

.subheading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.subheading p {
    color: var(--muted);
    font-size: 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 640px;
}

th, td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(35, 58, 88, 0.8);
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.45px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
}

.pill.red { background: rgba(255, 93, 102, 0.18); color: #ffb5b8; }
.pill.orange { background: rgba(255, 179, 71, 0.2); color: #ffd6a0; }
.pill.yellow { background: rgba(245, 211, 101, 0.2); color: #faebad; }
.pill.green { background: rgba(60, 212, 143, 0.2); color: #b8f4d9; }

.split-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.chart-box {
    height: 220px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 30%),
        repeating-linear-gradient(to right, transparent, transparent 32px, rgba(148, 170, 200, 0.08) 33px),
        repeating-linear-gradient(to top, transparent, transparent 40px, rgba(148, 170, 200, 0.08) 41px),
        #0e1d35;
    position: relative;
}

.line {
    position: absolute;
    height: 2px;
    border-radius: 10px;
}

.line.red {
    width: 85%;
    left: 8%;
    top: 55%;
    background: linear-gradient(90deg, transparent, #ff6f72 20%, #ff6f72 80%, transparent);
}

.line.blue {
    width: 84%;
    left: 8%;
    top: 44%;
    background: linear-gradient(90deg, transparent, #5a95ff 20%, #5a95ff 80%, transparent);
}

.donut {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(#4f87ff 0 45%, #3cd48f 45% 70%, #f5d365 70% 85%, #ff5d66 85% 100%);
    display: grid;
    place-items: center;
    margin: 4px auto;
}

.donut::after {
    content: "$2.48M";
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #091528;
    font-weight: 700;
}

.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 14px;
}

.settings-nav a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    padding: 9px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid transparent;
    font-size: 13px;
}

.settings-nav a.active {
    color: #fff;
    background: rgba(63, 134, 255, 0.18);
    border-color: rgba(63, 134, 255, 0.35);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

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

.settings-content {
    min-height: 420px;
}

.settings-tab-panel {
    display: none;
}

.settings-tab-panel.active {
    display: block;
}

.settings-tab-panel h4 {
    margin-bottom: 10px;
}

.panel.card {
    overflow-x: auto;
}

.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(35, 58, 88, 0.8);
    font-size: 13px;
}

.option-row label {
    color: var(--text);
    font-size: 13px;
    width: 52%;
}

.option-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
}

.settings-content table {
    min-width: 100%;
}

.integration-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 230px;
}

.muted {
    color: var(--muted);
}

@media (max-width: 1200px) {
    .dashboard-layout,
    .settings-layout,
    .split-2 {
        grid-template-columns: 1fr;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .content-grid[style*="repeat(4"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 992px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .kpi .value {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .app-shell {
        padding: 10px;
        gap: 10px;
    }

    .sidebar {
        padding: 12px;
    }

    .main {
        gap: 10px;
    }

    .map-placeholder {
        height: 280px;
    }
}

.promo-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    border: 1px solid rgba(46, 196, 182, 0.35);
    background: rgba(46, 196, 182, 0.08);
    font-size: 13px;
}

.promo-bar a {
    color: var(--teal);
    text-decoration: none;
    font-weight: 500;
}

.mode-switch {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
}

.mode-switch button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.mode-switch button[aria-pressed="true"] {
    background: rgba(46, 196, 182, 0.25);
    color: #fff;
}

body[data-mode="baseline"] .promo-bar {
    border-color: rgba(255, 93, 102, 0.35);
    background: rgba(255, 93, 102, 0.08);
}

body[data-mode="baseline"] .integrated-only {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.4);
}

body[data-mode="baseline"] .baseline-hide {
    display: none !important;
}

.hex-map {
    width: 100%;
    height: 100%;
    display: block;
}

.hex-map .hex-zone {
    cursor: pointer;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.hex-map .hex-label {
    fill: #e5eefc;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
}

.zone-popup {
    position: absolute;
    left: 50%;
    top: 14%;
    transform: translateX(-50%);
    min-width: 190px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(6, 14, 28, 0.95);
    border: 1px solid rgba(46, 196, 182, 0.4);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 3;
}

.zone-popup.visible {
    opacity: 1;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 50;
    padding: 12px 16px;
    border-radius: 10px;
    background: #102039;
    border: 1px solid rgba(46, 196, 182, 0.45);
    color: var(--text);
    font-size: 13px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(20px);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.action-row {
    cursor: pointer;
}

.action-row:hover {
    background: rgba(63, 134, 255, 0.08);
}

.action-row.acked td:first-child::after {
    content: " · Acked";
    color: var(--green);
    font-size: 11px;
}

.chart-box.baseline-mode .line.blue {
    opacity: 0.15;
}

.chart-box.integrated-mode .line.blue {
    top: 62%;
    background: linear-gradient(90deg, transparent, #3cd48f 20%, #3cd48f 80%, transparent);
}

.nav-external {
    margin-top: auto;
    font-size: 12px;
}

.nav-external a {
    color: var(--muted);
    text-decoration: none;
}

.nav-external a:hover {
    color: var(--teal);
}

.gauge {
    width: 140px;
    height: 70px;
    margin: 8px auto 0;
    border-radius: 140px 140px 0 0;
    background: conic-gradient(from 180deg, #3cd48f 0deg, #3cd48f calc(var(--pct, 78) * 1.8deg), #1f3657 0deg);
    position: relative;
}

.gauge::after {
    content: attr(data-label);
    position: absolute;
    left: 50%;
    bottom: 4px;
    transform: translateX(-50%);
    font-size: 22px;
    font-weight: 700;
}
