/* ===================================================================
   EduMarkets — Bank ALM Simulation
   CSS Variables, Layout, and Component Styles
   =================================================================== */

/* ── CSS Variables ────────────────────────────────────────────────── */

:root {
    /* Dark theme (default) — EduMarkets charcoal-blue palette */
    --bg: #0D1117;
    --bg-surface: #161B22;
    --bg-header: #1A1F26;
    --bg-elevated: #1C232C;
    --bg-input: #20262F;
    --bg-hover: #262C36;
    --border: #252830;
    --border-subtle: #1a1c22;
    --text: #e8eaf0;
    --text-secondary: #c8ccdc;
    --text-muted: #9da3b8;
    --color-accent: #4f8cff;
    --color-accent-light: #6da0ff;
    --color-accent-bg: rgba(79, 140, 255, 0.15);
    --formula-numeric: #7ec8f0;
    --teal: #14b8a6;
    --teal-dim: rgba(20, 184, 166, 0.45);
    --positive: #34d399;
    --positive-bg: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.15);
    --negative: #f87171;
    --negative-bg: rgba(248, 113, 113, 0.15);
    --font-base: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    /* Font-size scale */
    --fs-xs:   11px;  /* chips, badges, captions floor */
    --fs-sm:   12px;  /* table headers, secondary labels */
    --fs-md:   13px;  /* table cells, compact data */
    --fs-base: 14px;  /* default UI: buttons, nav, form inputs */
    --fs-body: 16px;  /* reading prose, narratives, briefings, callouts */
    --fs-lg:   18px;  /* section titles, card titles */
    --fs-xl:   22px;  /* KPI values medium */
    --fs-2xl:  28px;  /* KPI values large */
    --fs-3xl:  40px;  /* reveal headlines */
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --transition: 150ms ease;
    /* Shared height for sidebar-footer and Decisions sticky footer so their
       top dividers align when both are visible. */
    --footer-h: 64px;
}

[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-elevated: #ffffff;
    --bg-surface: #ffffff;
    --bg-header: #ffffff;
    --bg-hover: #f0f0f2;
    --bg-input: #f8f8fa;
    --border: #e0e0e4;
    --border-subtle: #eaeaee;
    --text: #1a1a1e;
    --text-secondary: #404048;
    --text-muted: #5a5a64;
    --color-accent: #2563eb;
    --color-accent-light: #1d4ed8;
    --color-accent-bg: rgba(37, 99, 235, 0.1);
    --formula-numeric: #1a6faa;
    --teal: #0d9488;
    --teal-dim: rgba(13, 148, 136, 0.50);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

/* ── Reset & Base ─────────────────────────────────────────────────── */

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

/* Form controls don't inherit font-family by default in any browser. */
button, input, select, textarea { font-family: inherit; }

html, body {
    height: 100%;
    font-family: var(--font-base);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── App Shell ────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    min-height: 64px;
    background: var(--bg-header);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

/* Light mode: white-on-white border is invisible — swap for a soft shadow
   (matches EduMarkets' light-mode header treatment exactly). */
[data-theme="light"] .app-header {
    border-bottom: 0;
    box-shadow: 0 1px 3px rgba(27,58,92,0.08);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -0.3px;
}

.app-logo .logo-icon {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

.header-round-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    margin-right: 16px;
    padding: 6px 14px;
    background: var(--color-accent-bg);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    box-shadow: 0 0 8px rgba(79, 140, 255, 0.15);
}

.header-round-label {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-accent);
    white-space: nowrap;
}

.header-round-status {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.header-round-timer {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.header-round-timer.warning {
    color: var(--warning);
    animation: timer-pulse 1.5s infinite;
}

.header-round-timer.urgent {
    color: var(--negative);
    animation: timer-pulse 0.8s infinite;
}

.header-round-timer.expired {
    color: var(--negative);
    font-size: 12px;
    letter-spacing: 0.5px;
    animation: timer-pulse 0.5s infinite;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online { background: var(--positive); }
.status-dot.active { background: var(--color-accent); }
.status-dot.warning { background: var(--warning); }
.status-dot.offline { background: var(--negative); }
.status-dot.reconnecting { background: var(--warning); animation: pulse-dot 1s ease-in-out infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.theme-toggle {
    background: transparent;
    border: 1px solid transparent;     /* invisible by default, shows on hover (EduMarkets pattern) */
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
    /* Desaturate the colour emoji glyphs (🌙 yellow → grey) for visual consistency,
       matching EduMarkets's exact treatment. */
    filter: grayscale(1);
}

.theme-toggle:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text);
}

/* ── Main Content ─────────────────────────────────────────────────── */

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding-left: 24px;
}

.sidebar {
    width: 252px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-base);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--color-accent-bg); color: var(--color-accent); }
.nav-item.nav-disabled { opacity: 0.35; cursor: default; }
.nav-item.nav-disabled:hover { background: transparent; color: var(--text-muted); }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--negative);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}


.team-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.team-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.team-members {
    font-size: 11px;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Cap every view's content width and pin it to the left — same pattern Financials uses,
   now applied globally so wide monitors don't stretch UI to the edges. */
.main-content > * {
    max-width: 1400px;
    margin-left: 0;
    margin-right: auto;
}

/* ── View Container ───────────────────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Grid Layout ──────────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Metric Cards ─────────────────────────────────────────────────── */

.metric {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.metric-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.metric-value.positive { color: var(--positive); }
.metric-value.negative { color: var(--negative); }
.metric-value.warning { color: var(--warning); }

.metric-delta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.data-table tr:hover td { background: var(--bg-hover); }
.data-table td.right, .data-table th.right { text-align: right; }
.data-table td.positive { color: var(--positive); }
.data-table td.negative { color: var(--negative); }
.data-table td.mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-sublabel {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.form-input, .form-select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-base);
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-bg);
}

.form-input.mono { font-family: var(--font-mono); font-size: 13px; }

/* Hide spinner arrows on all number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-group input[type="range"] {
    flex: 1;
    height: 4px;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.slider-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    border: none;
    transition: background-color 0.15s ease;
}
/* Direction-from-baseline colouring */
.slider-group input[type="range"].slider-up::-webkit-slider-thumb { background: var(--positive); }
.slider-group input[type="range"].slider-up::-moz-range-thumb    { background: var(--positive); }
.slider-group input[type="range"].slider-down::-webkit-slider-thumb { background: var(--negative); }
.slider-group input[type="range"].slider-down::-moz-range-thumb    { background: var(--negative); }

.slider-val {
    font-family: var(--font-mono);
    font-size: 13px;
    min-width: 60px;
    text-align: right;
    color: var(--text);
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-base);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}
.btn-primary:hover { background: var(--color-accent-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text); }

.btn-success {
    background: var(--positive);
    color: #fff;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
    background: var(--negative);
    color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: var(--positive-bg); color: var(--positive); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--negative-bg); color: var(--negative); }
.badge-info { background: var(--color-accent-bg); color: var(--color-accent); }

/* ── Balance Sheet Visual ─────────────────────────────────────────── */

.bs-visual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
}

.bs-column { display: flex; flex-direction: column; gap: 2px; }
.bs-column-header {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-accent);
    margin-bottom: 4px;
}

.bs-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.bs-row-label {
    font-size: 14px;
    color: var(--text);
}

.bs-row-value {
    font-family: var(--font-mono);
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}

