/* ═══════════════════════════════════════════════════════════════════════════
   ECO QUALITY — UI/UX REDESIGN SPECIFICATION (EQ-UIUX-2026)
   Eastern Samar State University • Capstone Project
   Dual-Mode Progressive Disclosure Dashboard • ISO/IEC 25010 & IBM CSUQ
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── RESET & BOX SIZING ─────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── DESIGN SYSTEM TOKENS: DARK (DEFAULT) ───────────────────────────────── */
:root {
    /* Color Palette */
    --bg: #0B0F17;              /* Deep Slate */
    --card: #141C2B;            /* Elevated Navy */
    --card-surface: #141C2B;
    --card-subtle: #1A2438;     /* Slightly lighter inner card surface */
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --border-subtle: rgba(255, 255, 255, 0.04);
    
    --accent: #00CFA8;          /* Mint Emerald */
    --accent-hover: #00E5BA;
    --accent-glow: rgba(0, 207, 168, 0.18);
    --accent-tint: rgba(0, 207, 168, 0.10);
    
    --cyan: #38BDF8;
    --warn: #F5A623;
    --warn-tint: rgba(245, 166, 35, 0.12);
    --danger: #F05252;
    --danger-tint: rgba(240, 82, 82, 0.12);
    --purple: #A855F7;
    --purple-tint: rgba(168, 85, 247, 0.12);
    
    --text: #F1F5F9;
    --muted: #94A3B8;
    --soft: #64748B;
    --white: #FFFFFF;

    /* Concentric Border Radii */
    --radius-outer: 16px;       /* Outer card containers */
    --radius-inner: 8px;        /* Inner badges, progress bars, pills, buttons */
    --radius-full: 9999px;      /* Pill badges */

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Shadows & Glass */
    --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.35), 0 2px 6px -1px rgba(0, 0, 0, 0.2);
    --card-shadow-hover: 0 8px 30px -4px rgba(0, 0, 0, 0.45);
    --glass-bg: rgba(11, 15, 23, 0.82);
    --glass-blur: blur(14px);

    /* Ergonomics */
    --hit-target: 44px;
}

/* ── DESIGN SYSTEM TOKENS: LIGHT MODE (DEFAULT) ───────────────────────── */
body.light,
html.light {
    --bg: #EEF2F6;              /* Soft, cool slate canvas with tangible depth (was #F8FAFC) */
    --card: #FFFFFF;            /* Crisp elevated cards */
    --card-surface: #F8FAFC;    /* Refined surface */
    --card-subtle: #E2E8F0;     /* Distinct Slate-200 for nested panels, chips & inputs (was #F1F5F9) */
    --border: #CBD5E1;          /* Defined Slate-300 border for crisp card separation (was #E2E8F0) */
    --border-hover: #94A3B8;    /* Slate-400 on hover */
    --border-subtle: #E2E8F0;
    
    --accent: #008769;          /* Rich emerald with high contrast on white (WCAG AAA) */
    --accent-hover: #007057;
    --accent-glow: rgba(0, 135, 105, 0.16);
    --accent-tint: rgba(0, 135, 105, 0.10);

    --cyan: #0284C7;
    --warn: #D97706;
    --warn-tint: rgba(217, 119, 6, 0.12);
    --danger: #DC2626;
    --danger-tint: rgba(220, 38, 38, 0.12);
    --purple: #7C3AED;
    --purple-tint: rgba(124, 58, 237, 0.12);

    --text: #0F172A;            /* Slate-900 high contrast */
    --muted: #334155;           /* Slate-700 darker, sharper secondary text (was #475569) */
    --soft: #475569;            /* Slate-600 for captions and units (was #64748B) */

    --card-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.08), 0 1px 3px -1px rgba(15, 23, 42, 0.06);
    --card-shadow-hover: 0 12px 28px -4px rgba(15, 23, 42, 0.12), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
    --glass-bg: rgba(238, 242, 246, 0.94);
    --glass-blur: blur(16px);
}

/* ── BASE & TYPOGRAPHY ──────────────────────────────────────────────────── */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hover) transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.015em;
}

/* Tabular Numerals for Live Dynamic Indicators */
.tabular-stat,
.telemetry-num,
.aqi-value,
.step-aqi,
.compare-val,
.pill-val,
.risk-val,
.z-val,
.improvement-badge {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ── TOP BAR (STICKY HEADER & SEGMENTED VIEW CONTROL) ───────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    padding: max(10px, env(safe-area-inset-top)) clamp(16px, 2.5vw, 40px) 10px;
    width: 100%;
    transition: background 0.25s ease, border-color 0.25s ease;
}

.topbar-inner {
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    padding: 6px 8px;
    border-radius: var(--radius-inner);
    transition: opacity 0.15s ease;
}

.brand-container:hover {
    opacity: 0.9;
}

.pulse-dot.logo-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent);
    box-shadow: 0 0 10px var(--accent);
    animation: pulseGlow 2.5s infinite ease-in-out;
    flex-shrink: 0;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.9); }
}

.brand-text {
    display: flex;
    align-items: center;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1;
}

.brand-subtitle {
    display: none;
}

/* Segmented View Switch */
.topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 440px;
}

.segmented-control {
    display: flex;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    width: 100%;
    gap: 4px;
}

.seg-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 14px;
    min-height: 38px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 7px;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
}

.seg-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

body.light .segmented-control {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

body.light .seg-btn {
    color: #475569;
}

body.light .seg-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #0F172A;
}

.seg-btn:active {
    transform: scale(0.98);
}

