/* ═══════════════════════════════════════
   Design Tokens
   ═══════════════════════════════════════ */
:root {
    /* Base Light Theme */
    --bg-color: #F0F4F8;
    --primary: #0F3D2E;
    --emerald: #10B981;
    --emerald-dark: #059669;
    --emerald-glow: 0 4px 12px rgba(16, 185, 129, .2);
    --blue-ispu: #3B82F6;
    --amber: #F59E0B;
    --amber-glow: 0 4px 12px rgba(245, 158, 11, .2);
    --red: #EF4444;
    --red-glow: 0 4px 12px rgba(239, 68, 68, .2);
    --purple: #7E22CE;

    --text-primary: #1E293B;
    --text-secondary: #475569;
    --text-muted: #64748B;
    --glass-bg: rgba(255, 255, 255, .85);
    --glass-border: rgba(15, 61, 46, .1);
    --card-hover-border: rgba(16, 185, 129, .4);
    --card-bg-gradient: linear-gradient(145deg, rgba(255, 255, 255, .95), rgba(248, 250, 252, .8));

    --panel-gap: 12px;
    --left-w: 320px;
    --right-w: 330px;
    --header-h: 56px;
    --footer-h: 28px;
}

/* Base Dark Theme Overrides */
body.dark-theme {
    --bg-color: #0F172A;
    --primary: #10B981;
    /* Emerald acts as primary bright in dark mode */
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    --glass-bg: rgba(15, 23, 42, .75);
    --glass-border: rgba(148, 163, 184, .15);
    --card-hover-border: rgba(16, 185, 129, .5);
    --card-bg-gradient: linear-gradient(145deg, rgba(30, 41, 59, .85), rgba(15, 23, 42, .7));
}

/* ═══════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    background-image: linear-gradient(rgba(148, 163, 184, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, .05) 1px, transparent 1px);
    background-size: 40px 40px;
    width: 100vw;
    height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ═══════════════════════════════════════
   Layout Grid — 100vw × 100vh
   ═══════════════════════════════════════ */
.app-container {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: var(--header-h) 1fr var(--footer-h);
    grid-template-columns: var(--left-w) 1fr var(--right-w);
    grid-template-areas: "header header header" "left map right" "footer footer footer";
    gap: var(--panel-gap);
    padding: var(--panel-gap);
}

.app-container.map-expanded {
    grid-template-columns: 0 1fr 0;
}

.app-container.map-expanded .left-panel,
.app-container.map-expanded .right-panel {
    display: none;
}

/* ═══════════════════════════════════════
   Typography
   ═══════════════════════════════════════ */
h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: .5px;
}

h1 {
    font-size: 16px;
    line-height: 1.2;
}

h2 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0;
    letter-spacing: 1px;
}

/* ═══════════════════════════════════════
   Glass Panels & Cards
   ═══════════════════════════════════════ */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .1);
    transition: background 0.3s, border-color 0.3s;
}

.glass-card {
    background: var(--card-bg-gradient);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 14px 16px;
    transition: all .3s;
}

.glass-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 2px 12px rgba(16, 185, 129, .1);
}

/* ═══════════════════════════════════════
   Expandable Cards
   ═══════════════════════════════════════ */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 6px;
}

.expand-icon {
    transition: transform .3s;
    color: var(--text-muted);
    width: 16px;
    height: 16px;
}

.card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease, opacity .3s;
    opacity: 0;
}

.expandable.expanded .card-details {
    max-height: 400px;
    opacity: 1;
    margin-top: 8px;
}

.expandable.expanded .expand-icon {
    transform: rotate(180deg);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(148, 163, 184, .1);
    font-size: 11px;
}

.detail-row span {
    color: var(--text-secondary);
}

.detail-row span:last-child {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    max-width: 55%;
}

/* Card Explainer/Timestamp */
.card-explainer {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
}

.card-timestamp {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    border-top: 1px dashed rgba(148, 163, 184, .2);
    padding-top: 5px;
}