.bs-row-rate {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.bs-total {
    font-weight: 700;
    font-size: 16px;
    padding-top: 10px;
    border-top: 2px solid var(--color-accent);
    margin-top: 4px;
}

/* ── Regulatory Gauges ────────────────────────────────────────────── */

.gauge-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.gauge {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.gauge-value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
}

.gauge-value.ok { color: var(--positive); }
.gauge-value.warn { color: var(--warning); }
.gauge-value.breach { color: var(--negative); }

.gauge-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.gauge-min {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Join Screen (EduMarkets auth-style) ─────────────────────────── */

.join-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #111114;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

/* Subtle grid background */
.join-screen::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
}

/* Ambient glow */
.join-screen::after {
    content: '';
    position: fixed;
    top: -200px; left: -200px;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.06) 0%, transparent 70%);
    z-index: 0;
}

[data-theme="light"] .join-screen {
    background: #f0f2f7;
}

[data-theme="light"] .join-screen::before {
    background-image:
        linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
}

[data-theme="light"] .join-screen::after {
    background: radial-gradient(circle, rgba(13, 148, 136, 0.06) 0%, transparent 70%);
}

.join-logo {
    position: relative;
    z-index: 1;
    margin-bottom: 56px;
    text-align: center;
}

.join-logo img {
    max-width: 320px;
    width: 100%;
    height: auto;
    filter: brightness(1.05);
}

[data-theme="light"] .join-logo img {
    filter: brightness(0.95);
}

.join-card {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 44px 40px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.03),
        0 20px 60px -10px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 440px;
}

[data-theme="light"] .join-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.65) 100%);
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.03), 0 20px 60px -10px rgba(0,0,0,0.12);
}

.join-title {
    font-size: 24px;
    font-weight: 500;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
    color: #f0f0f0;
}

[data-theme="light"] .join-title {
    color: #1a1a1e;
}

.join-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.45);
    font-weight: 300;
    text-align: center;
    margin-bottom: 28px;
}

[data-theme="light"] .join-subtitle {
    color: rgba(0,0,0,0.45);
}

.join-footer {
    position: relative;
    z-index: 1;
    margin-top: 28px;
    font-size: 12px;
    color: rgba(255,255,255,0.3);
    text-align: center;
}

[data-theme="light"] .join-footer {
    color: rgba(0,0,0,0.3);
}

/* Auth-style form fields */
.auth-field {
    margin-bottom: 20px;
    text-align: left;
}

.auth-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}

[data-theme="light"] .auth-field label {
    color: rgba(0,0,0,0.5);
}

.auth-field input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--radius);
    color: #ffffff;
    font-family: var(--font-base);
    font-size: 15px;
    font-weight: 400;
    outline: none;
    transition: all 0.25s ease;
}

.auth-field input:focus {
    border-color: var(--teal-dim);
    background: rgba(255,255,255,0.06);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.08);
}

.auth-field input::placeholder {
    color: rgba(255,255,255,0.25);
}

[data-theme="light"] .auth-field input {
    background: #f4f6fa;
    border: 1px solid #dde1ec;
    color: #1a1a1e;
}

[data-theme="light"] .auth-field input::placeholder {
    color: rgba(0,0,0,0.3);
}

[data-theme="light"] .auth-field input:focus {
    border-color: var(--teal);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.08);
}

.auth-field input.mono {
    font-family: var(--font-mono);
    letter-spacing: 2px;
}

.auth-field .auth-sublabel {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    margin-top: -4px;
    margin-bottom: 8px;
    letter-spacing: 0;
    text-transform: none;
    font-weight: 400;
}

[data-theme="light"] .auth-field .auth-sublabel {
    color: rgba(0,0,0,0.35);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #ffffff 0%, #e8e8e8 100%);
    color: #0B0B0C;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-base);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.25s ease;
    letter-spacing: -0.2px;
}

.auth-btn:hover {
    box-shadow: 0 8px 30px rgba(255,255,255,0.1);
}

.auth-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

[data-theme="light"] .auth-btn {
    background: linear-gradient(135deg, #1a1a1e 0%, #333 100%);
    color: #ffffff;
}

[data-theme="light"] .auth-btn:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.auth-btn-secondary {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: var(--radius);
    font-family: var(--font-base);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.25s ease;
}

.auth-btn-secondary:hover {
    color: rgba(255,255,255,0.7);
    border-color: rgba(255,255,255,0.2);
}

[data-theme="light"] .auth-btn-secondary {
    color: rgba(0,0,0,0.5);
    border-color: rgba(0,0,0,0.12);
}

[data-theme="light"] .auth-btn-secondary:hover {
    color: rgba(0,0,0,0.7);
    border-color: rgba(0,0,0,0.25);
}

.auth-info-box {
    background: rgba(20, 184, 166, 0.06);
    border: 1px solid rgba(20, 184, 166, 0.15);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 24px;
}

.auth-info-box .auth-info-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 6px;
}

.auth-info-box .auth-info-detail {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
}

[data-theme="light"] .auth-info-box .auth-info-detail {
    color: rgba(0,0,0,0.45);
}

.auth-error {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.15);
    color: #f87171;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
}

.auth-error.visible { display: block; }

/* ── Round Banner ─────────────────────────────────────────────────── */

.round-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--color-accent-bg);
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

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

.round-number {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-accent);
}

.round-info {
    display: flex;
    flex-direction: column;
}

.round-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.round-status {
    font-size: 11px;
    color: var(--text-secondary);
}

.round-timer {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.round-timer.urgent { color: var(--negative); }

/* ── Decision Form ────────────────────────────────────────────────── */

/* ── Decisions page ───────────────────────────────────────────────── */

.decisions-page {
    display: flex;
    flex-direction: column;
}

.decisions-header { margin-bottom: 24px; }
.decisions-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text);
}
.decisions-header p {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    margin: 0;
}

.decisions-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.decisions-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

/* Section card — subtle tint, no border */
.dec-section {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
}

.dec-section-header { margin-bottom: 10px; }
.dec-section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 2px;
}
.dec-section-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* "How this works" disclosure inside section headers — uses native
   <details>/<summary>. Default closed; opt-in detail. */
.dec-section-explain {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.55;
}
.dec-section-explain summary {
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    list-style: none;          /* hide native marker — we draw our own */
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    transition: color 0.15s ease;
}
.dec-section-explain summary::-webkit-details-marker { display: none; }
.dec-section-explain summary::before {
    content: '\25B8';          /* ▸ */
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 10px;
}
.dec-section-explain[open] summary::before { transform: rotate(90deg); }
.dec-section-explain summary:hover { color: var(--text); }
.dec-section-explain p {
    margin: 6px 0 0;
    color: var(--text-secondary);
}

/* ── Reference / Mechanics ─────────────────────────────────────────── */

.ref-mechanics {
    max-width: 760px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-secondary);
}
.ref-mechanics .ref-lead {
    margin: 0 0 24px;
    font-size: 16px;
    color: var(--text);
}
.ref-mechanics .ref-section {
    margin: 28px 0 8px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.ref-mechanics .ref-section .formula-btn { margin-left: 4px; }
.ref-mechanics p { margin: 0 0 12px; }
.ref-mechanics .ref-list-ordered {
    margin: 0 0 16px 22px;
    padding: 0;
}
.ref-mechanics .ref-list-ordered li {
    margin-bottom: 6px;
}
.ref-mechanics .ref-list-ordered strong { color: var(--text); }

/* Engine Constants table on the Mechanics tab. */
.ref-engine-constants {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 16px;
    font-size: 14px;
}
.ref-engine-constants thead th {
    text-align: left;
    padding: 8px 10px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.ref-engine-constants tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.05));
    vertical-align: top;
}
.ref-engine-constants tbody td:nth-child(2) {
    white-space: nowrap;
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, monospace);
    color: var(--text);
}
.ref-engine-constants tbody tr:last-child td { border-bottom: none; }

