:root {
    --bg: #f0fdf9;
    --bg-alt: #e6f7f2;
    --surface: #ffffff;
    --surface-raised: #f8fffe;
    --border: #d1e8e0;
    --border-light: #b8d8cd;
    --text: #1a2e35;
    --text-dim: #5a7a7a;
    --text-muted: #8faaaa;
    --primary: #0d9488;
    --primary-light: #14b8a6;
    --primary-dim: rgba(13,148,136,0.1);
    --primary-dark: #0a7a70;
    --green: #10b981;
    --green-dim: rgba(16,185,129,0.1);
    --red: #ef4444;
    --red-dim: rgba(239,68,68,0.08);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245,158,11,0.1);
    --blue: #3b82f6;
    --blue-dim: rgba(59,130,246,0.1);
    --purple: #8b5cf6;
    --cyan: #0d9488;
    --cyan-dim: rgba(13,148,136,0.1);
    --shadow-sm: 0 1px 3px rgba(0,40,30,0.04), 0 1px 2px rgba(0,40,30,0.06);
    --shadow-md: 0 4px 12px rgba(0,40,30,0.06), 0 1px 3px rgba(0,40,30,0.04);
    --shadow-lg: 0 10px 30px rgba(0,40,30,0.08), 0 2px 6px rgba(0,40,30,0.04);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --sidebar-w: 220px;
    --header-h: 52px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Login ── */
.login-container {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(160deg, #f0fdfa 0%, #e0f7f0 40%, #ccfbf1 70%, #d5f5e8 100%);
}
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
    padding: 48px 44px 40px; width: 380px; box-shadow: 0 20px 60px rgba(0,40,30,0.1), 0 4px 16px rgba(0,40,30,0.05);
    text-align: center;
}
.login-logo { margin-bottom: 20px; }
.login-logo svg { filter: drop-shadow(0 2px 8px rgba(13,148,136,0.25)); }
.login-title {
    font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.8px; margin-bottom: 4px;
}
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; letter-spacing: 0.5px; text-transform: uppercase; }
.login-form { text-align: left; }
.login-field { margin-bottom: 16px; }
.login-field label {
    display: block; font-size: 11px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.login-field input {
    width: 100%; padding: 11px 14px; background: var(--bg); border: 1.5px solid var(--border);
    border-radius: 10px; color: var(--text); font-family: inherit; font-size: 13.5px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.login-field input::placeholder { color: var(--text-muted); }
.login-btn {
    width: 100%; padding: 13px; background: var(--primary); color: #fff; border: none;
    border-radius: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
    font-size: 14px; margin-top: 8px; transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(13,148,136,0.3);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.login-btn:hover { background: var(--primary-dark); box-shadow: 0 6px 20px rgba(13,148,136,0.35); }
.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.login-spinner {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.login-error {
    color: var(--red); font-size: 12px; margin-bottom: 8px; text-align: center;
    background: var(--red-dim); padding: 8px 12px; border-radius: 8px;
}
.login-footer {
    margin-top: 24px; font-size: 11px; color: var(--text-muted); text-align: center;
    display: flex; align-items: center; justify-content: center; gap: 4px;
}
.login-footer::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    background: var(--green); border-radius: 50%;
}

/* ── Dashboard Shell: Sidebar + Main ── */
.dashboard {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--header-h) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
    grid-row: 1 / -1;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 24px 16px;
    display: flex; align-items: center; gap: 10px;
}
.sidebar-brand h1 { font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.sidebar-brand .brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

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

.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
    font-weight: 500; color: var(--text-dim); background: none; border: none;
    font-family: inherit; transition: all 0.15s; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-alt); color: var(--text); }
.nav-item.active {
    background: var(--primary); color: #fff; font-weight: 600;
    box-shadow: 0 2px 8px rgba(13,148,136,0.3);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px; border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 8px;
}
.sidebar-status { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim); }
.sidebar-status .ws-dot { margin: 0; }

/* ── Header Bar ── */
.header {
    grid-column: 2; grid-row: 1;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 0 24px; display: flex; align-items: center; gap: 16px;
}
.header h1 { display: none; }
.header-breadcrumb { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.3px; }