.card-timestamp .ts-time {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.top-bar {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 20;
}

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

.logo-img {
    height: 32px;
    object-fit: contain;
}

/* MUSA Green Logo */
.brand-text h1 {
    font-size: 17px;
}

.brand-sub {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 1px;
    margin-top: 1px;
    text-transform: uppercase;
}

.controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

.glass-btn {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all .2s;
    outline: none;
}

.glass-btn i {
    width: 14px;
    height: 14px;
}

.glass-btn:hover {
    border-color: var(--emerald);
    color: var(--emerald);
}

.map-style-control select {
    background: transparent;
    border: none;
    color: inherit;
    font-weight: inherit;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    cursor: pointer;
}

.map-style-control select option {
    background: var(--bg-color);
    color: var(--text-primary);
}

/* LIVE Badge — prominent glowing indicator */
.live-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, .12);
    border: 1px solid rgba(16, 185, 129, .35);
    padding: 4px 14px 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 800;
    color: var(--emerald);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.live-ring {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--emerald);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: liveRing 2s ease-in-out infinite;
}

.live-core {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald), 0 0 16px rgba(16, 185, 129, .4);
    animation: liveCore 2s ease-in-out infinite;
}

@keyframes liveRing {

    0%,
    100% {
        border-color: var(--emerald);
        transform: scale(1);
    }

    50% {
        border-color: rgba(16, 185, 129, .4);
        transform: scale(1.15);
    }
}

@keyframes liveCore {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--emerald), 0 0 16px rgba(16, 185, 129, .4);
    }

    50% {
        opacity: .6;
        box-shadow: 0 0 4px var(--emerald);
    }
}

/* Small pulsing dot on card timestamps */
.live-dot-sm {
    display: inline-block;
    color: var(--emerald);
    font-size: 8px;
    animation: liveDotPulse 1.5s ease-in-out infinite;
    vertical-align: middle;
    margin-right: 2px;
}

@keyframes liveDotPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .3;
        transform: scale(.7);
    }
}

.timestamp {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════
   Micro-Interactions & Animations
   ═══════════════════════════════════════ */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1
    }

    50% {
        transform: scale(1.4);
        opacity: .7
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px)
    }

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px)
    }

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

@keyframes breathe {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, .15)
    }

    50% {
        box-shadow: 0 0 0 5px rgba(16, 185, 129, 0)
    }
}

.fade-in {
    animation: fadeIn .5s ease both;
}

.fade-in:nth-child(1) {
    animation-delay: .1s;
}

.fade-in:nth-child(2) {
    animation-delay: .25s;
}

.fade-in:nth-child(3) {
    animation-delay: .4s;
}

.pulse-dot {
    animation: pulse 2s infinite;
    color: var(--emerald);
    font-size: 10px;
}

.status-card {
    animation: breathe 3s infinite;
}

/* Value update flash */
.val-update {
    animation: valFlash .5s ease;
}

@keyframes valFlash {
    0% {
        background: rgba(16, 185, 129, .3);
        color: #fff
    }

    100% {
        background: transparent;
    }
}

/* ═══════════════════════════════════════
   LEFT PANEL
   ═══════════════════════════════════════ */
.left-panel {
    grid-area: left;
    display: flex;
    flex-direction: column;
    gap: var(--panel-gap);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Status ISPU ── */
.status-card {
    border-left: 4px solid var(--emerald);
}

.ispu-baik {
    color: var(--emerald);
}

.ispu-sedang {
    color: var(--blue-ispu);
}

.ispu-tidak-sehat {
    color: var(--amber);
}

.ispu-sangat-tidak-sehat {
    color: var(--red);
}

.ispu-berbahaya {
    color: var(--purple);
}

.ispu-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.ispu-category {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1.5px;
    line-height: 1;
}

.ispu-num {
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    flex-shrink: 0;
    transition: all .3s;
}

.ispu-text-context {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
    padding: 4px;
    border-radius: 4px;
    background: rgba(148, 163, 184, .05);
}

.ispu-text-context strong {
    color: var(--emerald);
}

.ispu-bar-wrap {
    margin-bottom: 2px;
}

.ispu-bar {
    height: 6px;
    background: linear-gradient(to right, #10B981, #3B82F6, #F59E0B, #EF4444, #7E22CE);
    border-radius: 3px;
    position: relative;
    overflow: visible;
    margin-bottom: 3px;
}

.ispu-bar-fill {
    position: absolute;
    top: -3px;
    width: 12px;
    height: 12px;
    background: var(--bg-color);
    border-radius: 50%;
    border: 3px solid var(--text-primary);
    box-shadow: 0 0 6px rgba(0, 0, 0, .3);
    transform: translateX(-50%);
    transition: left .6s ease;
}

.ispu-bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    font-weight: 600;
}

/* ── Kualitas Udara (user-friendly ISPU params) ── */
.air-quality-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.aq-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 5px;
    transition: background .2s;
    animation: slideIn .4s ease both;
}

