:root {
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
}

[data-theme="night"] {
    --bg-primary: #000000;
    --bg-secondary: #050301;
    --bg-tertiary: #0d0702;
    --bg-card: rgba(8, 4, 1, 0.86);
    --bg-card-hover: rgba(18, 9, 2, 0.94);
    --chart-surface: rgba(3, 1, 0, 0.72);
    --bg-glass: rgba(8, 4, 1, 0.62);

    --text-primary: #ffffff;
    --text-secondary: #a5d8ff;
    --text-muted: #81b4e3;

    --accent-blue: #64d2ff;
    --accent-cyan: #81d4fa;
    --accent-light: #5ac8fa;
    --accent-gradient: linear-gradient(135deg, #64d2ff 0%, #5ac8fa 30%, #4fc3f7 62%, #29b6f6 100%);
    --accent-gradient-horizontal: linear-gradient(90deg, #5ac8fa 0%, #64d2ff 35%, #81d4fa 70%, #4fc3f7 100%);

    --border-color: rgba(100, 210, 255, 0.22);
    --border-glow: rgba(100, 210, 255, 0.42);
    --border-glow-strong: rgba(129, 212, 250, 0.72);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65);
    --shadow-aurora: 0 0 44px rgba(100, 210, 255, 0.16), 0 0 90px rgba(90, 200, 250, 0.1);
    --shadow-aurora-strong: 0 0 70px rgba(100, 210, 255, 0.26), 0 0 120px rgba(90, 200, 250, 0.14);
    --shadow-neon: 0 0 20px rgba(100, 210, 255, 0.35), 0 0 40px rgba(90, 200, 250, 0.12);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --chart-grid: rgba(100, 210, 255, 0.14);
    --chart-text: #a5d8ff;
    --chart-tooltip-bg: rgba(8, 4, 1, 0.96);
    --sparkline-color: rgba(100, 210, 255, 0.72);

    --progress-bg: rgba(100, 210, 255, 0.12);
    --progress-fill: linear-gradient(90deg, #5ac8fa, #64d2ff, #29b6f6);

    --live-badge-bg: #64d2ff;
    --live-badge-text: #0a192f;
    --check-icon: #5ac8fa;

    --sidebar-bg: rgba(8, 4, 1, 0.78);
    --sidebar-border: rgba(100, 210, 255, 0.2);
    --header-border: rgba(100, 210, 255, 0.22);
    --kpi-icon-bg: rgba(100, 210, 255, 0.15);
    --kpi-icon-stroke: #5ac8fa;
}

[data-theme="day"] {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f7ff;
    --bg-card: rgba(255, 255, 255, 0.86);
    --bg-card-hover: rgba(248, 250, 255, 0.94);
    --chart-surface: rgba(240, 247, 255, 0.82);
    --bg-glass: rgba(255, 255, 255, 0.72);

    --text-primary: #1a1f2e;
    --text-secondary: #3a4a6b;
    --text-muted: #5a6a8b;

    --accent-blue: #007aff;
    --accent-cyan: #5ac8fa;
    --accent-light: #64b5f6;
    --accent-gradient: linear-gradient(135deg, #007aff 0%, #5ac8fa 30%, #64b5f6 62%, #90caf9 100%);
    --accent-gradient-horizontal: linear-gradient(90deg, #5ac8fa 0%, #007aff 35%, #64b5f6 70%, #90caf9 100%);

    --border-color: rgba(0, 122, 255, 0.35);
    --border-glow: rgba(0, 122, 255, 0.52);
    --border-glow-strong: rgba(90, 200, 250, 0.65);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.1);
    --shadow-aurora: 0 0 42px rgba(0, 122, 255, 0.08), 0 0 90px rgba(90, 200, 250, 0.06);
    --shadow-aurora-strong: 0 0 70px rgba(0, 122, 255, 0.12), 0 0 120px rgba(90, 200, 250, 0.08);
    --shadow-neon: 0 0 20px rgba(0, 122, 255, 0.2), 0 0 40px rgba(90, 200, 250, 0.1);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --chart-grid: rgba(0, 122, 255, 0.1);
    --chart-text: #3a4a6b;
    --chart-tooltip-bg: rgba(255, 255, 255, 0.98);
    --sparkline-color: rgba(0, 122, 255, 0.6);

    --progress-bg: rgba(0, 122, 255, 0.1);
    --progress-fill: linear-gradient(90deg, #5ac8fa, #007aff, #64b5f6);

    --live-badge-bg: #007aff;
    --live-badge-text: #ffffff;
    --check-icon: #5ac8fa;

    --sidebar-bg: rgba(255, 255, 255, 0.76);
    --sidebar-border: rgba(0, 122, 255, 0.3);
    --header-border: rgba(0, 122, 255, 0.3);
    --kpi-icon-bg: rgba(0, 122, 255, 0.1);
    --kpi-icon-stroke: #007aff;
    --kpi-value-gradient: linear-gradient(135deg, #007aff, #5ac8fa, #64b5f6);
}

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

[hidden] {
    display: none !important;
}

html {
    transition: background-color var(--transition-slow);
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    transition: background var(--transition-slow), color var(--transition-slow);
}

a, button, .kpi-card, .chart-item, .infra-card, .progress-fill, .scenario-card {
    transition: background-color var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
}

[data-theme="night"] body {
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(100, 210, 255, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(90, 200, 250, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse 50% 30% at 50% 10%, rgba(100, 210, 255, 0.05) 0%, transparent 55%),
        var(--bg-primary);
}

[data-theme="day"] body {
    background:
        radial-gradient(ellipse 80% 50% at 18% 18%, rgba(0, 122, 255, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 84% 82%, rgba(90, 200, 250, 0.04) 0%, transparent 55%),
        radial-gradient(ellipse 50% 30% at 50% 10%, rgba(100, 210, 255, 0.03) 0%, transparent 55%),
        var(--bg-primary);
}

.bg-aurora {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
}

.bg-aurora::before,
.bg-aurora::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.32;
    animation: auroraDrift 20s ease-in-out infinite;
}

[data-theme="night"] .bg-aurora::before {
    width: 55vw;
    height: 55vw;
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, rgba(100, 210, 255, 0.28), transparent 70%);
}

[data-theme="night"] .bg-aurora::after {
    width: 45vw;
    height: 45vw;
    bottom: -15%;
    right: -10%;
    background: radial-gradient(circle, rgba(90, 200, 250, 0.18), transparent 70%);
    animation-delay: -10s;
}

[data-theme="day"] .bg-aurora::before {
    width: 60vw;
    height: 60vw;
    top: -15%;
    left: -15%;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.12), transparent 65%);
}

[data-theme="day"] .bg-aurora::after {
    width: 50vw;
    height: 50vw;
    bottom: -20%;
    right: -15%;
    background: radial-gradient(circle, rgba(90, 200, 250, 0.08), transparent 65%);
    animation-delay: -10s;
}

.scanlines {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.06;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(100, 210, 255, 0.06) 2px,
        rgba(100, 210, 255, 0.06) 4px
    );
    animation: scanlineMove 10s linear infinite;
}

[data-theme="day"] .scanlines {
    opacity: 0.04;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 122, 255, 0.04) 2px,
        rgba(0, 122, 255, 0.04) 4px
    );
}

