:root {
    /* Color Palette - Elite Executive */
    --bg-main: #05080F;
    --bg-sidebar: #090E17;
    --bg-card-top: rgba(23, 32, 48, 0.6);
    --bg-card-bottom: rgba(13, 18, 28, 0.8);
    --bg-card-hover-top: rgba(30, 41, 60, 0.7);
    --bg-card-hover-bottom: rgba(18, 25, 40, 0.9);

    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(129, 140, 248, 0.5);

    /* Text Colors */
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    /* Refined Semantic Colors */
    --accent-indigo: #818CF8;
    --accent-violet: #A78BFA;
    --semantic-green: #10B981;
    --semantic-green-bg: rgba(16, 185, 129, 0.08);
    --semantic-amber: #F59E0B;
    --semantic-amber-bg: rgba(245, 158, 11, 0.08);
    --semantic-red: #FB7185;
    --semantic-red-bg: rgba(251, 113, 133, 0.08);

    /* Depth & Atmosphere */
    --shadow-soft: 0 12px 40px -8px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(129, 140, 248, 0.15);
    --inner-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.06);
    --inner-highlight-hover: inset 0 1px 1px rgba(255, 255, 255, 0.1);

    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --transition-smooth: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at 50% -10%, rgba(129, 140, 248, 0.06) 0%, transparent 60%);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography Helpers */
.text-positive {
    color: var(--semantic-green);
    font-weight: 500;
}

.text-negative {
    color: var(--semantic-red);
    font-weight: 500;
}

.text-warning {
    color: var(--semantic-amber);
    font-weight: 500;
}

.text-action {
    color: var(--accent-indigo);
    font-weight: 500;
}

.text-sm {
    font-size: 0.85rem;
}

.text-muted-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* Status Indicators */
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: var(--semantic-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot.risk {
    background-color: var(--semantic-red);
    box-shadow: 0 0 8px rgba(251, 113, 133, 0.5);
}

.status-dot.warning {
    background-color: var(--semantic-amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.status-dot.opportunity {
    background-color: var(--semantic-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.status-dot.active-sync {
    background-color: var(--accent-indigo);
    box-shadow: 0 0 8px rgba(129, 140, 248, 0.6);
    animation: pulseSync 3s infinite;
}

@keyframes pulseSync {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 10;
}

.brand-area {
    padding: 0 8px 24px 8px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
    color: white;
    font-size: 14px;
    box-shadow: var(--inner-highlight);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: rgba(129, 140, 248, 0.08);
    color: var(--accent-indigo);
    position: relative;
}

.nav-item.active::before {
    content: '→';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background-color: var(--accent-indigo);
    border-radius: 0 4px 4px 0;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 16px 0 6px 12px;
    font-weight: 600;
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border-subtle);
    padding-top: 16px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1500px;
    margin: 0 auto;
}

/* Executive Pulse Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    position: relative;
    z-index: 50;
}

.page-title {
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Header Widgets & Health Gauge */
.header-widgets {
    display: inline-flex;
    align-items: center;
    gap: 16px;
}

.header-widget {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 20px;
    border-radius: 100px;
    backdrop-filter: blur(12px);
    box-shadow: var(--inner-highlight);
    height: 44px;
    transition: all 0.2s;
    position: relative;
}

.header-widget.interactive-widget:hover {
    cursor: pointer;
    background: rgba(30, 41, 60, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

/* (Legacy Health dropdown removed — replaced by the Store Health Report modal) */

.close-popup {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-popup:hover {
    color: var(--text-primary);
}

.health-gauge-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.health-gauge-svg {
    position: relative;
    width: 48px;
    height: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 8px;
}

.health-gauge-svg svg {
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 200%;
    /* Double height since it's a half-circle drawn on a viewBox of 100x50 */
    overflow: visible;
}

.gauge-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.gauge-value {
    stroke: var(--semantic-green);
    /* 125.6 is the approx circumference of half circle with r=40 (2 * pi * 40 / 2). Dashoffset sets value */
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.4));
    transition: stroke-dashoffset 1s ease-out;
}

.gauge-score {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    z-index: 1;
    color: var(--text-primary);
}

.header-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.1);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

/* Online / Away Status Selector */
.status-selector {
    position: relative;
    font-size: 0.85rem;
    user-select: none;
    height: 44px;
}

.status-current {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0 16px;
    height: 100%;
    border-radius: 100px;
    backdrop-filter: blur(12px);
    box-shadow: var(--inner-highlight);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.status-current:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(30, 41, 60, 0.5);
}

.dropdown-icon {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.status-selector.active .dropdown-icon {
    transform: rotate(180deg);
}

.status-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card-top);
    border: 1px solid var(--border-hover);
    border-radius: var(--border-radius-md);
    padding: 6px;
    box-shadow: var(--shadow-soft);
    width: 140px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
}

.status-selector.active .status-dropdown {
    display: flex;
}

.status-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.status-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Grids */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.top-metrics {
    display: grid;
    /* Grid flexibility based on number of active metrics. We set a min-width to ensure they don't get too squeezed. */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.bento-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(min-content, max-content);
    gap: 20px;
}

/* Card Placements */
.card-executive-summary {
    grid-column: 1 / -1;
}

.card-root-cause {
    grid-column: 1 / -1;
}

/* Card Base - Premium Depth */
.card {
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--inner-highlight), var(--shadow-soft);
    transition: transform var(--transition-smooth), border-color var(--transition-smooth), box-shadow var(--transition-smooth), background var(--transition-smooth);
}

.interactive-card {
    cursor: pointer;
}

.interactive-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--inner-highlight-hover), var(--shadow-glow);
    background: linear-gradient(180deg, var(--bg-card-hover-top) 0%, var(--bg-card-hover-bottom) 100%);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.card-action {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s;
    opacity: 0.3;
}

.card:hover .card-action {
    opacity: 1;
}

.card-action:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* Metric Cards Refinement */
.status-chip {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--transition-smooth);
}

