:root {
    /* Global Reset */
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

:root {
    /* Compatibility with old names */
    --bg-color: var(--bg-primary);
    --text-accent: var(--primary);
    --card-bg: #ffffff;
    --card-shadow: 0 4px 12px rgba(42, 51, 66, 0.05);
    --card-shadow-hover: 0 8px 24px rgba(42, 51, 66, 0.08);
}

/* Base body styles */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* Spacing for fixed header */
body.has-fixed-header {
    padding-top: 120px;
}

@media screen and (max-width: 768px) {
    body.has-fixed-header {
        padding-top: 80px;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

h2,
h3 {
    margin-top: 0;
    font-weight: 600;
    color: var(--secondary);
}

/* Vital Signs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px 15px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.kpi-value {
    font-size: 2.2em;
    font-weight: bold;
    color: var(--primary);
    margin: 10px 0;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.kpi-sub {
    font-size: 0.8em;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-top: -5px;
}

/* KPI and Chart Box Styles */
.kpi-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.metric-card {
    flex: 1;
    min-width: 250px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-value {
    font-size: 2.5em;
    font-weight: 600;
    color: var(--primary);
    margin: 10px 0;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--card-shadow);
}

.chart-header {
    color: var(--secondary);
    font-size: 1.1em;
    margin-bottom: 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* ECharts responsive overrides if needed */
.chart-container {
    width: 100%;
    height: 400px;
}

/* Mobile responsiveness adjustments for dashboard content */
@media screen and (max-width: 768px) {
    .container {
        padding: 15px;
        width: 100%;
    }

    /* Fix mobile menu overlay covering the header */
    body.has-nav .nav-links-wrapper {
        z-index: 9999 !important;
        justify-content: flex-start !important;
        padding-top: calc(var(--header-height, 90px) + 2rem) !important;
    }

    /* Brand the suite menu section with Terracotta */
    .mobile-suite-content > div > div:first-child {
        color: var(--primary) !important;
        font-weight: 700 !important;
        text-transform: uppercase;
        letter-spacing: 1px !important;
    }

    .mobile-suite-content .suite-link-mobile:hover {
        color: var(--primary) !important;
        background-color: rgba(232, 145, 107, 0.1) !important;
    }
}


.freshness-line {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
    margin-bottom: 10px;
    margin-top: -10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Dark Mode Overrides to align with Orange Dev Network */
[data-theme="dark"] {
    --bg-primary: #05070A;
    --bg-secondary: #0D0F14;
    --surface: #0D0F14;
    --card-bg: #080A0F;
    --text-primary: #FDF6E3;
    --text-secondary: #94A3B8;
    --border-color: rgba(253, 246, 227, 0.08);
    --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] body {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}



[data-theme="dark"] .header-text h1,
[data-theme="dark"] section h2 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] h3,
[data-theme="dark"] section h3,
[data-theme="dark"] h4,
[data-theme="dark"] section h4,
[data-theme="dark"] .metric-card h4,
[data-theme="dark"] .chart-header,
[data-theme="dark"] .issue-title {
    color: var(--text-secondary) !important;
    font-weight: 600;
}

[data-theme="dark"] .header-text p,
[data-theme="dark"] .issue-meta,
[data-theme="dark"] section p,
[data-theme="dark"] .sidebar a,
[data-theme="dark"] .details-box dt {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .sidebar a:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: var(--primary) !important;
}

[data-theme="dark"] .sidebar a.active {
    background-color: rgba(232, 145, 107, 0.1) !important;
    color: var(--primary) !important;
}

[data-theme="dark"] pre {
    background-color: #000 !important;
    border: 1px solid var(--border-color) !important;
}

/* ── Page Hero: Shared tab-page intro ── */
.page-hero {
    max-width: 1100px;
    margin: 0 auto 24px auto;
    padding: 20px 20px 0 20px;
}

.page-hero .hero-narrative {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.5;
    max-width: 700px;
    margin: 0;
}

/* Tier 1 only: Narrative title for thesis pages */
.page-hero h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 10px 0;
}

/* Hero scorecard: shared orange-accent treatment */
.hero-scorecard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--primary);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    padding: 0;
    overflow: hidden;
    margin-top: 24px;
}

/* ── Global Toggles ── */
.window-toggle {
    display: flex;
    gap: 8px;
    margin: 4px auto 20px auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    width: fit-content;
}

.window-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.window-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.window-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}


/* Shared Trend/Delta Pills */
.delta-pill, .trend-badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border-color);
    display: inline-block;
}

.delta-up, .trend-rising {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border-color: rgba(16, 185, 129, 0.2);
}

.delta-down, .trend-fading {
    background: rgba(248, 113, 113, 0.15);
    color: #F87171;
    border-color: rgba(248, 113, 113, 0.2);
}

.delta-flat, .trend-steady {
    background: rgba(232, 145, 107, 0.1);
    color: var(--text-secondary);
}
