/* ========================================
   AIF — Sci-Fi EA Trading System
   Cyberpunk dark theme with non-linear dynamics
   GPU-accelerated, no layout-thrash animations
   ======================================== */

/* ============================================================
   QCAi Design System — Light default + Dark override
   One accent (warm orange). Everything else is warm neutral.
   ============================================================ */

:root {
    color-scheme: light;

    /* --- Surfaces --- */
    --bg-base: #f4f3f1;
    --bg-surface: #ffffff;
    --bg-elevated: #faf9f7;
    --bg-hover: #f0eeeb;

    /* --- Hairlines (real warm grey, NOT tinted) --- */
    --border-subtle: #edebe8;
    --border-default: #e3e0dc;
    --border-strong: #d3cec7;

    /* --- Text --- */
    --text-primary: #1f1f1f;
    --text-secondary: #8a8a8a;
    --text-tertiary: #a3a3a3;
    --text-muted: #c2beb8;

    /* --- Hero figure (deep brown-gold) --- */
    --hero: #7a5a2e;

    /* --- Brand accent (constant across themes) --- */
    --accent-primary: #f5a623;
    --accent-primary-dim: rgba(245, 166, 35, 0.12);
    --accent-primary-glow: rgba(245, 166, 35, 0.28);
    --accent-green: #22a06b;
    --accent-green-dim: rgba(34, 160, 107, 0.12);
    --accent-green-glow: rgba(34, 160, 107, 0.26);
    --accent-red: #d64545;
    --accent-red-dim: rgba(214, 69, 69, 0.1);
    --accent-red-glow: rgba(214, 69, 69, 0.24);
    --accent-yellow: #e0a020;
    --accent-yellow-dim: rgba(224, 160, 32, 0.14);
    --accent-yellow-glow: rgba(224, 160, 32, 0.3);

    /* --- Gradients --- */
    --grad-brand: linear-gradient(135deg, #f7b84e, #ef9a1c);
    --grad-surface: linear-gradient(160deg, #ffffff, #fbfaf8);
    --grad-line: linear-gradient(90deg, transparent, rgba(245,166,35,0.45) 30%, rgba(245,166,35,0.3) 70%, transparent);
    --grad-line-full: linear-gradient(90deg, transparent, #f5a623, #ef9a1c, transparent);

    /* --- Overlay / scrim --- */
    --bg-overlay: rgba(30, 26, 20, 0.42);
    --hairline: #edebe8;
    --hairline-strong: #ded9d2;

    /* --- Chart tokens --- */
    --chart-grid: #edebe8;
    --chart-tick: #9a938a;
    --chart-tooltip-bg: rgba(255, 255, 255, 0.98);
    --chart-tooltip-border: #e3e0dc;
    --chart-tooltip-title: #6b4a2a;
    --chart-tooltip-body: #3d3830;

    /* --- Typography --- */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
    --font-display: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
    --fs-unit: 12px;
    --fs-label: 13px;
    --fs-body: 15px;
    --fs-value: 17px;
    --fs-section: 17px;
    --fs-hero: 48px;

    /* --- Spacing --- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --sp-5: 28px;

    /* --- Radius --- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;

    /* --- Shadows (warm, soft, single layer) --- */
    --shadow-sm: 0 1px 2px rgba(120, 100, 70, 0.06), 0 1px 6px rgba(120, 100, 70, 0.05);
    --shadow-md: 0 2px 8px rgba(120, 100, 70, 0.08), 0 6px 20px rgba(120, 100, 70, 0.06);
    --shadow-lg: 0 8px 28px rgba(120, 100, 70, 0.12), 0 16px 48px rgba(120, 100, 70, 0.08);
    --shadow-card: 0 2px 12px rgba(120, 100, 70, 0.08);
    --shadow-glow: 0 0 20px rgba(245, 166, 35, 0.18);

    /* --- Easing / transitions --- */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out-quint: cubic-bezier(0.83, 0, 0.17, 1);
    --ease-back: cubic-bezier(0.68, -0.55, 0.27, 1.55);
    --transition-fast: 120ms var(--ease-out-expo);
    --transition-normal: 220ms var(--ease-spring);
    --transition-slow: 400ms var(--ease-out-expo);

    /* --- Legacy aliases (keep the 4000-line stylesheet working) --- */
    --accent: var(--accent-primary);
    --accent-blue: var(--accent-primary);
    --accent-blue-dim: var(--accent-primary-dim);
    --accent-blue-glow: var(--accent-primary-glow);
    --accent-purple: var(--accent-primary);
    --accent-purple-dim: var(--accent-primary-dim);
    --accent-purple-glow: var(--accent-primary-glow);
    --accent-red-dim: rgba(214, 69, 69, 0.1);
    --accent-red-glow: rgba(214, 69, 69, 0.24);
    --accent-green-dim: rgba(34, 160, 107, 0.12);
    --accent-green-glow: rgba(34, 160, 107, 0.26);
    --grad-cyan: var(--grad-brand);
    --grad-violet: var(--grad-brand);
    --grad-green: var(--grad-brand);
    --grad-border: var(--grad-brand);
    --nofx-gold: var(--accent-primary);
    --nofx-success: var(--accent-green);
    --panel-bg: var(--bg-surface);
    --panel-border: var(--border-subtle);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg-base: #0b0b0c;
    --bg-surface: #17171a;
    --bg-elevated: #1e1e21;
    --bg-hover: #26262a;

    --border-subtle: #262629;
    --border-default: #34343a;
    --border-strong: #4a4a52;

    --text-primary: #f5f5f5;
    --text-secondary: #8a8a8a;
    --text-tertiary: #6e6e73;
    --text-muted: #4c4c52;

    --hero: #f0d6a0;

    --accent-primary: #f5a623;
    --accent-primary-dim: rgba(245, 166, 35, 0.16);
    --accent-primary-glow: rgba(245, 166, 35, 0.34);
    --accent-green: #2bb673;
    --accent-green-dim: rgba(43, 182, 115, 0.16);
    --accent-green-glow: rgba(43, 182, 115, 0.32);
    --accent-red: #e5484d;
    --accent-red-dim: rgba(229, 72, 77, 0.16);
    --accent-red-glow: rgba(229, 72, 77, 0.32);
    --accent-yellow: #e8b04b;
    --accent-yellow-dim: rgba(232, 176, 75, 0.16);
    --accent-yellow-glow: rgba(232, 176, 75, 0.34);

    --grad-surface: linear-gradient(160deg, #1a1a1d, #141416);
    --grad-line: linear-gradient(90deg, transparent, rgba(245,166,35,0.5) 30%, rgba(245,166,35,0.35) 70%, transparent);

    --bg-overlay: rgba(0, 0, 0, 0.62);
    --hairline: #262629;
    --hairline-strong: #34343a;

    --chart-grid: #262629;
    --chart-tick: #8a8a8a;
    --chart-tooltip-bg: rgba(28, 28, 32, 0.97);
    --chart-tooltip-border: #34343a;
    --chart-tooltip-title: #f0d6a0;
    --chart-tooltip-body: #e8e8e8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45), 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.55), 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(245, 166, 35, 0.22);
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Animated aurora mesh — purple & gold */
    background-image:
        radial-gradient(ellipse 60% 50% at 20% 0%, var(--accent-primary-dim), transparent 70%),
        radial-gradient(ellipse 50% 40% at 80% 10%, var(--accent-yellow-dim), transparent 70%),
        radial-gradient(ellipse 40% 30% at 50% 100%, var(--accent-primary-dim), transparent 70%),
        var(--bg-base);
    background-attachment: fixed;
    background-size: 100% 100%;
}

/* Subtle grid overlay for tech feel — pure CSS, no images */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--accent-primary-dim) 1px, transparent 1px),
        linear-gradient(90deg, var(--accent-yellow-dim) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 90%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 90%);
}

/* All content above grid overlay */
.topbar, .agent-status-bar, .account-bar, .main-content, .bottom-section {
    position: relative;
    z-index: 1;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-primary-glow), var(--accent-yellow-glow));
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-primary-glow), var(--accent-yellow-glow));
}

/* === Top Navigation Bar === */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 var(--space-lg);
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--grad-line);
    background-size: 200% 100%;
    opacity: 0.6;
    animation: line-flow 4s linear infinite;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--grad-cyan);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-icon {
    width: 20px;
    height: 20px;
}