.status-chip.positive {
    color: var(--semantic-green);
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.15);
}

.status-chip.warning {
    color: var(--semantic-amber);
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.15);
}

.interactive-card:hover .status-chip.positive {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.interactive-card:hover .status-chip.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.metric-value-row {
    margin-bottom: 4px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 4px;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Metric Chart with Y-Axis */
.mini-chart-container {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    height: 46px;
}

.y-axis-labels {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-top: 2px;
}

.mini-chart-svg {
    flex: 1;
    position: relative;
}

.chart-grid-line {
    stroke: rgba(255, 255, 255, 0.03);
    stroke-width: 1;
    stroke-dasharray: 2 2;
}

.chart-line {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke-width 0.3s, filter 0.3s;
}

.interactive-card:hover .chart-line.positive {
    stroke-width: 2.5;
    filter: drop-shadow(0 4px 6px rgba(16, 185, 129, 0.4));
}

.interactive-card:hover .chart-line.warning {
    stroke-width: 2.5;
    filter: drop-shadow(0 4px 6px rgba(245, 158, 11, 0.4));
}

.chart-line.positive {
    stroke: var(--semantic-green);
}

.chart-area.positive {
    fill: var(--semantic-green);
    opacity: 0.06;
}

.chart-line.warning {
    stroke: var(--semantic-amber);
}

.chart-area.warning {
    fill: var(--semantic-amber);
    opacity: 0.06;
}

/* AI Executive Memo */
.memo-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 20px;
    position: relative;
}

.confidence-score {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.75rem;
    color: var(--accent-indigo);
    border: 1px solid rgba(129, 140, 248, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(129, 140, 248, 0.05);
    font-weight: 500;
}

.memo-content {
    display: flex;
    gap: 16px;
    position: relative;
}

.memo-accent-line {
    width: 2px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--accent-indigo) 0%, transparent 100%);
    flex-shrink: 0;
    opacity: 0.8;
}

.briefing-sections {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.briefing-section {
    background: rgba(255, 255, 255, 0.015);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    position: relative;
}

.briefing-section p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.briefing-section strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Root Cause Preview - Premium Visual Chain */
.chain-visual {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    margin-bottom: 20px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.chain-node {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.chain-node.active-node {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--semantic-amber);
}

.chain-link {
    flex: 1;
    display: flex;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.4;
}

.chain-link svg {
    width: 14px;
    height: 14px;
}

.rc-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.rc-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
}

.rc-action-box {
    background: rgba(129, 140, 248, 0.05);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgba(129, 140, 248, 0.15);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-read-btn {
    background: rgba(129, 140, 248, 0.1);
    border: 1px solid rgba(129, 140, 248, 0.2);
    color: var(--accent-indigo);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    font-weight: 500;
}

.action-read-btn:hover {
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.3);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge.positive {
    background-color: var(--semantic-green-bg);
    color: var(--semantic-green);
}

.badge.negative {
    background-color: var(--semantic-red-bg);
    color: var(--semantic-red);
}


@media (max-width: 1200px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-executive-summary {
        grid-column: span 2;
    }

    .card-root-cause {
        grid-column: span 2;
    }
}

@media (max-width: 992px) {
    .top-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-controls {
        display: none;
    }
}

/* =========================================
   Intelligence Page - 3 Column Layout
   ========================================= */

.intelligence-layout {
    display: grid;
    grid-template-columns: 350px 1fr 400px;
    gap: 20px;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Common Column Styles */
.col-signals,
.col-analysis,
.col-recommendation {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--inner-highlight), var(--shadow-soft);
    overflow: hidden;
}

.col-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.col-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Signals Column */
.filter-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 2px;
    border: 1px solid var(--border-subtle);
}

.filter-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.filter-tab.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.signal-filters-scroll {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    scrollbar-width: none;
    /* Firefox */
}

.signal-filters-scroll::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-pill:hover {
    background: rgba(255, 255, 255, 0.08);
}

.filter-pill.active {
    background: rgba(129, 140, 248, 0.15);
    color: var(--accent-indigo);
    border-color: rgba(129, 140, 248, 0.3);
}

.signals-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.signal-card {
    padding: 16px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.signal-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-hover);
}

.signal-card.active {
    background: rgba(129, 140, 248, 0.08);
    border-color: rgba(129, 140, 248, 0.3);
    box-shadow: 0 0 20px rgba(129, 140, 248, 0.05);
}