.ref-fbtn-inline {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-size: 0.7rem;
    line-height: 16px;
    text-align: center;
    vertical-align: middle;
}

/* Lending: three product sub-blocks */
.dec-product-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}
.dec-product { min-width: 0; }
.dec-product-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}

/* Generic 3-column row inside a section */
.dec-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

/* Capital: slider + helper text side by side */
.dec-grid-payout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: end;
}
.dec-helper {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    padding-bottom: 12px;
}

/* Scoped form-control sizing inside the Decisions page (match Financials) */
.decisions-page .form-label    { font-size: 13px; margin-bottom: 2px; }
.decisions-page .form-input,
.decisions-page .form-select   { font-size: 14px; }
.decisions-page .slider-val    { font-size: 13px; }
/* Tighter slider rows inside Decisions sections */
.decisions-page .form-group    { margin-bottom: 8px; gap: 2px; }
.decisions-page .slider-group  { gap: 8px; }
.decisions-page .decisions-header { margin-bottom: 12px; }
.decisions-page .decisions-header h2 { font-size: 20px; }

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-base);
    font-size: 14px;
    text-decoration: underline;
    text-decoration-color: var(--text-muted);
    text-underline-offset: 3px;
    padding: 4px 8px;
}
.btn-link:hover { color: var(--text); text-decoration-color: var(--text); }

/* ── Footers ─────────────────────────────────────────────────────────
   Two separate footers, both of height --footer-h so their top borders
   align when both are visible:

   - .sidebar-footer  — always visible, lives inside the sidebar (left
                        band only). Holds the copyright.
   - .dec-footer      — only on the Decisions page, lives inside
                        .main-content with position: sticky. Holds the
                        Submit / Preview / Reset buttons.

   On the Decisions page the two appear side-by-side and their border-
   tops form one continuous line. On every other page only the sidebar
   footer is visible — the divider runs across the sidebar only, never
   across the main content. */

.sidebar-footer {
    flex-shrink: 0;
    height: var(--footer-h);
    box-sizing: border-box;
    padding: 0 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

.dec-footer {
    position: sticky;
    bottom: 0;
    height: var(--footer-h);
    box-sizing: border-box;
    margin: 0 -24px;             /* extend through .main-content's 24px padding to touch sidebar */
    padding: 0 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.dec-footer-actions {
    display: flex;
    gap: 12px;
}

/* On the Decisions page, zero .main-content's bottom padding so the
   sticky footer sits flush against the viewport bottom (matching the
   sidebar-footer which is already at viewport bottom). */
.main-content:has(.decisions-page) {
    padding-bottom: 0;
}

@media (max-width: 768px) {
    .sidebar-footer { display: none; }   /* sidebar itself is hidden on mobile */
    .dec-footer {
        margin: 0 -12px;
        padding: 0 12px;
        flex-wrap: wrap;
        gap: 8px;
        height: auto;
        min-height: var(--footer-h);
    }
}

/* ── Leaderboard ──────────────────────────────────────────────────── */

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    transition: var(--transition);
}

.leaderboard-row:hover { background: var(--bg-hover); }
.leaderboard-row.highlight { border-color: var(--color-accent); background: var(--color-accent-bg); }

.leaderboard-rank {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 30px;
    text-align: center;
}

.leaderboard-rank.first { color: #ffd700; }
.leaderboard-rank.second { color: #c0c0c0; }
.leaderboard-rank.third { color: #cd7f32; }

.leaderboard-team {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}

.leaderboard-score {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--color-accent);
}

/* ── Narrative ────────────────────────────────────────────────────── */

.narrative-box {
    background: var(--bg-elevated);
    padding: 16px 20px;
    margin: 16px 0;
    font-size: var(--fs-body);
    line-height: 1.65;
    color: var(--text-secondary);
}

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

/* ── Countdown / Timer ────────────────────────────────────────────── */

.countdown {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
}

.countdown.urgent {
    border-color: var(--negative);
    color: var(--negative);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ── Online Indicators ────────────────────────────────────────────── */

.online-list {
    display: flex;
    gap: -6px;
}

.online-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 2px solid var(--bg-elevated);
}

/* ── Toast / Notifications ────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    animation: slideIn 300ms ease;
    max-width: 360px;
}

.toast.success { border-color: var(--positive); }
.toast.error { border-color: var(--negative); }
.toast.info { border-color: var(--color-accent); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Tabs (for results sub-views) ─────────────────────────────────── */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    font-family: var(--font-base);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

/* ── Loading ──────────────────────────────────────────────────────── */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 12px;
}

/* ── Chat Panel ───────────────────────────────────────────────────── */

.chat-panel {
    position: fixed;
    right: 0;
    top: 52px;
    bottom: 0;
    width: 320px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 200ms ease;
    z-index: 100;
}

.chat-panel.open { transform: translateX(0); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    padding: 8px 12px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    font-size: 13px;
}

.chat-message .chat-from {
    font-weight: 600;
    font-size: 11px;
    color: var(--color-accent);
    margin-bottom: 2px;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.chat-input-bar input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-base);
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar { display: none; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
    .dec-product-grid { grid-template-columns: 1fr; gap: 16px; }
    .dec-grid-3 { grid-template-columns: 1fr; }
    .dec-grid-payout { grid-template-columns: 1fr; }
    .bs-visual { grid-template-columns: 1fr; }
    .gauge-row { grid-template-columns: 1fr; }
}

/* ── Plotly Chart Override ────────────────────────────────────────── */

.chart-container {
    width: 100%;
    min-height: 300px;
    border-radius: var(--radius);
    overflow: hidden;
}

/* ── Scenario Info ────────────────────────────────────────────────── */

.scenario-info {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.scenario-economy {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.eco-stat {
    text-align: center;
}

.eco-stat-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.eco-stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Nav Divider ─────────────────────────────────────────────────── */

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 12px;
}

/* ── Income Statement Table ──────────────────────────────────────── */

.is-table .is-section-header th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.is-table .is-subtotal td {
    font-weight: 600;
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.is-table .is-total td {
    font-weight: 700;
    font-size: 16px;
    border-top: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    padding: 10px 12px;
}

.is-table .is-grand-total td {
    font-weight: 700;
    font-size: 18px;
    border-top: 3px double var(--text);
    padding: 12px 12px;
}

/* ── Reference / Guide Sections ──────────────────────────────────── */

.ref-section {
    margin-bottom: 16px;
}

.ref-body {
    font-size: var(--fs-body);
    line-height: 1.65;
    color: var(--text-secondary);
}

.ref-body p { margin-bottom: 12px; }
.ref-body h4 { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin-bottom: 10px; }
.ref-body ul, .ref-body ol { margin-left: 18px; margin-bottom: 12px; }
.ref-body li { margin-bottom: 6px; }
.ref-body strong { color: var(--text); }

.ref-formula {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    margin: 8px 0 12px;
    color: var(--color-accent);
    text-align: center;
}

/* ── Glossary ────────────────────────────────────────────────────── */

.glossary-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.glossary-item:last-child { border-bottom: none; }

.glossary-term {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 3px;
}

.glossary-def {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Tooltip System ──────────────────────────────────────────────── */

.tip {
    position: relative;
    cursor: help;
}

.tip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--teal);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-size: 12px;
    font-weight: 400;
    font-family: var(--font-base);
    color: var(--text);
    line-height: 1.5;
    white-space: normal;
    width: max-content;
    max-width: 320px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

/* ── Formula icon button ── */
.formula-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    line-height: 1;
    padding: 0;
    font-size: 0;
}
.formula-btn::before {
    content: 'ƒ';
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-weight: normal;
    font-size: 0.72rem;
    display: inline-block;
    line-height: 1;
    transform: translateY(-1.5px);
}
.formula-btn:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-bg);
}
.formula-btn--active {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: var(--color-accent-bg);
}

/* ── Formula panel (sliding from right) ── */
.formula-panel {
    position: fixed;
    top: 80px;
    right: -580px;
    width: 560px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 100px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    z-index: 500;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
    overflow: hidden;
}
.formula-panel--visible { right: 16px; }

.formula-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}
.formula-panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.formula-panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.formula-panel-close:hover { color: var(--text); }