.logo-text {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.status-pills {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 100px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.pill-mode.online {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    border-color: var(--accent-green-dim);
    box-shadow: 0 0 12px var(--accent-green-dim);
}

.pill-mode.offline {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border-color: var(--accent-red-dim);
}

.pill-mode.warning {
    background: var(--accent-yellow-dim);
    color: var(--accent-yellow);
    border-color: var(--accent-yellow-glow);
}

.pill-env.online {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.pill-env.warning {
    background: var(--accent-yellow-dim);
    color: var(--accent-yellow);
}

.pill-equity {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Topbar Center */
.topbar-center {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.mode-toggle {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 2px;
    border: 1px solid var(--border-subtle);
}

.mode-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
}

.controls {
    display: flex;
    gap: var(--space-xs);
}

.ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ctrl-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ctrl-start:hover {
    background: var(--accent-green-dim);
    color: var(--accent-green);
    border-color: var(--accent-green-glow);
}

.ctrl-pause:hover {
    background: var(--accent-yellow-dim);
    color: var(--accent-yellow);
    border-color: var(--accent-yellow-glow);
}

.ctrl-stop:hover {
    background: var(--accent-red-dim);
    color: var(--accent-red);
    border-color: var(--accent-red-glow);
}

.interval-select {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
}

.interval-select:hover {
    border-color: var(--border-default);
}

/* Topbar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.symbol-display {
    padding: 4px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-blue);
}

/* Symbol Prices Ticker */
.symbol-prices {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0 var(--space-sm);
}

.symbol-price-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    transition: all var(--transition-fast);
}

.symbol-price-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.symbol-price-item .coin-icon {
    flex-shrink: 0;
    border-radius: 50%;
}

.symbol-price-item .symbol-name {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 10px;
}

.symbol-price-item .symbol-price {
    color: var(--text-primary);
    font-weight: 600;
}

.symbol-price-item .symbol-change {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Status colors for price changes */
.symbol-price-item .symbol-change.positive {
    color: var(--accent-green);
    background: var(--accent-green-dim);
}

.symbol-price-item .symbol-change.negative {
    color: var(--accent-red);
    background: var(--accent-red-dim);
}

.symbol-price-item .symbol-change.neutral {
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

/* Status indicator dot — hidden, replaced by coin icons */
.symbol-price-item::before {
    display: none;
}

.symbol-price-item.status-neutral::before {
    background: var(--text-secondary);
}

.symbol-price-item.status-warning::before {
    background: var(--accent-yellow);
    box-shadow: 0 0 4px var(--accent-yellow);
}

.llm-badge {
    padding: 4px 10px;
    background: var(--accent-purple-dim);
    border: 1px solid var(--accent-primary-glow);
    border-radius: var(--radius-md);
    font-size: 11px;
    color: var(--accent-purple);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-sm::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--grad-cyan);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.btn-sm:hover {
    color: var(--text-primary);
    border-color: var(--accent-blue-glow);
    transform: translateY(-1px);
}

.btn-sm:hover::before {
    opacity: 0.08;
}

/* === Main Content Layout === */
.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg);
    flex: 1 1 0;
    min-height: 300px;
    overflow: hidden;
}

/* Grid 子项必须设 min-width:0，否则内容会撑开列宽导致溢出/消失 */
.main-content > .panel {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

/* === Team PnL Chart Panel === */
.panel-team-chart {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.pnl-timeframe-tabs {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.pnl-timeframe-tabs .tf-tab {
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.pnl-timeframe-tabs .tf-tab:hover {
    color: var(--text-primary);
    background: var(--accent-primary-dim);
}

.pnl-timeframe-tabs .tf-tab.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    box-shadow: inset 0 0 8px var(--accent-primary-dim);
}

.team-pnl-chart-wrapper {
    flex: 1 1 0;
    position: relative;
    min-height: 120px;
    height: 100%;
}

#teamPnlChart {
    width: 100% !important;
    height: 100% !important;
}

.team-pnl-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
}

.team-pnl-empty p {
    margin-top: var(--space-sm);
    font-size: 12px;
}

/* === Agent Status Bar === */
.agent-status-bar {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 6px var(--space-lg);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.agent-status-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.agent-status-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    margin-right: 2px;
}

.agent-status-sep {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 2px;
    opacity: 0.4;
}

.agent-status-dot {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    flex-shrink: 0;
}

.agent-status-dot .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.agent-status-dot .dot-label {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

.agent-status-dot .agent-badge {
    font-size: 7px;
    padding: 1px 4px;
    border-radius: 3px;
}

.agent-status-dot.dot-running {
    border-color: var(--accent-blue-glow);
    background: var(--accent-blue-dim);
}

.agent-status-dot.dot-running .dot {
    background: var(--accent-blue);
    box-shadow: 0 0 8px var(--accent-blue-glow);
    animation: pulse-dot 1.2s var(--ease-in-out-quint) infinite;
}

.agent-status-dot.dot-completed {
    border-color: var(--accent-green-glow);
    background: var(--accent-green-dim);
}

.agent-status-dot.dot-completed .dot {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

.agent-status-dot.dot-off {
    opacity: 0.35;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.65); }
}

.agent-status-cycle {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    padding: 2px 8px;
    border-radius: 100px;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    overflow-y: auto;
}

/* === Panel Base === */
.panel {
    background: var(--grad-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    contain: content;
}

/* Gradient top-border accent on each panel */
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--grad-line);
    background-size: 200% 100%;
    opacity: 0.7;
    pointer-events: none;
    animation: line-flow 6s linear infinite;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, var(--accent-primary-dim), transparent);
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
}

.panel-header h2 svg {
    color: var(--accent-blue);
    filter: drop-shadow(0 0 4px var(--accent-blue-glow));
}

.panel-header h2 svg {
    color: var(--text-tertiary);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cycle-tag {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 500;
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border-radius: 100px;
}

.count-badge {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-radius: 100px;
}

/* === Chatroom Panel === */
.panel-chatroom {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.chatroom-container {
    flex: 1 1 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chatroom-messages {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-md);
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Chat bubble — card style with colored left border per agent type */
.chat-bubble {
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--border-default);
    font-size: 12px;
    line-height: 1.5;
    animation: msg-in 280ms var(--ease-spring) both;
    word-break: break-word;
}

/* Agent-specific left border colors */
.chat-bubble.symbol_selector { border-left-color: var(--accent-primary); }
.chat-bubble.system          { border-left-color: var(--text-tertiary); }
.chat-bubble.quant_analyst   { border-left-color: var(--accent-primary); }
.chat-bubble.predict_agent   { border-left-color: var(--accent-primary); }
.chat-bubble.trend_agent     { border-left-color: var(--accent-green); }
.chat-bubble.setup_agent     { border-left-color: var(--accent-yellow); }
.chat-bubble.trigger_agent   { border-left-color: var(--accent-primary); }
.chat-bubble.bull_agent      { border-left-color: var(--accent-green); }
.chat-bubble.bear_agent      { border-left-color: var(--accent-red); }
.chat-bubble.multi_period_agent { border-left-color: var(--accent-primary); }
.chat-bubble.decision_core   { border-left-color: var(--accent-yellow); background: linear-gradient(135deg, var(--accent-yellow-dim), var(--bg-surface)); }
.chat-bubble.risk_audit      { border-left-color: var(--accent-red); }
.chat-bubble.reflection_agent { border-left-color: var(--accent-primary); }

/* Level-based background tint */
.chat-bubble.chat-level-success { background: linear-gradient(135deg, var(--accent-green-dim), var(--bg-surface)); }
.chat-bubble.chat-level-warning { background: linear-gradient(135deg, var(--accent-yellow-dim), var(--bg-surface)); }
.chat-bubble.chat-level-error   { background: linear-gradient(135deg, var(--accent-red-dim), var(--bg-surface)); }

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

.chat-bubble .chat-agent-name {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-secondary);
}

.chat-bubble .chat-timestamp {
    font-size: 10px;
    color: var(--text-tertiary);
}

.chat-bubble .chat-content {
    color: var(--text-primary);
    font-size: 12px;
}

.chatroom-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: var(--space-md);
}

.chatroom-empty svg {
    opacity: 0.5;
}

.chat-message {
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border-left: 2px solid var(--border-default);
    font-size: 13px;
    line-height: 1.6;
    animation: msg-in 280ms var(--ease-spring) both;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateX(-8px) scale(0.98); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

.chat-message.agent {
    border-left-color: var(--accent-blue);
    box-shadow: -2px 0 8px var(--accent-primary-dim);
}

.chat-message.decision {
    border-left-color: var(--accent-yellow);
    background: linear-gradient(135deg, var(--accent-yellow-dim), var(--bg-surface));
}

.chat-message .agent-name {
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 4px;
    font-size: 12px;
    text-shadow: 0 0 8px var(--accent-primary-glow);
}

.chat-message .message-content {
    color: var(--text-primary);
}

.chat-message .message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* === Agent Badge (used in status bar) === */
.agent-badge {
    font-size: 7px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 100px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.agent-badge.idle {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.agent-badge.running {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
}

.agent-badge.completed {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.agent-badge.off {
    background: var(--bg-elevated);
    color: var(--text-muted);
    opacity: 0.5;
}

/* === Sidebar Panels === */
.panel-account,
.panel-positions,
.panel-llm {
    flex-shrink: 0;
}

.account-stats,
.positions-summary,
.llm-metrics {
    padding: var(--space-md) var(--space-lg);
}

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

.stat-row:last-child {
    border-bottom: none;
}

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

.stat-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.stat-value.pos,
.stat-value.stat-positive {
    color: var(--accent-green);
}

.stat-value.neg,
.stat-value.stat-negative {
    color: var(--accent-red);
}

.stat-value.neutral {
    color: var(--text-secondary);
}

.stat-mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* === Positions List === */
.positions-list {
    padding: 6px 10px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.empty-state {
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-muted);
    font-size: 12px;
}

.position-item {
    padding: 6px 10px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    border-left: 3px solid var(--border-default);
}

.position-item.long {
    border-left-color: var(--accent-green);
}

.position-item.short {
    border-left-color: var(--accent-red);
}

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

.position-symbol {
    font-weight: 600;
    font-size: 12px;
}

.position-side {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
}

.position-side.long {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.position-side.short {
    background: var(--accent-red-dim);
    color: var(--accent-red);
}

.position-details {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 10px;
}

.position-detail {
    display: flex;
    gap: 3px;
    align-items: center;
}

.position-detail .label {
    color: var(--text-tertiary);
    font-size: 10px;
}

.position-detail .value {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 10px;
}

/* === Bottom Section === */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    padding: 0 var(--space-lg) var(--space-lg);
    height: 390px;
    max-height: 45vh;
    flex-shrink: 1;
    overflow: hidden;
}

.panel-rankings,
.panel-trades,
.panel-decisions {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    height: 100%;
}

/* === Tables === */
.table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
    max-width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: auto;
    white-space: nowrap;
    max-width: 100%;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    backdrop-filter: blur(8px);
    padding: 10px 12px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: 1px solid var(--border-default);
}

.data-table th.text-right {
    text-align: right;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.data-table td.text-right {
    text-align: right;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--accent-primary-dim);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 24px !important;
}

/* Table value styles */
.val.pos {
    color: var(--accent-green);
}

.val.neg {
    color: var(--accent-red);
}

.val.neutral,
.val.warn {
    color: var(--accent-yellow);
}

.cell-na {
    color: var(--text-muted);
}

/* Action badges in tables */
.action-buy,
.action-long {
    color: var(--accent-green);
    font-weight: 600;
}

.action-sell,
.action-short {
    color: var(--accent-red);
    font-weight: 600;
}

.action-hold,
.action-wait {
    color: var(--text-tertiary);
}

/* === Filter Selects === */
.filter-select {
    padding: 4px 8px;
    font-size: 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

/* === Ranking Summary === */
.ranking-summary {
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    gap: var(--space-lg);
}

/* === Modal === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
}

.modal-content {
    position: relative;
    background: var(--grad-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 40px var(--accent-primary-dim);
    animation: modal-in 320ms var(--ease-spring);
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--grad-line-full);
    opacity: 0.7;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-content.modal-xlarge {
    max-width: 900px;
    width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.modal-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.settings-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

/* === Settings Tabs === */
.settings-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-sm);
    overflow-x: auto;
    scrollbar-width: thin;
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-sm) var(--space-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.settings-tab .icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--accent-primary-dim);
}

.settings-tab:hover .icon {
    opacity: 1;
}

.settings-tab.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    box-shadow: inset 0 -2px 0 var(--accent-blue);
}

.settings-tab.active .icon {
    opacity: 1;
    filter: drop-shadow(0 0 4px var(--accent-blue-glow));
}

.settings-tab-content {
    display: none;
    animation: settingsTabIn 120ms ease;
}

.settings-tab-content.active {
    display: block;
}

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

/* === Settings Sections === */
.settings-section {
    margin-bottom: var(--space-xl);
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.settings-hint {
    margin-top: var(--space-xs);
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
}

.login-error {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-red-dim);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-sm);
    color: var(--accent-red);
    font-size: 12px;
}

/* === Strategy Profile Form === */
.strategy-section {
    margin-bottom: var(--space-xl);
}

.strategy-section:last-child {
    margin-bottom: 0;
}

.strategy-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.strategy-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    padding: 4px var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.strategy-row:hover {
    background: var(--bg-elevated);
}

.strategy-label {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
}

.strategy-input {
    width: 100px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: var(--font-mono);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-align: right;
}

.strategy-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.strategy-default {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    min-width: 60px;
}

.strategy-reset-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    transition: all var(--transition-fast);
}