.seg-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.seg-btn.active {
    background: var(--card);
    color: var(--accent);
    font-weight: 600;
    border-color: var(--border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
}

body.light .seg-btn.active {
    background: #FFFFFF;
    color: var(--accent);
    border-color: #CBD5E1;
    box-shadow: 0 2px 6px -1px rgba(15, 23, 42, 0.10), 0 1px 3px -1px rgba(15, 23, 42, 0.06);
}

.seg-svg {
    flex-shrink: 0;
    transition: stroke 0.15s ease;
}

.seg-icon {
    font-size: 0.95rem;
    line-height: 1;
}

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

.btn-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--hit-target);
    height: var(--hit-target);
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

body.light .btn-icon-action {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #334155;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.btn-icon-action:hover {
    background: var(--card);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px var(--accent-glow);
}

body.light .btn-icon-action:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
    color: var(--accent);
}

.btn-icon-action:active {
    transform: scale(0.94);
}

.btn-icon-action:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── PUBLIC HEALTH ALERT BANNER ─────────────────────────────────────────── */
.health-alert-banner {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 14px 46px 14px 18px;
    margin: 16px clamp(16px, 2.5vw, 40px) 0;
    max-width: 100%;
    width: calc(100% - 2 * clamp(16px, 2.5vw, 40px));
    border-radius: var(--radius-outer);
    border: 1px solid rgba(240, 82, 82, 0.3);
    border-left: 5px solid var(--danger);
    background: var(--danger-tint);
    backdrop-filter: blur(8px);
    gap: 12px;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.alert-icon {
    font-size: 1.35rem;
    line-height: 1.1;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.alert-text strong {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--danger);
    line-height: 1.35;
}

.alert-text span {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.45;
}

.alert-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.35rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-inner);
    transition: color 0.2s, background 0.2s;
}

.alert-close:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.06);
}

/* ── MAIN CONTENT CONTAINER ─────────────────────────────────────────────── */
.main-viewport {
    flex: 1;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: clamp(16px, 2vw, 28px) clamp(16px, 2.5vw, 40px) clamp(48px, 6vw, 72px);
}

.view-section {
    animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── COMMON CARD ERGONOMICS ─────────────────────────────────────────────── */
.card,
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-outer);
    padding: 22px 24px;
    box-shadow: var(--card-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.panel-body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.card:hover,
.panel:hover {
    border-color: var(--border-hover);
    box-shadow: var(--card-shadow-hover);
}

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

.card-title-group,
.panel-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-eyebrow,
.panel-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-svg {
    flex-shrink: 0;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-inner);
    background: var(--card-subtle);
    border: 1px solid var(--border);
    color: var(--accent);
    letter-spacing: 0.02em;
}

.badge-pill.rf-badge {
    color: var(--accent);
    background: var(--accent-tint);
    border-color: rgba(0, 207, 168, 0.2);
}

.badge-pill.sensor-tag {
    color: var(--cyan);
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.2);
}

.btn-info-circle,
.btn-info-circle-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.btn-info-circle-sm {
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
}

.btn-info-circle:hover,
.btn-info-circle-sm:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-tint);
}

body.light .btn-info-circle,
body.light .btn-info-circle-sm {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #475569;
}

body.light .btn-info-circle:hover,
body.light .btn-info-circle-sm:hover {
    background: #E2E8F0;
    border-color: var(--accent);
    color: var(--accent);
}


/* ── MINIMAL STATION LOCATION INDICATOR (OVERVIEW TAB) ── */
.overview-station-strip {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 14px;
}

.station-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    color: var(--muted);
    letter-spacing: 0.01em;
    backdrop-filter: var(--glass-blur);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.station-chip:hover {
    border-color: var(--accent);
    background: var(--card);
}

.station-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    flex-shrink: 0;
    display: inline-block;
}

.station-chip .pin-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.station-loc-label {
    font-weight: 500;
    color: var(--muted);
}

.station-loc-name {
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-sans);
}

.station-node-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: var(--accent-tint);
    border: 1px solid rgba(0, 207, 168, 0.25);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    margin-left: 2px;
}

body.light .station-chip {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #334155;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

body.light .station-node-badge {
    border-color: rgba(0, 150, 119, 0.3);
}

@media (max-width: 480px) {
    .overview-station-strip {
        margin-bottom: 10px;
    }
    .station-chip {
        padding: 5px 11px;
        font-size: 0.7rem;
        gap: 6px;
    }
}

/* ── MODE 1: HERO SECTION (2-COLUMN DESKTOP, STACKED MOBILE) ────────────── */
.hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* Hero A: Primary Air Quality Gauge */
.hero-aqi {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(145deg, var(--card) 0%, var(--card-subtle) 100%);
    border: 1px solid var(--border);
}

.hero-aqi.c-accent {
    border-color: rgba(0, 207, 168, 0.3);
    box-shadow: 0 4px 24px -2px rgba(0, 207, 168, 0.12);
}

.hero-aqi.c-warn {
    border-color: rgba(245, 166, 35, 0.35);
    box-shadow: 0 4px 24px -2px rgba(245, 166, 35, 0.12);
}

.hero-aqi.c-orange {
    border-color: rgba(255, 140, 0, 0.35);
    box-shadow: 0 4px 24px -2px rgba(255, 140, 0, 0.12);
}

.hero-aqi.c-danger {
    border-color: rgba(240, 82, 82, 0.35);
    box-shadow: 0 4px 24px -2px rgba(240, 82, 82, 0.12);
}

.hero-aqi.c-purple {
    border-color: rgba(155, 89, 182, 0.35);
    box-shadow: 0 4px 24px -2px rgba(155, 89, 182, 0.12);
}

.hero-aqi.c-maroon {
    border-color: rgba(123, 36, 28, 0.35);
    box-shadow: 0 4px 24px -2px rgba(123, 36, 28, 0.12);
}

.aqi-score-container {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin: 12px 0 16px;
    flex-wrap: wrap;
}

.aqi-value {
    font-size: clamp(3.2rem, 7vw, 4.8rem);
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 0.95;
    letter-spacing: -0.04em;
    color: var(--accent);
    transition: color 0.3s ease;
}

.aqi-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--radius-inner);
    font-size: 0.92rem;
    font-weight: 700;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    color: var(--text);
    letter-spacing: 0.01em;
}