.badge {
    padding: 4px 12px; border-radius: 20px; font-size: 10px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-scan { background: var(--blue-dim); color: var(--blue); }
.badge-paper { background: var(--yellow-dim); color: var(--yellow); }
.badge-live { background: var(--red-dim); color: var(--red); }
.badge-paused { background: rgba(107,114,128,0.1); color: var(--text-dim); }

.header-stats { display: flex; gap: 16px; align-items: center; flex-wrap: nowrap; overflow: hidden; }
.stat { color: var(--text-dim); white-space: nowrap; font-size: 12px; }
.stat b { color: var(--text); font-weight: 600; }

.ws-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.ws-dot.connected { background: var(--green); box-shadow: 0 0 4px rgba(16,185,129,0.4); }
.ws-dot.disconnected { background: var(--red); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Tab Bar: HIDDEN (replaced by sidebar) ── */
.tab-bar { display: none; }
.tab { display: none; }

/* ── Main Content Area ── */
.main-content {
    grid-column: 2; grid-row: 2;
    overflow: hidden;
    display: flex; flex-direction: column;
}

/* ── Panels ── */
.panel {
    background: var(--surface); padding: 12px;
    border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.panel-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-dim); margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border); font-weight: 600;
}

/* ── Global Countdown ── */
.global-countdown {
    background: var(--surface); padding: 10px 14px; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.gc-ring-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.gc-center { position: absolute; text-align: center; }
.gc-time { font-size: 22px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.gc-label { font-size: 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.gc-stats { display: flex; gap: 10px; margin-top: 6px; font-size: 9px; }
.gc-stat { display: flex; gap: 3px; align-items: center; }
.gc-stat-val { color: var(--text); font-weight: 600; }
.gc-stat-dim { color: var(--text-muted); }
.gc-stat-active { color: var(--yellow); font-weight: 700; }

.countdown-green { color: var(--green); }
.countdown-yellow { color: var(--yellow); }
.countdown-red { color: var(--red); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Market Grid ── */
.market-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex: 1; }
.market-card {
    background: var(--surface); padding: 10px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.15s;
}
.market-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.market-card.has-trade { border-left: 3px solid var(--yellow); }
.mc-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.mc-asset { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; }
.mc-price { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.mc-delta { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mc-delta.positive { color: var(--green); }
.mc-delta.negative { color: var(--red); }
.mc-delta.neutral { color: var(--text-dim); }
.mc-countdown { margin-left: auto; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mc-prices { margin-bottom: 6px; }
.mc-row { display: grid; grid-template-columns: 40px 1fr 1fr 1fr; gap: 4px; padding: 2px 0; font-size: 11px; align-items: center; font-variant-numeric: tabular-nums; }
.mc-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.3px; font-weight: 500; }
.mc-vol { font-size: 10px; color: var(--text-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.mc-prob { margin-top: 4px; }
.mc-prob-labels { display: flex; justify-content: space-between; font-size: 10px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.mc-waiting { color: var(--text-muted); font-size: 11px; text-align: center; padding: 10px 0; }
.mc-pending {
    margin-top: 6px; padding: 4px 8px; background: var(--yellow-dim);
    border: 1px solid rgba(245,158,11,0.2); border-radius: var(--radius-xs);
    font-size: 10px; display: flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums;
}

.price-delta { text-align: center; font-size: 14px; font-weight: 600; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.price-delta.positive { color: var(--green); }
.price-delta.negative { color: var(--red); }
.price-delta.neutral { color: var(--text-dim); }

.price-grid { margin-top: 4px; }
.price-grid-header, .price-grid-row {
    display: grid; grid-template-columns: 48px 1fr 1fr 1fr; gap: 4px; padding: 4px 0;
    border-bottom: 1px solid var(--border); align-items: center;
}
.price-grid-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); text-align: right; letter-spacing: 0.5px; }
.price-grid-row span { text-align: right; font-variant-numeric: tabular-nums; }
.price-grid-row .ask-label { text-align: left; color: var(--text-dim); font-size: 11px; }
.ask-up { color: var(--green); font-weight: 600; }
.ask-down { color: var(--red); font-weight: 600; }
.fair-up { color: var(--green); font-size: 12px; }
.fair-down { color: var(--red); font-size: 12px; }
.edge-positive { color: var(--green); font-weight: 700; font-size: 11px; }
.edge-negative { color: var(--red); font-weight: 600; font-size: 11px; }
.edge-neutral { color: var(--text-dim); font-size: 11px; }

.prob-section { margin-top: 10px; }
.prob-label-row { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.prob-section-label { font-size: 10px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.5px; }
.prob-hint { font-size: 10px; color: var(--text-muted); }
.prob-container { margin-top: 3px; }
.prob-bar { height: 8px; background: var(--bg-alt); border-radius: 4px; overflow: hidden; display: flex; }
.prob-fill-up { height: 100%; background: var(--green); transition: width 0.3s ease; }
.prob-fill-down { height: 100%; background: var(--red); transition: width 0.3s ease; }
.prob-fill-up.mkt { background: rgba(16,185,129,0.2); }
.prob-fill-down.mkt { background: rgba(239,68,68,0.2); }
.prob-labels { display: flex; justify-content: space-between; font-size: 10px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.prob-up { color: var(--green); }
.prob-down { color: var(--red); }

/* ── Trading Tab Layout: top row + bottom charts ── */
/* ── Trading Layout: 2-column (main + sidebar) ── */
.trading-layout {
    display: flex;
    gap: 10px;
    padding: 10px 12px 12px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.trading-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.trading-top {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: stretch;
}
.trading-top-cards { flex: 1; min-width: 0; }
.trading-bottom {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.trading-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}
.trading-sidebar > .panel {
    padding: 10px;
    flex-shrink: 0;
}
.trading-sidebar > .panel .metric-grid { gap: 4px; margin-bottom: 6px; }
.trading-sidebar > .panel .metric-card { padding: 6px 8px; }
.trading-sidebar > .panel .metric-label { font-size: 8px; }
.trading-sidebar > .panel .metric-value { font-size: 13px; }
.trading-sidebar > .panel .panel-title { margin-bottom: 6px; padding-bottom: 4px; }
.trading-sidebar > .panel .risk-row { padding: 2px 0; font-size: 11px; }

/* ── Sidebar Panels (compact) ── */
.sidebar-panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.sidebar-panel-grow { flex: 1; min-height: 0; }
.sidebar-panel-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-panel-badge {
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 500;
}
.sidebar-panel-body {
    padding: 6px 0;
    overflow-y: auto;
}
.sidebar-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 12px;
    font-size: 11px;
}

/* Sidebar trade rows */
.sidebar-trade-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 11px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.sidebar-trade-row:last-child { border-bottom: none; }
.sidebar-trade-asset {
    font-weight: 700;
    font-size: 10px;
    color: var(--text-dim);
    min-width: 28px;
}
.sidebar-trade-edge {
    font-size: 10px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Sidebar event rows */
.sidebar-events-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.sidebar-event-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 10px;
}
.sidebar-event-time {
    color: var(--text-muted);
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
}
.sidebar-event-type {
    font-weight: 500;
    text-transform: capitalize;
}

/* ── Portfolio Panel (sidebar compact) ── */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.metric-card {
    background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px;
    border: 1px solid var(--border); transition: box-shadow 0.2s;
}
.metric-card:hover { box-shadow: var(--shadow-sm); }
.metric-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 1px; font-weight: 500; }
.metric-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-value.positive { color: var(--green); }
.metric-value.negative { color: var(--red); }
.metric-card.full-width { grid-column: 1 / -1; }

.risk-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--bg-alt); }
.risk-row:last-child { border-bottom: none; }
.risk-label { color: var(--text-dim); }
.risk-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }
.pnl-zero { color: var(--text-dim); }

.pending-panel {
    margin-top: 12px; padding: 10px 12px;
    background: linear-gradient(135deg, rgba(245,158,11,0.06), rgba(245,158,11,0.02));
    border: 1px solid rgba(245,158,11,0.2); border-radius: var(--radius-sm);
}
.pending-title { font-size: 10px; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; font-weight: 700; }

/* ── Live Charts Section ── */
.live-charts-section {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    overflow: hidden; flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.live-charts-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.live-charts-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); font-weight: 600; }

.chart-filter-tabs {
    display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border);
    border-radius: 20px; overflow: hidden; padding: 2px;
}
.chart-filter-tab {
    padding: 4px 12px; font-size: 10px; font-weight: 600; cursor: pointer;
    background: transparent; border: none; border-radius: 16px;
    color: var(--text-dim); font-family: inherit; transition: all 0.15s;
}
.chart-filter-tab:hover { color: var(--text); }
.chart-filter-tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }

.live-charts-grid { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 1px; background: var(--border); flex: 1; min-height: 0; }
.live-charts-grid.single { grid-template-columns: 1fr; }
.live-chart-panel { background: var(--surface); padding: 8px 12px 12px; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.live-chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; flex-shrink: 0; }
.live-chart-title { font-size: 11px; font-weight: 700; letter-spacing: -0.2px; }
.live-chart-pts { font-size: 9px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.live-chart-wrap { position: relative; flex: 1; min-height: 0; width: 100%; }

/* ── Charts Grid (Portfolio/Performance/Analytics) ── */
.charts-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px;
    flex: 1; min-height: 0; overflow-y: auto;
}
.chart-panel {
    background: var(--surface); padding: 12px; border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    min-height: 0; display: flex; flex-direction: column;
}
.chart-panel.full-width { grid-column: 1 / -1; }
.chart-container { position: relative; height: 180px; width: 100%; flex: 1; min-height: 0; }
.chart-container.tall { height: 260px; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 180px; color: var(--text-muted); font-size: 13px; }

/* ── Controls & Buttons ── */
.controls { display: flex; flex-direction: column; gap: 10px; }
.control-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.control-group { margin-bottom: 4px; }
.control-group label { display: block; color: var(--text-muted); font-size: 10px; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.control-input {
    width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-xs); color: var(--text); font-family: inherit; font-size: 13px; transition: border-color 0.2s;
}
.control-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }

.btn {
    padding: 8px 18px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); cursor: pointer; font-family: inherit;
    font-size: 12px; font-weight: 600; transition: all 0.15s; letter-spacing: 0.2px;
}
.btn:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(0.97); }
.btn-danger { border-color: rgba(239,68,68,0.3); color: var(--red); background: var(--red-dim); }
.btn-danger:hover { background: rgba(239,68,68,0.12); }
.btn-success { border-color: rgba(16,185,129,0.3); color: var(--green); background: var(--green-dim); }
.btn-success:hover { background: rgba(16,185,129,0.15); }
.btn-warn { border-color: rgba(245,158,11,0.3); color: var(--yellow); background: var(--yellow-dim); }
.btn-warn:hover { background: rgba(245,158,11,0.15); }
.btn-primary {
    border-color: var(--primary); color: #fff; background: var(--primary);
    box-shadow: 0 2px 6px rgba(13,148,136,0.3);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 5px 12px; font-size: 11px; }