.grid-floor {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.04;
    background-image:
        linear-gradient(rgba(100, 210, 255, 0.12) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 210, 255, 0.12) 1px, transparent 1px);
    background-size: 60px 60px;
    transform: perspective(500px) rotateX(60deg) translateY(30%);
    transform-origin: center bottom;
    animation: gridPulse 8s ease-in-out infinite;
}

@keyframes auroraDrift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(3%, 2%) scale(1.05); }
}

@keyframes scanlineMove {
    0% { background-position: 0 0; }
    100% { background-position: 0 20px; }
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.03; }
    50% { opacity: 0.06; }
}

@keyframes pulse {
    0%, 100% { opacity: 0.55; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.25); }
}

@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(100, 210, 255, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(100, 210, 255, 0); }
}

@keyframes numberPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

@keyframes borderSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 1580px;
    margin: 0 auto;
    padding: 8px 14px 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.dashboard-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 310px);
    gap: 10px;
    align-items: start;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.dashboard-primary {
    min-width: 0;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--header-border);
    flex-shrink: 0;
}

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

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    background: var(--accent-gradient-horizontal);
    color: #160800;
    box-shadow: var(--shadow-neon);
    animation: livePulse 2.5s ease-in-out infinite;
}

.header-left h1 {
    font-size: clamp(1.5rem, 2.2vw, 2rem);
    margin-bottom: 2px;
    background: var(--accent-gradient-horizontal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.header-left p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.header-info {
    display: flex;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.header-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 99px;
    font-weight: 600;
}

.live-clock {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-blue);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 99px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.header-badge {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--accent-amber);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 10px #00ff88;
    animation: pulse 2s infinite;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-glow);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--border-glow-strong);
    box-shadow: var(--shadow-aurora);
    transform: rotate(15deg);
}