/* Semi-Circular Radial Arc Gauge & Center Display */
.aqi-gauge-wrapper {
    position: relative;
    width: 100%;
    max-width: 280px;
    margin: 6px auto 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.aqi-arc-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.gauge-bg-track {
    stroke: var(--card-subtle);
    stroke-linecap: round;
}

body.light .gauge-bg-track {
    stroke: #E2E8F0;
}

.gauge-val-track {
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.aqi-center-display {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    pointer-events: none;
    width: 100%;
}

.aqi-center-display .aqi-value {
    font-size: clamp(2.6rem, 5.5vw, 3.6rem);
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 0.92;
    letter-spacing: -0.04em;
    color: var(--accent);
    margin-bottom: 2px;
}

.aqi-sub-unit {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.aqi-center-display .aqi-status-pill {
    font-size: 0.76rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--card-subtle);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

/* Continuous RA 8749 Spectrum Scale */
.aqi-spectrum-track {
    width: 100%;
    margin: 4px 0 14px;
    padding: 0 2px;
}

.spectrum-segments {
    display: flex;
    height: 7px;
    width: 100%;
    border-radius: var(--radius-full);
    overflow: hidden;
    gap: 2px;
}

.spec-seg {
    flex: 1;
    height: 100%;
}

.spectrum-marker-wrap {
    position: relative;
    width: 100%;
    height: 10px;
    margin-top: 2px;
}

.spectrum-pointer {
    position: absolute;
    top: 0;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pointer-tip {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid var(--text);
    margin: 0 auto;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

body.light .pointer-tip {
    border-bottom-color: #0F172A;
}

.spectrum-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.62rem;
    font-family: var(--font-mono);
    color: var(--muted);
    padding: 2px 0 0;
    opacity: 0.85;
}

/* 4 Action-Oriented Health Guidance Chips */
.action-chips-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

@media (max-width: 1080px) {
    .action-chips-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

.action-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 7px 10px;
    transition: border-color 0.2s, background-color 0.2s, transform 0.15s ease;
    min-width: 0;
    min-height: 52px;
}

body.light .action-chip {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

body.light .action-chip:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--accent);
    flex-shrink: 0;
}

body.light .chip-icon {
    background: rgba(0, 150, 119, 0.08);
}

.chip-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.chip-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.15;
}

.chip-status {
    font-size: 0.74rem;
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

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

.chip-status.fair {
    color: var(--warn);
}

.chip-status.caution {
    color: #FF8C00;
}

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

/* 1-Sentence Health Summary Line */
.aqi-guidance-line {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 8px 12px;
    font-size: 0.78rem;
    color: var(--text);
    margin-bottom: 14px;
    line-height: 1.35;
}

body.light .aqi-guidance-line {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.aqi-guidance-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
    margin-bottom: 18px;
}

body.light .aqi-guidance-box {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.guidance-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guidance-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.guidance-title {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.guidance-text {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.card-footer-meta {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--muted);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.meta-item .strong {
    color: var(--text);
    font-weight: 600;
}

/* Hero B: 3-Hour Predictive Outlook */
.hero-forecast {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.forecast-step-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 12px 0 16px;
}

.forecast-step-card {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform 0.2s, border-color 0.2s;
}

.forecast-step-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

body.light .forecast-step-card {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

body.light .forecast-step-card:hover {
    background: #E2E8F0;
    border-color: #94A3B8;
}

.step-hour {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
}

.step-aqi {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent);
    line-height: 1.1;
}

.step-cat {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.step-delta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    margin-top: 2px;
}

.step-delta.up {
    color: var(--danger);
    background: var(--danger-tint);
}

.step-delta.down {
    color: var(--accent);
    background: var(--accent-tint);
}

.step-delta.flat {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
}

/* Predictive Trajectory Strip */
.forecast-trajectory-strip {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

body.light .forecast-trajectory-strip {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.trajectory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
}

.traj-label {
    color: var(--muted);
    font-weight: 600;
}

.traj-state {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
    font-size: 0.72rem;
}

.trajectory-svg {
    width: 100%;
    height: 38px;
    overflow: visible;
}

.trajectory-svg circle {
    transition: cx 0.5s ease, cy 0.5s ease, fill 0.5s ease;
}

.trajectory-svg path {
    transition: d 0.5s ease, stroke 0.5s ease;
}

.forecast-summary-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
    margin-bottom: 16px;
}

body.light .forecast-summary-box {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.forecast-trend-icon {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forecast-summary-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.summary-text {
    font-size: 0.86rem;
    color: var(--text);
    font-weight: 500;
    line-height: 1.4;
}

.forecast-card-footer {
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.btn-driver-link {
    width: 100%;
    min-height: var(--hit-target);
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-driver-link:hover {
    background: var(--accent-tint);
    border-color: rgba(0, 207, 168, 0.3);
    transform: translateY(-1px);
}

.btn-driver-link .arrow {
    font-size: 1rem;
    transition: transform 0.2s;
}

.btn-driver-link:hover .arrow {
    transform: translateX(3px);
}

/* ── MODE 1: CLEAN TELEMETRY ROW (4 CARDS) ──────────────────────────────── */
.section-heading {
    display: flex;
    flex-direction: column;
    margin: 28px 0 16px;
    gap: 4px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.section-subtitle {
    font-size: 0.78rem;
    color: var(--muted);
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.telemetry-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.telemetry-body {
    margin: 8px 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.telemetry-reading {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.telemetry-num {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
    line-height: 1;
}

.telemetry-unit {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--muted);
    font-weight: 500;
}

.telemetry-sub {
    font-size: 0.74rem;
    color: var(--muted);
    font-weight: 500;
}

/* Telemetry Inline Sparkline & Momentum Badge */
.telemetry-spark-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 6px 0 10px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-inner);
    border: 1px solid var(--border-subtle);
}

body.light .telemetry-card {
    background: #FFFFFF;
    border-color: #CBD5E1;
    box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.08);
}

body.light .telemetry-card:hover {
    border-color: #94A3B8;
    box-shadow: 0 8px 22px -3px rgba(15, 23, 42, 0.12);
}

body.light .telemetry-spark-row {
    background: #E2E8F0;
    border-color: #CBD5E1;
}

.telemetry-sparkline {
    width: 105px;
    height: 24px;
    overflow: visible;
    flex-shrink: 0;
}

.spark-badge {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
}

body.light .spark-badge {
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    color: #1E293B;
}

.spark-badge.up {
    color: var(--danger);
    background: var(--danger-tint);
}

.spark-badge.down {
    color: var(--accent);
    background: var(--accent-tint);
}

.spark-badge.steady {
    color: var(--muted);
}

.telemetry-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--muted);
}

.meta-row .strong {
    color: var(--text);
    font-weight: 600;
}

/* ── PROGRESSIVE DISCLOSURE PROMPT STRIP ─────────────────────────────────── */
.disclosure-callout-card {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-outer);
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--card-shadow);
}

.disclosure-callout-card:hover {
    border-color: rgba(0, 207, 168, 0.4);
    box-shadow: 0 6px 24px -2px var(--accent-glow);
    transform: translateY(-2px);
}

body.light .disclosure-callout-card {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

body.light .disclosure-callout-card:hover {
    border-color: #94A3B8;
}

.disclosure-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.disclosure-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
}

.disclosure-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.disclosure-texts strong {
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 700;
}

.disclosure-texts span {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.4;
}

.btn-disclosure-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--hit-target);
    padding: 8px 18px;
    background: var(--accent);
    color: #080E1B;
    border: none;
    border-radius: var(--radius-inner);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

body.light .btn-disclosure-action {
    background: #008769;
    color: #FFFFFF;
}

.btn-disclosure-action:hover {
    background: var(--accent-hover);
    transform: translateX(2px);
}

body.light .btn-disclosure-action:hover {
    background: #007057;
}

/* ── MODE 2: TECHNICAL & AI DIAGNOSTICS VIEWPORT ────────────────────────── */
.sub-tab-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    overflow-x: auto;
}

.sub-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    min-height: var(--hit-target);
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius-inner);
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

body.light .sub-tab-btn {
    background: #FFFFFF;
    border-color: #CBD5E1;
    color: #475569;
}

.sub-tab-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

body.light .sub-tab-btn:hover {
    background: #EDF2F7;
    border-color: #94A3B8;
    color: #0F172A;
}

.sub-tab-btn.active {
    background: var(--card-subtle);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

body.light .sub-tab-btn.active {
    background: #EDF2F7;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 135, 105, 0.15);
}

.sub-tab-btn .tab-icon {
    font-size: 1rem;
}

.sub-tab-btn .tab-svg {
    flex-shrink: 0;
    transition: stroke 0.15s ease;
}

.tab-label-short {
    display: none;
}

.tech-sub-pane {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Sub-Tab 1: Daily Trends & History Chart */
.diag-panel {
    margin-bottom: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.btn-subtle-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    min-height: 32px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--text);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

body.light .btn-subtle-export {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #334155;
}

.btn-subtle-export:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-tint);
}

body.light .btn-subtle-export:hover {
    background: #E2E8F0;
    border-color: var(--accent);
    color: var(--accent);
}

.daily-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.daily-compare-card {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 16px;
}

body.light .daily-compare-card {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.compare-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.compare-lbl {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.03em;
}

.compare-val {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: var(--font-mono);
    line-height: 1;
}

.compare-cat {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 500;
}

.compare-divider {
    width: 1px;
    height: 48px;
    background: var(--border);
}

.daily-pills-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.metric-pill {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 14px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

body.light .metric-pill {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.pill-lbl {
    font-size: 0.7rem;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
}

.pill-val {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

.daily-change-banner {
    margin-bottom: 12px;
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-inner);
}

.change-badge.better {
    background: var(--accent-tint);
    color: var(--accent);
    border: 1px solid rgba(0, 207, 168, 0.25);
}

.change-badge.worse {
    background: var(--danger-tint);
    color: var(--danger);
    border: 1px solid rgba(240, 82, 82, 0.25);
}

.change-badge.same {
    background: var(--card-subtle);
    color: var(--muted);
    border: 1px solid var(--border);
}

.daily-narrative {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.5;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
}

/* History Chart & Multi-sensor Toggles */
.chart-controls-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chart-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 12px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.chart-pill:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.chart-pill.active {
    background: var(--card);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 8px var(--accent-glow);
}

.chart-pill.disabled {
    opacity: 0.45;
    text-decoration: line-through;
    border-color: var(--border);
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.chart-canvas-wrap {
    position: relative;
    height: clamp(240px, 34vh, 360px);
    width: 100%;
}

/* Sub-Tab 2: Machine Learning & Anomaly Diagnostics Grid */
.diagnostics-split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.diag-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Feature Importance Progress Bars */
.feature-bars-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.feature-bar-row {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

body.light .feature-bar-row {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.feature-bar-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-family: var(--font-mono);
    width: 100%;
    min-width: 0;
}

.feature-name {
    color: var(--text);
    font-weight: 500;
}

.feature-pct {
    color: var(--accent);
    font-weight: 700;
}

.feature-bar-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-inner);
    overflow: hidden;
    width: 100%;
    min-width: 0;
}

body.light .feature-bar-track {
    background: #CBD5E1;
}

.feature-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-inner);
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Model Benchmark Table */
.benchmark-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 14px;
    border-radius: var(--radius-inner);
}

.benchmark-table {
    width: 100%;
    min-width: 380px;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
}

.benchmark-table th {
    padding: 10px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.benchmark-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.benchmark-table tr.highlight-row {
    background: var(--accent-tint);
}

.arch-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.arch-sub {
    font-size: 0.7rem;
    color: var(--muted);
    font-family: var(--font-mono);
}

.eval-badge {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: var(--radius-inner);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.eval-badge.active {
    background: var(--accent);
    color: #080E1B;
}

.eval-badge.baseline {
    background: var(--card-subtle);
    color: var(--muted);
    border: 1px solid var(--border);
}

.benchmark-improvement-callout {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

body.light .benchmark-table th {
    background: #EDF2F7;
    color: #334155;
    border-bottom: 1px solid #CBD5E1;
}

body.light .benchmark-table td {
    border-bottom: 1px solid #E2E8F0;
}

body.light .benchmark-improvement-callout {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.improvement-badge {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    flex-shrink: 0;
}

.improvement-text {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
}

.improvement-text strong {
    color: var(--text);
}

/* Anomaly Detection Center */
.anomaly-status {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-inner);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    background: var(--card-subtle);
    margin-bottom: 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.anomaly-status.ok {
    border-color: rgba(0, 207, 168, 0.3);
    border-left-color: var(--accent);
    background: var(--accent-tint);
}

.anomaly-status.warning {
    border-color: rgba(245, 166, 35, 0.4);
    border-left-color: var(--warn);
    background: var(--warn-tint);
}

.anomaly-status.critical {
    border-color: rgba(240, 82, 82, 0.4);
    border-left-color: var(--danger);
    background: var(--danger-tint);
}

body.light .anomaly-status {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

body.light .anomaly-status.ok {
    border-color: rgba(0, 135, 105, 0.3);
    border-left-color: var(--accent);
    background: rgba(0, 135, 105, 0.08);
}

body.light .anomaly-status.warning {
    border-color: rgba(217, 119, 6, 0.35);
    border-left-color: var(--warn);
    background: rgba(217, 119, 6, 0.10);
}

body.light .anomaly-status.critical {
    border-color: rgba(220, 38, 38, 0.35);
    border-left-color: var(--danger);
    background: rgba(220, 38, 38, 0.10);
}

.anomaly-icon {
    font-size: 1.35rem;
    line-height: 1.1;
    flex-shrink: 0;
    margin-top: 1px;
}

.anomaly-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.anomaly-label {
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
}

.anomaly-msg {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Isolation Forest Risk Bar */
.iforest-container {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

body.light .iforest-container {
    border-bottom-color: #CBD5E1;
}

.risk-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.76rem;
}

.risk-label {
    color: var(--muted);
    font-weight: 600;
}

.risk-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
}

.risk-bar-track {
    height: 8px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

body.light .risk-bar-track {
    background: #CBD5E1;
    border-color: #94A3B8;
}

.risk-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-inner);
    transition: width 0.3s ease, background-color 0.3s ease;
}

/* Z-Score Explainability Grid */
.zscore-section {
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.zscore-title {
    display: block;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 10px;
}

.z-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.z-box {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 8px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

body.light .z-box {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.z-name {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--muted);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.z-val {
    font-size: 0.88rem;
    font-family: var(--font-mono);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.z-val.ok {
    color: var(--accent);
}

.z-val.flag {
    color: var(--danger);
    animation: flashFlag 1s infinite alternate;
}

@keyframes flashFlag {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

.stuck-badge {
    background: var(--danger-tint);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-inner);
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Pollution Source Diagnostic Card */
.source-card {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

body.light .source-card {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.source-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.source-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.source-title {
    font-size: 0.92rem;
    color: var(--text);
    font-weight: 700;
    line-height: 1.3;
}

.source-reasoning {
    font-size: 0.78rem;
    color: var(--muted);
    font-family: var(--font-mono);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Visual Source Attribution Stacked Distribution */
.source-distribution-card {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 12px 14px;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-sizing: border-box;
}

body.light .source-distribution-card {
    background: #EDF2F7;
    border-color: #CBD5E1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.74rem;
}

.dist-title {
    font-weight: 700;
    color: var(--text);
}

.dist-subtitle {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
}

.dist-bar-track {
    display: flex;
    height: 10px;
    width: 100%;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    gap: 2px;
}

body.light .dist-bar-track {
    background: #E2E8F0;
}

.dist-seg {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 2px;
}

.dist-seg.vehicular {
    background: var(--accent);
}

.dist-seg.biomass {
    background: var(--warn);
}

.dist-seg.marine {
    background: var(--cyan);
}

.dist-legend-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.dist-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

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

.legend-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.legend-label {
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-val {
    font-size: 0.74rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

/* ── CITIZEN FOOTER ─────────────────────────────────────────────────────── */
.citizen-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    background: var(--card);
    padding: 24px clamp(16px, 2.5vw, 40px);
    width: 100%;
}

.citizen-footer-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-primary-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-description {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.6;
}

.footer-meta-strip {
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--border);
    padding-top: 12px;
    font-size: 0.74rem;
    color: var(--muted);
    font-family: var(--font-mono);
    text-align: center;
}

.subtle-console-link {
    color: var(--muted);
    text-decoration: underline;
    transition: color 0.2s;
}

.subtle-console-link:hover {
    color: var(--accent);
}

/* ── MODALS (GLASSMORPHISM & ACCESSIBLE) ─────────────────────────────────── */
.glass-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeInModal 0.2s ease;
}

.glass-modal.show {
    display: flex;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.glass-modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-outer);
    padding: 24px;
    max-width: 520px;
    width: 100%;
    position: relative;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.tip-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.info-tip {
    display: none; /* Used as template source for modal display */
}

/* Feedback Form in Modal */
.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fb-input {
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s;
}

body.light .fb-input {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #0F172A;
}

.fb-input:focus {
    border-color: var(--accent);
}

body.light .fb-input:focus {
    background: #FFFFFF;
    border-color: var(--accent);
}

.fb-submit {
    min-height: var(--hit-target);
    background: var(--accent);
    color: #080E1B;
    border: none;
    border-radius: var(--radius-inner);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

body.light .fb-submit {
    color: #FFFFFF;
}

.fb-submit:hover {
    background: var(--accent-hover);
}

.fb-submit:active,
.preset-btn:active {
    transform: scale(0.98);
}

/* Export Modal Controls */
.export-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.export-type-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light .export-type-btn {
    background: #EDF2F7;
    border-color: #CBD5E1;
}

.export-type-btn:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

body.light .export-type-btn:hover {
    background: #E2E8F0;
    border-color: var(--accent);
}

.export-type-btn.active {
    background: rgba(0, 207, 168, 0.12);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(0, 207, 168, 0.15);
}

body.light .export-type-btn.active {
    background: rgba(0, 135, 105, 0.10);
    border-color: var(--accent);
    color: var(--accent);
}

.export-type-desc {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.export-type-desc .type-name {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.export-type-desc .type-hint {
    font-size: 0.68rem;
    color: var(--muted);
    line-height: 1.2;
}

.export-type-btn.active .type-hint {
    color: var(--text);
}

.quick-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.date-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.preset-btn {
    flex: 1;
    min-width: 90px;
    min-height: 36px;
    background: var(--card-subtle);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 8px 10px;
    border-radius: var(--radius-inner);
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

body.light .preset-btn {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #334155;
}

.preset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-tint);
}

body.light .preset-btn:hover {
    background: #E2E8F0;
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 480px) {
    .export-type-selector {
        grid-template-columns: 1fr;
    }
    .quick-presets {
        flex-direction: column;
    }
    .date-row {
        grid-template-columns: 1fr;
    }
}

/* ── SIDE DRAWER MENU ───────────────────────────────────────────────────── */
.menu-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10001;
}

.menu-backdrop.open {
    display: block;
}

.side-menu {
    position: fixed;
    top: 0; right: -320px;
    width: 300px;
    height: 100%;
    background: var(--card);
    border-left: 1px solid var(--border);
    z-index: 10002;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
}

.side-menu.open {
    right: 0;
}

.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.menu-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.btn-close-menu {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.5rem;
    cursor: pointer;
    min-width: var(--hit-target);
    min-height: var(--hit-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: var(--hit-target);
    background: var(--card-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--text);
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    text-align: left;
}

body.light .menu-link {
    background: #EDF2F7;
    border-color: #CBD5E1;
    color: #1E293B;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
}

.menu-link:hover {
    background: var(--card);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateX(3px);
    box-shadow: 0 4px 12px -2px var(--accent-glow);
}

body.light .menu-link:hover {
    background: #E2E8F0;
    border-color: var(--accent);
    color: var(--accent);
}

.menu-link:active {
    transform: translateX(1px) scale(0.99);
}

.menu-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.menu-icon-svg {
    width: 17px;
    height: 17px;
    color: var(--muted);
    flex-shrink: 0;
    transition: color 0.15s ease, transform 0.15s ease;
}

.menu-link:hover .menu-icon-svg {
    color: var(--accent);
    transform: scale(1.1);
}

.menu-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* ── PWA INSTALL PROMPT ─────────────────────────────────────────────────── */
.install-prompt {
    position: fixed;
    bottom: -120px;
    right: 24px;
    left: auto;
    transform: none;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-outer);
    padding: 12px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 9999;
    max-width: 400px;
    width: auto;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.install-prompt.show {
    bottom: 24px;
}

.install-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-size: 0.85rem;
    color: var(--text);
}

.install-text span {
    font-size: 0.72rem;
    color: var(--muted);
}

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

.btn-install {
    min-height: 36px;
    padding: 6px 14px;
    background: var(--accent);
    color: #080E1B;
    border: none;
    border-radius: var(--radius-inner);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-close-install {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── SKELETON LOADERS ───────────────────────────────────────────────────── */
.skeleton {
    position: relative;
    overflow: hidden;
    color: transparent !important;
    border-radius: var(--radius-inner);
    user-select: none;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.05);
}

.skeleton * {
    visibility: hidden !important;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    transform: translateX(-100%);
    animation: shimmer 1.8s infinite;
}

body.light .skeleton {
    background: rgba(0, 0, 0, 0.05);
}

body.light .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06), transparent);
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* ── RESPONSIVE BREAKPOINTS (CROSS-PLATFORM & FLUID DISPLAY SCALING) ────── */
@media (max-width: 1080px) {
    .telemetry-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 960px) {
    .hero-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .diagnostics-split-grid {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .diag-column {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: max(8px, env(safe-area-inset-top)) 14px 8px;
    }

    .topbar-inner {
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .topbar-left {
        order: 1;
    }

    .topbar-right {
        order: 2;
    }

    .topbar-center {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin-top: 4px;
    }

    .segmented-control {
        width: 100%;
        min-height: 42px;
        border-radius: 9px;
        padding: 3px;
    }

    .seg-btn {
        min-height: 38px;
        padding: 7px 10px;
        font-size: 0.82rem;
    }

    .health-alert-banner {
        margin: 12px 12px 0;
        width: calc(100% - 24px);
        padding: 12px 38px 12px 14px;
        gap: 10px;
    }

    .alert-content {
        gap: 10px;
    }

    .alert-icon {
        font-size: 1.25rem;
        margin-top: 2px;
    }

    .alert-text strong {
        font-size: 0.82rem;
        line-height: 1.3;
    }

    .alert-text span {
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .alert-close {
        top: 8px;
        right: 8px;
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        font-size: 1.25rem;
    }

    .main-viewport {
        padding: 16px 12px 64px;
    }

    .card,
    .panel {
        padding: 16px 14px;
        border-radius: var(--radius-outer);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .daily-metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Environmental Telemetry Stacked List for Mobile */
    .telemetry-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .telemetry-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "header header"
            "body   spark"
            "footer footer";
        align-items: center;
        gap: 6px 14px;
        padding: 14px 16px;
        transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    }

    .telemetry-card:active {
        transform: scale(0.995);
    }

    .telemetry-card .card-header {
        grid-area: header;
        margin-bottom: 2px;
        width: 100%;
    }

    .telemetry-card .telemetry-body {
        grid-area: body;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .telemetry-card .telemetry-reading {
        display: flex;
        align-items: baseline;
        gap: 6px;
    }

    .telemetry-card .telemetry-num {
        font-size: clamp(1.6rem, 5.5vw, 1.95rem);
        line-height: 1.1;
    }

    .telemetry-card .telemetry-unit {
        font-size: 0.8rem;
    }

    .telemetry-card .telemetry-sub {
        font-size: 0.72rem;
        color: var(--muted);
        line-height: 1.25;
    }

    .telemetry-card .telemetry-spark-row {
        grid-area: spark;
        margin: 0;
        align-self: center;
        justify-self: end;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 5px 8px;
        border-radius: var(--radius-inner);
    }

    .telemetry-card .telemetry-sparkline {
        width: clamp(75px, 20vw, 105px);
        height: 24px;
    }

    .telemetry-card .spark-badge {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .telemetry-card .telemetry-footer {
        grid-area: footer;
        border-top: 1px solid var(--border-subtle);
        padding-top: 8px;
        margin-top: 4px;
        width: 100%;
    }

    .telemetry-card .meta-row {
        font-size: 0.74rem;
        gap: 6px;
    }

    .chart-canvas-wrap {
        height: clamp(240px, 32vh, 320px);
    }

    .sub-tab-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        width: 100%;
        padding-bottom: 6px;
        margin-bottom: 16px;
        overflow-x: visible;
    }

    .sub-tab-btn {
        width: 100%;
        justify-content: center;
        padding: 8px 4px;
        font-size: 0.74rem;
        min-height: 40px;
        text-align: center;
        gap: 4px;
    }

    .tab-label-full {
        display: none;
    }

    .tab-label-short {
        display: inline;
    }

    .diagnostics-split-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .diag-column {
        gap: 16px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .panel-header {
        margin-bottom: 12px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .panel-title {
        font-size: 0.84rem;
    }

    .panel-title-group {
        gap: 8px;
        flex-wrap: wrap;
        min-width: 0;
        flex: 1;
    }

    .z-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .z-box {
        padding: 6px 2px;
        min-width: 0;
        box-sizing: border-box;
    }

    .z-name {
        font-size: 0.60rem;
        letter-spacing: 0.02em;
    }

    .z-val {
        font-size: 0.80rem;
    }

    .anomaly-status {
        display: flex;
        align-items: flex-start;
        padding: 11px 12px;
        gap: 10px;
        margin-bottom: 14px;
        border-radius: var(--radius-inner);
        border: 1px solid var(--border);
        border-left: 4px solid var(--accent);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .anomaly-status.ok {
        border-color: rgba(0, 207, 168, 0.25);
        border-left-color: var(--accent);
        background: var(--accent-tint);
    }

    .anomaly-status.warning {
        border-color: rgba(245, 166, 35, 0.35);
        border-left-color: var(--warn);
        background: var(--warn-tint);
    }

    .anomaly-status.critical {
        border-color: rgba(240, 82, 82, 0.35);
        border-left-color: var(--danger);
        background: var(--danger-tint);
    }

    .anomaly-icon {
        font-size: 1.25rem;
        line-height: 1.1;
        margin-top: 1px;
        flex-shrink: 0;
    }

    .anomaly-details {
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex: 1;
        min-width: 0;
    }

    .anomaly-label {
        font-size: 0.82rem;
        font-weight: 700;
        line-height: 1.25;
    }

    .anomaly-msg {
        font-size: 0.74rem;
        line-height: 1.35;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .iforest-container {
        margin-bottom: 14px;
        padding-bottom: 14px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .risk-bar-header {
        font-size: 0.72rem;
    }

    .benchmark-table-wrap {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 12px;
        border-radius: var(--radius-inner);
    }

    .benchmark-table {
        min-width: 340px;
        font-size: 0.75rem;
    }

    .benchmark-table th {
        padding: 8px 6px;
        font-size: 0.65rem;
    }

    .benchmark-table td {
        padding: 8px 6px;
    }

    .arch-cell strong {
        font-size: 0.78rem;
    }

    .arch-sub {
        font-size: 0.65rem;
    }

    .eval-badge {
        padding: 2px 6px;
        font-size: 0.65rem;
    }

    .benchmark-improvement-callout {
        gap: 10px;
        padding: 10px 12px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .improvement-badge {
        font-size: 1.2rem;
    }

    .improvement-text {
        font-size: 0.74rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .source-card {
        padding: 12px 14px;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .source-head {
        gap: 8px;
        min-width: 0;
    }

    .source-icon {
        font-size: 1.25rem;
    }

    .source-title {
        font-size: 0.88rem;
    }

    .source-reasoning {
        font-size: 0.75rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .disclosure-callout-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn-disclosure-action {
        width: 100%;
        justify-content: center;
    }

    .citizen-footer {
        padding: 20px 16px max(24px, env(safe-area-inset-bottom));
    }

    .citizen-footer-content {
        gap: 12px;
        align-items: center;
        text-align: center;
    }

    .footer-description {
        font-size: 0.74rem;
        line-height: 1.5;
        text-align: center;
        max-width: 720px;
    }

    .footer-meta-strip {
        font-size: 0.72rem;
        text-align: center;
        line-height: 1.5;
        padding-top: 12px;
        width: 100%;
        justify-content: center;
    }

    .install-prompt {
        left: 14px;
        right: 14px;
        max-width: calc(100% - 28px);
        margin: 0 auto;
        bottom: -140px;
    }

    .install-prompt.show {
        bottom: max(16px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 520px) {
    .telemetry-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .card,
    .panel {
        padding: 14px 12px;
    }

    .telemetry-card {
        padding: 12px 14px;
        gap: 6px 12px;
    }

    .telemetry-num {
        font-size: clamp(1.5rem, 5.5vw, 1.85rem);
    }

    .telemetry-unit {
        font-size: 0.78rem;
    }

    .telemetry-sub {
        font-size: 0.7rem;
    }

    .aqi-score-container {
        gap: 10px;
        margin: 8px 0 12px;
    }

    .aqi-value {
        font-size: clamp(2.8rem, 11vw, 3.8rem);
    }

    .aqi-status-pill {
        font-size: 0.84rem;
        padding: 5px 10px;
    }

    .aqi-guidance-box {
        padding: 10px 12px;
        gap: 10px;
    }

    .guidance-text {
        font-size: 0.78rem;
    }

    .forecast-step-row {
        gap: 6px;
        margin: 10px 0 12px;
    }

    .forecast-step-card {
        padding: 10px 4px;
        min-width: 0;
    }

    .step-hour {
        font-size: 0.65rem;
    }

    .step-aqi {
        font-size: 1.35rem;
    }

    .step-cat {
        font-size: 0.68rem;
    }

    .forecast-summary-box {
        padding: 10px 12px;
        gap: 10px;
    }

    .summary-text {
        font-size: 0.76rem;
    }

    .daily-pills-row {
        gap: 6px;
    }

    .metric-pill {
        padding: 10px 6px;
    }

    .pill-lbl {
        font-size: 0.64rem;
    }

    .pill-val {
        font-size: 1.05rem;
    }

    .compare-val {
        font-size: 1.5rem;
    }

    .daily-change-banner {
        margin-bottom: 8px;
    }

    .chart-controls-strip {
        gap: 8px;
        margin-bottom: 10px;
    }

    .filter-pills {
        gap: 6px;
    }

    .chart-pill {
        padding: 4px 8px;
        font-size: 0.7rem;
        min-height: 30px;
    }

    .glass-modal {
        padding: 12px;
    }

    .glass-modal-content {
        padding: 20px 16px;
        border-radius: 12px;
        max-height: 88dvh;
    }

    .close-modal-btn {
        top: 12px;
        right: 12px;
    }

    .quick-presets {
        flex-direction: column;
        gap: 6px;
    }

    .date-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 360px) {
    .card,
    .panel {
        padding: 12px 10px;
    }

    .telemetry-grid {
        grid-template-columns: 1fr;
    }

    .telemetry-card {
        padding: 10px 12px;
        gap: 6px 10px;
    }

    .telemetry-card .telemetry-sparkline {
        width: 72px;
    }

    .telemetry-card .spark-badge {
        font-size: 0.62rem;
        padding: 2px 4px;
    }

    .brand-title {
        font-size: 1.05rem;
    }

    .seg-text {
        font-size: 0.75rem;
    }

    .daily-pills-row {
        grid-template-columns: 1fr;
    }

    .z-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 330px) {
    .telemetry-card {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "body"
            "spark"
            "footer";
    }

    .telemetry-card .telemetry-spark-row {
        justify-self: stretch;
    }
}

/* ==========================================================================
   Leaflet Map Styles
   ========================================================================== */
.map-card {
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.dark .map-card {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.custom-map-marker {
    position: relative;
    width: 24px;
    height: 24px;
}

.map-pulse-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--accent);
    border-radius: 50%;
    top: 7px;
    left: 7px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.map-pulse-ring {
    position: absolute;
    width: 24px;
    height: 24px;
    background-color: var(--accent);
    border-radius: 50%;
    top: 0;
    left: 0;
    opacity: 0.4;
    animation: map-pulse 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    z-index: 1;
}

@keyframes map-pulse {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.dark .leaflet-control-layers,
.dark .leaflet-bar a {
    background: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.dark .leaflet-control-layers {
    border-radius: 8px;
    padding: 6px 10px;
    font-family: var(--font-sans);
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.dark .leaflet-control-layers label {
    color: var(--text) !important;
}

.dark .leaflet-bar a:hover {
    background: var(--card-subtle) !important;
    color: var(--accent) !important;
}