/* ── Mode Toggle ── */
.mode-tabs {
    display: flex; background: var(--bg); border: 1px solid var(--border);
    border-radius: 20px; overflow: hidden;
}
.mode-tab {
    padding: 5px 14px; font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.4px; cursor: pointer; background: transparent; border: none;
    color: var(--text-dim); font-family: inherit; transition: all 0.15s;
}
.mode-tab:hover { color: var(--text); }
.mode-tab.active-paper { background: var(--yellow-dim); color: var(--yellow); border-radius: 20px; }
.mode-tab.active-live { background: var(--red-dim); color: var(--red); border-radius: 20px; }

.mode-select {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); padding: 8px 12px; font-family: inherit; font-size: 12px;
    font-weight: 500; cursor: pointer;
}

/* ── History Page ── */
.history-page {
    flex: 1; min-height: 0; display: flex; flex-direction: column;
    padding: 12px 16px; overflow: hidden;
}
.history-page > .panel {
    flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.history-page .trades-table-wrap { flex: 1; min-height: 0; overflow: auto; }

/* ── Trades Table ── */
.trades-table-wrap { overflow-x: auto; border-radius: var(--radius-xs); }
.trades-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.trades-table th {
    text-align: left; font-size: 9px; color: var(--text-muted); padding: 6px 8px;
    border-bottom: 2px solid var(--border); text-transform: uppercase; letter-spacing: 0.4px;
    font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--surface);
}
.trades-table td { padding: 6px 8px; border-bottom: 1px solid var(--bg-alt); white-space: nowrap; }
.trades-table tr:hover td { background: var(--bg); }
.trades-table tr:last-child td { border-bottom: none; }
.result-win { color: var(--green); font-weight: 700; }
.result-loss { color: var(--red); font-weight: 700; }
.result-open { color: var(--yellow); font-weight: 600; }
.side-up { color: var(--green); }
.side-down { color: var(--red); }
.time-cell { color: var(--text-dim); font-size: 10px; }
.dim { color: var(--text-dim); }
.trades-table.compact th, .trades-table.compact td { padding: 4px 6px; font-size: 10px; }