.formula-panel-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
}
.formula-section {
    margin-bottom: 18px;
}
.formula-section:last-child { margin-bottom: 0; }

.formula-section-label {
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* De-carded — equations sit in flowing white space, flex-centred. */
.formula-symbolic,
.formula-numeric,
.formula-extra-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    padding: 10px 0;
    overflow-x: auto;
    font-size: 1rem;
}
.formula-symbolic .katex-display,
.formula-numeric .katex-display,
.formula-extra-content .katex-display { margin: 0; }
.formula-numeric {
    font-size: 0.95rem;
    color: var(--formula-numeric);
}
.formula-extra-content {
    font-size: 0.95rem;
}

.formula-var-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-family: var(--font-base);
}
.formula-var-table th {
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.9rem;
    color: var(--text);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.formula-var-table td {
    padding: 8px 10px;
    border-bottom: 0;
    color: var(--text);
    vertical-align: middle;
}
.formula-var-table tbody tr + tr td {
    border-top: 1px solid var(--border-subtle);
}
.formula-var-sym {
    color: var(--text);
    font-weight: 500;
    min-width: 48px;
    font-family: 'KaTeX_Main', 'STIX Two Text', Georgia, serif;
    font-style: italic;
}
.formula-var-val {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums lining-nums;
    color: var(--formula-numeric);
    text-align: right;
    white-space: nowrap;
}
.formula-var-unit {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.formula-intuition {
    font-size: 0.95rem;
    color: var(--formula-numeric);
    line-height: 1.6;
    font-style: italic;
    padding: 14px 16px;
    background: color-mix(in srgb, var(--formula-numeric) 8%, transparent);
    border-radius: var(--radius);
    margin-top: 8px;
}

/* Risk weight badge */
.rw-badge {
    display: inline-block;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 600;
    background: var(--color-accent-bg);
    color: var(--color-accent);
    border-radius: 3px;
    padding: 1px 5px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ── Preview Warnings ────────────────────────────────────────────── */

/* Decisions — Projected Impact panel: scoped compression to fit viewport */
#preview-panel > .card {
    padding: 12px 14px;
}
#preview-panel .card-header {
    margin-bottom: 10px;
}
#preview-panel .preview-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#preview-panel .metric {
    padding: 8px 12px;
}
#preview-panel .metric-value {
    line-height: 1.2;
    margin-top: 2px;
}
#preview-panel .metric--retained {
    padding: 6px 12px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    border-top: 1px dashed var(--border);
}
#preview-panel .metric--retained .metric-value {
    font-size: 14px;
}
#preview-panel .sandbox-gauge {
    padding: 4px 12px;
}
#preview-panel .sandbox-gauge-header {
    margin-bottom: 2px;
}

.preview-warnings {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--negative-bg);
    border: 1px solid var(--negative);
    border-radius: var(--radius-sm);
}

.preview-warning-item {
    font-size: 12px;
    color: var(--negative);
    padding: 2px 0;
    font-weight: 500;
}

.preview-warning-item::before {
    content: '\26A0 ';
}

/* ── Preview Delta Indicators ────────────────────────────────────── */

.preview-delta.positive { color: var(--positive); }
.preview-delta.negative { color: var(--negative); }
.preview-delta.positive::before { content: '\25B2 '; font-size: 8px; }
.preview-delta.negative::before { content: '\25BC '; font-size: 8px; }

/* ── Scenario Builder ────────────────────────────────────────────── */

.scenario-round-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.scenario-round-card .round-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    cursor: pointer;
}

.scenario-round-card .round-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-accent);
}

.scenario-round-card .round-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.scenario-round-card .round-body .form-group {
    margin-bottom: 8px;
}

.scenario-round-card .round-body .form-label {
    font-size: 11px;
}

.scenario-round-card .round-body .form-input,
.scenario-round-card .round-body .form-select,
.scenario-round-card .round-body textarea {
    padding: 6px 10px;
    font-size: 12px;
}

.scenario-round-card textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 12px;
    font-family: var(--font-base);
    resize: vertical;
    min-height: 60px;
    width: 100%;
}

.scenario-round-card textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-bg);
}

/* ── Admin & Trainer Session Management ──────────────────────────── */