.theme-toggle .moon-icon {
    display: none;
}

.kpi-section {
    margin-bottom: 6px;
    flex-shrink: 0;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 8px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(6px);
    min-height: 58px;
}

.kpi-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(110deg, transparent 30%, rgba(100, 210, 255, 0.18) 50%, transparent 70%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    background-size: 200% 100%;
    animation: borderSweep 5s linear infinite;
    pointer-events: none;
}

.kpi-card-glow {
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle, rgba(100, 210, 255, 0.15), transparent 60%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.kpi-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-aurora-strong);
    border-color: var(--border-glow);
}

.kpi-card:hover .kpi-card-glow {
    opacity: 1;
}

.kpi-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.kpi-card[data-kpi="cost"] .kpi-top {
    align-items: center;
}

.kpi-icon {
    width: 32px;
    height: 32px;
    background: var(--kpi-icon-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-glow);
}

.kpi-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--kpi-icon-stroke);
}

.kpi-mini-chart {
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}



.kpi-mini-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

.kpi-content h3 {
    font-size: 0.58rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.05;
    margin-bottom: 2px;
    background: var(--accent-gradient-horizontal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-mono);
}

.kpi-value.animated {
    animation: numberPop 0.3s ease-out;
}

/* Health metric stands out in green (positive) */
[data-kpi="health"] .kpi-value {
    background: linear-gradient(135deg, #16a34a, #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="day"] [data-kpi="health"] .kpi-value {
    background: linear-gradient(135deg, #15803d, #22c55e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.kpi-sub {
    font-size: 0.5rem;
    color: var(--text-muted);
}

.kpi-sparkline {
    margin-top: 8px;
    display: block;
    width: 100%;
    max-width: 120px;
    height: 22px;
}

.kpi-sparkline--wide {
    max-width: 100%;
}

/* .kpi-card--sidebar styles removed (Cost card moved to main KPI grid) */

.chart-canvas-wrap {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 138px;
    min-height: 110px;
    background: var(--chart-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    overflow: hidden;
    isolation: isolate;
}

.chart-canvas-wrap--donut {
    height: 138px;
}

.chart-canvas-wrap--radar {
    height: 138px;
}

.scenario-systems-section {
    margin-bottom: 12px;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
}

.section-head h2 {
    font-size: 1.05rem;
    background: var(--accent-gradient-horizontal);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.live-badge {
    background: var(--live-badge-bg);
    color: var(--live-badge-text);
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    animation: livePulse 2s ease-in-out infinite;
}

.scenario-cards-grid {
    --scenario-card-height: 62px;
    --scenario-card-gap: 5px;
    --scenario-visible-rows: 2;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: var(--scenario-card-gap);
    max-height: calc((var(--scenario-card-height) * var(--scenario-visible-rows)) + (var(--scenario-card-gap) * (var(--scenario-visible-rows) - 1)));
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) rgba(100, 210, 255, 0.12);
    flex-shrink: 0;
}

.scenario-cards-grid::-webkit-scrollbar {
    width: 6px;
}

.scenario-cards-grid::-webkit-scrollbar-track {
    background: rgba(100, 210, 255, 0.12);
    border-radius: 99px;
}

.scenario-cards-grid::-webkit-scrollbar-thumb {
    background: var(--accent-gradient);
    border-radius: 99px;
    box-shadow: 0 0 10px rgba(100, 210, 255, 0.4);
}

.scenario-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 5px 7px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    position: relative;
    overflow: hidden;
    font-size: 0.78rem;
}

.scenario-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 0%, rgba(100, 210, 255, 0.08) 42%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.scenario-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-aurora);
    transform: scale(1.02);
}

.scenario-card:hover::after {
    transform: translateX(120%);
}

.scenario-card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.scenario-num {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--accent-blue);
    background: var(--kpi-icon-bg);
    padding: 2px 7px;
    border-radius: 99px;
    border: 1px solid var(--border-glow);
    font-family: var(--font-mono);
}