/* ── Sortable ── */
.trades-table th.sortable { cursor: pointer; user-select: none; }
.trades-table th.sortable:hover { color: var(--text); background: var(--bg-alt); }
.trades-table th .sort-arrow { font-size: 9px; margin-left: 3px; opacity: 0.4; }
.trades-table th.sort-asc .sort-arrow, .trades-table th.sort-desc .sort-arrow { opacity: 1; color: var(--primary); }

/* ── Filter Bar ── */
.filter-bar {
    display: flex; gap: 8px; padding: 10px 16px; background: var(--bg);
    border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.filter-bar label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; }
.filter-select, .filter-input {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xs);
    color: var(--text); padding: 5px 8px; font-family: inherit; font-size: 11px;
}
.filter-select:focus, .filter-input:focus { outline: none; border-color: var(--primary); }
.filter-input { width: 100px; }
.filter-stats { margin-left: auto; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Cumulative Stats ── */
.cumulative-stats { display: flex; gap: 0; padding: 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.cum-stat { flex: 1; padding: 8px 12px; text-align: center; border-right: 1px solid var(--border); }
.cum-stat:last-child { border-right: none; }
.cum-label { display: block; font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 1px; }
.cum-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--border); }
.page-info { font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ── Session Panel ── */
.session-bar {
    display: flex; gap: 20px; padding: 8px 14px; background: var(--bg);
    border-radius: var(--radius-xs); font-size: 11px; align-items: center; margin-bottom: 10px;
}
.session-bar .session-label { color: var(--text-muted); text-transform: uppercase; font-size: 9px; letter-spacing: 0.4px; }
.session-bar .session-value { color: var(--text); font-weight: 600; }

/* ── Event Log ── */
.event-log { font-size: 11px; max-height: 300px; overflow-y: auto; }
.event-entry {
    padding: 6px 8px; border-bottom: 1px solid var(--bg-alt); display: flex;
    gap: 8px; align-items: baseline; border-radius: var(--radius-xs); transition: background 0.15s;
}
.event-entry:hover { background: var(--bg); }
.event-entry:last-child { border-bottom: none; }
.event-time { color: var(--text-muted); min-width: 56px; font-size: 10px; }
.event-type { min-width: 100px; font-weight: 600; font-size: 11px; }
.type-trade_opened { color: var(--yellow); }
.type-trade_resolved { color: var(--green); }
.type-signal_generated { color: var(--primary); }
.type-bot_paused { color: var(--text-dim); }
.type-bot_resumed { color: var(--green); }
.type-bot_stopped { color: var(--red); }
.type-mode_changed { color: var(--purple); }
.type-strategy_updated { color: var(--blue); }

/* ── Events Tab Page ── */
.events-page { padding: 12px 16px; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.events-table-wrap {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; flex: 1; min-height: 0;
    display: flex; flex-direction: column;
}
.events-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.events-title { font-size: 13px; font-weight: 600; color: var(--text); }
.events-filters { display: flex; gap: 8px; align-items: center; }
.event-list { flex: 1; overflow-y: auto; min-height: 0; }
.event-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 16px; border-bottom: 1px solid var(--bg-alt); transition: background 0.15s; font-size: 12px; }
.event-row:hover { background: var(--bg); }
.event-row:last-child { border-bottom: none; }
.event-row-time { color: var(--text-muted); font-size: 11px; min-width: 120px; font-variant-numeric: tabular-nums; }
.event-row-type { font-weight: 600; min-width: 130px; font-size: 11px; }
.event-row-data { flex: 1; font-size: 11px; color: var(--text-dim); }

/* ── Toasts ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 16px; font-size: 12px; display: flex; align-items: center; gap: 8px;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 3.7s forwards;
    max-width: 360px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; cursor: pointer;
}
.toast-icon {
    font-weight: 700; width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0;
}
.toast-success { border-color: rgba(16,185,129,0.3); }
.toast-success .toast-icon { background: var(--green-dim); color: var(--green); }
.toast-error { border-color: rgba(239,68,68,0.3); }
.toast-error .toast-icon { background: var(--red-dim); color: var(--red); }
.toast-info { border-color: var(--primary-dim); }
.toast-info .toast-icon { background: var(--primary-dim); color: var(--primary); }
.toast-progress { position: absolute; bottom: 0; left: 0; height: 2px; border-radius: 0 0 var(--radius-sm) var(--radius-sm); animation: toast-progress 4s linear forwards; }
.toast-success .toast-progress { background: var(--green); }
.toast-error .toast-progress { background: var(--red); }
.toast-info .toast-progress { background: var(--primary); }
@keyframes toast-progress { from { width: 100%; } to { width: 0%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Tilt / Streak ── */
.tilt-warning {
    background: var(--red-dim); border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-xs);
    padding: 8px 12px; font-size: 10px; font-weight: 700; color: var(--red);
    text-transform: uppercase; letter-spacing: 0.3px; animation: pulse 2s ease-in-out infinite;
}
.streak-win { color: var(--green); }
.streak-loss { color: var(--red); }
.streak-none { color: var(--text-muted); }
.tilt-on { color: var(--red); font-weight: 700; animation: pulse 2s ease-in-out infinite; }
.tilt-off { color: var(--text-muted); }

