/* ============================================================================
   S/R Paper Terminal — Binance-grade dark theme
   ========================================================================== */
:root {
  --bg: #0b0e11;
  --panel: #161a1e;
  --panel2: #1e2329;
  --panel3: #232a31;
  --border: #2b3139;
  --border2: #353d47;
  --text: #eaecef;
  --muted: #848e9c;
  --muted2: #5a6470;
  --yellow: #fcd535;
  --green: #0ecb81;
  --red: #f6465d;
  --blue: #3b9eff;
  --row-h: 30px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#root { height: 100vh; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; font-family: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, Menlo, monospace; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.zero, .dim { color: var(--muted); }
.accent { color: var(--yellow); }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2b3139; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a434e; }
::-webkit-scrollbar-track { background: transparent; }

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

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: stretch; gap: 0;
  height: 48px; flex: 0 0 48px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding-right: 14px;
}
.brand { display: flex; align-items: center; gap: 7px; padding: 0 15px 0 14px; border-right: 1px solid var(--border); }
.brand-mark { color: var(--yellow); font-size: 18px; transform: rotate(0deg); }
.brand-name { font-weight: 800; letter-spacing: 0.5px; font-size: 14px; }
.brand-accent { color: var(--yellow); }
.brand-paper { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--bg); background: var(--yellow); padding: 2px 5px; border-radius: 3px; }

.sym-header { display: flex; align-items: center; gap: 18px; padding: 0 16px; flex: 1; min-width: 0; }
.sym-pick { display: flex; align-items: center; gap: 8px; background: none; border: none; color: var(--text); padding: 5px 9px; border-radius: 6px; }
.sym-pick:hover { background: var(--panel2); }
.sym-ic { width: 20px; height: 20px; border-radius: 50%; background: var(--yellow); color: var(--bg); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.sym-name { font-size: 15px; font-weight: 700; }
.sym-quote { color: var(--muted); font-weight: 600; }
.sym-caret { color: var(--muted); font-size: 10px; }
.sym-perp { font-size: 9px; font-weight: 700; color: var(--yellow); border: 1px solid #5a4d12; background: #2a2510; padding: 2px 4px; border-radius: 3px; }
.sym-price { display: flex; flex-direction: column; gap: 1px; }
.sym-mark { font-size: 17px; font-weight: 700; line-height: 1.05; }
.sym-mark-sub { font-size: 10.5px; color: var(--muted); }
.sym-stats { display: flex; gap: 20px; flex: 1; min-width: 0; overflow: hidden; }
.hstat { display: flex; flex-direction: column; gap: 2px; white-space: nowrap; }
.hstat-k { font-size: 10.5px; color: var(--muted); }
.hstat-v { font-size: 12.5px; font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.hdr-pnl { text-align: right; }
.hdr-pnl-k { font-size: 10px; color: var(--muted); }
.hdr-pnl-v { font-size: 13px; font-weight: 700; line-height: 1.15; }
.hdr-combined { text-align: right; }
.hdr-combined-k { font-size: 10px; color: var(--muted); }
.hdr-combined-v { font-size: 15px; font-weight: 700; display: flex; align-items: center; justify-content: flex-end; gap: 8px; line-height: 1.15; }
.hdr-ret { font-size: 12px; font-weight: 700; }
.status-dots { display: flex; align-items: center; gap: 9px; padding-left: 13px; border-left: 1px solid var(--border); height: 26px; }
.sdot { width: 10px; height: 10px; border-radius: 50%; cursor: help; }
.sdot.live { background: var(--green); box-shadow: 0 0 0 0 rgba(14,203,129,0.6); animation: pulse 2s infinite; }
.sdot.bot { background: var(--yellow); }
.conn { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; }
.conn-dot { width: 7px; height: 7px; border-radius: 50%; }
.conn-dot.live { background: var(--green); box-shadow: 0 0 0 0 rgba(14,203,129,0.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(14,203,129,0.5); } 70% { box-shadow: 0 0 0 6px rgba(14,203,129,0); } 100% { box-shadow: 0 0 0 0 rgba(14,203,129,0); } }
.conn-text { font-size: 11px; font-weight: 700; color: var(--green); letter-spacing: 0.5px; }
.conn-sub { font-size: 10px; color: var(--muted); }
.bot-state { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.bot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }

/* ---------- tab nav ---------- */
.tabnav { display: flex; align-items: center; height: 34px; flex: 0 0 34px; background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 8px; gap: 2px; }
.tabnav-btn { position: relative; background: none; border: none; color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 0 14px; height: 100%; display: flex; align-items: center; gap: 7px; }
.tabnav-btn:hover { color: var(--text); }
.tabnav-btn.on { color: var(--text); font-weight: 600; }
.tabnav-btn.on::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; background: var(--yellow); border-radius: 2px; }
.tabnav-badge { font-size: 10px; font-weight: 700; background: var(--panel3); color: var(--muted); padding: 1px 6px; border-radius: 9px; min-width: 18px; text-align: center; }
.tabnav-btn.on .tabnav-badge { background: #2a2510; color: var(--yellow); }
.tabnav-spacer { flex: 1; }
.tabnav-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted2); padding-right: 12px; }
.dotdiv { color: var(--border2); }

/* ---------- content ---------- */
.content { flex: 1; min-height: 0; overflow: auto; }
.content:has(.terminal) { overflow: hidden; }

/* ---------- KPI row ---------- */
.terminal { padding: 8px; display: flex; flex-direction: column; gap: 8px; height: 100%; }
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 10px 12px; position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border2); }
.kpi.pos::before { background: var(--green); }
.kpi.neg::before { background: var(--red); }
.kpi.accent::before { background: var(--yellow); }
.kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 5px; }
.kpi-v { font-size: 18px; font-weight: 700; }
.kpi.pos .kpi-v { color: var(--green); }
.kpi.neg .kpi-v { color: var(--red); }
.kpi.accent .kpi-v { color: var(--yellow); }
.kpi-sub { font-size: 10.5px; color: var(--muted); margin-top: 3px; }

