/* Mission Control — Dashboard (command-center layout).
   Builds on app.css palette. Bigtech-exchange aesthetic: hairline borders,
   tabular numerics, meaningful colour only (green/red PnL, live/dry split,
   gold for the one premium metric). Flat panels, no decorative glow/lift.

   Mode language:
     --live → #3b82f6 (blue)     LIVE = real money
     --dry  → #a78bfa (lavender)  DRY  = paper / shadow
*/

:root {
    --live: #3b82f6;
    --live-bg: rgba(59, 130, 246, 0.12);
    --dry: #a78bfa;
    --dry-bg: rgba(167, 139, 250, 0.12);
    --gold: #d4af37;
    --gold-bg: rgba(212, 175, 55, 0.10);
    --panel: #0f1018;
    --panel-2: #14151f;
    --border-soft: #1f2030;
    --grid: 12px;
}

.mono, .dash .mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

.dash {
    display: flex; flex-direction: column;
    gap: var(--grid);
    padding-bottom: 28px;
}

/* ───────────────────────────────────────── Command bar (system vitals) */
.cmd-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding: 9px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    position: sticky;
    top: 64px;
    z-index: 9;
    backdrop-filter: blur(6px);
}
.cmd-cluster { display: flex; align-items: center; gap: 16px; }
.cmd-engine { gap: 10px; }
.cmd-div { width: 1px; height: 26px; background: var(--border-soft); }
.cmd-stat { display: flex; flex-direction: column; line-height: 1.25; gap: 1px; }
.cmd-k {
    font-size: 9px; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 600;
}
.cmd-v {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
    font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 5px;
}
.cmd-sub { font-size: 10.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cmd-bar .sep { color: var(--text-muted); }

/* Engine pulse dot */
.live-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--text-muted); flex: 0 0 auto;
}
#health-strip[data-engine="running"] .live-dot {
    background: var(--green); animation: pulse 1.6s infinite;
}
#health-strip[data-engine="stopped"] .live-dot { background: var(--red); }
#health-strip[data-engine="error"]   .live-dot { background: var(--yellow); }
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Mode pill */
.mode-pill {
    padding: 2px 9px; border-radius: 4px;
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--dry); background: var(--dry-bg); border: 1px solid var(--dry);
}
.mode-pill.is-live { color: var(--live); background: var(--live-bg); border-color: var(--live); }

/* Per-mode mini tags */
.mode-tag {
    display: inline-block; padding: 1px 6px; border-radius: 3px;
    font-size: 11px; font-weight: 600; margin-right: 3px; font-variant-numeric: tabular-nums;
}
.mt-live { color: var(--live); background: var(--live-bg); }
.mt-dry  { color: var(--dry);  background: var(--dry-bg); }
.m-live  { color: var(--live); }
.m-dry   { color: var(--dry); }

/* Command-bar quick-links — icon-only launchers pinned to the bar's right edge
   (margin-left:auto eats the empty space). No labels; the page name shows on
   hover. Glyphs match the sidebar rail's SVG set. */