.refresh-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--text-muted); vertical-align: middle; }
.refresh-dot.active { background: var(--green); animation: refresh-pulse 0.6s ease-out; }
@keyframes refresh-pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); transform: scale(1.3); } 100% { box-shadow: 0 0 0 6px rgba(16,185,129,0); transform: scale(1); } }

.connection-lost {
    background: linear-gradient(135deg, rgba(239,68,68,0.06), rgba(239,68,68,0.02));
    border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-sm);
    padding: 10px 16px; margin: 12px 20px; display: flex; align-items: center;
    gap: 8px; font-size: 12px; color: var(--red); font-weight: 600; animation: pulse 2s ease-in-out infinite;
}
.connection-lost-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; }

/* ── Signal Strength ── */
.signal-badge {
    display: inline-block; padding: 2px 6px; border-radius: 10px; font-size: 8px;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-left: 4px; vertical-align: middle;
}
.sig-weak { background: var(--red-dim); color: var(--red); }
.sig-moderate { background: var(--yellow-dim); color: var(--yellow); }
.sig-strong { background: var(--green-dim); color: var(--green); }
.sig-excellent { background: var(--primary-dim); color: var(--primary); }

/* ── Vol Display ── */
.vol-display {
    text-align: center; font-size: 10px; color: var(--text-dim); margin-bottom: 8px;
    padding: 4px 8px; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-xs); font-variant-numeric: tabular-nums;
}