/* ---------- terminal grid ---------- */
.terminal-grid { display: grid; grid-template-columns: 1fr 286px; gap: 8px; flex: 1; min-height: 0; }
.terminal-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; }
.terminal-rail { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; }

/* ---------- terminal account-cards bar (detailed cards) ---------- */
.term-acc-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.term-acc-bar .acc-card { padding: 11px 12px; border-radius: 7px; }
.term-acc-bar .acc-card-head { margin-bottom: 9px; }
.term-acc-bar .acc-chip { width: 26px; height: 26px; border-radius: 6px; font-size: 12px; }
.term-acc-bar .acc-tf { font-size: 13px; }
.term-acc-bar .acc-ret { font-size: 14px; }
.term-acc-bar .acc-eq { padding: 8px 0; margin-bottom: 8px; }
.term-acc-bar .acc-eq-v { font-size: 17px; }
.term-acc-bar .acc-metrics { gap: 7px 8px; margin-bottom: 9px; }
.term-acc-bar .acc-metrics .metric-v { font-size: 12px; }
.term-acc-bar .acc-wr-text { font-size: 10px; }

/* ---------- rail: recent-trades summary ---------- */
.rail-history { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 8px; }
.rh-list { display: flex; flex-direction: column; gap: 9px; margin-top: 2px; }
.rh-acct-head { display: flex; align-items: center; justify-content: space-between; padding: 3px 4px 5px; border-bottom: 1px solid var(--border); margin-bottom: 3px; }
.rh-acct-name { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; }
.rh-tf { color: var(--muted); font-size: 10px; }
.rh-open-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(14,203,129,0.18); }
.rh-acct-pnl { font-size: 11px; font-weight: 600; }
.rh-row { display: grid; grid-template-columns: 13px 1fr auto auto; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.rh-row:hover { background: var(--panel2); }
.rh-tri { font-size: 9px; }
.rh-tri.long { color: var(--green); }
.rh-tri.short { color: var(--red); }
.rh-line { font-size: 11px; color: var(--text); }
.rh-res { font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 3px; text-align: center; }
.rh-res.TP { color: var(--green); background: rgba(14,203,129,0.14); }
.rh-res.SL { color: var(--red); background: rgba(246,70,93,0.14); }
.rh-res.open { color: var(--yellow); background: #2a2510; }
.rh-pnl { font-size: 11px; font-weight: 600; text-align: right; min-width: 50px; }

/* ---------- chart ---------- */
.chart-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px 4px; position: relative; flex: 0 0 auto; }
.chart-overlay-top { position: absolute; top: 8px; left: 12px; right: 92px; z-index: 6; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.chart-overlay-top > * { pointer-events: auto; }
.chart-tf { display: flex; gap: 1px; background: rgba(11,14,17,0.55); border: 1px solid rgba(43,49,57,0.7); border-radius: 6px; padding: 2px; backdrop-filter: blur(3px); }
.tf-btn { background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 4px; opacity: 0.45; transition: opacity .12s, background .12s, color .12s; }
.tf-btn:hover { color: var(--text); opacity: 1; }
.tf-btn.on { color: var(--yellow); background: var(--panel3); opacity: 1; }
.chart-legend { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; background: rgba(11,14,17,0.55); border: 1px solid rgba(43,49,57,0.7); border-radius: 6px; padding: 3px; backdrop-filter: blur(3px); }
.leg-trades, .leg-lv { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: none; color: var(--muted); font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 4px; opacity: 0.4; transition: opacity .12s, background .12s, color .12s; }
.leg-trades:hover, .leg-lv:hover { opacity: 1; color: var(--text); }
.leg-trades.on, .leg-lv.on { opacity: 1; color: var(--text); background: rgba(43,49,57,0.6); }
.leg-dash { width: 12px; height: 3px; border-radius: 1px; }
.leg-tri { display: inline-block; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.leg-tri.up { border-bottom: 6px solid var(--green); }
.leg-tri.dn { border-top: 6px solid var(--red); }
.leg-sep { width: 1px; height: 14px; background: var(--border2); margin: 0 2px; }
.chart-svg { width: 100%; display: block; }
.chart-svg text { user-select: none; }
.chart-svg .daylbl { fill: #5a6470; opacity: 0.4; transition: opacity .15s; }
.chart-wrap:hover .daylbl { opacity: 0.92; }

/* chart tooltip */
.chart-tip { position: absolute; z-index: 30; width: 244px; background: #0e1419; border: 1px solid var(--border2); border-radius: 8px; padding: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.6); pointer-events: none; }
.tip-head { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.tip-side { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 3px; }
.tip-side.long { color: var(--green); background: rgba(14,203,129,0.14); }
.tip-side.short { color: var(--red); background: rgba(246,70,93,0.14); }
.tip-lv { font-size: 10px; font-weight: 700; color: var(--bg); padding: 1px 5px; border-radius: 3px; }
.tip-id { font-size: 10px; color: var(--muted); margin-left: auto; }
.tip-reason { font-size: 11.5px; line-height: 1.35; color: var(--text); background: var(--panel2); border-left: 2px solid var(--yellow); padding: 6px 8px; border-radius: 4px; margin-bottom: 8px; }
.tip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.tip-grid > div { display: flex; justify-content: space-between; font-size: 11px; }
.tip-grid span { color: var(--muted); }
.tip-grid b { font-weight: 600; }

/* ---------- active positions strip ---------- */
.aps { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; flex: 1; min-height: 92px; display: flex; flex-direction: column; }
.aps-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.aps-title { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.aps-count { font-size: 10px; font-weight: 700; background: #2a2510; color: var(--yellow); padding: 1px 7px; border-radius: 9px; }
.aps-hint { font-size: 10.5px; color: var(--muted2); }
.aps-table-wrap { overflow: auto; flex: 1; min-height: 0; }
.aps-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.aps-table thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.aps-table th { text-align: left; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 10px; white-space: nowrap; }
.aps-table th.r, .aps-table td.r { text-align: right; }
.aps-table td { padding: 6px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.aps-table tbody tr { cursor: pointer; }
.aps-table tbody tr:hover { background: var(--panel2); }

/* ---------- right rail ---------- */
.ticker-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.tk-head { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tk-price { font-size: 22px; font-weight: 700; line-height: 1; }
.tk-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.tk-meta .tk-mark { font-size: 11px; color: var(--muted); }
.tk-tape { max-height: 196px; overflow: hidden; }
.tk-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 2px 12px; font-size: 11px; }
.tk-row .qty { color: var(--muted); }
.tk-row .time { color: var(--muted2); }
.tk-row.up .px { color: var(--green); }
.tk-row.dn .px { color: var(--red); }

.rail-accounts { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.rail-title { font-size: 12px; font-weight: 600; padding: 2px 4px 6px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.rail-sub { font-size: 10px; color: var(--muted2); font-weight: 400; }
.ra-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 9px; }
.ra-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ra-name { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.ra-tf { color: var(--muted); font-size: 10px; font-weight: 500; }
.lv-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.ra-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(14,203,129,0.18); }
.ra-ret { font-size: 12px; font-weight: 700; }
.ra-mid { display: flex; gap: 14px; margin-bottom: 6px; }
.ra-mid > div { display: flex; flex-direction: column; gap: 1px; }
.ra-k { font-size: 9.5px; color: var(--muted); }
.ra-mid .mono { font-size: 12px; }
.ra-bar { height: 3px; background: #0e1216; border-radius: 2px; overflow: hidden; }
.ra-bar-fill { height: 100%; border-radius: 2px; }
.rail-total { display: flex; align-items: center; justify-content: space-between; padding: 8px 6px 4px; border-top: 1px solid var(--border); margin-top: 2px; font-size: 12px; font-weight: 600; }
.rail-total .mono { color: var(--yellow); }

/* ---------- generic page ---------- */
.page { padding: 14px 16px 28px; max-width: 1640px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 3px; }
.page-title h2 { margin: 0; font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; white-space: nowrap; line-height: 1.2; }
.page-sub { font-size: 12px; color: var(--muted); }
.audit-badge, .ref-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--yellow); background: #2a2510; padding: 3px 7px; border-radius: 4px; }
.ref-badge { color: var(--muted); background: var(--panel2); border: 1px solid var(--border); }

/* toolbar / filters */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tb-spacer { flex: 1; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
.seg-btn { background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 4px; display: flex; align-items: center; gap: 6px; }
.seg-btn b { font-size: 10px; background: var(--panel3); padding: 1px 5px; border-radius: 8px; color: var(--muted); }
.seg-btn.on { background: var(--panel3); color: var(--text); }
.seg-btn.on b { background: #2a2510; color: var(--yellow); }

.search { position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 9px; color: var(--muted); font-size: 14px; }
.search input { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12.5px; padding: 7px 26px 7px 27px; width: 230px; outline: none; }
.search input:focus { border-color: var(--border2); }
.search input::placeholder { color: var(--muted2); }
.search-x { position: absolute; right: 7px; background: none; border: none; color: var(--muted); font-size: 11px; }

.filt { position: relative; }
.filt-btn { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 7px 11px; border-radius: 6px; }
.filt-btn:hover { color: var(--text); }
.filt-btn.active { color: var(--text); border-color: var(--border2); }
.filt-caret { font-size: 9px; }
.filt-count { font-size: 10px; font-weight: 700; background: #2a2510; color: var(--yellow); padding: 0 5px; border-radius: 8px; }
.filt-backdrop { position: fixed; inset: 0; z-index: 40; }
.filt-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 41; background: var(--panel2); border: 1px solid var(--border2); border-radius: 7px; padding: 5px; min-width: 168px; box-shadow: 0 12px 40px rgba(0,0,0,0.55); }
.filt-all { width: 100%; text-align: left; background: none; border: none; color: var(--muted); font-size: 11px; padding: 5px 8px; border-bottom: 1px solid var(--border); margin-bottom: 3px; }
.filt-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 4px; font-size: 12px; cursor: pointer; }
.filt-row:hover { background: var(--panel3); }
.filt-row input { accent-color: var(--yellow); }
.filt-lv { display: flex; align-items: center; gap: 7px; }
.clear-all { background: none; border: 1px solid var(--border); color: var(--muted); font-size: 12px; padding: 7px 11px; border-radius: 6px; }
.clear-all:hover { color: var(--text); border-color: var(--border2); }

/* agg bar */
.agg-bar { display: flex; gap: 22px; padding: 9px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 7px 7px 0 0; border-bottom: none; }
.agg { display: flex; flex-direction: column; gap: 2px; }
.agg.sm { flex-direction: row; align-items: center; gap: 6px; }
.agg span { font-size: 10.5px; color: var(--muted); }
.agg b { font-size: 14px; font-weight: 700; }
.agg.filt-on b { color: var(--yellow); }

/* ---------- data table ---------- */
.table-card { background: var(--panel); border: 1px solid var(--border); border-radius: 0 0 7px 7px; overflow: hidden; }
.page > .table-card { border-radius: 7px; }
.dt { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dt thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sort-th { text-align: left; color: var(--muted); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 11px; white-space: nowrap; cursor: pointer; user-select: none; border-bottom: 1px solid var(--border); }
.sort-th.r { text-align: right; }
.sort-th:hover { color: var(--text); }
.sort-th.active { color: var(--text); }
.sort-caret { margin-left: 5px; font-size: 9px; color: var(--muted2); }
.sort-th.active .sort-caret { color: var(--yellow); }
.dt tbody td { padding: 7px 11px; border-bottom: 1px solid #1c2127; white-space: nowrap; }
.dt tbody td.r { text-align: right; }
.dt tbody tr { cursor: pointer; }
.dt tbody tr:hover { background: var(--panel2); }
.dt td.sm { font-size: 11px; }

/* tags */
.lv-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.lv-tag.sm { font-size: 11.5px; }
.lv-tag .lv-tf { color: var(--muted); font-size: 10px; margin-left: 2px; }
.side-tag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 3px; letter-spacing: 0.02em; }
.side-tag.long { color: var(--green); background: rgba(14,203,129,0.12); }
.side-tag.short { color: var(--red); background: rgba(246,70,93,0.12); }
.res-tag { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 3px; letter-spacing: 0.03em; }
.res-tag.tp { color: var(--green); background: rgba(14,203,129,0.14); }
.res-tag.sl { color: var(--red); background: rgba(246,70,93,0.14); }
.res-tag.open { color: var(--yellow); background: #2a2510; }

/* reason cells */
.reason-cell { max-width: 360px; }
.reason-pill { display: inline-block; font-size: 11.5px; color: var(--text); background: var(--panel2); border-left: 2px solid var(--yellow); padding: 3px 8px; border-radius: 0 4px 4px 0; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.reason-pill.TP { border-left-color: var(--green); }
.reason-pill.SL { border-left-color: var(--red); }
.reason-pill.muted { border-left-color: var(--muted2); color: var(--muted); }

/* pager */
.pager { display: flex; align-items: center; gap: 18px; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--panel); }
.pager-info { font-size: 12px; color: var(--muted); }
.pager-info span { color: var(--muted2); }
.pager-rpp { display: flex; align-items: center; gap: 4px; }
.pager-rpp span { font-size: 11px; color: var(--muted); margin-right: 3px; }
.rpp-btn { background: none; border: 1px solid var(--border); color: var(--muted); font-size: 11px; padding: 3px 8px; border-radius: 4px; }
.rpp-btn.on { background: var(--panel3); color: var(--yellow); border-color: var(--border2); }
.pager-nav { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.pg-btn { background: none; border: 1px solid var(--border); color: var(--muted); font-size: 12px; min-width: 26px; height: 26px; border-radius: 4px; }
.pg-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border2); }
.pg-btn.on { background: var(--yellow); color: var(--bg); border-color: var(--yellow); font-weight: 700; }
.pg-btn:disabled { opacity: 0.35; cursor: default; }
.pg-ell { color: var(--muted2); padding: 0 2px; }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 48px 20px; }
.empty-ic { font-size: 30px; color: var(--border2); }
.empty-title { font-size: 14px; font-weight: 600; color: var(--muted); }
.empty-sub { font-size: 12px; color: var(--muted2); }

/* ---------- history layout ---------- */
.history-grid { display: grid; grid-template-columns: 232px 1fr; gap: 10px; align-items: start; }
.day-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; position: sticky; top: 0; }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.day-clear { background: none; border: none; color: var(--yellow); font-size: 11px; }
.day-list { max-height: 560px; overflow: auto; }
.day-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; width: 100%; background: none; border: none; border-bottom: 1px solid #1c2127; padding: 7px 12px; text-align: left; }
.day-row.all { grid-template-columns: 1fr auto; }
.day-row:not(.all) { grid-template-columns: 64px 1fr auto; }
.day-row:hover { background: var(--panel2); }
.day-row.on { background: var(--panel3); }
.day-date { font-size: 11.5px; color: var(--text); font-variant-numeric: tabular-nums; display: flex; flex-direction: column; }
.day-n { font-size: 9.5px; color: var(--muted2); }
.day-mini { height: 4px; background: #0e1216; border-radius: 2px; overflow: hidden; }
.day-bar { display: block; height: 100%; border-radius: 2px; }
.day-pnl { font-size: 11.5px; font-weight: 600; text-align: right; }
.history-main { min-width: 0; }
.history-tb { margin-bottom: 10px; }

/* ---------- missed cats ---------- */
.miss-cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.miss-cat { display: flex; align-items: center; gap: 9px; background: var(--panel); border: 1px solid var(--border); border-radius: 7px; padding: 11px 13px; text-align: left; }
.miss-cat:hover { border-color: var(--border2); }
.miss-cat.on { background: var(--panel2); }
.miss-cat-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.miss-cat-label { font-size: 12.5px; font-weight: 600; flex: 1; }
.miss-cat-n { font-size: 16px; font-weight: 800; }
.miss-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; border: 1px solid; white-space: nowrap; }
.miss-row:hover { background: var(--panel2); }

/* ---------- accounts ---------- */
.combined { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 28px; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 16px 20px; margin-bottom: 14px; }
.combined-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.combined-eq { font-size: 28px; font-weight: 800; }
.combined-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.combined-stats { display: flex; gap: 30px; }
.cstat { display: flex; flex-direction: column; gap: 3px; }
.cstat-k { font-size: 11px; color: var(--muted); }
.cstat-v { font-size: 16px; font-weight: 700; }
.combined-curve { padding-left: 18px; border-left: 1px solid var(--border); }

/* terminal variant of the combined banner (replaces the old KPI cards) */
.terminal-combined { margin-bottom: 10px; padding: 14px 20px; }
.terminal-combined .combined-eq { font-size: 26px; }
.combined-accts { font-size: 10px; font-weight: 400; color: var(--muted2); margin-left: 6px; }
.terminal-combined .combined-stats { gap: 26px; }
.combined-curve-cap { font-size: 10px; color: var(--muted2); margin-top: 4px; text-align: right; }

.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.acc-card { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 14px; }
.acc-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.acc-name { display: flex; align-items: center; gap: 10px; }
.acc-chip { width: 30px; height: 30px; border-radius: 7px; color: var(--bg); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.acc-tf { font-size: 14px; font-weight: 700; }
.acc-tf-sub { color: var(--muted); font-size: 11px; font-weight: 500; }
.acc-strength { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.acc-open-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.acc-ret { font-size: 16px; font-weight: 800; }
.acc-eq { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.acc-eq-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.acc-eq-v { font-size: 20px; font-weight: 700; }
.acc-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 10px; margin-bottom: 12px; }
.metric { display: flex; flex-direction: column; gap: 2px; }
.metric-k { font-size: 10.5px; color: var(--muted); }
.metric-v { font-size: 13px; font-weight: 600; }
.acc-wr { display: flex; align-items: center; gap: 10px; }
.acc-wr-bar { flex: 1; height: 5px; background: #0e1216; border-radius: 3px; overflow: hidden; }
.acc-wr-fill { height: 100%; background: var(--yellow); border-radius: 3px; }
.acc-wr-text { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- strategy ---------- */
.strat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.strat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 16px 18px; }
.strat-card.span2 { grid-column: 1 / -1; }
.strat-card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.rule-accent { width: 4px; height: 15px; border-radius: 2px; }
.strat-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.strat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.strat-table th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.strat-table th.r, .strat-table td.r { text-align: right; }
.strat-table td { padding: 9px 12px; border-bottom: 1px solid #1c2127; }
.strat-lv { font-weight: 800; font-size: 14px; }
.strat-swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }
.strat-total td { font-weight: 700; color: var(--text); border-bottom: none; padding-top: 11px; }
.strat-total td:first-child { color: var(--muted); font-weight: 500; }
.rules { display: flex; flex-direction: column; gap: 11px; }
.rule { display: grid; grid-template-columns: 116px 1fr; gap: 12px; }
.rule-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.rule-body { font-size: 12.5px; line-height: 1.5; color: var(--text); }
.rule-code { display: inline-block; font-family: "SF Mono", ui-monospace, monospace; font-size: 11.5px; background: var(--panel3); color: var(--yellow); padding: 2px 7px; border-radius: 4px; margin: 2px 4px 2px 0; }
.skip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.skip { display: flex; gap: 10px; }
.skip-dot { width: 10px; height: 10px; border-radius: 3px; margin-top: 3px; flex: 0 0 10px; }
.skip-label { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.skip-body { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 432px; max-width: 92vw; background: var(--panel); border-left: 1px solid var(--border2); z-index: 51; display: flex; flex-direction: column; box-shadow: -16px 0 50px rgba(0,0,0,0.5); animation: slidein 0.22s cubic-bezier(0.2,0.7,0.2,1); }
@keyframes slidein { from { transform: translateX(34px); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.drawer-head-l { display: flex; align-items: center; gap: 8px; }
.drawer-id { font-size: 11px; color: var(--muted); }
.drawer-x { background: var(--panel2); border: 1px solid var(--border); color: var(--muted); width: 28px; height: 28px; border-radius: 6px; font-size: 12px; }
.drawer-x:hover { color: var(--text); }
.drawer-body { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.dr-section { }
.dr-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 7px; }
.reason-hero { display: flex; flex-direction: column; gap: 7px; background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--yellow); border-radius: 0 7px 7px 0; padding: 11px 13px; }
.reason-hero.close.TP { border-left-color: var(--green); }
.reason-hero.close.SL { border-left-color: var(--red); }
.reason-hero.close.open { border-left-color: var(--yellow); }
.reason-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.reason-text { font-size: 14px; font-weight: 600; line-height: 1.4; }
.dr-pnl { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-radius: 8px; border: 1px solid; }
.dr-pnl.pos { background: rgba(14,203,129,0.08); border-color: rgba(14,203,129,0.25); }
.dr-pnl.neg { background: rgba(246,70,93,0.08); border-color: rgba(246,70,93,0.25); }
.dr-pnl-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.dr-pnl-usd { font-size: 22px; font-weight: 800; }
.dr-pnl.pos .dr-pnl-usd { color: var(--green); }
.dr-pnl.neg .dr-pnl-usd { color: var(--red); }
.dr-pnl-pct { font-size: 14px; font-weight: 700; text-align: right; }
.dr-pnl-pct span { display: block; font-size: 10px; font-weight: 400; color: var(--muted); }
.ladder { display: flex; flex-direction: column; }
.ladder-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #232a31; }
.ladder-tick { width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--border2); }
.ladder-row.entry .ladder-tick { background: var(--yellow); border-color: var(--yellow); }
.ladder-row.tp .ladder-tick { background: var(--green); border-color: var(--green); }
.ladder-row.target .ladder-tick { border-color: var(--green); }
.ladder-row.prev .ladder-tick { border-color: var(--red); }
.ladder-name { font-size: 12px; color: var(--text); }
.ladder-row.entry .ladder-name { font-weight: 600; }
.ladder-px { font-size: 12.5px; font-weight: 600; }
.dr-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.fact { display: flex; flex-direction: column; gap: 2px; background: var(--panel); padding: 8px 10px; }
.fact-k { font-size: 10.5px; color: var(--muted); }
.fact-v { font-size: 12.5px; font-weight: 600; }
.dr-rules { background: var(--panel2); border: 1px solid var(--border); border-radius: 7px; padding: 12px 14px; }
.dr-rules-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 9px; }
.dr-rules ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.dr-rules li { font-size: 12px; line-height: 1.4; color: var(--text); display: flex; gap: 8px; }
.dr-rules .ok { color: var(--green); font-weight: 700; }

/* responsive */
@media (max-width: 1280px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .terminal-grid { grid-template-columns: 1fr 260px; }
  .term-acc-bar { grid-template-columns: repeat(3, 1fr); }
  .miss-cats { grid-template-columns: repeat(2, 1fr); }
  .sym-stats { display: none; }
}
@media (max-width: 1000px) {
  .terminal-grid { grid-template-columns: 1fr; }
  .term-acc-bar { grid-template-columns: repeat(2, 1fr); }
  .history-grid { grid-template-columns: 1fr; }
  .strat-grid { grid-template-columns: 1fr; }
  .combined { grid-template-columns: 1fr; gap: 14px; }
}