.strategy-reset-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-default);
}

.strategy-weights-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm) var(--space-lg);
}

.strategy-weights-sum {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-secondary);
}

.strategy-weights-sum .sum-value {
    font-family: var(--font-mono);
    font-weight: 600;
}

.strategy-weights-sum .sum-value.valid {
    color: var(--accent-green);
}

.strategy-weights-sum .sum-value.invalid {
    color: var(--accent-red);
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-xl);
    animation: shimmer 1.8s var(--ease-in-out-quint) infinite;
}

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

/* Dynamic gradient line flow — GPU-only (background-position) */
@keyframes line-flow {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* === Form Controls === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

.textarea-lg {
    min-height: 200px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* === Buttons === */
.btn-primary {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    background: var(--grad-cyan);
    color: var(--bg-base);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-normal);
    position: relative;
    box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-blue-glow);
    transform: translateY(-1px);
}

/* === Config Tabs === */
.config-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-sm);
}

.config-tab {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.config-tab:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.config-tab.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
}

/* === Logs (hidden but kept for compatibility) === */
.log-entry {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 4px 8px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.log-time {
    color: var(--text-muted);
    margin-right: 8px;
}

/* === Value Tags (for compatibility) === */
.value-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.value-tag.bullish {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}

.value-tag.bearish {
    background: var(--accent-red-dim);
    color: var(--accent-red);
}

.value-tag.neutral {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

/* === Responsive === */

/* Low height screens (Windows PCs with low resolution) */
@media (max-height: 800px) {
    :root {
        --space-lg: 10px;
        --space-md: 6px;
        --space-sm: 3px;
    }
    body {
        font-size: 13px;
    }
    .topbar {
        height: 40px;
        padding: 0 10px;
    }
    .symbol-price-item {
        padding: 2px 5px;
        font-size: 10px;
    }
    .symbol-price-item .symbol-name {
        font-size: 9px;
    }
    .symbol-price-item .coin-icon {
        width: 12px;
        height: 12px;
    }
    .account-bar {
        padding: 3px 10px;
        gap: 16px;
    }
    .account-bar-item {
        min-width: 75px;
    }
    .account-bar-label {
        font-size: 9px;
    }
    .account-bar-value {
        font-size: 13px;
    }
    .agent-status-bar {
        padding: 3px 10px;
    }
    .agent-status-bar .agent-badge {
        font-size: 6px;
        padding: 1px 3px;
    }
    .main-content {
        padding: 6px;
        gap: 6px;
        min-height: 350px;
    }
    .bottom-section {
        height: 240px;
        max-height: 32vh;
        padding: 0 6px 6px;
        gap: 6px;
    }
    .panel-header h2 {
        font-size: 13px;
    }
    .data-table {
        font-size: 10px;
    }
    .data-table th,
    .data-table td {
        padding: 3px 6px;
    }
    .chat-bubble {
        padding: 5px 8px;
        margin-bottom: 4px;
        font-size: 11px;
    }
    .chat-bubble .chat-agent-name {
        font-size: 10px;
    }
    .chat-bubble .chat-content {
        font-size: 11px;
    }
    .position-item {
        padding: 4px 8px;
        margin-bottom: 3px;
    }
    .pnl-timeframe-tabs .tf-tab {
        padding: 2px 6px;
        font-size: 10px;
    }
}

@media (max-height: 650px) {
    :root {
        --space-lg: 8px;
        --space-md: 4px;
        --space-sm: 2px;
    }
    body {
        font-size: 12px;
    }
    .topbar {
        height: 36px;
        padding: 0 8px;
    }
    .symbol-price-item {
        padding: 1px 4px;
        font-size: 9px;
    }
    .account-bar {
        padding: 2px 8px;
        gap: 12px;
    }
    .account-bar-item {
        min-width: 65px;
    }
    .account-bar-label {
        font-size: 8px;
    }
    .account-bar-value {
        font-size: 12px;
    }
    .agent-status-bar {
        padding: 2px 8px;
    }
    .main-content {
        padding: 4px;
        gap: 4px;
        min-height: 280px;
    }
    .bottom-section {
        height: 180px;
        max-height: 28vh;
        padding: 0 4px 4px;
        gap: 4px;
    }
    .panel-header h2 {
        font-size: 12px;
    }
    .data-table {
        font-size: 9px;
    }
    .data-table th,
    .data-table td {
        padding: 2px 4px;
    }
    .chat-bubble {
        padding: 4px 6px;
        margin-bottom: 3px;
        font-size: 10px;
    }
    .chat-bubble .chat-agent-name {
        font-size: 9px;
    }
    .chat-bubble .chat-content {
        font-size: 10px;
    }
    .position-item {
        padding: 3px 6px;
        margin-bottom: 2px;
    }
    .pnl-timeframe-tabs .tf-tab {
        padding: 1px 5px;
        font-size: 9px;
    }
}

@media (max-width: 1400px) {
    .bottom-section {
        grid-template-columns: 240px 1fr 1fr;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 2fr 1fr;
    }
    
    .bottom-section {
        grid-template-columns: 1fr 1fr;
        height: auto;
    }
    
    .panel-rankings {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    .panel-team-chart {
        grid-column: auto;
    }
    
    .column-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .column-sidebar .panel {
        flex: 1;
        min-width: 250px;
    }
    
    .bottom-section {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: var(--space-md);
    }
    
    .topbar-center {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: var(--space-md);
    }
}

/* === Animations (minimal for performance) === */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.panel {
    animation: fade-in 200ms ease;
}

/* === Utility Classes === */
.text-right {
    text-align: right;
}

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

.hidden {
    display: none !important;
}

/* === Team Selector === */
.team-select {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    margin-left: var(--space-sm);
    min-width: 120px;
}

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

/* === Teams Management === */
.teams-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.teams-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.team-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    transition: all var(--transition-fast);
}

.team-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.team-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
}

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

.team-card-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-surface);
}

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

.team-status-dot.active {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

.team-status-dot.inactive {
    background: var(--text-muted);
}

.team-card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.team-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm);
    background: var(--bg-surface);
}

.team-stat-label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.team-stat-value {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 12px;
}

.team-stat-value.positive {
    color: var(--accent-green);
}

.team-stat-value.negative {
    color: var(--accent-red);
}

.team-card-actions {
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
}

.team-card-actions button {
    padding: 4px 10px;
    font-size: 11px;
}

.teams-summary {
    margin-top: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

@media (max-width: 600px) {
    .team-card-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Leaderboard === */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.leaderboard-table th {
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-table tr:hover {
    background: var(--bg-elevated);
}

.leaderboard-rank {
    font-weight: 600;
    width: 40px;
}

.leaderboard-rank.gold {
    color: #ffd700;
}

.leaderboard-rank.silver {
    color: #c0c0c0;
}

.leaderboard-rank.bronze {
    color: #cd7f32;
}

/* === Trade/Decision Tabs === */
.panel-tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--space-md);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.panel-tab {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.panel-tab:hover {
    color: var(--text-primary);
}

.panel-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

/* === Backtest Modal Styles === */

/* Compact modal for backtest */
/* Backtest content now lives inside the Settings tab-backtest panel.
   The old .modal-backtest sizing rules are no longer needed. */
.backtest-modal-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* Live Status Indicator */
.live-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-overlay);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    align-self: flex-end;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.running {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
}

.status-dot.paused {
    background: var(--accent-yellow);
    box-shadow: 0 0 8px var(--accent-yellow-glow);
    animation: none;
}

.status-dot.stopped {
    background: var(--text-secondary);
    animation: none;
}

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

.live-status-text {
    color: var(--text-secondary);
}

.live-status-text.running {
    color: var(--accent-green);
}

.live-status-text.paused {
    color: var(--accent-yellow);
}

/* Backtest Form */
.backtest-form {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
}

.form-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

/* Backtest config row (Start/End/Capital/Step) */
.backtest-config-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
}

.backtest-config-field {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.backtest-config-field label {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.backtest-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.backtest-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

@media (max-width: 600px) {
    .backtest-config-field {
        min-width: 100%;
    }
}

/* Note: .form-group base styles defined earlier (see "=== Form Controls ===" section).
   The duplicate below used undefined vars (--bg-secondary, --panel-border) and was
   removed to prevent it from overriding the correct definitions. */

/* Run/Stop Buttons */
.run-btn {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-primary));
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--accent-primary-glow);
}