.scenario-cat {
    font-size: 0.62rem;
    color: var(--text-muted);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scenario-status {
    font-size: 0.58rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 99px;
}

.scenario-status.online {
    color: #00ff88;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.25);
}

.scenario-status.busy {
    color: #64d2ff;
    background: rgba(255, 170, 0, 0.1);
    border: 1px solid rgba(255, 170, 0, 0.25);
}

.scenario-card h4 {
    font-size: 0.72rem;
    line-height: 1.25;
    color: var(--text-primary);
    min-height: 1.8em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scenario-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.scenario-metrics div {
    text-align: center;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 5px 3px;
    border: 1px solid var(--border-color);
}

.scenario-metrics label {
    display: block;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.scenario-metrics span {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.scenario-sparkline {
    width: 100%;
    height: 18px;
    display: block;
    border-radius: 5px;
    background: var(--chart-surface);
    border: 1px solid var(--border-color);
}

.charts-section {
    margin-bottom: 12px;
}

.command-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(6px);
}

.command-tab {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 7px 16px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.command-tab.active,
.command-tab:hover {
    background: var(--accent-gradient-horizontal);
    color: #160800;
    border-color: var(--border-glow-strong);
    box-shadow: 0 0 16px rgba(100, 210, 255, 0.28);
}

.command-tab.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: translateX(-100%);
    animation: borderSweep 2.5s linear infinite;
    pointer-events: none;
}

.auto-rotate-badge {
    margin-left: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    background: var(--accent-gradient-horizontal);
    color: #160800;
    border-radius: 999px;
    align-self: center;
    letter-spacing: 0.05em;
}

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

.chart-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    transition: all var(--transition-normal);
    min-width: 0;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(6px);
    position: relative;
    overflow: hidden;
}

.chart-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--accent-gradient-horizontal);
    opacity: 0.4;
}

.chart-item--wide {
    grid-column: span 2;
}

.chart-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-glow);
    box-shadow: var(--shadow-aurora);
    transform: translateY(-2px);
}

.chart-item h3 {
    font-size: 0.82rem;
    margin-bottom: 10px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chart-item h3::after {
    content: '';
    flex-grow: 1;
    height: 1px;
    background: var(--accent-gradient-horizontal);
    opacity: 0.5;
}

.chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    position: relative;
    z-index: 2;
}

.chart-fallback {
    margin-top: 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.infra-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    align-content: start;
}

.infra-card {
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.infra-card h4 {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.progress-bar {
    width: 100%;
    height: 7px;
    background: var(--progress-bg);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 99px;
    transition: width 0.8s ease;
    box-shadow: 0 0 10px rgba(100, 210, 255, 0.35);
}

.progress-text {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.sidebar-right {
    width: 100%;
    padding: 14px;
    background: var(--sidebar-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-md);
    position: sticky;
    top: 14px;
    height: fit-content;
    min-width: 0;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-md);
}

.health-checklist,
.model-cloud-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 8px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sidebar-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    margin-bottom: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.sidebar-tab {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 6px 4px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
}

.sidebar-tab.active,
.sidebar-tab:hover {
    background: var(--accent-gradient-horizontal);
    color: #160800;
    border-color: var(--border-glow-strong);
    box-shadow: 0 0 12px rgba(100, 210, 255, 0.22);
}

/* Only Models and Health tabs are active. Other panels use .hidden attribute via JS */

.model-cloud-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
}

.model-cloud-head h3 {
    font-size: 0.92rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-title-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--accent-gradient-horizontal);
    color: #160800;
    font-size: 0.45rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    box-shadow: 0 0 8px rgba(100, 210, 255, 0.24);
}

.model-cloud-count {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-blue);
    background: var(--kpi-icon-bg);
    padding: 2px 7px;
    border-radius: 99px;
    border: 1px solid var(--border-glow);
    white-space: nowrap;
}

.model-cloud-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    line-height: 1.4;
}

.model-usage-spider {
    margin: 0 auto 4px;
    max-width: 140px;
    background: var(--chart-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 3px;
}

.server-models-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding-right: 0;
}