/* ── Data Summary ── */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.summary-card {
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; text-align: center;
}
.summary-card .num { font-size: 20px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.summary-card .label { font-size: 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── Settings ── */
/* ── Settings Page (slider-based, single screen) ── */
.settings-page {
    flex: 1; min-height: 0; overflow: hidden;
    display: flex; flex-direction: column;
    padding: 12px 16px;
}
.settings-layout {
    display: flex; flex-direction: column; gap: 10px;
    flex: 1; min-height: 0;
}

/* Control bar */
.settings-control-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 14px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    flex-shrink: 0; gap: 12px;
}
.settings-control-left { display: flex; gap: 8px; align-items: center; }
.settings-control-right { display: flex; gap: 8px; align-items: center; }
.tilt-badge {
    font-size: 10px; font-weight: 700; color: var(--red);
    background: rgba(239,68,68,0.1); padding: 3px 8px;
    border-radius: 10px; border: 1px solid rgba(239,68,68,0.2);
}
.btn-sm { padding: 6px 14px; font-size: 11px; }
.btn-reset {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-dim); cursor: pointer; font-family: inherit; font-size: 11px;
    padding: 6px 14px; transition: all 0.15s; font-weight: 500;
}
.btn-reset:hover { color: var(--text); border-color: var(--border-light); background: var(--bg); }

/* Slider parameter grid */
.sp-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    flex: 1; min-height: 0; overflow-y: auto;
}
.sp-group {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; padding: 10px 12px;
}
.sp-group-header {
    display: flex; align-items: center; gap: 6px;
    padding-bottom: 8px; margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.sp-group-icon { font-size: 13px; }
.sp-group-title {
    font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--primary); font-weight: 700;
}

/* Each slider row */
.sp-row {
    padding: 6px 8px; margin-bottom: 2px;
    border-radius: var(--radius-xs); cursor: pointer;
    transition: background 0.15s;
}
.sp-row:hover { background: var(--bg); }
.sp-row:last-child { margin-bottom: 0; }
.sp-modified { background: rgba(13,148,136,0.03); }