.run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.stop-btn {
    background: linear-gradient(135deg, var(--accent-red), var(--accent-red));
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--accent-red-glow);
}

.stop-btn.visible {
    display: inline-flex !important;
}

.stop-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-red-glow);
}

.stop-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Progress Section */
.progress-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    display: none;
}

.progress-section.active {
    display: block;
}

.progress-bar-container {
    background: var(--bg-surface);
    border-radius: 10px;
    height: 16px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-primary));
    border-radius: 10px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Realtime Metrics */
.realtime-metrics {
    background: var(--accent-primary-dim);
    border-radius: 8px;
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.realtime-metrics .metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.realtime-metrics .metric-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.realtime-metrics .metric-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.realtime-metrics .metric-value.positive {
    color: var(--accent-green) !important;
}

.realtime-metrics .metric-value.negative {
    color: var(--accent-red) !important;
}

/* Live Charts */
.live-chart-container,
.live-trades-container {
    background: var(--accent-primary-dim);
    border: 1px solid var(--accent-primary-dim);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    display: none;
}

.live-chart-container {
    height: 220px;
    position: relative;
}

.live-chart-container canvas {
    max-height: 180px !important;
    width: 100% !important;
}

#liveDrawdownContainer {
    background: var(--accent-red-dim);
    border: 1px solid var(--accent-red-dim);
}

.live-chart-container h4,
.live-trades-container h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Results Section */
.results-section {
    display: none;
    margin-top: 20px;
}

.results-section.active {
    display: block;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
}

.metric-card h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

.metric-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.metric-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.metric-value.positive {
    color: var(--accent-green);
}

.metric-value.negative {
    color: var(--accent-red);
}

/* Charts */
.chart-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.chart-card h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.chart-wrapper {
    position: relative;
    height: 250px;
}

/* Trades Table */
.trades-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
}

.trades-card h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trades-table th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    border-bottom: 2px solid var(--border-subtle);
}

.trades-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.trades-table tr:hover {
    background: var(--accent-primary-dim);
}

.side-long {
    color: var(--accent-green);
    font-weight: 600;
}

.side-short {
    color: var(--accent-red);
    font-weight: 600;
}

.trade-long {
    color: var(--accent-green);
    font-weight: 600;
}

.trade-short {
    color: var(--accent-red);
    font-weight: 600;
}

/* History Section */
.history-section {
    margin-top: 20px;
}

.history-title {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-list {
    display: grid;
    gap: 12px;
}

.history-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: var(--accent-blue);
}

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

.history-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-info .symbol {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.history-info .run-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-detail-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.history-info .period {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-info .config {
    font-size: 0.75rem;
    color: var(--accent-blue);
}

.history-stats {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
    margin-top: 6px;
}

.history-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 60px;
    text-align: center;
}

.history-stat .label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-stat .value {
    font-weight: 700;
    font-size: 0.9rem;
}

.history-stat .value.positive {
    color: var(--accent-green);
}

.history-stat .value.negative {
    color: var(--accent-red);
}

/* Quick Select Buttons */
.quick-btn {
    background: var(--accent-primary-dim);
    border: 1px solid var(--accent-primary-glow);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: var(--accent-primary-glow);
    border-color: var(--accent-primary-glow);
}

/* Symbol Checkboxes */
.symbol-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--hairline);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.symbol-checkbox:hover {
    background: var(--accent-primary-dim);
    border-color: var(--accent-primary-glow);
}

.symbol-checkbox input:checked+span,
.symbol-checkbox:has(input:checked) {
    background: var(--accent-primary-dim);
    border-color: var(--accent-blue);
}

.symbol-checkbox.major:has(input:checked) {
    background: var(--accent-yellow-dim);
    border-color: var(--accent-yellow);
}

.symbol-checkbox.ai500:has(input:checked) {
    background: var(--accent-green-dim);
    border-color: var(--accent-green);
}

.symbol-checkbox.alts:has(input:checked) {
    background: var(--accent-primary-dim);
    border-color: var(--accent-primary);
}

/* Tab Navigation */
.backtest-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--bg-surface);
    border-radius: 8px;
}

.backtest-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
}

.backtest-tab:hover {
    color: var(--text-primary);
    background: var(--hairline);
}

.backtest-tab.active {
    color: var(--text-primary);
    background: var(--accent-blue);
    box-shadow: 0 2px 8px var(--accent-primary-glow);
}

.backtest-tab .tab-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--hairline-strong);
    font-weight: 600;
    min-width: 45px;
    text-align: center;
}

.backtest-tab.active .tab-status {
    background: var(--hairline-strong);
}

.backtest-tab .tab-status.running {
    background: var(--accent-yellow-glow);
    color: var(--accent-yellow);
    animation: pulse 2s ease-in-out infinite;
}

.backtest-tab .tab-status.completed {
    background: var(--accent-green-glow);
    color: var(--accent-green);
}

.backtest-tab .tab-close {
    font-size: 0.9rem;
    opacity: 0.5;
    margin-left: 4px;
    padding: 2px 4px;
    border-radius: 4px;
}

.backtest-tab .tab-close:hover {
    opacity: 1;
    background: var(--accent-red-dim);
    color: var(--accent-red);
}

.add-tab-btn {
    padding: 8px 12px;
    background: transparent;
    border: 1px dashed var(--text-secondary);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-left: 4px;
    transition: all 0.2s;
}

.add-tab-btn:hover {
    background: var(--hairline);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

/* Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* === SVG Icon System === */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}

.icon-sm {
    width: 14px;
    height: 14px;
}

.icon-md {
    width: 18px;
    height: 18px;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

.icon-xl {
    width: 32px;
    height: 32px;
}

/* Icon color variants */
.icon-success {
    color: var(--accent-green);
}

.icon-danger {
    color: var(--accent-red);
}

.icon-warning {
    color: var(--accent-yellow);
}

.icon-info {
    color: var(--accent-blue);
}

.icon-muted {
    color: var(--text-secondary);
}

/* Icon in buttons */
button .icon,
.btn .icon {
    margin-right: 0.25em;
}

/* Icon in nav */
.topbar .icon {
    vertical-align: middle;
}

/* Icon animation */
@keyframes icon-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.icon-spin {
    animation: icon-spin 1s linear infinite;
}

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

.icon-pulse {
    animation: icon-pulse 2s ease-in-out infinite;
}

/* === Account Bar (Horizontal) === */
.account-bar {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    flex-shrink: 0;
}

.account-bar-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100px;
}

.account-bar-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.8px;
}

.account-bar-value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    text-shadow: 0 0 12px var(--hairline-strong);
}

.account-bar-value.neutral {
    color: var(--text-secondary);
}

.account-bar-value.positive {
    color: var(--accent-green);
    text-shadow: 0 0 12px var(--accent-green-dim);
}

.account-bar-value.negative {
    color: var(--accent-red);
    text-shadow: 0 0 12px var(--accent-red-dim);
}

/* === Chatroom Team Tabs === */
.chatroom-tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--space-md);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}

.chatroom-tabs::-webkit-scrollbar {
    height: 4px;
}

.chatroom-tabs::-webkit-scrollbar-track {
    background: var(--bg-elevated);
}

.chatroom-tabs::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-primary-glow), var(--accent-yellow-dim));
    border-radius: 2px;
}

.chatroom-tab {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatroom-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.chatroom-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.chatroom-tab .tab-label {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatroom-tab .tab-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    flex-shrink: 0;
}

.chatroom-tab .tab-indicator.inactive {
    background: var(--text-muted);
}

/* === Right Panel with Tabs === */
.panel-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.right-panel-tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--space-md);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.right-tab {
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.right-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.right-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.right-tab .count-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border-radius: 10px;
    font-weight: 600;
}

.right-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

.right-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* === Bottom Tab Content (merged Rankings/Decisions/Positions panel) === */
.bottom-tab-content {
    display: none;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
}

.bottom-tab-content.active {
    display: block !important;
}

/* === Adjust Bottom Section to 2 columns === */
.bottom-section {
    grid-template-columns: 1fr 1fr;
}

/* Remove old sidebar styles */
.column-sidebar {
    display: none;
}

/* === Responsive Adjustments === */
@media (max-width: 1400px) {
    .account-bar {
        gap: var(--space-lg);
    }
    
    .account-bar-item {
        min-width: 80px;
    }
    
    .account-bar-value {
        font-size: 14px;
    }
}

@media (max-width: 1200px) {
    .bottom-section {
        grid-template-columns: 1fr;
        max-height: none;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .account-bar {
        flex-wrap: wrap;
        gap: var(--space-md);
    }
    
    .account-bar-item {
        flex: 1 1 calc(33.33% - var(--space-md));
        min-width: 100px;
    }
}

/* === Agent Config in Settings === */
.agent-config-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 420px;
}

.agent-config-tabs {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    padding: var(--space-sm);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.agent-config-tab {
    padding: var(--space-sm) var(--space-md);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.agent-config-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.agent-config-tab.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    border-color: var(--accent-blue);
}

.agent-config-tab.is-disabled {
    opacity: 0.55;
}

.agent-tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--transition-fast);
}

.agent-tab-dot.on {
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green-glow);
}

.agent-tab-label {
    font-size: 12px;
}

.agent-config-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border-left: 2px solid var(--accent-blue);
    border-radius: var(--radius-sm);
}