.server-model-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px 6px;
    transition: border-color var(--transition-fast);
    box-shadow: inset 0 0 10px rgba(100, 210, 255, 0.05);
    position: relative;
    overflow: hidden;
    animation: modelCardBreathe 4s ease-in-out infinite;
    width: 100%;
    min-height: 48px;
}

.server-model-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 0%, rgba(100, 210, 255, 0.1) 42%, transparent 70%);
    transform: translateX(-120%);
    animation: modelSweep 5s ease-in-out infinite;
    pointer-events: none;
}

.server-model-item:hover {
    border-color: var(--border-glow);
}

.server-model-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 0;
}

.server-model-icon {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
    font-size: 0.42rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(100, 210, 255, 0.2);
    animation: modelIconPulse 2.8s ease-in-out infinite;
}

.server-model-glyph {
    font-size: 0.7rem;
    line-height: 1;
}

.server-model-abbr {
    font-size: 0.38rem;
    line-height: 1;
    letter-spacing: 0.02em;
}

.server-model-name {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.server-model-type {
    font-size: 0.46rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 99px;
    flex-shrink: 0;
}

.server-model-type.local {
    color: var(--accent-blue);
    background: rgba(100, 210, 255, 0.12);
    border: 1px solid rgba(100, 210, 255, 0.25);
}

.server-model-type.cloud {
    color: #00d2ff;
    background: rgba(0, 210, 255, 0.1);
    border: 1px solid rgba(0, 210, 255, 0.22);
}

.server-model-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 0.58rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    line-height: 1.1;
}

.server-model-meta span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-model-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
}

.server-model-status::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 5px #00ff88;
}

.server-model-status.warm::before {
    background: #64d2ff;
    box-shadow: 0 0 5px #64d2ff;
}

.server-model-load {
    width: 100%;
    height: 4px;
    background: var(--progress-bg);
    border-radius: 99px;
    overflow: hidden;
}

.server-model-load-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--progress-fill);
    transition: width 0.6s ease;
    box-shadow: 0 0 8px rgba(100, 210, 255, 0.35);
}

@keyframes modelIconPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.06); filter: brightness(1.18); }
}

@keyframes modelCardBreathe {
    0%, 100% { box-shadow: inset 0 0 14px rgba(100, 210, 255, 0.05); }
    50% { box-shadow: inset 0 0 22px rgba(100, 210, 255, 0.1), 0 0 14px rgba(100, 210, 255, 0.06); }
}

@keyframes modelSweep {
    0%, 62% { transform: translateX(-120%); }
    100% { transform: translateX(120%); }
}

.model-cloud-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-amber);
    text-decoration: none;
}

.model-cloud-link:hover {
    color: var(--accent-blue);
    text-decoration: underline;
}

.health-checklist h3 {
    font-size: 0.92rem;
    margin: 0;
    color: var(--text-primary);
}

.health-list {
    list-style: none;
}

.health-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.72rem;
}

.health-list li:last-child {
    border-bottom: none;
}

.check-icon {
    color: var(--check-icon);
    font-weight: 800;
    animation: pulse 2s infinite;
}

footer {
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    border-top: 1px solid var(--header-border);
    margin-top: 24px;
}

.footer-left,
.footer-right {
    display: inline-block;
    margin: 0 8px;
}