.sp-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 4px;
}
.sp-label { font-size: 11px; color: var(--text); font-weight: 500; }
.sp-value-wrap { display: flex; align-items: center; gap: 6px; }
.sp-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--primary); flex-shrink: 0;
}
.sp-value {
    font-size: 12px; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums;
}
.sp-zone {
    font-size: 8px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.4px; padding: 1px 5px;
    border-radius: 6px; background: rgba(0,0,0,0.04);
}

/* Custom range slider */
.sp-slider-wrap { padding: 0 2px; }
.sp-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px; border-radius: 2px;
    background: linear-gradient(to right,
        var(--zone-color, var(--primary)) 0%,
        var(--zone-color, var(--primary)) var(--pct, 50%),
        var(--border) var(--pct, 50%),
        var(--border) 100%
    );
    outline: none; cursor: pointer; margin: 4px 0;
}
.sp-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--zone-color, var(--primary));
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: pointer; transition: transform 0.1s, box-shadow 0.1s;
}
.sp-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 1px 6px rgba(0,0,0,0.25);
}
.sp-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--zone-color, var(--primary));
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: pointer;
}
.sp-range-labels {
    display: flex; justify-content: space-between;
    font-size: 8px; color: var(--text-muted); margin-top: 1px;
    font-variant-numeric: tabular-nums;
}

/* Expandable detail panel */
.sp-detail {
    margin-top: 8px; padding: 8px 10px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    animation: sp-expand 0.2s ease;
}
@keyframes sp-expand {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.sp-desc {
    font-size: 11px; color: var(--text-dim); line-height: 1.5;
    margin-bottom: 8px;
}
.sp-zones {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-bottom: 8px;
}
.sp-zone-chip {
    font-size: 8px; font-weight: 600; padding: 2px 7px;
    border-radius: 8px; border: 1px solid;
    letter-spacing: 0.3px; transition: all 0.15s;
}
.sp-input-row {
    display: flex; align-items: center; gap: 8px;
}
.sp-input-label {
    font-size: 10px; color: var(--text-muted);
}
.sp-exact-input {
    width: 80px; padding: 4px 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-xs); color: var(--text);
    font-family: inherit; font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.sp-exact-input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}

/* Footer hint */
.sp-footer {
    flex-shrink: 0; padding: 6px 10px;
    font-size: 10px; color: var(--text-muted);
    text-align: center; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-xs);
}
.info-note {
    font-size: 10px; color: var(--text-muted); padding: 6px 10px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-xs); line-height: 1.4;
}

/* ── Portfolio Page ── */
.portfolio-page {
    display: flex; flex-direction: column; gap: 10px; padding: 12px 16px;
    flex: 1; min-height: 0; overflow-y: auto;
}
.portfolio-top-row { background: transparent; flex-shrink: 0; }
.portfolio-page > .risk-metrics-bar { flex-shrink: 0; }
.portfolio-page > .charts-grid {
    flex-shrink: 0; padding: 0; gap: 10px; min-height: 320px;
}