.agent-config-count {
    margin-left: var(--space-xs);
    padding: 1px 7px;
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.agent-config-panel {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    max-height: 52vh;
}

.agent-config-section {
    margin-bottom: var(--space-lg);
}

.agent-config-section:last-child {
    margin-bottom: 0;
}

.agent-config-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

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

.agent-config-row:last-child {
    border-bottom: none;
}

.agent-config-row-params,
.agent-config-row-prompt {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
}

.agent-config-row-params > label,
.agent-config-row-prompt > label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agent-config-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    margin-bottom: var(--space-md);
}

.agent-config-toggle-row label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.agent-config-toggle-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

.agent-config-panel textarea[data-field="system_prompt"] {
    width: 100%;
    min-height: 140px;
    max-height: 220px;
    padding: var(--space-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    resize: vertical;
    line-height: 1.5;
}

.agent-config-panel textarea[data-field="system_prompt"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.agent-config-param-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm) var(--space-md);
    margin-top: var(--space-xs);
}

.agent-config-param-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.agent-config-param-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agent-config-param-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.agent-config-param-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-blue);
    font-family: var(--font-mono);
}

.agent-config-param-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.agent-config-param-controls input[type="range"] {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.agent-config-param-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
}

.agent-config-param-controls input[type="number"] {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.agent-config-param-controls input[type="number"]:focus,
.agent-config-param-item input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.agent-config-param-item input[type="text"] {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.agent-config-param-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

.agent-config-param-inline {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.agent-config-param-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: var(--space-lg);
    grid-column: 1 / -1;
}

.agent-config-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

@media (max-width: 720px) {
    .agent-config-param-list {
        grid-template-columns: 1fr;
    }
}

/* Toast notification */
#agent-config-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    z-index: 10000;
    box-shadow: 0 4px 12px var(--bg-overlay);
}

#agent-config-toast.success {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

#agent-config-toast.error {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

#agent-config-toast.info {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* === LLM Info Bar in Settings === */
.llm-info-bar {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, var(--accent-primary-dim), var(--accent-yellow-dim), transparent 70%);
    border: 1px solid var(--accent-yellow-dim);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    align-items: center;
}

.llm-info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 100px;
}