.aq-row:nth-child(1) {
    animation-delay: .05s;
}

.aq-row:nth-child(2) {
    animation-delay: .1s;
}

.aq-row:nth-child(3) {
    animation-delay: .15s;
}

.aq-row:nth-child(4) {
    animation-delay: .2s;
}

.aq-row:nth-child(5) {
    animation-delay: .25s;
}

.aq-row:nth-child(6) {
    animation-delay: .3s;
}

.aq-row:hover {
    background: rgba(148, 163, 184, .05);
}

.aq-name {
    width: 36px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.aq-bar-wrap {
    flex: 1;
}

.aq-bar-track {
    height: 6px;
    background: rgba(148, 163, 184, .15);
    border-radius: 3px;
    overflow: hidden;
}

.aq-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .8s ease, background .5s;
}

.aq-val {
    width: 36px;
    text-align: right;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
    padding: 0 2px;
    border-radius: 3px;
}

.aq-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    width: 16px;
    justify-content: flex-end;
}

.aq-status i {
    width: 14px;
    height: 14px;
}

.aq-aman i {
    color: var(--emerald);
}

.aq-perhatian i {
    color: var(--amber);
}

.aq-bahaya i {
    color: var(--red);
}

/* ── Contributor List ── */
.contributor-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 4px;
}

.contributor-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 6px;
    background: rgba(148, 163, 184, .05);
    border: 1px solid var(--glass-border);
    font-size: 12px;
    transition: all .2s;
    cursor: default;
}

.contributor-row:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.contributor-row.rank-1 {
    border-color: rgba(16, 185, 129, .35);
    background: rgba(16, 185, 129, .08);
}

.contributor-row.rank-2 {
    border-color: rgba(59, 130, 246, .25);
    background: rgba(59, 130, 246, .05);
}

.contributor-row.rank-3 {
    border-color: rgba(245, 158, 11, .22);
    background: rgba(245, 158, 11, .05);
}

.c-rank {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    width: 14px;
    flex-shrink: 0;
    text-align: center;
}

.contributor-row.rank-1 .c-rank {
    color: var(--emerald);
}

.contributor-row.rank-2 .c-rank {
    color: var(--blue-ispu);
}

.contributor-row.rank-3 .c-rank {
    color: var(--amber);
}

.c-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.c-tenant {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.c-stack {
    font-size: 10px;
    color: var(--text-muted);
}

.c-pct {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* ── AQMS ── */
.receptor-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aqms-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(16, 185, 129, .15);
    border: 1px solid rgba(16, 185, 129, .3);
    color: var(--emerald);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    margin-bottom: 4px;
}

.receptor-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.concentration {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.concentration .unit {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

.tag-online {
    color: var(--emerald);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   CENTER — MAP
   ═══════════════════════════════════════ */
.center-map {
    grid-area: map;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
}

#map-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.maplibregl-ctrl-bottom-left {
    display: none !important;
}

.maplibregl-ctrl-bottom-right {
    display: block !important;
    z-index: 5;
}

.maplibregl-ctrl-group {
    background: var(--glass-bg) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1) !important;
}

.maplibregl-ctrl-group button {
    width: 32px !important;
    height: 32px !important;
}

.map-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    padding: 12px;
}

/* Pollutant chips */
.pollutant-toggles {
    position: absolute;
    top: 12px;
    left: 12px;
    pointer-events: auto;
    display: flex;
    gap: 4px;
    padding: 4px 6px;
}

.pollutant-chip {
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .2s;
    outline: none;
}

.pollutant-chip.active {
    background: var(--primary);
    color: var(--bg-color);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(15, 61, 46, .3);
}

body.dark-theme .pollutant-chip.active {
    background: var(--emerald);
    color: #000;
    border-color: var(--emerald);
    box-shadow: 0 4px 12px rgba(16, 185, 129, .3);
}

.pollutant-chip:hover:not(.active) {
    border-color: var(--emerald);
    color: var(--emerald);
    transform: translateY(-1px);
}

/* Map actions */
.map-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    pointer-events: auto;
}