.cmd-quicklinks { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex: 0 0 auto; }
.cmd-qlink {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px;
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: color 0.13s ease, background 0.13s ease, border-color 0.13s ease;
}
.cmd-qlink:hover {
    color: var(--accent-hover);
    background: var(--bg-tertiary);
    border-color: var(--border);
}
.cmd-qico {
    width: 16px; height: 16px; flex: 0 0 auto;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ───────────────────────────────────────── Quick-nav hub */
.qnav {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}
@media (max-width: 1320px) { .qnav { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px)  { .qnav { grid-template-columns: repeat(2, 1fr); } }
.qnav-tile {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    text-decoration: none;
    transition: border-color 0.13s ease, background 0.13s ease;
    min-width: 0;
}
.qnav-tile:hover { border-color: var(--accent); background: var(--panel-2); }
.qnav-ico {
    flex: 0 0 auto; width: 30px; height: 30px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px; background: var(--bg-tertiary);
    color: var(--text-secondary); transition: color 0.13s ease;
}
.qnav-tile:hover .qnav-ico { color: var(--accent-hover); }
.qnav-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.qnav-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.qnav-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qnav-meta { font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.qnav-meta b { color: var(--text-secondary); font-weight: 700; }

/* ───────────────────────────────────────── Section heads + panels */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex; flex-direction: column;
}
.sec-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 2px;
}
.sec-head > h3, .panel-head h3 {
    margin: 0;
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; font-weight: 600; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--text-primary);
}
.sec-ico {
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.sec-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.panel-head {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel-head .muted { font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.legend { display: flex; gap: 10px; font-size: 10.5px; color: var(--text-secondary); align-items: center; }
.lg-live { color: var(--live); } .lg-dry { color: var(--dry); }
.lg-win { color: var(--green); } .lg-loss { color: var(--red); } .lg-dd { color: #b45309; }
.link-out { font-size: 11px; color: var(--accent); text-decoration: none; letter-spacing: 0.03em; white-space: nowrap; }
.link-out:hover { color: var(--accent-hover); text-decoration: underline; }

/* ───────────────────────────────────────── Performance toolbar (filters) */
.perf { display: flex; flex-direction: column; gap: var(--grid); }
.perf-head { flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fb-group { display: flex; align-items: center; gap: 4px; }
.fb-group + .fb-group { margin-left: 4px; padding-left: 10px; border-left: 1px solid var(--border-soft); }
.fb-meta { gap: 9px; }
.chip {
    background: transparent; border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 11px; border-radius: 999px;
    font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all 0.12s ease;
    display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { color: var(--text-primary); border-color: var(--accent); }
.chip.is-active { color: #fff; background: var(--accent); border-color: var(--accent); }
.chip-mode .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-both { background: var(--accent); } .dot-live { background: var(--live); } .dot-dry { background: var(--dry); }
.chip-mode.is-active[data-mode="live"] { background: var(--live); border-color: var(--live); }
.chip-mode.is-active[data-mode="dry"]  { background: var(--dry); border-color: var(--dry); color: #1a1a28; }
.chip-ghost { padding: 4px 9px; color: var(--text-muted); border-color: var(--border-soft); }
.fb-select {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.fb-select select {
    background: var(--panel-2); border: 1px solid var(--border); color: var(--text-primary);
    padding: 4px 7px; border-radius: 5px; font-size: 12px; min-width: 96px; max-width: 180px;
}
.range-label { font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.auto-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); cursor: pointer; }
.auto-toggle input { accent-color: var(--accent); }

/* ───────────────────────────────────────── KPI strip (compact) */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--grid); }
@media (max-width: 1320px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-tile {
    background: var(--panel); border: 1px solid var(--border); border-radius: 9px;
    padding: 10px 13px 11px;
    transition: border-color 0.13s ease;
}
.kpi-tile:hover { border-color: var(--border); }
.kpi-tile.is-premium { border-color: rgba(212, 175, 55, 0.28); }
.kpi-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.kpi-label { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.kpi-tile.is-premium .kpi-label { color: var(--gold); }
.kpi-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); line-height: 1.15; letter-spacing: -0.01em; }
.kpi-value.positive { color: var(--green); }
.kpi-value.negative { color: var(--red); }
.kpi-value.premium  { color: var(--gold); }
.kpi-sub { margin-top: 3px; font-size: 10.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-row { margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-modes { display: flex; gap: 6px; font-size: 10.5px; flex-wrap: wrap; }
.kpi-modes .m { font-variant-numeric: tabular-nums; }
.kpi-sparkline { width: 64px; height: 22px; flex-shrink: 0; }
.delta-pill { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta-pill.up { color: var(--green); background: var(--green-bg); }
.delta-pill.down { color: var(--red); background: var(--red-bg); }
.delta-pill.flat { color: var(--text-muted); background: var(--bg-tertiary); }

/* ───────────────────────────────────────── Charts row */
.charts-row { display: grid; grid-template-columns: 1.7fr 1fr; gap: var(--grid); }
@media (max-width: 1320px) { .charts-row { grid-template-columns: 1fr; } }
.chart-wrap { height: 220px; padding: 6px; }

/* ───────────────────────────────────────── Analytics grid */
.analytics {
    display: grid;
    grid-template-columns: 1fr 1.25fr 1fr;
    grid-template-areas:
        "byex    bypair  capital"
        "heatmap exit    streaks";
    gap: var(--grid);
    align-items: stretch;
}
.panel-byex { grid-area: byex; } .panel-bypair { grid-area: bypair; } .panel-capital { grid-area: capital; }
.panel-heatmap { grid-area: heatmap; } .panel-exit { grid-area: exit; } .panel-streaks { grid-area: streaks; }
@media (max-width: 1320px) {
    .analytics {
        grid-template-columns: 1fr 1fr;
        grid-template-areas: "byex bypair" "capital capital" "heatmap heatmap" "exit streaks";
    }
}
@media (max-width: 880px) {
    .analytics { grid-template-columns: 1fr; grid-template-areas: "byex" "bypair" "capital" "heatmap" "exit" "streaks"; }
}
.panel-byex .panel-head + div,
.panel-bypair .panel-head + div,
.panel-exit .panel-head + div,
.panel-capital .panel-head + div { padding: 6px; }

/* The three top-row list panels share ONE fixed, low body height so they line
   up edge-to-edge; By Pair fills to its 10 rows and scrolls under a hairline
   scrollbar, the two exchange panels (active venues only) pad out to match. */
.byex-list, .bypair-list, .capital-list {
    box-sizing: border-box;
    height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-soft) transparent;
}
.byex-list::-webkit-scrollbar,
.bypair-list::-webkit-scrollbar,
.capital-list::-webkit-scrollbar { width: 6px; }
.byex-list::-webkit-scrollbar-track,
.bypair-list::-webkit-scrollbar-track,
.capital-list::-webkit-scrollbar-track { background: transparent; }
.byex-list::-webkit-scrollbar-thumb,
.bypair-list::-webkit-scrollbar-thumb,
.capital-list::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 3px; }
.byex-list:hover::-webkit-scrollbar-thumb,
.bypair-list:hover::-webkit-scrollbar-thumb,
.capital-list:hover::-webkit-scrollbar-thumb { background: var(--border); }

/* List rows (by exchange / by pair / capital) */
.byex-row, .bypair-row, .capital-row {
    display: grid;
    grid-template-columns: 1.4fr 0.9fr 1fr 0.9fr 0.7fr;
    align-items: center; gap: 8px;
    padding: 7px 9px; border-radius: 6px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 12px; transition: background 0.1s; cursor: pointer;
}
.byex-row:last-child, .bypair-row:last-child, .capital-row:last-child { border-bottom: none; }
.byex-row:hover, .bypair-row:hover, .capital-row:hover { background: var(--bg-hover); }
.byex-name, .bypair-name { display: flex; align-items: center; gap: 6px; color: var(--text-primary); font-weight: 600; }
.byex-modes { display: flex; gap: 3px; flex-wrap: wrap; }
.run-badge { display: inline-block; padding: 1px 5px; border-radius: 3px; font-size: 10px; font-weight: 700; letter-spacing: 0.04em; }
.run-badge.live { color: var(--live); background: var(--live-bg); border: 1px solid var(--live); }
.run-badge.dry  { color: var(--dry);  background: var(--dry-bg);  border: 1px solid var(--dry); }
.run-badge.stopped { color: var(--text-muted); background: var(--bg-tertiary); border: 1px solid var(--border); }
.wl-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--border-soft); min-width: 72px; }
.wl-bar > span { display: block; height: 100%; }
.wl-bar .w { background: var(--green); } .wl-bar .l { background: var(--red); }
.cell-pnl { font-variant-numeric: tabular-nums; text-align: right; }
.cell-pnl.pos { color: var(--green); } .cell-pnl.neg { color: var(--red); }
.cell-trades { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cell-wr { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.bypair-row { grid-template-columns: 1.1fr 0.7fr 1.2fr 0.7fr 0.7fr; }
.bypair-spark { width: 100%; height: 22px; }

/* Heatmap */
.heatmap-wrap { padding: 10px; overflow-x: auto; }
.heatmap-grid { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; min-width: 460px; }
.heatmap-grid .h-head, .heatmap-grid .h-rowlabel { font-size: 9px; color: var(--text-muted); text-align: center; padding: 2px 0; letter-spacing: 0.04em; }
.heatmap-grid .h-rowlabel { text-align: right; padding-right: 4px; font-weight: 600; }
.heatmap-cell { height: 20px; border-radius: 3px; background: var(--bg-tertiary); cursor: default; }
.heatmap-cell[data-q="0"]  { background: rgba(99,102,241,0.05); }
.heatmap-cell[data-q="1"]  { background: rgba(99,102,241,0.15); }
.heatmap-cell[data-q="2"]  { background: rgba(99,102,241,0.30); }
.heatmap-cell[data-q="3"]  { background: rgba(34,197,94,0.40); }
.heatmap-cell[data-q="4"]  { background: rgba(34,197,94,0.65); }
.heatmap-cell[data-q="-1"] { background: rgba(239,68,68,0.30); }
.heatmap-cell[data-q="-2"] { background: rgba(239,68,68,0.55); }
.heatmap-scale { width: 88px; height: 7px; background: linear-gradient(90deg, rgba(239,68,68,0.6), rgba(99,102,241,0.2), rgba(34,197,94,0.6)); border-radius: 2px; }

/* Exit reasons */
.exit-row { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); font-size: 12px; }
.exit-row:last-child { border-bottom: none; }
.exit-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.exit-name { font-weight: 600; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.03em; font-size: 11px; }
.exit-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.exit-bar { display: flex; height: 5px; border-radius: 3px; overflow: hidden; background: var(--border-soft); }
.exit-bar .seg { height: 100%; }
.exit-bar .seg-tp { background: var(--green); } .exit-bar .seg-sl { background: var(--red); }
.exit-bar .seg-l2 { background: var(--live); } .exit-bar .seg-fn { background: var(--yellow); }
.exit-bar .seg-mn { background: var(--text-muted); } .exit-bar .seg-x { background: var(--accent); }
.exit-meta { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Streaks */
.streaks-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 11px; }
.streak-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.streak-stat { background: var(--panel-2); border-radius: 6px; padding: 9px 11px; border: 1px solid var(--border-soft); }
.streak-stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.streak-stat .v.pos { color: var(--green); } .streak-stat .v.neg { color: var(--red); }
.streak-stat .l { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.streak-chain { display: flex; gap: 3px; flex-wrap: wrap; }
.streak-dot { width: 15px; height: 15px; border-radius: 4px; background: var(--border-soft); }
.streak-dot.win { background: var(--green); } .streak-dot.loss { background: var(--red); }

/* Capital */
.capital-row { grid-template-columns: 1fr 0.8fr 0.9fr 0.9fr 0.7fr; }
.cap-name { color: var(--text-primary); font-weight: 600; }
.cap-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--border-soft); min-width: 72px; }
.cap-bar .live { background: var(--live); height: 100%; } .cap-bar .dry { background: var(--dry); height: 100%; }
.cap-free { background: transparent; height: 100%; }
.cap-meta { font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ───────────────────────────────────────── Active ops */
.panel-ops { margin-top: 2px; }
.ops-head { padding: 0; padding-right: 14px; border-bottom: 1px solid var(--border-soft); }
.ops-tabs { display: flex; }
.ops-tab {
    background: transparent; border: none; color: var(--text-secondary);
    padding: 11px 16px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
    text-transform: uppercase; cursor: pointer; border-bottom: 2px solid transparent;
    display: inline-flex; align-items: center; gap: 8px;
}
.ops-tab:hover { color: var(--text-primary); }
.ops-tab.is-active { color: var(--text-primary); border-bottom-color: var(--accent); }
.ops-count { background: var(--bg-tertiary); padding: 1px 7px; border-radius: 999px; font-size: 10px; font-variant-numeric: tabular-nums; }
.ops-tab.is-active .ops-count { background: var(--accent); color: #fff; }
.ops-body { min-height: 110px; max-height: 420px; overflow-y: auto; }
.ops-pane { display: none; padding: 6px 0; }
.ops-pane.is-active { display: block; }
.ops-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.ops-table thead th {
    text-align: left; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-muted); padding: 8px 12px; font-weight: 600;
    border-bottom: 1px solid var(--border-soft); background: var(--panel-2); position: sticky; top: 0;
}
.ops-table tbody td { padding: 7px 12px; border-bottom: 1px solid var(--border-soft); color: #b7bccd; font-variant-numeric: tabular-nums; line-height: 1.4; }
.ops-table tbody tr:hover { background: var(--bg-hover); }
.ops-table tbody tr:hover td { color: #d7dae6; }
.ops-table .side-long { color: var(--green); font-weight: 600; }
.ops-table .side-short { color: var(--red); font-weight: 600; }
.ops-table .num { text-align: right; color: #cdd1de; }
.ops-table .num.pos { color: var(--green); } .ops-table .num.neg { color: var(--red); }
.ops-table a.sym { color: #e5e7ee; text-decoration: none; font-weight: 600; letter-spacing: 0.01em; }
.ops-table a.sym:hover { color: var(--accent); }
.sl-bar { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-muted); }
.sl-bar .bar { width: 56px; height: 4px; background: var(--border-soft); border-radius: 2px; overflow: hidden; position: relative; }
.sl-bar .bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--red)); }

/* ───────────────────────────────────────── States */
.empty-state { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 12px; }
.skeleton {
    background: linear-gradient(90deg, var(--panel-2) 0%, var(--bg-hover) 50%, var(--panel-2) 100%);
    background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 4px; color: transparent;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .skeleton, .kpi-tile { animation: none !important; transition: none !important; } }