.llm-info-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.llm-info-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.llm-badge-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* === AIF Logo === */
.logo-image {
    height: 32px;
    width: auto;
    display: block;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* === Team Performance Cards === */
.team-performance-cards {
    display: flex;
    gap: var(--space-sm);
    margin-left: auto;
    padding-left: var(--space-lg);
    border-left: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.team-performance-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    min-width: 90px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.team-performance-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.team-performance-card.active {
    border-color: var(--accent-blue);
    background: var(--accent-blue-dim);
}

.team-card-name {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.team-card-values {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.team-pnl {
    font-family: var(--font-mono);
    font-weight: 700;
    white-space: nowrap;
}

.team-pnl.large {
    font-size: 14px;
}

.team-pct {
    font-family: var(--font-mono);
    font-weight: 600;
    white-space: nowrap;
}

.team-pct.small {
    font-size: 10px;
}

/* Color states */
.team-pnl.positive,
.team-pct.positive {
    color: var(--accent-green);
}

.team-pnl.negative,
.team-pct.negative {
    color: var(--accent-red);
}

.team-pnl.neutral,
.team-pct.neutral {
    color: var(--text-secondary);
}

/* === Trading Tab in Settings === */
.trading-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.trading-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.trading-field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.form-control-sm {
    width: auto;
    min-width: 140px;
    padding: 8px 12px;
    font-size: 13px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.form-control-sm:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.mode-toggle-inline {
    display: inline-flex;
    gap: var(--space-xs);
    padding: 3px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.mode-toggle-inline .mode-btn {
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.mode-toggle-inline .mode-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.mode-toggle-inline .mode-btn.active {
    background: var(--grad-cyan);
    color: var(--bg-base);
    box-shadow: 0 0 12px var(--accent-blue-glow);
}

.control-buttons-inline {
    display: inline-flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.control-buttons-inline .ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    height: auto;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
}

.control-buttons-inline .ctrl-btn:hover {
    transform: translateY(-1px);
}

.control-buttons-inline .ctrl-start {
    border-color: var(--accent-green-glow);
    color: var(--accent-green);
}

.control-buttons-inline .ctrl-start:hover {
    background: var(--accent-green-dim);
    box-shadow: 0 0 16px var(--accent-green-dim);
}

.control-buttons-inline .ctrl-pause {
    border-color: var(--accent-yellow-glow);
    color: var(--accent-yellow);
}

.control-buttons-inline .ctrl-pause:hover {
    background: var(--accent-yellow-dim);
    box-shadow: 0 0 16px var(--accent-yellow-dim);
}

.control-buttons-inline .ctrl-stop {
    border-color: var(--accent-red-glow);
    color: var(--accent-red);
}

.control-buttons-inline .ctrl-stop:hover {
    background: var(--accent-red-dim);
}

.trading-status-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border-subtle);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-md) var(--space-sm);
    background: var(--bg-elevated);
    min-width: 0;
}

.status-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-value {
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {
    .trading-status-info {
        grid-template-columns: repeat(2, 1fr);
    }
    .trading-field {
        justify-content: flex-start;
    }
}

/* Remove old topbar controls styles */
.topbar .mode-toggle,
.topbar .controls,
.topbar .interval-select,
.topbar .status-pills {
    display: none;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    /* Allow page to scroll on mobile */
    body {
        overflow: auto;
        min-height: 100vh;
        height: auto;
    }

    /* Global smaller fonts but more spacing between panels */
    :root {
        --space-lg: 10px;
        --space-md: 6px;
        --space-sm: 3px;
    }
    body {
        font-size: 12px;
    }

    /* Topbar: compact */
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 6px 10px;
        gap: 6px;
    }
    .topbar-center {
        order: 3;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
    }
    .symbol-prices {
        gap: 3px;
    }
    .symbol-price-item {
        padding: 2px 5px;
        font-size: 9px;
    }
    .symbol-price-item .coin-icon {
        width: 11px;
        height: 11px;
    }
    .symbol-price-item .symbol-name {
        font-size: 8px;
    }

    /* Account bar: compact + scroll */
    .account-bar {
        overflow-x: auto;
        gap: 10px;
        padding: 5px 10px;
        margin-bottom: 2px;
    }
    .account-bar-item {
        min-width: 65px;
        flex-shrink: 0;
    }
    .account-bar-label {
        font-size: 8px;
    }
    .account-bar-value {
        font-size: 12px;
    }

    /* Agent status bar: force strictly horizontal, scrollable */
    .agent-status-bar {
        overflow-x: auto;
        overflow-y: hidden;
        gap: 3px;
        padding: 3px 10px;
        margin-bottom: 4px;
        white-space: nowrap;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
    }
    .agent-status-bar .agent-status-group {
        display: inline-flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
        flex-shrink: 0;
        align-items: center;
    }
    .agent-status-bar .agent-status-label {
        white-space: nowrap !important;
        font-size: 8px;
        flex-shrink: 0;
    }
    .agent-status-bar .agent-status-dot {
        display: inline-flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
        flex-shrink: 0;
        align-items: center;
    }
    .agent-status-bar .dot-label {
        white-space: nowrap !important;
        font-size: 9px;
        flex-shrink: 0;
    }
    .agent-status-bar .agent-badge {
        font-size: 6px;
        padding: 1px 3px;
        white-space: nowrap !important;
        flex-shrink: 0;
    }
    .agent-status-bar .agent-status-sep {
        flex-shrink: 0;
        white-space: nowrap !important;
    }

    /* Main content: single column, auto height, scrollable */
    .main-content {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 14px;
        flex: 0 0 auto;
        overflow: visible;
        height: auto;
        min-height: 0;
    }
    .main-content > .panel {
        min-height: 180px;
        height: auto;
        overflow: visible;
        margin-bottom: 4px;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        padding-bottom: 8px;
    }

    /* PnL chart: taller on mobile */
    .main-content > .panel.panel-team-chart {
        min-height: 300px;
        height: 300px;
    }
    .team-pnl-chart-wrapper {
        min-height: 200px;
    }
    /* Chart legend: single line, scrollable on mobile */
    .team-pnl-chart-wrapper canvas {
        max-width: 100%;
    }

    /* Chatroom: 1.5x taller on mobile */
    .main-content > .panel.panel-chatroom {
        min-height: 525px;
        height: 525px;
    }
    .panel-chatroom .chatroom-container {
        flex: 1 1 0;
        min-height: 0;
    }
    .panel-chatroom .chatroom-messages {
        flex: 1 1 0;
        min-height: 400px;
        overflow-y: auto;
    }
    .chatroom-messages {
        overflow-y: auto;
    }

    /* Bottom section: single column, auto height */
    .bottom-section {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        padding: 0 10px 10px;
        gap: 14px;
        flex-shrink: 0;
    }
    .panel-rankings,
    .panel-trades {
        min-height: 180px;
        max-height: 300px;
        overflow: hidden;
        border: 1px solid var(--border-subtle);
        border-radius: var(--radius-md);
        padding-bottom: 4px;
    }

    /* Tables: smaller */
    .data-table {
        font-size: 9px;
    }
    .data-table th,
    .data-table td {
        padding: 3px 5px;
    }

    /* Chatroom tabs: scrollable */
    .chatroom-tabs {
        overflow-x: auto;
        gap: 3px;
    }
    .chatroom-tab {
        padding: 3px 7px;
        font-size: 9px;
        white-space: nowrap;
    }

    /* Chat bubbles: compact */
    .chat-bubble {
        padding: 5px 8px;
        margin-bottom: 4px;
        font-size: 10px;
    }
    .chat-bubble .chat-agent-name {
        font-size: 9px;
    }
    .chat-bubble .chat-content {
        font-size: 10px;
    }

    /* Position cards: compact */
    .position-item {
        padding: 3px 6px;
        margin-bottom: 3px;
    }
    .position-details {
        gap: 6px;
        font-size: 8px;
    }

    /* Modal: full width */
    .modal-content {
        width: 96vw;
        max-width: 96vw;
        max-height: 92vh;
    }
    .modal-content.modal-xlarge {
        width: 96vw;
        max-width: 96vw;
    }

    /* Settings tabs: scrollable */
    .settings-tabs {
        overflow-x: auto;
        gap: 2px;
    }
    .settings-tab {
        padding: 5px 8px;
        font-size: 10px;
        white-space: nowrap;
    }

    /* Form controls: full width */
    .form-control {
        width: 100%;
        font-size: 12px;
    }
    .form-control-sm {
        width: 100%;
        min-width: 0;
        font-size: 11px;
    }

    /* Demo team rows: stack vertically */
    .demo-team-row {
        flex-direction: column !important;
        gap: 3px !important;
    }
    .demo-team-row .form-group {
        min-width: 100% !important;
    }

    /* PnL timeframe tabs: smaller */
    .pnl-timeframe-tabs .tf-tab {
        padding: 2px 5px;
        font-size: 9px;
    }

    /* Team performance cards: smaller on mobile */
    .team-performance-cards {
        gap: 3px;
        padding-left: 6px;
    }
    .team-performance-card {
        min-width: 65px;
        padding: 2px 4px;
        gap: 1px;
    }
    .team-card-name {
        font-size: 7px;
        max-width: 60px;
    }
    .team-pnl.large {
        font-size: 10px;
    }
    .team-pct.small {
        font-size: 8px;
    }

    /* Panel headers: smaller + clear separation */
    .panel-header {
        padding: 8px 10px;
        border-bottom: 1px solid var(--border-subtle);
        margin-bottom: 4px;
    }
    .panel-header h2 {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    body {
        font-size: 11px;
    }
    .topbar-center {
        display: none;
    }
    .account-bar {
        gap: 6px;
        padding: 3px 8px;
    }
    .account-bar-item {
        min-width: 55px;
    }
    .account-bar-value {
        font-size: 11px;
    }
    .account-bar-label {
        font-size: 7px;
    }
    .panel-header h2 {
        font-size: 11px;
    }
    .chat-bubble {
        padding: 4px 6px;
        font-size: 9px;
    }
    .chat-bubble .chat-agent-name {
        font-size: 8px;
    }
    .chat-bubble .chat-content {
        font-size: 9px;
    }
    .data-table {
        font-size: 8px;
    }
    .data-table th,
    .data-table td {
        padding: 2px 4px;
    }
    .position-details {
        font-size: 7px;
    }
    .pnl-timeframe-tabs .tf-tab {
        padding: 1px 4px;
        font-size: 8px;
    }
    .symbol-price-item {
        padding: 1px 3px;
        font-size: 8px;
    }
    .team-performance-card {
        min-width: 55px;
        padding: 1px 3px;
    }
    .team-card-name {
        font-size: 6px;
        max-width: 50px;
    }
    .team-pnl.large {
        font-size: 9px;
    }
    .team-pct.small {
        font-size: 7px;
    }
}


/* ============================================================
   QCAi Components — card anatomy, hero figure, stat grid
   ============================================================ */

/* --- Circuit-board decorative background --- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill='none' stroke='%23ddd8d0' stroke-width='1'%3E%3Crect x='24' y='28' width='92' height='72' rx='16'/%3E%3Crect x='56' y='60' width='92' height='72' rx='16'/%3E%3Crect x='150' y='120' width='88' height='70' rx='16'/%3E%3Cpath d='M116 64 H150 V120'/%3E%3Cpath d='M102 132 V176 H150'/%3E%3Cpath d='M238 96 H210 V120'/%3E%3C/g%3E%3Cg fill='%23ddd8d0'%3E%3Crect x='21' y='25' width='6' height='6'/%3E%3Crect x='113' y='25' width='6' height='6'/%3E%3Crect x='147' y='117' width='6' height='6'/%3E%3Crect x='235' y='187' width='6' height='6'/%3E%3Crect x='99' y='173' width='6' height='6'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 260px 260px;
}
:root[data-theme="dark"] body::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260' viewBox='0 0 260 260'%3E%3Cg fill='none' stroke='%232a2a2c' stroke-width='1'%3E%3Crect x='24' y='28' width='92' height='72' rx='16'/%3E%3Crect x='56' y='60' width='92' height='72' rx='16'/%3E%3Crect x='150' y='120' width='88' height='70' rx='16'/%3E%3Cpath d='M116 64 H150 V120'/%3E%3Cpath d='M102 132 V176 H150'/%3E%3Cpath d='M238 96 H210 V120'/%3E%3C/g%3E%3Cg fill='%232a2a2c'%3E%3Crect x='21' y='25' width='6' height='6'/%3E%3Crect x='113' y='25' width='6' height='6'/%3E%3Crect x='147' y='117' width='6' height='6'/%3E%3Crect x='235' y='187' width='6' height='6'/%3E%3Crect x='99' y='173' width='6' height='6'/%3E%3C/g%3E%3C/svg%3E");
}

/* --- Base card --- */
.qc-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--sp-5);
    position: relative;
    z-index: 1;
}

/* --- Hero figure card --- */
.hero-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: var(--sp-5);
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.hero-label {
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0;
    text-transform: none;
}
.hero-label-row .icon {
    width: 15px;
    height: 15px;
    color: var(--text-tertiary);
}

.hero-figure {
    font-family: var(--font-display);
    font-size: var(--fs-hero);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.022em;
    color: var(--hero);
    font-variant-numeric: tabular-nums;
    margin-top: -2px;
}
.hero-unit {
    font-family: var(--font-sans);
    font-size: var(--fs-unit);
    font-weight: 400;
    color: var(--text-tertiary);
    margin-top: -12px;
}

.hero-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

/* --- Stat grid (2 cols, label above value) --- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 22px;
    column-gap: 24px;
}
.stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}
.stat-label {
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.2;
}
.stat-value {
    font-family: var(--font-display);
    font-size: var(--fs-value);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.012em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.stat-value.positive { color: var(--accent-green); }
.stat-value.negative { color: var(--accent-red); }
.stat-value.muted    { color: var(--text-tertiary); }

/* --- Card header (icon block + title/desc + arrow) --- */
.qc-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
}
.qc-icon-block {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}
.qc-icon-block .icon { width: 20px; height: 20px; }
.qc-card-title {
    font-family: var(--font-sans);
    font-size: var(--fs-section);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.012em;
    line-height: 1.25;
}
.qc-card-desc {
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 2px;
}
.qc-card-arrow {
    margin-left: auto;
    flex: none;
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

/* ============================================================
   B1 — Topbar rebuild (kills the dark band)
   ============================================================ */
.topbar {
    height: 60px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 20px;
}
.topbar::after { display: none; }
.logo {
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    -webkit-text-fill-color: currentColor;
    color: var(--text-primary);
}
.symbol-price-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 5px 10px;
    font-family: var(--font-sans);
    font-size: 12px;
}
.symbol-price-item:hover {
    background: var(--bg-surface);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

/* --- Theme toggle --- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--accent-primary);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--accent-primary);
    cursor: pointer;
    transition: var(--transition-fast);
    flex: none;
}
.theme-toggle:hover {
    background: var(--accent-primary-dim);
    box-shadow: var(--shadow-glow);
}
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ============================================================
   B2 — account-bar becomes the hero card
   ============================================================ */
.account-bar {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    padding: 20px 20px 4px;
    display: block;
    overflow: visible;
}
.hero-card .stat-grid { margin-top: 2px; }
.team-performance-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 0;
    border-left: none;
}
.team-performance-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

/* JS-driven state classes (setColorState / setPnlClass use pos|neg|neutral) */
.stat-value.pos, .stat-value.stat-positive { color: var(--accent-green); }
.stat-value.neg, .stat-value.stat-negative { color: var(--accent-red); }
.stat-value.neutral { color: var(--text-tertiary); }
.hero-figure.pos { color: var(--accent-green); }
.hero-figure.neg { color: var(--accent-red); }
.hero-figure.neutral { color: var(--hero); }

/* === B2 refinements (from screenshot review) === */
.account-bar {
    display: flex;
    align-items: flex-start;
    justify-content: stretch;
}
.hero-card {
    flex: 1 1 auto;
    align-self: start;
    height: fit-content;
}
.hero-unit {
    margin-top: 6px;
    letter-spacing: 0.04em;
}
.stat-value,
.stat-value.neutral {
    color: var(--text-primary);
}
.stat-value.pos, .stat-value.stat-positive { color: var(--accent-green); }
.stat-value.neg, .stat-value.stat-negative { color: var(--accent-red); }
.team-performance-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0 0;
    margin-left: 0 !important;
    padding: 0;
    border-left: none !important;
    justify-content: flex-start;
}
.team-performance-card {
    flex: 0 0 auto;
    width: 180px;
}

/* B2b: grid fills width, hero card is content-height */
.hero-card { flex: 0 1 auto; width: 100%; }
.stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    row-gap: 20px;
    column-gap: 28px;
}
.team-performance-cards { margin-top: 14px; }

/* B2c: stack hero card above team cards; tone down texture */
.account-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}
body::before { opacity: 0.42; }

/* ============================================================
   B3 — Agent pipeline: dark band -> white card + pill chips
   ============================================================ */