.admin-stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.trainer-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.back-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}
.badge-info { background: var(--color-accent-bg); color: var(--color-accent); }
.badge-success { background: rgba(52,211,153,0.12); color: #34d399; }
.badge-warning { background: rgba(251,191,36,0.12); color: #fbbf24; }
.badge-danger { background: rgba(239,68,68,0.12); color: #ef4444; }
.badge-secondary { background: rgba(255,255,255,0.08); color: var(--text-muted); }

.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: var(--radius-sm);
}
.btn-warning {
    background: rgba(251,191,36,0.15);
    color: #fbbf24;
    border: 1px solid rgba(251,191,36,0.3);
}
.btn-warning:hover { background: rgba(251,191,36,0.25); }
.btn-danger {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-success {
    background: rgba(52,211,153,0.15);
    color: #34d399;
    border: 1px solid rgba(52,211,153,0.3);
}
.btn-success:hover { background: rgba(52,211,153,0.25); }

@media (max-width: 768px) {
    .admin-stat-row { grid-template-columns: repeat(2, 1fr); }
    .trainer-form-grid { grid-template-columns: 1fr; }
}

/* ── Scenario Viewer (Trainer) — Vertical Table Layout ────────────── */

.scenario-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}
.scenario-badge--processed {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}
.scenario-badge--active {
    background: var(--color-accent-bg);
    color: var(--color-accent);
}
.scenario-badge--upcoming {
    background: rgba(52, 211, 153, 0.12);
    color: #34d399;
}

/* Table structure */
.scenario-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.scenario-table th,
.scenario-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.scenario-th-label {
    width: 160px;
    min-width: 140px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
}
.scenario-th-round {
    text-align: center;
    min-width: 100px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.scenario-th-round .scenario-badge {
    display: block;
    margin-top: 4px;
}
.scenario-th-round.processed { opacity: 0.6; }
.scenario-th-round.active { color: var(--color-accent); }

/* Section header row */
.scenario-section-row td {
    padding: 10px 10px 4px;
    border-bottom: 2px solid var(--border);
    background: var(--bg-elevated);
}
.scenario-td-section {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Label column */
.scenario-td-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* Read-only cells */
.scenario-td-ro {
    text-align: center;
}
.scenario-cell-mono {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 13px;
}
.scenario-cell-text {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* Editable cells */
.scenario-td-edit {
    text-align: center;
    padding: 4px 6px;
}
.scenario-cell-input {
    width: 100%;
    max-width: 120px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-main);
    color: var(--text);
    text-align: center;
}
.scenario-cell-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px var(--color-accent-bg);
}
textarea.scenario-cell-input {
    text-align: left;
    min-height: 48px;
    resize: vertical;
    font-family: var(--font-base);
    font-style: italic;
}
select.scenario-cell-input {
    cursor: pointer;
}

/* Hover highlight */
.scenario-table tbody tr:not(.scenario-section-row):hover {
    background: var(--bg-elevated);
}

/* Old card-based styles (kept for setup.js scenario editor) */
.scenario-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 6px;
}
.scenario-edit-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .scenario-edit-grid { grid-template-columns: repeat(2, 1fr); }
    .scenario-th-label { width: 120px; min-width: 100px; }
    .scenario-th-round { min-width: 80px; }
    .scenario-cell-input { max-width: 80px; font-size: 11px; }
}

/* ── Mobile / Tablet Responsive ──────────────────────────────────── */

@media (max-width: 1024px) {
    .main-content { padding: 16px; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .scenario-economy { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 12px; height: 48px; }
    .app-logo { font-size: 13px; }
    .sidebar { display: none; }
    .main-content { padding: 12px; }

    .grid-2 { grid-template-columns: 1fr; }
    .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
    .dec-product-grid { grid-template-columns: 1fr; gap: 16px; }
    .dec-grid-3 { grid-template-columns: 1fr; }
    .dec-grid-payout { grid-template-columns: 1fr; }
    .bs-visual { grid-template-columns: 1fr; }
    .gauge-row { grid-template-columns: 1fr; }
    .scenario-economy { grid-template-columns: 1fr 1fr; }

    /* Stack decision form + preview vertically */
    .decisions-layout {
        display: flex !important;
        flex-direction: column !important;
    }

    #preview-panel { order: -1; }
    .dec-section { padding: 18px 16px; }

    .card { padding: 14px; }
    .card-header { flex-wrap: wrap; gap: 8px; }

    .join-card { padding: 32px 24px; }
    .join-logo img { max-width: 260px; }
    .join-logo { margin-bottom: 40px; }

    .round-banner { flex-direction: column; gap: 8px; align-items: flex-start; }

    .leaderboard-row { flex-wrap: wrap; }
    .leaderboard-score { width: 100%; text-align: right; }

    /* Table scroll */
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 8px 6px; }

    .toast { max-width: 280px; font-size: 12px; }
    .chat-panel { width: 100%; }

    .btn-lg { padding: 10px 16px; font-size: 13px; }

    /* Mobile nav — bottom bar */
    .app-body { flex-direction: column; }
}

@media (max-width: 480px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .scenario-economy { grid-template-columns: 1fr; }
    .metric-value { font-size: 18px; }
    .gauge-value { font-size: 22px; }
    .app-logo .header-logo { height: 36px; }
    .header-controls { gap: 6px; }
    .header-round-info { gap: 6px; margin-right: 8px; padding: 4px 10px; }
    .header-round-label { font-size: 12px; }
    .header-round-status { display: none; }
    .header-round-timer { font-size: 13px; }
}

/* ── Financials View (combined BS + IS) ────────────────────────── */

.fin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
    max-width: 1400px;
}

.fin-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Keep numbers close to labels on wide screens */
.fin-table td.r,
.fin-table th.r {
    width: 100px;
    min-width: 80px;
}

.is-multi td.r,
.is-multi th.r {
    width: 90px;
    min-width: 70px;
}

.fin-card {
    padding: 16px;
    margin-bottom: 0;
}

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

.fin-card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.fin-units {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
}

.fin-tabs {
    display: flex;
    gap: 4px;
}