.portfolio-summary-bar {
    display: flex; align-items: center; padding: 10px 16px; gap: 0; overflow-x: auto;
    background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.psb-item { display: flex; flex-direction: column; align-items: center; padding: 0 14px; min-width: 0; }
.psb-label { font-size: 8px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 2px; white-space: nowrap; font-weight: 500; }
.psb-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.psb-divider { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }

/* ── Risk Metrics Bar (compact single-line) ── */
.risk-metrics-bar {
    display: flex; align-items: center; padding: 8px 12px; gap: 0; overflow-x: auto;
    background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}
.risk-metrics-bar::-webkit-scrollbar { height: 3px; }
.risk-metrics-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.rmb-item { display: flex; flex-direction: column; align-items: center; padding: 0 10px; min-width: 0; }
.rmb-label { font-size: 7px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 1px; white-space: nowrap; font-weight: 500; }
.rmb-value { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rmb-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

/* ── Asset Breakdown ── */
.asset-breakdown-table-wrap { overflow-x: auto; margin-top: 8px; }
.asset-breakdown-table { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.asset-breakdown-table th { text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); padding: 5px 6px; border-bottom: 2px solid var(--border); white-space: nowrap; font-weight: 600; }
.asset-breakdown-table td { padding: 6px 6px; border-bottom: 1px solid var(--bg-alt); white-space: nowrap; }
.asset-breakdown-table tr:last-child td { border-bottom: none; }
.asset-breakdown-table tr:hover td { background: var(--bg); }

/* ── Asset P&L Bars ── */
.asset-pnl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.asset-pnl-label { font-size: 11px; font-weight: 700; min-width: 36px; }
.asset-pnl-bar-track { flex: 1; height: 16px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.asset-pnl-bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s ease; min-width: 2px; }
.asset-pnl-val { font-size: 11px; font-weight: 600; min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Analytics Page ── */
.analytics-page {
    display: flex; flex-direction: column; gap: 10px; padding: 12px 16px;
    flex: 1; min-height: 0; overflow: hidden;
}
.analytics-summary {
    flex-shrink: 0;
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    padding: 16px;
}
.analytics-summary .panel-title { margin-bottom: 12px; }
.analytics-page .charts-grid {
    flex: 1; min-height: 0; overflow-y: auto; padding: 0; gap: 10px;
}

/* ── Performance Page ── */
.performance-page {
    display: flex; flex-direction: column; gap: 10px; padding: 12px 16px;
    flex: 1; min-height: 0; overflow: hidden;
}
.performance-page .charts-grid {
    flex: 1; min-height: 0; overflow-y: auto; padding: 0; gap: 10px;
}

/* ── Responsive ── */
@media (max-width: 1280px) {
    .trading-sidebar { width: 250px; }
    .market-grid { grid-template-columns: repeat(4, 1fr); }
    .sp-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1024px) {
    :root { --sidebar-w: 180px; }
    .main-content { overflow-y: auto; }
    .trading-layout { flex-direction: column; flex: none; overflow: visible; }
    .trading-sidebar { width: 100%; flex-direction: row; gap: 8px; overflow: visible; flex-wrap: wrap; }
    .sidebar-panel { flex: 1; min-width: 240px; max-height: 250px; }
    .sidebar-panel-grow { flex: 1; }
    .trading-bottom { min-height: 400px; }
    .portfolio-page { overflow-y: auto; }
    .portfolio-grid { grid-template-columns: 1fr; }
    .sp-grid { grid-template-columns: 1fr 1fr; }
    .settings-page { overflow-y: auto; }
    .market-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; padding: 12px; overflow-y: visible; }
    .live-charts-grid { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .risk-metrics-grid { grid-template-columns: repeat(3, 1fr); }
    .portfolio-summary-bar { flex-wrap: wrap; gap: 8px; justify-content: center; }
    .psb-divider { display: none; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .dashboard { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .tab-bar {
        display: flex; background: var(--surface); border-bottom: 1px solid var(--border);
        padding: 0 12px; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    }
    .tab {
        display: block; padding: 10px 14px; font-size: 12px; color: var(--text-dim); cursor: pointer;
        border-bottom: 2px solid transparent; transition: color 0.2s; font-family: inherit;
        background: none; border-top: none; border-left: none; border-right: none; font-weight: 500; white-space: nowrap;
    }
    .tab:hover { color: var(--text); }
    .tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
    .trading-layout { flex-direction: column; overflow: visible; flex: none; }
    .trading-sidebar { width: 100%; flex-direction: column; overflow: visible; }
    .sidebar-panel { max-height: 200px; }
    .market-grid { grid-template-columns: repeat(2, 1fr); }
    .header-stats { display: none; }
    .main-content { overflow-y: auto; }
    .trading-bottom { min-height: 300px; }
    .risk-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .sp-grid { grid-template-columns: 1fr; }
    .settings-page { overflow-y: auto; }
    .settings-control-bar { flex-wrap: wrap; }
    body { overflow: auto; height: auto; }
}

@media (max-width: 480px) {
    .market-grid { grid-template-columns: 1fr; }
    .risk-metrics-grid { grid-template-columns: 1fr 1fr; }
    .portfolio-summary-bar { padding: 8px; }
    .psb-item { padding: 0 8px; }
    .psb-value { font-size: 12px; }
    .sidebar-panel { max-height: 180px; }
    .settings-control-bar { padding: 8px; gap: 6px; }
    .strategy-summary { gap: 8px; padding: 8px 10px; }
}

/* ── Live Mode Styling ── */
.live-mode-banner {
    background: var(--red);
    color: white;
    text-align: center;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}
.main-content.live-mode .panel { border-color: rgba(239,68,68,0.2); }
.main-content.live-mode .header .badge-live {
    background: var(--red); color: white; font-weight: 700;
}
.sidebar .mode-tab.active-live {
    background: var(--red); color: white;
}
.sidebar .mode-tab.active-paper {
    background: var(--green); color: white;
}