.agent-status-bar {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin: 14px 20px 0;
    padding: 12px 20px;
    gap: 6px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.agent-status-label {
    font-size: 10px;
    letter-spacing: 0.9px;
    color: var(--text-tertiary);
    margin-right: 4px;
}
.agent-status-sep {
    color: var(--text-muted);
    opacity: 0.55;
    margin: 0 4px;
}
.agent-status-dot {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 4px 11px 4px 8px;
    gap: 5px;
}
.agent-status-dot:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}
.agent-status-dot .dot {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    box-shadow: none;
}
.agent-status-dot .dot-label {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}
.agent-status-dot .agent-badge {
    font-family: var(--font-sans);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--bg-hover);
    color: var(--text-tertiary);
}
.agent-status-dot.dot-running {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}
.agent-status-dot.dot-running .dot {
    background: var(--accent-primary);
    box-shadow: none;
}
.agent-status-dot.dot-running .agent-badge {
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
}
.agent-status-dot.dot-completed {
    border-color: var(--accent-green-dim);
    background: var(--accent-green-dim);
}
.agent-status-dot.dot-completed .dot {
    background: var(--accent-green);
    box-shadow: none;
}
.agent-status-dot.dot-completed .agent-badge {
    background: var(--accent-green-dim);
    color: var(--accent-green);
}
.agent-status-cycle {
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
    border-radius: 999px;
}

/* ============================================================
   B4/B5 — panels, chart cards, tab strips, table headers
   ============================================================ */
.panel {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.panel::before { display: none; }
.panel-header {
    background: transparent;
    border-bottom: 1px solid var(--border-subtle);
    padding: 18px 22px;
}
.panel-header h2 {
    font-family: var(--font-sans);
    font-size: var(--fs-section);
    font-weight: 700;
    letter-spacing: -0.012em;
    color: var(--text-primary);
}
.panel-header h2 svg {
    color: var(--accent-primary);
    filter: none;
}

/* timeframe pill */
.pnl-timeframe-tabs {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.pnl-timeframe-tabs .tf-tab {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 5px 13px;
    border-radius: 999px;
}
.pnl-timeframe-tabs .tf-tab:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.pnl-timeframe-tabs .tf-tab.active {
    background: var(--accent-primary);
    color: var(--bg-surface);
    box-shadow: none;
}

/* table headers — kill the dark navy band */
.data-table th {
    background: var(--bg-elevated);
    backdrop-filter: none;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.5px;
    padding: 11px 14px;
}
.data-table td {
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 10px 14px;
}
.data-table tbody tr:hover { background: var(--bg-hover); }

.trades-table th {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.5px;
}
.trades-table td {
    color: var(--text-primary);
    font-family: var(--font-sans);
}
.trades-table tr:hover { background: var(--bg-hover); }

/* generic tab strips (All Teams / Team Alpha etc.) */
.tabs-bar, .team-tabs, .chat-tabs {
    background: transparent !important;
    border: none !important;
}

/* ============================================================
   Screenshot review fixes
   ============================================================ */

/* (1) language selector — was browser-default dark control */
.lang-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    border: 1px solid var(--border-default);
    border-radius: 999px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 34px 8px 16px;
    cursor: pointer;
    transition: border-color 150ms;
}
.lang-select:hover { border-color: var(--accent-primary); }
.lang-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

/* (2) hero card — tighten internal rhythm */
.hero-card { gap: 14px; padding: 26px 28px 28px; }
.hero-figure { margin-top: 0; }
.hero-unit { margin-top: 2px; }
.hero-divider { margin: 6px 0 2px; }
.stat-grid { margin-top: 4px; row-gap: 18px; }

/* (3) stat grid — cap column width so 5 cols don't sprawl */
.stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    max-width: 1100px;
    column-gap: 24px;
}

/* (5) kill any residual tinted band on panels */
.panel, .panel::before, .panel::after { background-image: none; }
.panel::before, .panel::after { display: none !important; }
.panel-header { background: transparent !important; }
.team-pnl-chart-wrapper, .chart-wrapper, .live-chart-container { background: transparent; }

/* (4) team performance card — QCai card language */
.team-performance-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 16px 18px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: border-color 150ms, box-shadow 150ms;
    width: 200px;
}
.team-performance-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}
.team-performance-card.active {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}
.team-card-name {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.team-card-values {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.team-pnl {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.012em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.team-pnl.large { font-size: 19px; }
.team-pnl.positive { color: var(--accent-green); }
.team-pnl.negative { color: var(--accent-red); }
.team-pnl.neutral  { color: var(--text-primary); }
.team-pct {
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}
.team-pct.positive { color: var(--accent-green); }
.team-pct.negative { color: var(--accent-red); }

/* ============================================================
   Layout fixes — from box measurements + full-page screenshot
   ============================================================ */

/* FIX 3: content reachability — page must scroll, panels must not clip */
body {
    overflow-x: hidden;
    overflow-y: auto;
}
.main-content {
    overflow: visible;
    flex: 0 0 auto;
    min-height: 0;
}
.bottom-section {
    height: auto;
    min-height: 360px;
    max-height: none;
    overflow: visible;
    flex-shrink: 0;
}

/* FIX 1: hero stat row fills card width — 5 equal columns + hairline dividers
   (echoes QCai's "Pending Earnings" 3-column footer row, scaled to 5) */
.stat-grid {
    grid-template-columns: repeat(5, 1fr);
    column-gap: 0;
    row-gap: 0;
    max-width: none;
    width: 100%;
}
.stat {
    padding: 2px 22px;
    min-width: 0;
}
.stat:first-child { padding-left: 0; }
.stat:last-child  { padding-right: 0; }
.stat + .stat { border-left: 1px solid var(--border-subtle); }

/* FIX 2: top region = hero card (left) + team performance card (right) */
.top-region {
    display: grid;
    grid-template-columns: 1.65fr 1fr;
    gap: 16px;
    align-items: start;
    width: 100%;
}
.top-region > .hero-card { width: auto; }
.team-panel {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.team-panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-sans);
    font-size: var(--fs-label);
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text-secondary);
}
.team-panel-title .icon {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}
.team-performance-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 !important;
    padding: 0;
    border-left: none !important;
}
.team-performance-card {
    width: 100% !important;
    flex: 0 0 auto;
}

/* ============================================================
   LAYOUT: restore original horizontal arrangement
   (QCai skin kept: light/dark tokens, type, palette)
   ============================================================ */

/* undo the two-column / hero-card experiment */
.top-region, .hero-card, .hero-label-row, .hero-figure, .hero-unit,
.hero-divider, .stat-grid, .stat, .stat-label, .stat-value,
.team-panel, .team-panel-title, .qc-card, .qc-card-head,
.qc-icon-block, .qc-card-title, .qc-card-desc, .qc-card-arrow {
    all: revert;
}

/* --- account bar: original horizontal row, QCai skin --- */
.account-bar {
    display: flex;
    align-items: center;
    gap: 34px;
    padding: 16px 24px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}
.account-bar-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 118px;
    flex: 0 0 auto;
}
.account-bar-label {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-secondary);
    line-height: 1.2;
}
.account-bar-value {
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    text-shadow: none;
    line-height: 1.15;
    white-space: nowrap;
}
.account-bar-value.neutral { color: var(--text-tertiary); }
.account-bar-value.positive { color: var(--accent-green); }
.account-bar-value.negative { color: var(--accent-red); }

/* first metric carries the hero treatment, still inline */
#acc-equity {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -0.022em;
    color: var(--hero);
}

/* --- team cards: original inline row pinned to the right --- */
.team-performance-cards {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-left: auto;
    margin-top: 0;
    padding-left: 22px;
    border-left: 1px solid var(--border-subtle);
    overflow-x: auto;
    flex-shrink: 0;
}
.team-performance-card {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 13px;
    min-width: 128px;
    width: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    flex: 0 0 auto;
}
.team-performance-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}
.team-performance-card.active {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}
.team-card-name {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-secondary);
    max-width: 110px;
}
.team-card-values { display: flex; flex-direction: column; gap: 1px; }
.team-pnl {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.012em;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.team-pnl.positive, .team-pnl.stat-positive { color: var(--accent-green); }
.team-pnl.negative, .team-pnl.stat-negative { color: var(--accent-red); }
.team-pnl.neutral { color: var(--text-primary); }
.team-pct {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}
.team-pct.positive { color: var(--accent-green); }
.team-pct.negative { color: var(--accent-red); }

/* explicit direction — earlier block had left flex-direction: column behind */
.account-bar {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
}
.team-performance-cards {
    flex-direction: row;
    align-items: stretch;
}

/* FIX 4: main content must keep a usable height — the chart is not a strip.
   (earlier fix set min-height: 0 which crushed the middle row to 190px) */
.main-content {
    flex: 1 1 0;
    min-height: 320px;
    grid-template-rows: minmax(320px, 1fr);
    overflow: visible;
}
.main-content > .panel {
    min-height: 320px;
}
.bottom-section {
    flex: 0 0 auto;
    height: auto;
    min-height: 320px;
}

/* ============================================================
   Review fixes (from box audit at 1990x1210)
   ============================================================ */

/* A) agent pipeline — restore original chip density so it fits one row */
.agent-status-bar {
    padding: 10px 18px;
    gap: 4px;
}
.agent-status-dot {
    padding: 3px 8px 3px 6px;
    gap: 4px;
    border-radius: var(--radius-md);
}
.agent-status-dot .dot { width: 6px; height: 6px; }
.agent-status-dot .dot-label { font-size: 11px; }
.agent-status-dot .agent-badge {
    font-size: 8px;
    padding: 1px 5px;
    letter-spacing: 0.2px;
}
.agent-status-label {
    font-size: 9px;
    letter-spacing: 0.7px;
    margin-right: 2px;
}
.agent-status-sep { margin: 0 2px; font-size: 12px; }

/* B) account row — spread metrics, pin team cards to the right
   (overrides the earlier `margin-left: 0 !important`) */
.account-bar {
    gap: 46px;
    padding: 16px 28px;
}
.account-bar-item { min-width: 132px; }
.team-performance-cards {
    margin-left: auto !important;
    padding-left: 26px;
}

/* C) team card — compact so it lines up with the metric height */
.team-performance-card {
    padding: 6px 12px;
    gap: 2px;
    min-width: 132px;
}
.team-pnl { font-size: 15px; }
.team-pct { font-size: 11px; }
.team-card-name { font-size: 9px; letter-spacing: 0.5px; }

/* account row — metrics share the width evenly so the row is balanced
   whether values are $0.00 or $19,549,836.64 */
.account-bar { gap: 22px; }
.account-bar-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: 300px;
}