.map-action-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: var(--glass-bg);
    transition: all .2s;
    outline: none;
}

.map-action-btn:hover,
.map-action-btn.active {
    border-color: var(--emerald);
    color: var(--emerald);
    box-shadow: var(--emerald-glow);
}

.map-action-btn.active span {
    color: var(--emerald);
}

.map-action-btn i {
    width: 16px;
    height: 16px;
    color: var(--text-primary);
}

.map-action-btn:hover i {
    color: var(--emerald);
}

/* Map bottom-left: Wind Rose + Meteo */
.map-bottom-left {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    pointer-events: auto;
    z-index: 5;
}

.wind-rose-container {
    padding: 2px;
    border-radius: 8px;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.map-meteo {
    pointer-events: auto;
    padding: 6px 10px;
    border-radius: 6px;
}

.meteo-mini-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.meteo-mini-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s;
}

.meteo-mini-icon {
    width: 12px;
    height: 12px;
    color: var(--emerald);
}

/* Animations for updates */
.meteo-value-update {
    animation: meteo-highlight 1.5s ease-out;
}

@keyframes meteo-highlight {
    0% {
        color: var(--emerald);
        transform: scale(1.1);
    }

    100% {
        color: var(--text-primary);
        transform: scale(1);
    }
}

#wind-arrow-group {
    transition: transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 60px 60px;
    /* Center of SVG */
}

/* ── CEMS Popup ── */
.cems-popup .maplibregl-popup-content {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(16px) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 10px !important;
    padding: 0 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15) !important;
    overflow: hidden;
}

.cems-popup .maplibregl-popup-close-button {
    font-size: 16px;
    color: var(--text-secondary);
    right: 6px;
    top: 4px;
}

.cems-popup-content {
    padding: 12px 14px;
}