.signal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.signal-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.signal-badge.risk {
    background: var(--semantic-red-bg);
    color: var(--semantic-red);
}

.signal-badge.warning {
    background: var(--semantic-amber-bg);
    color: var(--semantic-amber);
}

.signal-badge.opportunity {
    background: var(--semantic-green-bg);
    color: var(--semantic-green);
}

.signal-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.signal-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.signal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
}

.signal-impact {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Analysis Column */
.analysis-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.analysis-section p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.rc-tree {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.rc-tree-node {
    font-size: 0.9rem;
    color: var(--text-secondary);
    position: relative;
    padding-left: 20px;
}

.rc-tree-node::before {
    content: '→';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.rc-tree-node.depth-1 {
    margin-left: 16px;
}

.rc-tree-node.depth-2 {
    margin-left: 32px;
}

.rc-tree-node.depth-3 {
    margin-left: 48px;
}

.rc-tree-node.active {
    color: var(--semantic-red);
    font-weight: 500;
}

.rc-tree-node.active::before {
    background: var(--semantic-red);
    box-shadow: 0 0 8px rgba(251, 113, 133, 0.6);
}

.evidence-list {
    list-style: none;
    margin-top: 8px;
}

.evidence-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}

.evidence-list li::before {
    content: '\2192';
    position: absolute;
    left: 0;
    color: var(--accent-indigo);
}

/* Recommendation Column */
.recommendation-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.rec-highlight-box {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 8px;
    padding: 16px;
}

.rec-title {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.rec-rationale {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.rec-est-impact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
}

.next-steps-list {
    margin-left: 16px;
    margin-top: 8px;
}

.next-steps-list li {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

.action-read-btn.primary-action {
    background: var(--accent-indigo);
    color: white;
    border: none;
    text-align: center;
    padding: 10px;
}

.action-read-btn.primary-action:hover {
    background: var(--accent-violet);
}

.action-read-btn.outline {
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-read-btn.outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Responsive adjustments for 3 column */
@media (max-width: 1400px) {
    .intelligence-layout {
        grid-template-columns: 300px 1fr 350px;
    }
}

@media (max-width: 1024px) {
    .intelligence-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .col-signals,
    .col-analysis,
    .col-recommendation {
        height: 600px;
    }
}

/* =========================================
   Revenue Page Layout
   ========================================= */

.revenue-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.rev-chart-card {
    display: flex;
    flex-direction: column;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compare-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.compare-toggle input {
    accent-color: var(--accent-indigo);
    cursor: pointer;
}

.rev-chart-area {
    flex: 1;
    min-height: 250px;
    position: relative;
    margin-top: 10px;
}

.rev-x-axis {
    display: flex;
    justify-content: space-between;

    padding-top: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    margin-top: 10px;
}

/* Breakdown Area */
.rev-breakdown-card {
    display: flex;
    flex-direction: column;
}

.breakdown-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 6px;
    width: 100%;
}

.b-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.b-tab.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.breakdown-table-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.data-table th {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
}

.data-table td:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

.align-right {
    text-align: right !important;
}

/* Bottom Drivers Grid */
.revenue-bottom-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.drivers-container {
    display: flex;
    gap: 24px;
}

.driver-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.divider-vertical {
    width: 1px;
    background: var(--border-subtle);
}

.driver-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.driver-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.driver-info strong {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.driver-val {
    font-weight: 600;
    font-size: 1.05rem;
}

/* Revenue Risk Card */
.risk-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.risk-amount {
    font-size: 2rem;
    font-weight: 600;
    color: var(--semantic-red);
}

.risk-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.risk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.015);
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.risk-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.risk-dot.risk {
    background: var(--semantic-red);
    box-shadow: 0 0 8px rgba(251, 113, 133, 0.6);
}

.risk-dot.warning {
    background: var(--semantic-amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.risk-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.risk-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.risk-val {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 1200px) {

    .revenue-layout,
    .revenue-bottom-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   Operations Page Layout
   ========================================= */

/* Pipeline */
.pipeline-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
}

.pipe-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    position: relative;
    z-index: 2;
}

.pipe-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.pipe-icon svg {
    width: 20px;
    height: 20px;
}

.pipe-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pipe-val {
    font-size: 1.2rem;
    font-weight: 600;
}

.pipe-subtext {
    font-size: 0.75rem;
    position: absolute;
    bottom: -20px;
    white-space: nowrap;
}

.pipe-connector {
    flex: 1;
    height: 2px;
    background: var(--border-subtle);
    margin: 0 -20px;
    position: relative;
    top: -25px;
    /* align with icon center */
    z-index: 1;
}

.pipe-node.active-warn .pipe-icon {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.4);
    color: var(--semantic-amber);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
}

/* Operations Layout */
.ops-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.ops-issues-card {
    display: flex;
    flex-direction: column;
}

.issue-row {
    transition: background 0.2s;
}

.issue-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.issue-row.warning {
    background: rgba(245, 158, 11, 0.03);
}

.issue-row.risk {
    background: rgba(251, 113, 133, 0.03);
}

/* Inventory Health */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.inv-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.inv-img-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: rgba(129, 140, 248, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.inv-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inv-title {
    font-size: 0.9rem;
    font-weight: 500;
}

.inv-stats {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.inv-status {
    text-align: right;
}

/* Responsive */
@media (max-width: 1200px) {
    .ops-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .pipeline-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .pipe-node {
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }

    .pipe-connector {
        display: none;
    }

    .pipe-subtext {
        position: static;
        margin-left: auto;
    }
}

/* =========================================
   Alerts Page Layout
   ========================================= */

.alerts-layout {
    display: grid;
    grid-template-columns: 250px 350px 1fr;
    gap: 20px;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Common Column Styles */
.alerts-sidebar,
.alerts-list,
.alert-detail {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--inner-highlight), var(--shadow-soft);
    overflow-y: auto;
}

/* Sidebar Filters */
.alerts-sidebar {
    padding: 20px;
    gap: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.filter-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-weight: 500;
}

/* Alert List */
.alerts-list {
    padding: 12px;
    gap: 12px;
}

.alert-card {
    padding: 16px;
    border-radius: var(--border-radius-md);
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.alert-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border-hover);
}

.alert-card.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-subtle);
    box-shadow: inset 3px 0 0 var(--text-primary);
}

.alert-card.active.risk {
    box-shadow: inset 3px 0 0 var(--semantic-red);
    background: rgba(251, 113, 133, 0.05);
    border-color: rgba(251, 113, 133, 0.2);
}

.alert-card.active.warning {
    box-shadow: inset 3px 0 0 var(--semantic-amber);
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.2);
}

.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.alert-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alert-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.alert-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.alert-meta {
    font-size: 0.8rem;
}

/* Alert Detail */

.alert-detail-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

.risk-badge {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.risk-badge.risk {
    background: rgba(251, 113, 133, 0.15);
    color: var(--semantic-red);
    border: 1px solid rgba(251, 113, 133, 0.3);
}

.detail-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    line-height: 1.3;
}

.detail-meta {
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.detail-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

/* Responsive */
@media (max-width: 1200px) {
    .alerts-layout {
        grid-template-columns: 200px 300px 1fr;
    }
}

@media (max-width: 992px) {
    .alerts-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .alerts-sidebar {
        flex-direction: row;
        overflow-x: auto;
        gap: 30px;
    }

    .alerts-list {
        max-height: 400px;
    }
}/* Time Selector */
.time-selector {
    display: flex;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 2px;
}

.time-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.time-btn:hover {
    color: var(--text-primary);
}

.time-btn.active {
    background: rgba(129, 140, 248, 0.2);
    color: #ffffff;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
}
/* Globe styles removed */

/* Metric Modal */
.metric-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 15, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.metric-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.metric-modal-content {
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 1000px;
    padding: 32px;
    box-shadow: var(--shadow-soft), var(--shadow-glow), var(--inner-highlight);
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metric-modal-overlay.active .metric-modal-content {
    transform: scale(1) translateY(0);
}

.metric-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 16px;
}

.metric-modal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.metric-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-time-filters {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
}

.metric-modal-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metric-modal-chart-container {
    display: flex;
    gap: 16px;
    height: 350px;
}

.metric-modal-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    padding-bottom: 24px;
    width: 60px;
    flex-shrink: 0;
}

.metric-modal-chart {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s;
}

.metric-modal-chart svg {
    flex: 1;
}

.metric-modal-x-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 8px;
    height: 24px;
}

.metric-modal-insight {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-modal-insight p {
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
}

/* ==========================================================================
   Cream Light Theme Variables
   ========================================================================== */
[data-theme="cream-light"] {
    /* Color Palette - Cream Light */
    --bg-main: #FDFBF7;
    --bg-sidebar: #F5F3EC;
    --bg-card-top: rgba(255, 255, 255, 0.95);
    --bg-card-bottom: rgba(250, 248, 243, 0.98);
    --bg-card-hover-top: #FFFFFF;
    --bg-card-hover-bottom: #FDFBF7;

    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(15, 23, 42, 0.15);
    --border-focus: rgba(129, 140, 248, 0.5);

    /* Text Colors */
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #64748B;

    --inner-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.8);
    --inner-highlight-hover: inset 0 1px 1px #ffffff;

    --shadow-soft: 0 4px 20px -4px rgba(15, 23, 42, 0.08);
    --shadow-glow: 0 0 24px rgba(129, 140, 248, 0.1);

    /* Reusable Light Theme Tokens (Segmented Controls, Blocks, Pills) */
    --light-surface-primary: #fffdf8;
    --light-surface-secondary: #f5f1e9;
    --light-surface-muted: #ece7de;
    --light-surface-hover: #eeeafd;
    --light-surface-selected: #e5e1fb;
    --light-border: #ded8ce;
    --light-border-accent: #b9b1f4;
    --light-text-primary: #172033;
    --light-text-secondary: #627087;
    --light-accent: #756de8;
    
    --light-success-surface: #edfdf4;
    --light-success-border: #a7f3d0;
    --light-warning-surface: #fffbeb;
    --light-warning-border: #fde68a;
}

[data-theme="cream-light"] body {
    background-image: radial-gradient(circle at 50% -10%, rgba(129, 140, 248, 0.1) 0%, transparent 60%);
}

[data-theme="cream-light"] .btn-outline {
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

[data-theme="cream-light"] .btn-outline:hover {
    background: rgba(15, 23, 42, 0.03);
    border-color: var(--border-hover);
}

/* ==========================================================================
   Cream Light Theme - Component Overrides
   ========================================================================== */

/* 1. Segmented Controls (.filter-tab, .time-btn, .b-tab) */
[data-theme="cream-light"] .filter-tabs,
[data-theme="cream-light"] .time-selector,
[data-theme="cream-light"] .breakdown-tabs {
    background: var(--light-surface-secondary);
    border: 1px solid var(--light-border);
    box-shadow: none;
}

[data-theme="cream-light"] .filter-tab,
[data-theme="cream-light"] .time-btn,
[data-theme="cream-light"] .b-tab {
    background: transparent;
    color: var(--light-text-secondary);
    border: none;
    outline: none;
}

[data-theme="cream-light"] .filter-tab:hover,
[data-theme="cream-light"] .time-btn:hover,
[data-theme="cream-light"] .b-tab:hover {
    background: var(--light-surface-hover);
    color: var(--light-text-primary);
}

[data-theme="cream-light"] .filter-tab.active,
[data-theme="cream-light"] .time-btn.active,
[data-theme="cream-light"] .b-tab.active {
    background: var(--light-surface-selected);
    color: var(--light-text-primary);
    border: 1px solid var(--light-border-accent);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* 2. Expected Benefit Block */
[data-theme="cream-light"] .rec-est-impact {
    background: var(--light-success-surface);
    border: 1px solid var(--light-success-border);
}

[data-theme="cream-light"] .rec-est-impact .text-muted-label {
    color: var(--light-text-secondary);
}

[data-theme="cream-light"] .rec-est-impact .text-positive {
    color: var(--semantic-green);
}

/* 3. Command Center Status Pills */
[data-theme="cream-light"] .header-widget,
[data-theme="cream-light"] .status-current {
    background: var(--light-surface-primary);
    border: 1px solid var(--light-border);
    color: var(--light-text-primary);
}

[data-theme="cream-light"] .header-widget:hover,
[data-theme="cream-light"] .status-current:hover {
    background: var(--light-surface-hover);
    border: 1px solid var(--light-border-accent);
}

/* 4. Command Center Root Cause Preview Chain */
[data-theme="cream-light"] .chain-visual {
    background: var(--light-surface-secondary);
    border: 1px solid var(--light-border);
    box-shadow: none;
}

[data-theme="cream-light"] .chain-node {
    background: var(--light-surface-primary);
    border: 1px solid var(--light-border);
    color: var(--light-text-secondary);
}

[data-theme="cream-light"] .chain-link {
    color: var(--light-text-muted);
}

[data-theme="cream-light"] .chain-node.active-node {
    background: var(--light-warning-surface);
    border-color: var(--light-warning-border);
    color: var(--semantic-amber);
}

/* ==========================================================================
   Settings Layout & Components
   ========================================================================== */
.settings-main {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
}

.settings-header {
    width: 100%;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.header-status {
    display: flex;
    align-items: center;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
    color: var(--semantic-green);
    font-size: 0.8rem;
    font-weight: 500;
}

.settings-layout {
    display: flex;
    width: 100%;
    gap: 32px;
    align-items: flex-start;
}

/* Settings Navigation */
.settings-nav {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 24px;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.settings-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

[data-theme="cream-light"] .settings-tab:hover {
    background: rgba(15, 23, 42, 0.04);
}

.settings-tab.active {
    background: rgba(129, 140, 248, 0.1);
    color: var(--accent-indigo);
    font-weight: 600;
}

/* Settings Content */
.settings-content {
    flex: 1;
    max-width: 800px;
}

.settings-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-card {
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 24px;
}

.settings-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.settings-card-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

[data-theme="cream-light"] .form-control {
    background: #FFFFFF;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.15);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-indigo);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(129, 140, 248, 0.3);
}

.btn-primary:hover {
    background: var(--accent-violet);
    box-shadow: 0 6px 16px rgba(167, 139, 250, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-hover);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
}

.btn-text:hover {
    color: var(--text-primary);
}

/* Avatar Upload */
.profile-photo-area {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-subtle);
    background: var(--bg-sidebar);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.theme-card {
    cursor: pointer;
    position: relative;
}

.theme-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.theme-card-visual {
    height: 140px;
    border-radius: var(--border-radius-md);
    border: 2px solid var(--border-subtle);
    margin-bottom: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

.theme-card input[type="radio"]:checked + .theme-card-visual {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.1);
}

.dark-theme .theme-card-visual {
    background: #05080F;
}

.dark-theme .visual-header {
    height: 24px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.dark-theme .visual-body {
    padding: 16px;
    flex: 1;
}

.dark-theme .visual-line {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin-bottom: 8px;
}

.dark-theme .visual-line.short {
    width: 60%;
}

.cream-light-theme .theme-card-visual {
    background: #FDFBF7;
}

.cream-light-theme .visual-header {
    height: 24px;
    background: #F5F3EC;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.cream-light-theme .visual-body {
    padding: 16px;
    flex: 1;
}

.cream-light-theme .visual-line {
    height: 8px;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    margin-bottom: 8px;
}

.cream-light-theme .visual-line.short {
    width: 60%;
}

.theme-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.theme-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Toggles / Switches */
.toggle-list {
    display: flex;
    flex-direction: column;
}

.toggle-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.toggle-item:last-child {
    border-bottom: none;
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 24px;
}

.toggle-label {
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-subtle);
}

[data-theme="cream-light"] .slider {
    background-color: rgba(0, 0, 0, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: .4s;
}

[data-theme="cream-light"] .slider:before {
    background-color: #FFFFFF;
}

input:checked + .slider {
    background-color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: #FFFFFF;
}

input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Sessions List */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-sm);
}

[data-theme="cream-light"] .session-item {
    background: #FFFFFF;
}

.session-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

[data-theme="cream-light"] .session-icon {
    background: rgba(0, 0, 0, 0.05);
}

.session-info {
    flex: 1;
}

.session-os {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.session-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card-top);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    transform: translateX(100%);
}

.toast.success {
    border-left: 4px solid var(--semantic-green);
}

@keyframes toastSlideIn {
    to { transform: translateX(0); }
}

@keyframes toastFadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* =========================================================================
   Responsive shell (shared by every page)
   At <=900px the fixed 250px sidebar is what pushes content off-screen, so we
   collapse it into a compact horizontal top bar. This keeps navigation fully
   labelled and reachable without any page scrolling horizontally.
   ========================================================================= */
@media (max-width: 900px) {
    /* Belt-and-braces: no page scrolls horizontally; the nav bar keeps its own
       internal horizontal scroll. */
    body {
        overflow-x: hidden;
    }

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 8px 12px;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        overflow-x: auto;
    }

    .brand-area {
        padding: 0 12px 0 4px;
        margin-bottom: 0;
        border-bottom: none;
        border-right: 1px solid var(--border-subtle);
        flex-shrink: 0;
    }

    .nav-menu {
        flex-direction: row;
        gap: 4px;
        flex-grow: 1;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        white-space: nowrap;
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    /* The side "→" active marker doesn't make sense in a horizontal bar */
    .nav-item.active::before {
        display: none;
    }

    .sidebar-bottom {
        margin-top: 0;
        border-top: none;
        padding-top: 0;
        flex-shrink: 0;
    }

    .main-content {
        padding: 20px 16px;
    }

    /* Single-column stacking for the overview grids on small screens */
    .top-metrics,
    .bento-grid {
        grid-template-columns: 1fr;
    }
}

/* Globe fills the space below the collapsed top bar (approx. bar height) */
@media (max-width: 900px) {
    .globe-main {
        height: calc(100dvh - 56px);
    }
}

/* =========================================================================
   Respect users who prefer reduced motion.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}


/* =========================================================================
   COMMAND CENTER — Health control, chart inspection, Health Report modal
   ========================================================================= */

/* Health control (button) */
.health-control {
    font: inherit;
    color: var(--text-primary);
    gap: 10px;
    cursor: pointer;
    text-align: left;
}
.health-control .health-control-caret {
    color: var(--text-muted);
    transition: color var(--transition-smooth), transform var(--transition-smooth);
}
.health-control:hover .health-control-caret,
.health-control[aria-expanded="true"] .health-control-caret {
    color: var(--text-secondary);
    transform: translateX(2px);
}
.health-control:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* Reusable chart tooltip / crosshair */
.cc-chart-host { position: relative; }
.cc-chart-svg { overflow: visible; }
.cc-chart-svg text.cc-axis-text {
    fill: var(--text-muted);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
}
.cc-crosshair { transition: opacity 0.12s ease; }
.cc-tooltip {
    position: absolute;
    top: 0; left: 0;
    pointer-events: none;
    z-index: 6;
    background: rgba(9, 14, 23, 0.96);
    border: 1px solid var(--border-hover);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 108px;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.cc-tooltip[hidden] { display: none; }
.cc-tt-label {
    color: var(--text-muted);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
    white-space: nowrap;
}
.cc-tt-time { color: var(--text-secondary); text-transform: none; letter-spacing: 0; }
.cc-tt-value {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}
.cc-tt-delta { font-size: 0.72rem; font-weight: 600; }
.cc-tt-delta.pos { color: var(--semantic-green); }
.cc-tt-delta.neg { color: var(--semantic-red); }

/* KPI card affordance / focus */
.metric-card[role="button"] { cursor: pointer; }
.metric-card:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}
.mini-chart-svg { position: relative; }

/* Metric detail modal chart host */
.metric-modal-chart-host { position: relative; width: 100%; height: 320px; }
.metric-modal-chart-host:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Store Health Report modal */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.health-modal-overlay {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    background: rgba(5, 8, 15, 0.82);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    z-index: 1000; display: none; align-items: flex-start; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease; padding: 3vh 0; overflow-y: auto;
}
.health-modal-overlay.active { display: flex; opacity: 1; }
.health-modal-content {
    background: linear-gradient(180deg, var(--bg-card-top) 0%, var(--bg-card-bottom) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    width: 88%; max-width: 1320px; max-height: 94vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: var(--shadow-soft), var(--shadow-glow), var(--inner-highlight);
    transform: scale(0.97) translateY(16px);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.health-modal-overlay.active .health-modal-content { transform: none; }

.health-modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 24px 28px; border-bottom: 1px solid var(--border-subtle);
    background: rgba(9, 14, 23, 0.35); flex-shrink: 0;
}
.health-modal-eyebrow {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); font-weight: 600; margin-bottom: 10px;
}
.health-modal-scoreline { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.health-modal-score { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.health-modal-score-max { font-size: 1rem; color: var(--text-muted); }
.health-status-chip {
    align-self: center; font-size: 0.72rem; font-weight: 600;
    padding: 4px 10px; border-radius: 100px; border: 1px solid transparent;
}
.health-status-chip.positive { color: var(--semantic-green); background: var(--semantic-green-bg); border-color: rgba(16,185,129,0.2); }
.health-status-chip.warning { color: var(--semantic-amber); background: var(--semantic-amber-bg); border-color: rgba(245,158,11,0.2); }
.health-status-chip.critical { color: var(--semantic-red); background: var(--semantic-red-bg); border-color: rgba(251,113,133,0.2); }
.health-modal-delta { font-size: 0.85rem; color: var(--semantic-green); font-weight: 500; align-self: center; }
.health-modal-meta { margin-top: 10px; font-size: 0.75rem; color: var(--text-muted); }
.health-modal-close { font-size: 1.6rem; flex-shrink: 0; }

.health-modal-body {
    padding: 24px 28px 28px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 28px;
}
.health-section-title {
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-secondary); font-weight: 600; margin-bottom: 14px;
}
.health-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.health-section-head .health-section-title { margin-bottom: 0; }

/* A. Overview */
.health-overview {
    display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
    background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-md); padding: 24px;
}
.health-overview-ring { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cc-ring { display: block; }
.cc-ring-score { fill: var(--text-primary); font-size: 34px; font-weight: 600; font-family: 'Inter', sans-serif; }
.health-overview-band {
    font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 3px 12px; border-radius: 100px;
}
.health-overview-band.positive { color: var(--semantic-green); background: var(--semantic-green-bg); }
.health-overview-band.warning { color: var(--semantic-amber); background: var(--semantic-amber-bg); }
.health-overview-band.critical { color: var(--semantic-red); background: var(--semantic-red-bg); }
.health-summary { font-size: 1.02rem; line-height: 1.6; color: var(--text-primary); margin-bottom: 16px; max-width: 760px; }
.health-band-scale { display: flex; gap: 8px; flex-wrap: wrap; }
.band-pill {
    display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 500;
    color: var(--text-muted); padding: 4px 10px; border-radius: 6px;
    border: 1px solid var(--border-subtle); background: rgba(255, 255, 255, 0.02);
}
.band-pill em { font-style: normal; opacity: 0.7; font-size: 0.68rem; }
.band-pill.active { color: var(--text-primary); border-color: var(--border-hover); background: rgba(255, 255, 255, 0.05); }
.band-pill.active.positive { color: var(--semantic-green); border-color: rgba(16,185,129,0.35); }
.band-pill.active.warning { color: var(--semantic-amber); border-color: rgba(245,158,11,0.35); }
.band-pill.active.critical { color: var(--semantic-red); border-color: rgba(251,113,133,0.35); }

/* C. Dimensions */
.health-dim-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.health-dim {
    background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-md); padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.health-dim-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.health-dim-label { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.health-dim-status { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.health-dim-status.positive { color: var(--semantic-green); background: var(--semantic-green-bg); }
.health-dim-status.warning { color: var(--semantic-amber); background: var(--semantic-amber-bg); }
.health-dim-status.critical { color: var(--semantic-red); background: var(--semantic-red-bg); }
.health-dim-scorerow { display: flex; justify-content: space-between; align-items: baseline; }
.health-dim-score { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
.health-dim-score em { font-style: normal; font-size: 0.8rem; color: var(--text-muted); }
.health-dim-delta { font-size: 0.75rem; font-weight: 600; }
.health-dim-delta.pos { color: var(--semantic-green); }
.health-dim-delta.neg { color: var(--semantic-red); }
.health-dim-delta.flat { color: var(--text-muted); }
.health-dim-bar { height: 4px; border-radius: 100px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.health-dim-bar span { display: block; height: 100%; border-radius: 100px; }
.health-dim-bar span.positive { background: var(--semantic-green); }
.health-dim-bar span.warning { background: var(--semantic-amber); }
.health-dim-bar span.critical { background: var(--semantic-red); }
.health-dim-detail { font-size: 0.8rem; line-height: 1.45; color: var(--text-secondary); }
.health-dim-contrib { font-size: 0.72rem; color: var(--text-muted); }
.health-dim-contrib strong { color: var(--text-secondary); font-weight: 600; }

/* D. Trend */
.health-trend-chart {
    position: relative; width: 100%; height: 260px;
    background: rgba(255, 255, 255, 0.015); border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-md);
}
.health-trend-chart:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* E. Drivers */
.health-drivers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.health-driver-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.health-driver {
    display: grid; grid-template-columns: 16px 1fr auto auto; align-items: center; gap: 12px;
    padding: 10px 12px; border: 1px solid var(--border-subtle); border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}
.health-driver-dir { font-size: 0.8rem; }
.health-driver.pos .health-driver-dir { color: var(--semantic-green); }
.health-driver.neg .health-driver-dir { color: var(--semantic-red); }
.health-driver-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.health-driver-label { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.health-driver-ev { font-size: 0.75rem; color: var(--text-muted); }
.health-driver-val { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.health-driver-val.pos { color: var(--semantic-green); }
.health-driver-val.neg { color: var(--semantic-red); }
.health-driver-weight {
    font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
    border: 1px solid var(--border-subtle); border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}

/* F + G. System status + primary risk */
.health-lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.health-svc-list { display: flex; flex-direction: column; gap: 10px; }
.health-svc {
    display: grid; grid-template-columns: 20px 1fr auto;
    grid-template-areas: "icon name status" "icon meta meta" "detail detail detail";
    gap: 2px 10px; align-items: center;
    padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}
.health-svc-icon { grid-area: icon; align-self: center; }
.health-svc.positive .health-svc-icon { color: var(--semantic-green); }
.health-svc.warning .health-svc-icon { color: var(--semantic-amber); }
.health-svc-name { grid-area: name; font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.health-svc-status { grid-area: status; font-size: 0.72rem; font-weight: 600; text-align: right; }
.health-svc.positive .health-svc-status { color: var(--semantic-green); }
.health-svc.warning .health-svc-status { color: var(--semantic-amber); }
.health-svc-meta { grid-area: meta; font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.health-svc-detail { grid-area: detail; font-size: 0.78rem; color: var(--text-secondary); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle); }

.health-risk {
    border: 1px solid rgba(251, 113, 133, 0.25); background: rgba(251, 113, 133, 0.05);
    border-radius: var(--border-radius-md); padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.health-risk-tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--semantic-red); }
.health-risk-head h4 { font-size: 1.15rem; font-weight: 600; color: var(--text-primary); margin-top: 6px; }
.health-risk-grid { display: flex; flex-direction: column; gap: 12px; }
.health-risk-grid > div { display: flex; flex-direction: column; gap: 2px; }
.health-risk-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.health-risk-v { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.4; }
.health-risk-v.critical { color: var(--semantic-red); font-weight: 600; }
.health-risk-btn {
    display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; text-decoration: none;
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
    background: rgba(129, 140, 248, 0.15); border: 1px solid rgba(129, 140, 248, 0.3);
    padding: 8px 16px; border-radius: 8px; transition: all var(--transition-smooth);
}
.health-risk-btn:hover { background: rgba(129, 140, 248, 0.25); }

/* H. Methodology */
.health-metho { border-top: 1px solid var(--border-subtle); padding-top: 16px; }
.health-metho-toggle {
    display: flex; align-items: center; gap: 8px; background: none; border: none;
    color: var(--text-secondary); font: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer; padding: 0;
}
.health-metho-toggle:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 3px; border-radius: 4px; }
.health-metho-toggle svg { transition: transform var(--transition-smooth); }
.health-metho-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.health-metho-body {
    max-height: 0; overflow: hidden; opacity: 0; font-size: 0.85rem; line-height: 1.6; color: var(--text-muted);
    transition: max-height var(--transition-smooth), opacity var(--transition-smooth), margin var(--transition-smooth);
    max-width: 780px;
}
.health-metho.open .health-metho-body { max-height: 240px; opacity: 1; margin-top: 12px; }

/* Responsive */
@media (max-width: 1024px) {
    .health-dim-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .health-modal-content { width: 96%; max-height: 96vh; }
    .health-overview { grid-template-columns: 1fr; text-align: center; justify-items: center; }
    .health-summary { text-align: left; }
    .health-drivers-grid, .health-lower-grid, .health-dim-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .health-modal-overlay { padding: 0; }
    .health-modal-content { width: 100%; max-width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; border: none; }
    .health-modal-header, .health-modal-body { padding-left: 16px; padding-right: 16px; }
    .metric-modal-content { width: 96%; padding: 20px; }
    .metric-modal-chart-host { height: 240px; }
    .health-trend-chart { height: 220px; }
}

/* Subtle ring entrance (value-independent; reduced-motion rule neutralizes it) */
.health-modal-overlay.active .health-overview-ring .cc-ring {
    transform-origin: center;
    animation: cc-ring-pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cc-ring-pop {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: none; }
}

/* AI Executive Brief — summary on top, risk/action in two columns */
.briefing-primary p { font-size: 0.98rem; }
.briefing-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.briefing-attention { border-left: 2px solid rgba(245, 158, 11, 0.45); }
.briefing-action { border-left: 2px solid rgba(129, 140, 248, 0.45); }
@media (max-width: 768px) {
    .briefing-lower { grid-template-columns: 1fr; }
}

/* Root Cause — stronger active-node emphasis + impact tie-in */
.chain-node.active-node {
    font-weight: 600;
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}
.chain-link:last-of-type { color: var(--semantic-amber); opacity: 0.7; }
.rc-detail-item .text-negative { font-weight: 600; }