@media (max-width: 1200px) {
    .dashboard-body {
        grid-template-columns: 1fr;
    }

    .sidebar-right {
        position: static;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-right {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    .main-content {
        padding: 12px;
        overflow-y: auto;
        height: auto;
    }

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

    .kpi-card {
        padding: 12px;
    }

    .kpi-value {
        font-size: 1.45rem;
    }

    .kpi-mini-chart {
        width: 52px;
        height: 32px;
    }

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

    .chart-item--wide {
        grid-column: auto;
    }

    .chart-canvas-wrap,
    .chart-canvas-wrap--donut,
    .chart-canvas-wrap--radar {
        height: 220px;
        min-height: 200px;
    }

    .command-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .command-tab {
        padding: 8px 10px;
        font-size: 0.68rem;
    }

    .scenario-cards-grid {
        --scenario-card-height: 150px;
        --scenario-visible-rows: 3;
        grid-template-columns: 1fr;
        max-height: calc((var(--scenario-card-height) * var(--scenario-visible-rows)) + (var(--scenario-card-gap) * (var(--scenario-visible-rows) - 1)));
    }

    .scenario-card h4 {
        min-height: auto;
    }

    .server-models-list {
        /* no internal scroll, compact */
    }

    .scanlines,
    .grid-floor {
        display: none;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .header-brand {
        gap: 10px;
    }

    .header-logo {
        width: 36px;
        height: 36px;
        font-size: 0.6rem;
    }

    .header-left h1 {
        font-size: 1.25rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-aurora::before,
    .bg-aurora::after,
    .scanlines,
    .grid-floor,

    .check-icon,
    .server-model-item,
    .server-model-item::after,
    .server-model-icon,
    .kpi-card::before,
    .command-tab.active::after,
    .status-dot,
    .live-badge,
    .header-logo {
        animation: none !important;
    }

    .kpi-card:hover,
    .chart-item:hover,
    .scenario-card:hover,
    .theme-toggle:hover {
        transform: none;
    }
}

/* Desktop single-screen lock */
@media (min-width: 1280px) {
    html,
    body {
        height: 100%;
    }

    body {
        overflow: hidden;
    }

    .dashboard,
    .main-content {
        height: 100vh;
        min-height: 0;
        overflow: hidden;
    }

    .main-content {
        max-width: 1760px;
        padding: 12px 14px;
    }

    .header {
        margin-bottom: 10px;
        padding-bottom: 8px;
    }

    .header-left h1 {
        font-size: clamp(1.4rem, 1.6vw, 1.8rem);
    }

    .header-left p {
        font-size: 0.7rem;
    }

    .header-badge {
        padding: 4px 10px;
        font-size: 0.7rem;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;
    }

    .dashboard-body {
        grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
        gap: 12px;
        height: calc(100vh - 76px);
        min-height: 0;
    }

    .dashboard-primary,
    .sidebar-right {
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .kpi-section,
    .scenario-systems-section,
    .charts-section {
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .kpi-section {
        flex-shrink: 0;
    }

    .scenario-systems-section {
        flex-shrink: 0;
    }

    .charts-section {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .chart-grid {
        flex: 1;
        min-height: 0;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-rows: minmax(0, 1fr);
        gap: 10px;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 4px;
        scrollbar-width: thin;
        scrollbar-color: var(--accent-blue) transparent;
        align-content: start;
    }

    .chart-grid::-webkit-scrollbar {
        width: 6px;
    }

    .chart-grid::-webkit-scrollbar-track {
        background: rgba(100, 210, 255, 0.1);
        border-radius: 99px;
    }

    .chart-grid::-webkit-scrollbar-thumb {
        background: var(--accent-gradient);
        border-radius: 99px;
    }

    .chart-item {
        min-height: 0;
        padding: 10px;
        border-radius: 12px;
    }

    .chart-item--wide {
        grid-column: span 2;
    }

    .chart-canvas-wrap,
    .chart-canvas-wrap--donut,
    .chart-canvas-wrap--radar {
        height: 100%;
        min-height: 0;
        padding: 6px;
    }

    .chart-item h3 {
        font-size: 0.72rem;
        margin-bottom: 6px;
    }

    .infra-cards {
        gap: 8px;
    }

    .infra-card {
        padding: 8px;
    }

    .infra-card h4 {
        font-size: 0.62rem;
    }

    .progress-text {
        font-size: 0.72rem;
    }

    .kpi-grid {
        gap: 10px;
    }

    .kpi-card {
        padding: 10px;
        border-radius: 12px;
    }

    .kpi-icon {
        width: 34px;
        height: 34px;
    }

    .kpi-mini-chart {
        width: 56px;
        height: 34px;
    }

    .kpi-content h3 {
        font-size: 0.68rem;
        margin-bottom: 4px;
    }

    .kpi-value {
        font-size: 1.35rem;
    }

    .kpi-sub {
        font-size: 0.6rem;
    }

    .section-head {
        margin-bottom: 6px;
    }

    .section-head h2 {
        font-size: 0.85rem;
    }

    .scenario-cards-grid {
        --scenario-card-height: 120px;
        --scenario-card-gap: 6px;
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: var(--scenario-card-gap);
        max-height: calc((var(--scenario-card-height) * var(--scenario-visible-rows)) + (var(--scenario-card-gap) * (var(--scenario-visible-rows) - 1)));
        padding-right: 4px;
    }

    .scenario-card {
        padding: 8px;
        gap: 5px;
    }

    .scenario-card h4 {
        font-size: 0.64rem;
        min-height: 1.7em;
    }

    .scenario-metrics {
        gap: 4px;
    }

    .scenario-metrics div {
        padding: 4px 2px;
    }

    .scenario-metrics label {
        font-size: 0.5rem;
    }

    .scenario-metrics span {
        font-size: 0.64rem;
    }

    .scenario-sparkline {
        height: 16px;
    }

    .sidebar-right {
        top: 10px;
        max-height: calc(100vh - 20px);
        padding: 10px;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--accent-blue) transparent;
    }

    .model-cloud-card,
    .health-checklist {
        margin-bottom: 8px;
        padding: 10px;
    }



    .server-model-item {
        padding: 6px;
        margin-bottom: 4px;
    }

    .server-models-list {
        gap: 5px;
    }

    .server-model-item {
        min-height: 46px;
        padding: 4px;
    }

    .server-model-icon {
        width: 18px;
        height: 18px;
    }

    .server-model-glyph {
        font-size: 0.7rem;
    }

    .server-model-name {
        font-size: 0.7rem;
    }



    .health-list li {
        padding: 6px 0;
        font-size: 0.68rem;
    }
}

html.ncc-force-night,
html.ncc-force-night[data-theme="day"] {
    --bg-primary: #000000;
    --bg-secondary: #050301;
    --bg-tertiary: #0d0702;
    --bg-card: rgba(8, 4, 1, 0.86);
    --bg-card-hover: rgba(18, 9, 2, 0.94);
    --chart-surface: rgba(3, 1, 0, 0.72);
    --text-primary: #ffffff;
    --text-secondary: #f3c68f;
    --text-muted: #c28a52;
    --accent-orange: #64d2ff;
    --accent-amber: #5ac8fa;
    --accent-red: #29b6f6;
    --accent-cyan: #4fc3f7;
    --accent-magenta: #ff00ff;
    --accent-gradient: linear-gradient(135deg, #64d2ff 0%, #5ac8fa 30%, #4fc3f7 62%, #29b6f6 100%);
    --accent-gradient-horizontal: linear-gradient(90deg, #5ac8fa 0%, #64d2ff 35%, #4fc3f7 70%, #29b6f6 100%);
    --border-color: rgba(100, 210, 255, 0.22);
    --border-glow: rgba(100, 210, 255, 0.42);
    --border-glow-strong: rgba(255, 176, 0, 0.72);
    --header-border: rgba(100, 210, 255, 0.22);
    --kpi-icon-bg: rgba(100, 210, 255, 0.15);
    --kpi-icon-stroke: #5ac8fa;
    --progress-bg: rgba(100, 210, 255, 0.12);
    --progress-fill: linear-gradient(90deg, #5ac8fa, #64d2ff, #29b6f6);
    --live-badge-bg: #64d2ff;
    --live-badge-text: #120700;
    --check-icon: #5ac8fa;
}

html.ncc-force-night body,
html.ncc-force-night[data-theme="day"] body {
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(100, 210, 255, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(90, 200, 250, 0.08) 0%, transparent 55%),
        radial-gradient(ellipse 50% 30% at 50% 10%, rgba(100, 210, 255, 0.05) 0%, transparent 55%),
        #000000 !important;
    color: #ffffff;
}

html.ncc-force-night .kpi-card,
html.ncc-force-night .chart-item,
html.ncc-force-night .sidebar-right,
html.ncc-force-night .model-cloud-card,
html.ncc-force-night .health-checklist,
html.ncc-force-night .scenario-card,
html.ncc-force-night .infra-card,
html.ncc-force-night .server-model-item,
html.ncc-force-night .scenario-metrics div {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

html.ncc-force-night .chart-canvas-wrap,
html.ncc-force-night .scenario-sparkline,
html.ncc-force-night .kpi-mini-chart {
    background: var(--chart-surface) !important;
    border-color: var(--border-color) !important;
}

html.ncc-force-night .header-left h1,
html.ncc-force-night .kpi-value,
html.ncc-force-night .section-head h2 {
    background: var(--accent-gradient-horizontal) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

html.ncc-force-night .command-tab.active,
html.ncc-force-night .sidebar-tab.active,
html.ncc-force-night .command-tab:hover,
html.ncc-force-night .sidebar-tab:hover {
    color: #160800 !important;
}

html:not(.ncc-force-night)[data-theme="day"] body {
    background:
        radial-gradient(ellipse 80% 50% at 18% 18%, rgba(255, 122, 0, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 84% 82%, rgba(215, 90, 0, 0.05) 0%, transparent 55%),
        radial-gradient(ellipse 50% 30% at 50% 10%, rgba(255, 176, 0, 0.05) 0%, transparent 55%),
        #ffffff;
}

/* ==================== NCC REVAMP: Compact Desktop (no-scroll), Category Tabs, Responsive ==================== */

/* Desktop no-scroll fit */
@media (min-width: 900px) {
  .dashboard {
    height: 100vh;
  }
  .main-content {
    padding: 6px 12px 8px;
  }
  .kpi-card {
    padding: 6px 8px;
    min-height: 62px;
  }
  .scenario-cards-grid {
    --scenario-card-height: 56px;
    --scenario-visible-rows: 2;
  }
  .chart-canvas-wrap,
  .chart-canvas-wrap--donut,
  .chart-canvas-wrap--radar {
    height: 126px;
    min-height: 100px;
    padding: 5px;
  }
  .section-head h2 {
    font-size: 0.95rem;
  }
  .command-tabs {
    margin-bottom: 6px;
  }
}

/* Category Tabs - horizontal scrollable pills for selecting scenario categories */
.category-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 3px 2px 5px;
  margin-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-blue) transparent;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.category-tabs::-webkit-scrollbar {
  height: 3px;
}
.category-tabs::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 3px;
}

.category-tab {
  flex: 0 0 auto;
  padding: 3px 11px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.category-tab:hover {
  border-color: var(--border-glow);
  color: var(--text-primary);
}
.category-tab.active {
  background: var(--accent-gradient-horizontal);
  color: #160800;
  border-color: var(--border-glow-strong);
  box-shadow: 0 0 10px rgba(100, 210, 255, 0.3);
}

/* Make scenario cards even tighter */
.scenario-card-head {
  gap: 4px;
}
.scenario-num {
  font-size: 0.58rem;
  padding: 1px 5px;
}
.scenario-cat {
  font-size: 0.55rem;
}
.scenario-metrics {
  gap: 3px;
}
.scenario-metrics div {
  padding: 2px 2px;
}
.scenario-metrics label {
  font-size: 0.48rem;
}
.scenario-metrics span {
  font-size: 0.62rem;
}
.scenario-sparkline {
  height: 12px;
}

/* Tighter chart grid + section */
.chart-grid {
  gap: 6px;
}
.charts-section {
  margin-bottom: 4px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.command-tabs {
  flex-shrink: 0;
}
#chart-grid {
  flex: 1;
  min-height: 0;
  overflow: auto; /* allow internal scroll only for charts if needed */
}

/* Sidebar tighter */
.sidebar-right {
  font-size: 0.78rem;
  overflow: auto;
  max-height: 100%;
}
.sidebar-tabs {
  gap: 2px;
  margin: 3px 0 4px;
}
.sidebar-tab {
  padding: 2px 8px;
  font-size: 0.6rem;
}

/* Responsive: Mobile & Tablet */
@media (max-width: 899px) {
  .dashboard {
    height: auto;
    min-height: 100vh;
  }
  .main-content {
    padding: 10px 10px 16px;
    overflow-y: auto;
    height: auto;
  }
  .dashboard-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .kpi-card {
    min-height: 72px;
    padding: 10px;
  }
  .scenario-cards-grid {
    --scenario-card-height: 72px;
    --scenario-visible-rows: 3;
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  }
  .category-tabs {
    gap: 5px;
    padding-bottom: 6px;
  }
  .category-tab {
    font-size: 0.72rem;
    padding: 5px 13px;
  }
  .chart-canvas-wrap,
  .chart-canvas-wrap--donut,
  .chart-canvas-wrap--radar {
    height: 168px;
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .sidebar-right {
    order: 2;
  }
}

/* Very small phones */
@media (max-width: 420px) {
  .header-brand h1 { font-size: 1.1rem; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .scenario-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  .category-tabs { gap: 3px; }
  .category-tab { font-size: 0.64rem; padding: 4px 9px; }
}

/* Reduce some text sizes globally for density */
.section-sub, .kpi-sub { font-size: 0.62rem; }
.kpi-value { font-size: 1.35rem; line-height: 1.05; }