.cems-popup-header {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.cems-popup-tenant {
    font-size: 11px;
    font-weight: 600;
    color: var(--emerald);
}

.cems-popup-unit {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.cems-popup-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.cems-popup-param {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(148, 163, 184, .06);
    border-radius: 6px;
    padding: 6px 4px;
}

.cems-popup-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.cems-popup-val {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
}

.cems-popup-unit2 {
    font-size: 8px;
    color: var(--text-muted);
}

.cems-popup-status {
    text-align: center;
    font-size: 11px;
    padding-top: 4px;
    border-top: 1px solid var(--glass-border);
}

/* Legend — gradient style */
.map-legend {
    position: absolute;
    top: 56px;
    right: 12px;
    pointer-events: auto;
    padding: 10px 12px;
    width: 140px;
}

.map-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.map-title span {
    color: var(--emerald);
}

.legend-gradient {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, rgba(16, 185, 129, .4), rgba(245, 200, 0, .6), rgba(239, 100, 68, .9));
    margin-bottom: 3px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ═══════════════════════════════════════
   RIGHT PANEL
   ═══════════════════════════════════════ */
.right-panel {
    grid-area: right;
    display: flex;
    flex-direction: column;
    gap: var(--panel-gap);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Kapasitas Card ── */
.kapasitas-summary {
    text-align: center;
    margin-bottom: 8px;
}

.kap-big-num {
    font-size: 56px;
    font-weight: 800;
    color: var(--emerald);
    line-height: 1;
    transition: all .4s;
    text-shadow: var(--emerald-glow);
}

.kap-pct {
    font-size: 24px;
    color: var(--text-secondary);
    font-weight: 400;
}

.kap-desc {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.headroom-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hr-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.hr-label {
    width: 34px;
    color: var(--text-secondary);
    font-weight: 600;
    flex-shrink: 0;
    font-size: 10px;
}

.hr-track {
    flex: 1;
    height: 6px;
    background: rgba(148, 163, 184, .15);
    border-radius: 3px;
    overflow: hidden;
}

.hr-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .8s ease;
}

.hr-fill.emerald {
    background: var(--emerald);
    box-shadow: 0 0 6px rgba(16, 185, 129, .4);
}

.hr-fill.amber {
    background: var(--amber);
}

.hr-fill.red {
    background: var(--red);
}

.hr-val {
    width: 30px;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* ── Chart Card ── */
.chart-card {
    flex: 0 0 auto;
}

.chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.chart-tabs {
    display: flex;
    gap: 2px;
    background: rgba(148, 163, 184, .1);
    border-radius: 4px;
    padding: 2px;
}

.chart-tab {
    font-family: inherit;
    font-size: 9px;
    font-weight: 600;
    padding: 4px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 3px;
    cursor: pointer;
    transition: all .2s;
    outline: none;
}

.chart-tab.active {
    background: var(--primary);
    color: #fff;
}

body.dark-theme .chart-tab.active {
    background: var(--text-primary);
    color: var(--bg-color);
}

.chart-container {
    width: 100%;
    height: 110px;
    position: relative;
    border-bottom: 1px solid rgba(148, 163, 184, .2);
    border-left: 1px solid rgba(148, 163, 184, .2);
    margin-top: 5px;
}

.chart-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chart-legend-dot.emerald {
    background: var(--emerald);
}

.chart-legend-dot.amber {
    background: var(--amber);
}

.chart-legend-dot.blue {
    background: var(--blue-ispu);
}

/* ── Warning Panel ── */
.warning-panel {
    border-left: 4px solid var(--text-muted);
}

.warning-panel h2 {
    color: var(--text-secondary);
}

.alert-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.alert-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px;
    border-left: 3px solid var(--text-muted);
    border-radius: 0 4px 4px 0;
}

.alert-item i {
    flex-shrink: 0;
    margin-top: 2px;
    width: 16px;
    height: 16px;
}

.alert-text {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-primary);
    font-weight: 400;
}

/* ═══════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════ */
.bottom-footer {
    grid-area: footer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.bottom-footer .footer-note strong {
    color: var(--emerald);
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════ */
.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar {
    width: 4px;
}

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .3);
    border-radius: 2px;
}

/* ═══════════════════════════════════════
   Dispersion Popup
   ═══════════════════════════════════════ */
.disperse-popup .maplibregl-popup-content {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
}

.disperse-popup .maplibregl-popup-tip {
    border-top-color: var(--glass-bg);
}

.popup-content {
    font-size: 12px;
    line-height: 1.5;
}

.popup-content strong {
    color: var(--emerald);
    font-weight: 700;
}

/* ── CEMS Card ── */
.cems-stack-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cems-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(148, 163, 184, .04);
    border: 1px solid var(--glass-border);
    font-size: 11px;
    transition: all .2s;
}

.cems-row:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.cems-compliant {
    border-left: 3px solid var(--emerald);
}

.cems-attention {
    border-left: 3px solid var(--amber);
    background: rgba(245, 158, 11, .04);
}

.cems-stack-id {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    color: var(--text-primary);
    width: 56px;
    flex-shrink: 0;
}

.cems-params {
    flex: 1;
    display: flex;
    gap: 8px;
    font-size: 10px;
    color: var(--text-secondary);
}

.cems-params b {
    color: var(--text-primary);
    font-weight: 700;
    margin-left: 2px;
}

.cems-badge-ok {
    color: var(--emerald);
    flex-shrink: 0;
}

.cems-badge-warn {
    color: var(--amber);
    flex-shrink: 0;
}

/* AQMS Marker */
.aqms-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.aqms-marker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--emerald);
    border: 2px solid var(--bg-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, .6);
    animation: pulse 2s infinite;
}

.aqms-marker-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 3px;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
}