.fin-tab {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.fin-tab:hover { color: var(--text); background: var(--bg-hover); }
.fin-tab.active { background: var(--color-accent-bg); color: var(--color-accent); border-color: var(--color-accent); }

.fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.fin-table th {
    text-align: left;
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.fin-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.fin-table td.r, .fin-table th.r { text-align: right; }
.fin-table td.mono { font-family: var(--font-mono); font-size: 14px; }
.fin-table td.positive { color: var(--positive); }
.fin-table td.negative { color: var(--negative); }
.fin-table tr:hover td { background: var(--bg-hover); }

.fin-total {
    font-weight: 700;
}

.fin-total td {
    border-top: 2px solid var(--teal);
    border-bottom: none;
    padding-top: 6px;
}

/* Remove bottom border from row immediately before a total row so lines overlap */
tr:has(+ .fin-total) td,
tr:has(+ .fin-spacer) td {
    border-bottom: none;
}

.fin-spacer td {
    border-bottom: none;
    padding: 4px 0;
}

.fin-subtotal td {
    border-top: 1px solid var(--teal-dim);
    padding-top: 6px;
}

.fin-grand-total td {
    border-top: 2px solid var(--teal);
    padding-top: 8px;
    font-weight: 700;
}

/* Remove bottom border from row immediately before grand-total/subtotal */
tr:has(+ .fin-grand-total) td,
tr:has(+ .fin-subtotal) td {
    border-bottom: none;
}

.fin-dim td {
    color: var(--text-muted);
    font-size: 12px;
}

.is-multi td:first-child {
    white-space: nowrap;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.is-sec td {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
}

/* Expandable IS detail rows */
.is-expand-toggle {
    cursor: pointer;
    user-select: none;
}

.is-expand-toggle .is-arrow {
    display: inline-block;
    font-size: 11px;
    margin-right: 4px;
    transition: transform 0.15s ease;
    color: var(--text-muted);
}

.is-detail-row td {
    padding-left: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

.is-detail-row td:first-child {
    font-style: italic;
}

/* Team name in header */
.header-team-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    padding-left: 20px;
    border-left: 1px solid var(--border);
    margin-left: 8px;
    letter-spacing: -0.3px;
}

/* RWA toggle */
.rwa-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text);
}

.rwa-expand {
    font-size: 16px;
    color: var(--text-muted);
    transition: var(--transition);
}

/* Regulatory mini-gauges */
.fin-gauges {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.fin-gauge {
    text-align: center;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.fin-gauge-val {
    font-size: 26px;
    font-weight: 700;
    font-family: var(--font-mono);
    transition: color 0.4s ease;
}

.fin-gauge-val.ok { color: var(--positive); }
.fin-gauge-val.warn { color: var(--warning); }
.fin-gauge-val.breach { color: var(--negative); }

/* Gradient bar */
.fin-gauge-bar {
    position: relative;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, var(--negative) 0%, var(--warning) 35%, var(--positive) 65%);
    margin: 8px 4px 4px;
}

.fin-gauge-pos {
    position: absolute;
    top: -4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
    transform: translateX(-50%);
    transition: left 0.5s ease;
}
.fin-gauge-pos.ok { background: var(--positive); }
.fin-gauge-pos.warn { background: var(--warning); }
.fin-gauge-pos.breach { background: var(--negative); }

.fin-gauge-tick {
    position: absolute;
    top: -5px;
    width: 2px;
    height: 14px;
    background: var(--text-muted);
    opacity: 0.4;
    transform: translateX(-50%);
    border-radius: 1px;
}

.fin-gauge-ghost {
    position: absolute;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--text-muted);
    background: transparent;
    transform: translateX(-50%);
    opacity: 0.4;
}

.fin-gauge-lbl {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.fin-gauge-prev {
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.5;
    margin-top: 1px;
}

/* ── Sparklines ──────────────────────────────────────────────────── */

.sparkline {
    display: block;
    margin: 4px auto 0;
}

/* ── Risk Dashboard (Decisions sidebar) ──────────────────────────── */

.risk-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.risk-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.risk-light.ok { background: var(--positive); box-shadow: 0 0 6px rgba(52, 211, 153, 0.4); }
.risk-light.warning { background: var(--warning); box-shadow: 0 0 6px rgba(251, 191, 36, 0.4); }
.risk-light.danger { background: var(--negative); box-shadow: 0 0 6px rgba(248, 113, 113, 0.4); }

.risk-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
}

.risk-detail {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Theme Toggle Sun/Moon ─────────────────────────────────────── */

.icon-sun, .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="light"] .icon-moon { display: inline; }

/* ── Header Logo (dark/light mode) ─────────────────────────────── */

.header-logo {
    object-fit: contain;
}

.dark-only { display: none; }
.light-only { display: none; }
[data-theme="dark"] .dark-only { display: inline; }
[data-theme="light"] .light-only { display: inline; }

/* ── Economy Charts ────────────────────────────────────────────── */

.eco-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .eco-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

.eco-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.eco-chart-card {
    padding: 16px;
    margin-bottom: 0;
}

.eco-chart-card .chart-container {
    min-height: 220px;
}

/* ── Financials Responsive ─────────────────────────────────────── */

@media (max-width: 1024px) {
    .fin-grid { grid-template-columns: 1fr; }
    .eco-charts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .fin-gauges { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .fin-gauges { grid-template-columns: 1fr; }
    .learn-layout { grid-template-columns: 1fr; }
    .learn-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
    .eco-charts { grid-template-columns: 1fr; }
}

/* ── Reference Tab (EduMarkets Platform style) ─────────────────── */

.ref-wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ref-sub-tabs-wrap {
    flex-shrink: 0;
    padding: 4px 0 16px;
}

.ref-sub-tabs {
    display: flex;
    gap: 4px;
    width: fit-content;
}

.ref-sub-tab {
    padding: 7px 20px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-family: var(--font-base);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.ref-sub-tab:hover {
    color: var(--text-secondary);
    border-color: var(--color-accent);
}

.ref-sub-tab.active {
    background: var(--color-accent-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.ref-panel-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Learn layout (sidebar TOC + content) */
.learn-layout {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 24px;
    align-items: start;
}

.learn-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 0;
}

.learn-nav-link {
    display: block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.4;
    cursor: pointer;
}

.learn-nav-link:hover {
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

.learn-nav-link.active {
    color: var(--color-accent);
    background: var(--color-accent-bg);
    font-weight: 600;
}

.learn-content {
    min-width: 0;
    padding-bottom: 48px;
}

.learn-chapter {
    margin-bottom: 36px;
    scroll-margin-top: 16px;
    font-size: var(--fs-body);
    line-height: 1.65;
    color: var(--text-secondary);
}

.learn-chapter p { margin-bottom: 12px; }
.learn-chapter h4 { font-size: var(--fs-lg); font-weight: 600; color: var(--text); margin-bottom: 10px; }
.learn-chapter ul, .learn-chapter ol { margin-left: 18px; margin-bottom: 12px; }
.learn-chapter li { margin-bottom: 6px; }
.learn-chapter strong { color: var(--text); }

.learn-section-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.learn-callout {
    padding: 0;
    margin: 16px 0;
    font-size: var(--fs-body);
    color: var(--text);
    line-height: 1.65;
}

.learn-formula-box {
    font-family: var(--font-mono);
    font-size: 14px;
    background: var(--bg-elevated);
    padding: 10px 16px;
    margin: 12px 0;
    color: var(--text);
    text-align: center;
}

.learn-example {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow: hidden;
}

.learn-example-title {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border);
}

.learn-example-body {
    padding: 14px 16px;
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.65;
}

/* Glossary cards (platform style) */
.glossary-controls {
    margin-bottom: 16px;
}

.glossary-search-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.glossary-search {
    flex: 1;
    max-width: 400px;
}

.glossary-count {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.glossary-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.glossary-card {
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.glossary-card:first-child {
    padding-top: 0;
}

.glossary-card-term {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.glossary-card-def {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Confirm Modal ──────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: modalFadeIn 150ms ease;
}

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

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-dialog {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px 24px;
    min-width: 380px;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 200ms ease;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.modal-message {
    font-size: var(--fs-body);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-btn {
    min-width: 100px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

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


/* ── CET1 Capital Requirements Popup ──────────────────────────────── */

.cap-req-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(760px, 92vw);
    padding: 28px;
    animation: modalIn 200ms ease;
}

.cap-req-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.cap-req-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.cap-req-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.cap-req-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.cap-req-close:hover { color: var(--text); }

.cap-req-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 0 2px;
}

.cap-req-total-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

/* Stacked bar */
.cap-req-bar {
    display: flex;
    height: 40px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.cap-bar-seg {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity var(--transition), filter var(--transition);
    position: relative;
    min-width: 0;
}

.cap-bar-seg:not(:last-child) {
    border-right: 1px solid rgba(0,0,0,0.2);
}

.cap-bar-seg:hover,
.cap-bar-seg.active {
    filter: brightness(1.2);
    z-index: 1;
}

.cap-bar-lbl {
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* Body: legend + description */
.cap-req-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 320px;
}

/* Legend */
.cap-req-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cap-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    font-size: 13px;
}

.cap-legend-row:hover,
.cap-legend-row.active {
    background: var(--bg-hover);
}

.cap-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.cap-legend-name {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.cap-legend-full {
    color: var(--text-muted);
    font-size: 11px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cap-legend-val {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Description panel */
.cap-req-desc {
    border-left: 1px solid var(--border);
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 8px;
    overflow-y: auto;
}

.cap-desc-placeholder {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

.cap-desc-header {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 8px;
}

.cap-desc-text {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Clickable min label on gauges */
.gauge-min-link {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-muted);
    transition: color var(--transition);
}
.gauge-min-link:hover {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* Responsive */
@media (max-width: 600px) {
    .cap-req-body {
        grid-template-columns: 1fr;
    }
    .cap-req-desc {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 16px;
    }
    .cap-req-modal {
        padding: 20px;
    }
}

/* ── Pre-Round Briefing ──────────────────────────────────────────── */

.briefing-container {
    max-width: 720px;
    margin: 0 auto;
}

.briefing-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.briefing-round {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.briefing-timer {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 4px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.briefing-narrative {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.briefing-narrative-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.briefing-narrative-text {
    font-size: var(--fs-body);
    line-height: 1.65;
    color: var(--text-secondary);
}

.briefing-section {
    margin-bottom: 16px;
}

.briefing-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.briefing-changes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.briefing-change {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.briefing-change-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.briefing-change-vals {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-family: var(--font-mono);
}

.briefing-from { color: var(--text-muted); }
.briefing-arrow { color: var(--text-muted); font-size: 11px; }
.briefing-to { color: var(--text); font-weight: 600; }
.briefing-delta {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
}
.briefing-delta.up { color: var(--negative); background: rgba(248, 113, 113, 0.12); }
.briefing-delta.down { color: var(--positive); background: rgba(52, 211, 153, 0.12); }

.briefing-shocks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.briefing-shock-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--warning);
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-sm);
}

.briefing-shock-item::before {
    content: '\26A0';
    font-size: 14px;
}

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

.briefing-demand-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.briefing-demand-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.briefing-demand-val {
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
}

.briefing-question {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(79, 140, 255, 0.08);
    border: 1px solid rgba(79, 140, 255, 0.2);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.briefing-question-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.briefing-question-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.5;
}

.briefing-actions {
    text-align: center;
}

/* ── Sandbox Gauge (Decisions preview) ────────────────────────────── */

.sandbox-gauge {
    padding: 8px 0;
}

.sandbox-gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.sandbox-gauge-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.sandbox-gauge-val {
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font-mono);
    transition: color 0.3s ease;
}

.sandbox-gauge-val.ok { color: var(--positive); }
.sandbox-gauge-val.warn { color: var(--warning); }
.sandbox-gauge-val.breach { color: var(--negative); }

.sandbox-gauge-bar {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--bg);
    overflow: visible;
}

.sandbox-gauge-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease, background 0.3s ease;
}

.sandbox-gauge-fill.ok { background: var(--positive); }
.sandbox-gauge-fill.warn { background: var(--warning); }
.sandbox-gauge-fill.breach { background: var(--negative); }

.sandbox-gauge-tick {
    position: absolute;
    top: -4px;
    width: 2px;
    height: 14px;
    background: var(--text-muted);
    opacity: 0.5;
    transform: translateX(-50%);
    border-radius: 1px;
}

/* ── Repricing Gap Chart ─────────────────────────────────────────── */

.repricing-gap-card {
    margin-top: 12px;
}

/* ── CET1 Waterfall ──────────────────────────────────────────────── */

.waterfall-container {
    margin-top: 16px;
}

.waterfall-chart {
    height: 280px;
}

/* ── Pause Overlay ───────────────────────────────────────────────── */

.pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(11, 11, 12, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pauseFadeIn 0.3s ease;
}

[data-theme="light"] .pause-overlay {
    background: rgba(245, 245, 247, 0.85);
}

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

.pause-overlay-content {
    text-align: center;
    max-width: 520px;
    padding: 48px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.pause-overlay-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.pause-overlay-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--warning);
    margin-bottom: 16px;
}

.pause-overlay-message {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: var(--radius);
    white-space: pre-wrap;
}

.pause-overlay-hint {
    font-size: 13px;
    color: var(--text-muted);
    animation: pausePulse 2s ease-in-out infinite;
}

@keyframes pausePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Guided Debrief Panel ────────────────────────────────────────── */

.debrief-card {
    border-color: var(--color-accent);
}

.debrief-section {
    margin-bottom: 20px;
}

.debrief-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.debrief-text {
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--text-secondary);
}

.debrief-highlight {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    padding: 14px 16px;
    background: var(--color-accent-bg);
    border-radius: var(--radius);
}

.debrief-questions {
    list-style: decimal;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.debrief-questions li {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.debrief-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.debrief-real-world {
    font-size: var(--fs-body);
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 14px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius);
    font-style: italic;
}

/* ── Leaderboard Context ─────────────────────────────────────────── */

.lb-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}

.lb-legend-title {
    font-weight: 600;
    color: var(--text-muted);
}

.lb-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

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

.rank-arrow {
    font-size: 11px;
    font-weight: 600;
}

.rank-arrow.up { color: var(--positive); }
.rank-arrow.down { color: var(--negative); }
.rank-arrow.same { color: var(--text-muted); font-size: 11px; }

.lb-gap {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.lb-breakdown {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.score-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-bar-label {
    width: 32px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}

.score-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
    max-width: 120px;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.score-bar-val {
    width: 28px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.lb-penalties {
    font-size: 11px;
    color: var(--negative);
    margin-left: 38px;
}

/* ── Round Awards ────────────────────────────────────────────────── */

.round-awards {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.award-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    transition: border-color var(--transition);
}

.award-badge.mine {
    border-color: var(--color-accent);
    background: var(--color-accent-bg);
}

.award-label {
    font-weight: 600;
    color: var(--text);
}

.award-team {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ── Smooth Tab Transitions (5.5) ────────────────────────────────── */

.main-content {
    animation: fadeIn 200ms ease-out;
}

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

/* ── Animated Results Reveal (4.1) ───────────────────────────────── */

.results-reveal .metric-value,
.results-reveal .gauge-value {
    animation: revealPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.results-reveal .metric:nth-child(1) .metric-value { animation-delay: 0.1s; }
.results-reveal .metric:nth-child(2) .metric-value { animation-delay: 0.3s; }
.results-reveal .metric:nth-child(3) .metric-value { animation-delay: 0.5s; }
.results-reveal .metric:nth-child(4) .metric-value { animation-delay: 0.7s; }

.results-reveal .gauge:nth-child(1) .gauge-value { animation-delay: 0.9s; }
.results-reveal .gauge:nth-child(2) .gauge-value { animation-delay: 1.0s; }
.results-reveal .gauge:nth-child(3) .gauge-value { animation-delay: 1.1s; }

.results-reveal .narrative-box {
    animation: fadeIn 0.5s ease both;
    animation-delay: 1.2s;
}

.results-reveal .round-awards {
    animation: fadeIn 0.5s ease both;
    animation-delay: 0.8s;
}

@keyframes revealPop {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.results-reveal-headline {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: var(--bg);
    z-index: 1000;
    animation: headlineFade 2s ease both;
}

.results-reveal-headline h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.results-reveal-headline .reveal-score {
    font-size: 48px;
    font-weight: 700;
    color: var(--color-accent);
    font-family: var(--font-mono);
}

.results-reveal-headline .reveal-rank {
    font-size: 20px;
    color: var(--text-secondary);
    margin-top: 8px;
}

@keyframes headlineFade {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; pointer-events: none; }
}

.results-reveal-skip {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 1001;
    animation: fadeIn 0.5s ease both;
    animation-delay: 0.5s;
}

/* ── Decision Confirmation Dialog (2.5) ──────────────────────────── */

.confirm-decisions-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin: 16px 0;
    font-size: 13px;
}

.confirm-decisions-summary dt {
    color: var(--text-muted);
    font-weight: 500;
}

.confirm-decisions-summary dd {
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 600;
    text-align: right;
}

/* ── Peer Benchmark Bands (2.3) ──────────────────────────────────── */

.benchmark-bar {
    position: relative;
    height: 24px;
    background: var(--bg-hover);
    border-radius: 4px;
    margin: 6px 0;
    overflow: visible;
}

.benchmark-range {
    position: absolute;
    top: 4px;
    height: 16px;
    background: rgba(79, 140, 255, 0.15);
    border: 1px solid rgba(79, 140, 255, 0.3);
    border-radius: 3px;
}

.benchmark-median {
    position: absolute;
    top: 2px;
    width: 2px;
    height: 20px;
    background: var(--color-accent);
    border-radius: 1px;
}

.benchmark-you {
    position: absolute;
    top: 0;
    width: 8px;
    height: 24px;
    background: var(--positive);
    border-radius: 4px;
    border: 2px solid var(--bg-surface);
    transform: translateX(-4px);
    z-index: 1;
}

.benchmark-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── Sensitivity Table (2.4) ─────────────────────────────────────── */

.sensitivity-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.sensitivity-table th {
    padding: 6px 8px;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.sensitivity-table td {
    padding: 6px 8px;
    text-align: center;
    font-family: var(--font-mono);
}

.sensitivity-table .base-row {
    background: var(--color-accent-bg);
    font-weight: 600;
}

.sensitivity-table .negative { color: var(--negative); }
.sensitivity-table .positive { color: var(--positive); }

/* ── Sankey Diagram container (5.1) ──────────────────────────────── */

.sankey-container {
    min-height: 400px;
    width: 100%;
}

/* ── Lessons Learned Library (1.6) ───────────────────────────────── */

.lessons-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-card {
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition), opacity var(--transition);
}

.lesson-card.locked {
    opacity: 0.5;
    filter: grayscale(0.5);
}

.lesson-card.unlocked {
    border-color: var(--color-accent);
}

.lesson-card.new {
    animation: lessonUnlock 0.5s ease;
}

@keyframes lessonUnlock {
    from { border-left-color: var(--positive); background: var(--color-accent-bg); transform: scale(1.02); }
    to { border-left-color: var(--color-accent); background: var(--bg-surface); transform: scale(1); }
}

.lesson-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.lesson-trigger {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

/* ── Strategy Labels (4.4) ───────────────────────────────────────── */

.strategy-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.strategy-label.aggressive { background: rgba(248,113,113,0.15); color: var(--negative); }
.strategy-label.conservative { background: rgba(52,211,153,0.15); color: var(--positive); }
.strategy-label.balanced { background: rgba(79,140,255,0.15); color: var(--color-accent); }
.strategy-label.yield-hunter { background: rgba(251,191,36,0.15); color: var(--warning); }

/* ── Dashboard — KPI Strip + Gauges + Score + P&L + BS Mix ─────── */

.dash-kpi-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    margin-bottom: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.dash-kpi-strip .metric {
    padding: 14px 12px 10px;
    text-align: center;
    background: var(--bg-surface);
}

.dash-kpi-strip .metric:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.dash-kpi-strip .metric:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.dash-kpi-strip .metric-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.dash-kpi-strip .metric-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.dash-kpi-strip .metric-value.positive { color: var(--positive); }
.dash-kpi-strip .metric-value.negative { color: var(--negative); }
.dash-kpi-strip .metric-value.status-ok { color: var(--positive); }
.dash-kpi-strip .metric-value.status-warning { color: var(--warning); }
.dash-kpi-strip .metric-value.status-danger { color: var(--negative); }

.metric-delta-tag {
    font-size: 12px;
    font-weight: 500;
    margin-top: 2px;
    line-height: 1;
}

.metric-delta-tag.positive { color: var(--positive); }
.metric-delta-tag.negative { color: var(--negative); }
.metric-delta-tag.positive::before { content: '\25B2 '; font-size: 8px; }
.metric-delta-tag.negative::before { content: '\25BC '; font-size: 8px; }

/* Two-column layout */
.dash-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Gauge */
.dash-gauge {
    padding: 8px 16px;
}

.dash-gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.dash-gauge-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.dash-gauge-val {
    font-size: 14px;
    font-weight: 700;
}

.dash-gauge-val.status-ok { color: var(--positive); }
.dash-gauge-val.status-warning { color: var(--warning); }
.dash-gauge-val.status-danger { color: var(--negative); }

.dash-gauge-bar {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    overflow: visible;
}

.dash-gauge-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.dash-gauge-fill.status-ok { background: var(--positive); }
.dash-gauge-fill.status-warning { background: var(--warning); }
.dash-gauge-fill.status-danger { background: var(--negative); }

.dash-gauge-tick {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 12px;
    background: var(--text-muted);
    border-radius: 1px;
    opacity: 0.6;
}

/* Score breakdown rows */
.dash-score-rows {
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-score-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-score-row.total {
    border-top: 1px solid var(--border);
    padding-top: 8px;
}

.dash-score-row.penalty .dash-score-label { color: var(--negative); }

.dash-score-label {
    width: 100px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.dash-score-bar-wrap {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--bg-hover);
    overflow: hidden;
}

.dash-score-bar {
    height: 100%;
    border-radius: 4px;
    background: var(--color-accent);
    transition: width 0.5s ease;
}

.dash-score-val {
    width: 40px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.dash-score-val.negative { color: var(--negative); }

/* Mini P&L */
.dash-pnl {
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dash-pnl-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 2px 0;
}

.dash-pnl-row .positive { color: var(--positive); font-weight: 600; }
.dash-pnl-row .negative { color: var(--negative); font-weight: 600; }

/* Balance sheet mix */
.dash-bs-mix {
    padding: 8px 16px 12px;
}

.dash-bs-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 6px;
}

.dash-bs-bar-wrap {
    margin-bottom: 6px;
}

.dash-stacked-bar {
    display: flex;
    height: 18px;
    border-radius: 4px;
    overflow: hidden;
    gap: 1px;
}

.dash-stacked-seg {
    transition: width 0.5s ease;
    min-width: 2px;
}

.dash-stacked-seg:first-child { border-radius: 4px 0 0 4px; }
.dash-stacked-seg:last-child { border-radius: 0 4px 4px 0; }

.dash-bs-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 4px;
}

.dash-bs-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.dash-bs-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* Team + Actions bar */
.dash-team-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px !important;
}

.online-avatar-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive: stack KPI strip on narrow screens */
@media (max-width: 900px) {
    .dash-kpi-strip { grid-template-columns: repeat(3, 1fr); }
    .dash-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .dash-kpi-strip { grid-template-columns: repeat(2, 1fr); }
}

/* ── Scenario Grid Editor ──────────────────────────────────────── */

.scenario-grid-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

.scenario-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.scenario-grid th,
.scenario-grid td {
    padding: 3px 4px;
    vertical-align: middle;
    white-space: nowrap;
}

.scenario-grid thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-surface);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    padding: 6px 4px;
    border-bottom: 2px solid var(--border);
    color: var(--text);
}

.sg-label-col {
    width: 140px;
    min-width: 140px;
    text-align: left !important;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
}

.sg-round-col {
    width: 100px;
    min-width: 90px;
}

.sg-section-row td {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 10px 4px 4px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.sg-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    padding-right: 8px;
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-surface);
}

.sg-cell {
    padding: 2px 3px;
}

.sg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 4px;
    font-size: 12px;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text);
    text-align: right;
    -moz-appearance: textfield;
}

.sg-input::-webkit-inner-spin-button,
.sg-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.sg-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.15);
}

.sg-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 6px;
    font-size: 11px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text);
    resize: vertical;
    min-height: 36px;
}

.sg-textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.15);
}

.sg-select {
    width: 100%;
    box-sizing: border-box;
    padding: 4px 4px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
}

.sg-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Hover highlight on grid rows */
.scenario-grid tbody tr:not(.sg-section-row):hover td {
    background: var(--bg-hover);
}

.scenario-grid tbody tr:not(.sg-section-row):hover .sg-label {
    background: var(--bg-hover);
}

@media (max-width: 600px) {
    .sg-label-col { width: 110px; min-width: 110px; }
    .sg-round-col { min-width: 80px; }
    .sg-input, .sg-textarea, .sg-select { font-size: 11px; }
}

/* ── Quick Analytics (3.5) ───────────────────────────────────────── */

.analytics-dist {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analytics-dist-label {
    width: 120px;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.analytics-dist-bar {
    flex: 1;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.analytics-dist-range {
    position: absolute;
    top: 3px;
    height: 14px;
    background: rgba(79, 140, 255, 0.25);
    border-radius: 3px;
}

.analytics-dist-val {
    width: 60px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
}

/* ── Mobile-Responsive (5.3) ─────────────────────────────────────── */

@media (max-width: 768px) {
    .app-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        gap: 0;
        padding: 4px;
        width: 100%;
    }

    .nav-item {
        flex: 0 0 auto;
        padding: 8px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

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

    .grid-2, .grid-4, .dec-product-grid, .dec-grid-3, .dec-grid-payout {
        grid-template-columns: 1fr !important;
    }

    .gauge-row {
        flex-direction: column;
        align-items: stretch;
    }

    .app-header {
        padding: 8px 12px;
    }

    .header-logo {
        height: 30px;
    }

    /* Hide non-essential elements on mobile */
    .eco-stat-label { font-size: 11px; }
    .scenario-economy { flex-wrap: wrap; }

    /* Leaderboard responsive */
    .leaderboard-row {
        flex-direction: column;
        gap: 8px;
    }

    .lb-breakdown {
        margin-left: 0;
    }
}

@media (max-width: 480px) {
    .app-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .join-card {
        padding: 20px;
        margin: 0 8px;
    }

    .round-awards {
        flex-direction: column;
    }
}