/* agent bar — compact enough to fit 1680px laptops; fade edge signals scroll on narrower */
.agent-status-bar {
    padding: 10px 8px;
    gap: 2px;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 22px), transparent 100%);
}
.agent-status-dot {
    padding: 3px 6px 3px 5px;
    gap: 3px;
}
.agent-status-dot .dot-label { font-size: 10.5px; }
.agent-status-dot .agent-badge {
    padding: 1px 4px;
    font-size: 8px;
}
.agent-status-label {
    font-size: 8.5px;
    letter-spacing: 0.5px;
    margin-right: 1px;
}
.agent-status-sep { margin: 0 1px; }

/* ============================================================
   Part A — mobile: stop page-level horizontal overflow
   ============================================================ */
.pnl-timeframe-tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    max-width: 100%;
}
.pnl-timeframe-tabs::-webkit-scrollbar { display: none; }

.main-content > .panel,
.bottom-section > .panel,
.bottom-section > div {
    min-width: 0;
}
.table-container {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
}
.trades-table, .data-table { min-width: 0; }

@media (max-width: 600px) {
    .account-bar { gap: 18px; padding: 12px 14px; }
    .account-bar-item { min-width: 96px; }
    .account-bar-value { font-size: 17px; }
    #acc-equity { font-size: 21px; }
    .team-performance-card { min-width: 118px; padding: 6px 10px; }
    .agent-status-bar { padding: 8px 10px; }
}

@media (max-width: 700px) {
    .panel-header { flex-wrap: wrap; row-gap: 10px; padding: 14px 16px; }
    .panel-header h2 { white-space: nowrap; flex: 0 0 auto; }
    .pnl-timeframe-tabs { flex: 1 1 100%; max-width: 100%; }
}

/* ============================================================
   Iframe embedding — parent page owns theme/language controls
   ============================================================ */
:root[data-embedded] .theme-toggle,
:root[data-embedded] #btn-language,
:root[data-embedded] .lang-select,
:root[data-embedded] .lang-selector-wrapper {
    display: none !important;
}

/* ============================================================
   FIX: layout explodes once real data arrives
   ------------------------------------------------------------
   A) team cards were width:100% !important (an earlier fix), which
      made every card full-bleed and wrapped them into a column.
   B) account metrics were flex:1 1 0 + min-width:0, so wide values
      like $19,549,836.64 overflowed and overlapped the next column.
   ============================================================ */

/* --- A: team cards stay a single horizontal row --- */
.team-performance-cards {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    gap: 10px;
    margin-left: auto !important;
    margin-top: 0 !important;
    margin-right: 0 !important;
    padding-left: 22px;
    border-left: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    max-width: 55%;
    scrollbar-width: none;
}
.team-performance-cards::-webkit-scrollbar { display: none; }

.team-performance-card {
    display: flex !important;
    flex-direction: column;
    width: auto !important;
    min-width: 132px !important;
    max-width: 190px !important;
    flex: 0 0 auto !important;
    padding: 7px 12px;
    gap: 2px;
    overflow: hidden;
}
.team-card-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.team-pnl, .team-pct {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- B: account metrics size to their content, bar scrolls if needed --- */
.account-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 30px;
    padding: 16px 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.account-bar::-webkit-scrollbar { display: none; }

.account-bar-item {
    flex: 0 0 auto !important;
    min-width: 110px !important;
    max-width: none !important;
    width: auto !important;
}
.account-bar-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* team cards: fit the full PnL figure instead of truncating it */
.team-performance-card { max-width: 178px !important; min-width: 122px !important; padding: 7px 11px; }
.team-pnl, .team-pnl.large { font-size: 13.5px !important; letter-spacing: -0.018em; }
.team-pct { font-size: 10.5px; }
.team-card-name { font-size: 8.5px; }

/* ============================================================
   Mobile: restore the original compact layout
   (earlier fixes made items too wide -> horizontal scrolling;
    and grid-template-rows only defined ONE row so the chatroom
    fell into an implicit row and overflowed out of view)
   ============================================================ */

/* --- main content stacks both panels, rows sized by content --- */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-rows: minmax(320px, auto);
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
        overflow: visible;
    }
    .bottom-section { flex: 0 0 auto; height: auto; }
    .main-content > .panel {
        min-height: 320px;
    }
    .main-content > .panel.panel-chatroom {
        min-height: 525px;
        height: 525px;
    }
    .panel-chatroom .chatroom-container,
    .panel-chatroom .chatroom-messages {
        flex: 1 1 0;
        min-height: 0;
    }
    .panel-chatroom .chatroom-messages {
        min-height: 400px;
        overflow-y: auto;
    }
}

/* --- account bar: original compact scale so it fits a phone row --- */
@media (max-width: 768px) {
    .account-bar {
        gap: 10px;
        padding: 5px 10px;
        margin-bottom: 2px;
        overflow-x: auto;
    }
    .account-bar-item {
        min-width: 65px !important;
        max-width: none !important;
        flex: 0 0 auto !important;
    }
    .account-bar-label { font-size: 8px; }
    .account-bar-value { font-size: 12px !important; letter-spacing: -0.01em; }
    #acc-equity { font-size: 13px !important; }

    /* team cards: original compact scale */
    .team-performance-cards {
        gap: 3px;
        padding-left: 6px;
        max-width: 52%;
    }
    .team-performance-card {
        min-width: 65px !important;
        max-width: 110px !important;
        padding: 2px 4px !important;
        gap: 1px;
    }
    .team-card-name { font-size: 7px; letter-spacing: 0.3px; }
    .team-pnl, .team-pnl.large { font-size: 10px !important; }
    .team-pct { font-size: 8px; }

    .chatroom-tabs { overflow-x: auto; gap: 3px; }
    .chatroom-tab { padding: 3px 7px; font-size: 9px; white-space: nowrap; }
}

/* ============================================================
   Panel geometry — stop the four panels overlapping / overflowing
   ------------------------------------------------------------
   Root cause: nothing capped the panel height, so a 50-row table
   grew .tradesPanel to 2126px, .table-container grew with it and
   overflow:auto never fired, and the panels above spilled into the
   ones below.
   ============================================================ */

/* --- main row: panels fill the row, never exceed it --- */
.main-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: minmax(0, 1fr);
    gap: var(--space-lg);
    padding: var(--space-lg);
    flex: 1 1 auto;
    min-height: 360px;
    overflow: hidden;
}
.main-content > .panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* --- bottom row: fixed height, panels scroll internally --- */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    padding: 0 var(--space-lg) var(--space-lg);
    height: 380px;
    max-height: 45vh;
    min-height: 0;
    flex: 0 0 auto;
    overflow: hidden;
}
.bottom-section > * {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* --- the scrollable region inside each panel --- */
.table-container {
    flex: 1 1 0;
    min-height: 0;
    max-width: 100%;
    overflow: auto;
}
.panel-team-chart .team-pnl-chart-wrapper,
.panel-chatroom .chatroom-container,
.panel-chatroom .chatroom-messages {
    min-height: 0;
    overflow: auto;
}

/* --- panels themselves clip, children scroll --- */
.panel {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* --- mobile: stack, each panel grows to its content --- */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-rows: minmax(320px, auto);
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
        overflow: visible;
    }
    .main-content > .panel { overflow: hidden; }
    .main-content > .panel.panel-chatroom { min-height: 525px; height: 525px; }
    .bottom-section {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        flex: 0 0 auto;
        overflow: visible;
    }
    .bottom-section > * { height: 360px; overflow: hidden; }
}

/* ============================================================
   Topbar — frosted glass on scroll
   transparent at rest, translucent + blur once the page moves
   ============================================================ */
.topbar {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}
.topbar.scrolled {
    background: rgba(244, 243, 241, 0.72);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-bottom-color: var(--border-subtle);
    box-shadow: 0 4px 18px rgba(120, 100, 70, 0.10);
}
:root[data-theme="dark"] .topbar.scrolled {
    background: rgba(13, 13, 15, 0.72);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

/* mobile: same frosted behaviour, a touch more opaque so content
   underneath stays legible through the blur */
@media (max-width: 900px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: var(--space-md);
    }
    .topbar.scrolled {
        background: rgba(244, 243, 241, 0.82);
        backdrop-filter: blur(22px) saturate(150%);
        -webkit-backdrop-filter: blur(22px) saturate(150%);
    }
    :root[data-theme="dark"] .topbar.scrolled {
        background: rgba(13, 13, 15, 0.82);
    }
}

/* ============================================================
   Mobile vertical rhythm — one consistent 12px step
   (was 14 / 0 / 12 / 30 / 14 / 10: stray margins plus a
    grid-auto-rows floor of 320px that left dead space inside
    the row when a panel was shorter than 320px)
   ============================================================ */
@media (max-width: 900px) {
    .agent-status-bar {
        margin: 12px 12px 0;
        padding: 10px 12px;
    }
    .account-bar {
        margin: 12px 0 0;
        padding: 0 12px;
    }
    .main-content {
        padding: 12px;
        gap: 12px;
        grid-auto-rows: auto;          /* rows hug their panel, no dead space */
    }
    .main-content > .panel {
        margin: 0 !important;
        padding-bottom: 0;
    }
    .main-content > .panel.panel-team-chart { min-height: 300px; }
    .main-content > .panel.panel-chatroom {
        min-height: 460px;
        height: 460px;
    }
    .bottom-section {
        padding: 0 12px 12px;
        gap: 12px;
    }
    .bottom-section > * {
        margin: 0 !important;
        padding-bottom: 0;
        min-height: 300px;
    }
}

/* === Live-value smoothing — colour eases instead of snapping === */
.account-bar-value,
.team-pnl,
.team-pct,
.metric-value,
.symbol-price,
.symbol-change,
.stat-value {
    transition: color 320ms ease;
}
