/* ============================================================================
   Paper Trader — reimagined UI draft
   One stylesheet, no build step, no external fonts. System stacks only so the
   screenshots render deterministically.
   ========================================================================= */

:root {
  /* --- surfaces: 4 steps of depth, not 2 --------------------------------- */
  --bg:        #090b10;
  --surface:   #101319;
  --surface-2: #161a23;
  --surface-3: #1d222d;
  --border:    #232937;
  --border-soft: #1a1f29;

  /* --- text --------------------------------------------------------------- */
  --text:      #e9edf5;
  --text-2:    #aeb7c9;
  --muted:     #737d92;
  --faint:     #4d5566;

  /* --- semantics ---------------------------------------------------------- */
  --long:      #2ebd85;
  --short:     #f2545b;
  --accent:    #6b8dff;
  --caution:   #f5a623;
  --danger:    #f2545b;
  --safe:      #2ebd85;

  --long-dim:  rgba(46,189,133,.14);
  --short-dim: rgba(242,84,91,.14);
  --caution-dim: rgba(245,166,35,.13);
  --accent-dim: rgba(107,141,255,.14);

  /* --- type --------------------------------------------------------------- */
  --ui: "Segoe UI", -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --num: "Consolas", "SF Mono", "Roboto Mono", ui-monospace, monospace;

  --r: 10px;
  --r-sm: 6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(107,141,255,.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Every number in the product is tabular. This is the single most important
   typographic rule in a trading UI: columns of figures must align. */
.num, td.num, .stat-value, .hero-value, table td, table th {
  font-variant-numeric: tabular-nums;
}
.num { font-family: var(--num); letter-spacing: -.01em; }

/* ============================ chrome ==================================== */

.topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 62px;
  padding: 0 18px;
  background: linear-gradient(180deg, #12161e, #0d1016);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107,141,255,.35), transparent);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding-right: 20px; margin-right: 20px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(145deg, var(--accent), #3f5fd6);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}
.brand-name { font-weight: 650; font-size: 14px; letter-spacing: .01em; }
.brand-sub { display: block; font-size: 10px; color: var(--muted); letter-spacing: .09em; text-transform: uppercase; line-height: 1; margin-top: 2px; }

/* The header carries THREE things, not eight: what you have, what it did,
   and whether you are about to be liquidated. */
.hdr-block { display: flex; flex-direction: column; justify-content: center; padding: 0 20px; border-right: 1px solid var(--border-soft); }
.hdr-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.hdr-value { font-family: var(--num); font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.hdr-value.sm { font-size: 15px; font-weight: 600; }
.hdr-delta { font-family: var(--num); font-size: 12px; }

.hdr-risk { display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.risk-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.risk-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px currentColor; opacity: .95; }
.risk-pill .dot { box-shadow: 0 0 8px currentColor; }
.risk-pill.safe    { color: var(--safe);    background: var(--long-dim);   }
.risk-pill.caution { color: var(--caution); background: var(--caution-dim);}
.risk-pill.danger  { color: var(--danger);  background: var(--short-dim);  }

.spacer { flex: 1; }

.user-box { display: flex; align-items: center; gap: 10px; padding-left: 18px; margin-left: 18px; border-left: 1px solid var(--border-soft); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
  font-size: 11px; font-weight: 700;
}
.user-mail { font-size: 12px; color: var(--text-2); }
.user-role { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.btn {
  font-family: inherit; font-size: 12px; cursor: pointer;
  border-radius: var(--r-sm); padding: 7px 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--accent); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-sm { padding: 3px 9px; font-size: 11px; }

/* ============================ layout ==================================== */

.layout {
  display: grid;
  grid-template-columns: 328px minmax(0, 1fr) 344px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.full { grid-column: 1 / -1; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255,255,255,.022), transparent);
}
.panel-title { font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; color: var(--text-2); }
.panel-note { font-size: 11px; color: var(--muted); }
.panel-body { padding: 14px; }
.panel-body.tight { padding: 10px 14px 14px; }
.panel-body.flush { padding: 0; }

/* ==================== account rail: the money waterfall ================== */

.equity-hero { padding: 16px 16px 14px; border-bottom: 1px solid var(--border-soft); background: linear-gradient(180deg, rgba(107,141,255,.05), transparent); }
.hero-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.hero-value { font-family: var(--num); font-size: 30px; font-weight: 650; letter-spacing: -.025em; line-height: 1.15; margin-top: 3px; }
.hero-sub { display: flex; align-items: baseline; gap: 8px; margin-top: 5px; font-size: 12px; color: var(--muted); }

/* balance -> +unrealized -> equity -> -used -> free. Shown as a ledger, so the
   relationship between the numbers is visible instead of eight flat siblings. */
.ledger { padding: 4px 0; }
.ledger-row {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: baseline; gap: 8px;
  padding: 7px 16px;
}
.ledger-row .op { color: var(--faint); font-family: var(--num); font-size: 12px; text-align: center; }
.ledger-row .k { color: var(--text-2); font-size: 12px; }
.ledger-row .k small { display: block; color: var(--muted); font-size: 10.5px; }
.ledger-row .v { font-family: var(--num); font-size: 13px; font-weight: 600; }
.ledger-row.total { border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); background: rgba(255,255,255,.018); }
.ledger-row.total .k { color: var(--text); font-weight: 600; }
.ledger-row.total .v { font-size: 14px; }

/* how the equity is split between collateral at work and dry powder */
.split-bar { margin: 12px 16px 4px; }
.split-track { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.split-used { background: linear-gradient(90deg, var(--accent), #8aa5ff); }
.split-free { background: #2a3242; }
.split-legend { display: flex; justify-content: space-between; margin-top: 7px; font-size: 11px; color: var(--muted); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* ==================== the margin-level meter ============================= */
/* Margin level runs 50% -> 20,000%, so a linear bar is useless. Log scale,
   with the two lines that actually matter drawn ON the track. */

.meter { padding: 14px 16px 16px; border-top: 1px solid var(--border-soft); }
.meter-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.meter-value { font-family: var(--num); font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.meter-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

.meter-track {
  position: relative; height: 10px; border-radius: 5px; overflow: visible;
  background: linear-gradient(90deg,
    rgba(242,84,91,.55) 0%,
    rgba(242,84,91,.45) 12%,
    rgba(245,166,35,.45) 14%,
    rgba(245,166,35,.35) 33%,
    rgba(46,189,133,.30) 38%,
    rgba(46,189,133,.22) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px 0 0 5px; background: linear-gradient(90deg, rgba(46,189,133,.0), rgba(46,189,133,.35)); }
.meter-mark { position: absolute; top: -4px; bottom: -4px; width: 1px; background: rgba(255,255,255,.35); }
.meter-mark span {
  position: absolute; top: 15px; left: 0; transform: translateX(-50%);
  font-size: 9.5px; letter-spacing: .04em; color: var(--muted); white-space: nowrap;
}
.meter-mark.stop span { transform: none; }
.meter-mark.stop { background: var(--danger); }
.meter-mark.stop span { color: var(--danger); }
.meter-mark.call { background: var(--caution); }
.meter-mark.call span { color: var(--caution); }

.meter-needle {
  position: absolute; top: -6px; width: 3px; height: 22px; border-radius: 2px;
  background: var(--text); box-shadow: 0 0 10px rgba(233,237,245,.55);
  transform: translateX(-50%);
}
.meter-scale { display: flex; justify-content: space-between; margin-top: 24px; font-size: 10px; color: var(--faint); }
.meter-note { margin-top: 6px; font-size: 10.5px; color: var(--caution); }

/* the number that actually answers "how much room do I have" */
.buffer {
  margin: 14px 16px 0; padding: 11px 12px;
  border: 1px solid rgba(46,189,133,.28); background: rgba(46,189,133,.07);
  border-radius: 8px;
}
.buffer .k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--safe); }
.buffer .v { font-family: var(--num); font-size: 17px; font-weight: 650; margin-top: 2px; }
.buffer .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ==================== watchlist ========================================= */

.wl-tabs { display: flex; gap: 0; padding: 0 6px; border-bottom: 1px solid var(--border-soft); }
.wl-tabs label {
  flex: 1; text-align: center; padding: 9px 0 8px; font-size: 11px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabin { position: absolute; opacity: 0; pointer-events: none; }
.tabpane { display: none; }

.wl-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 8px 14px; align-items: center; cursor: pointer;
  border-left: 2px solid transparent;
}
.wl-row + .wl-row { border-top: 1px solid var(--border-soft); }
.wl-row:hover { background: var(--surface-2); }
.wl-row.active { background: var(--accent-dim); border-left-color: var(--accent); }
.wl-sym { font-weight: 650; font-size: 12.5px; }
.wl-name { grid-column: 1; font-size: 10.5px; color: var(--muted); }
.wl-px { font-family: var(--num); font-size: 12.5px; text-align: right; }
.wl-chg { font-family: var(--num); font-size: 10.5px; text-align: right; }
.wl-spark { grid-column: 1 / -1; height: 0; }

.search {
  width: 100%; padding: 8px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 12px;
}
.search::placeholder { color: var(--faint); }

/* ==================== chart ============================================= */

.chart-head { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.chart-sym { font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.chart-cls { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; }
.chart-px { font-family: var(--num); font-size: 19px; font-weight: 600; letter-spacing: -.02em; }
.chart-chg { font-family: var(--num); font-size: 12.5px; }
.chart-meta { font-size: 11px; color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.seg button, .seg label {
  border: 0; background: transparent; color: var(--muted); font-family: inherit;
  font-size: 11px; padding: 5px 11px; cursor: pointer;
}
.seg .on { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.chart-wrap { padding: 6px 8px 10px; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; padding: 0 14px 12px; font-size: 11px; color: var(--muted); }

/* ==================== order ticket ====================================== */

.ticket { display: flex; flex-direction: column; gap: 12px; }
.side-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-btn {
  padding: 11px 0; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); font-family: inherit;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; cursor: pointer;
}
.side-btn small { display: block; font-size: 9.5px; letter-spacing: .1em; font-weight: 600; color: var(--muted); }
.side-btn.on-long { background: linear-gradient(180deg, #2ebd85, #26a06f); border-color: #2ebd85; color: #04160f; }
.side-btn.on-long small { color: rgba(4,22,15,.65); }
.side-btn.on-short { background: linear-gradient(180deg, #f2545b, #d63a41); border-color: #f2545b; color: #1a0405; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.input, select.input {
  padding: 9px 10px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: var(--num); font-size: 13.5px;
}
.input.readonly { color: var(--text-2); background: var(--surface-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* --- the leverage ladder ------------------------------------------------
   The real app has an <input type=range> over 10 stops: you drag blind and the
   only feedback is a number. Here every stop is a target you can hit directly,
   the track is colour-graded by risk band, and the consequence of the stop you
   picked is spelled out underneath in money. */
.lev-head { display: flex; align-items: baseline; justify-content: space-between; }
.lev-value { font-family: var(--num); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.lev-band { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.lev-ladder { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin-top: 8px; }
.lev-stop {
  position: relative; padding: 7px 0 6px; text-align: center; cursor: pointer;
  font-family: var(--num); font-size: 10.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 4px;
}
.lev-stop:first-child { border-radius: 5px 2px 2px 5px; }
.lev-stop:last-child { border-radius: 2px 5px 5px 2px; }
.lev-stop.b-safe    { background: rgba(46,189,133,.10); }
.lev-stop.b-caution { background: rgba(245,166,35,.10); }
.lev-stop.b-danger  { background: rgba(242,84,91,.11); }
.lev-stop.sel {
  color: #0a0d12; font-weight: 700;
  background: var(--caution); border-color: var(--caution);
  box-shadow: 0 0 0 1px var(--caution), 0 4px 14px rgba(245,166,35,.28);
}
.lev-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }

/* consequence panel: what this leverage does to real money */
.consequence { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.cons-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 11px; font-size: 12px; }
.cons-row + .cons-row { border-top: 1px solid var(--border-soft); }
.cons-row .k { color: var(--muted); }
.cons-row .v { font-family: var(--num); font-weight: 600; }
.cons-row.hi { background: rgba(242,84,91,.08); }
.cons-row.hi .k { color: var(--text-2); }
.cons-foot { padding: 8px 11px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border-soft); background: rgba(255,255,255,.015); }

.impact { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.impact-track { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.impact-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #8aa5ff); }

.submit {
  padding: 13px; border-radius: 8px; border: 0; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 700; letter-spacing: .03em;
  background: linear-gradient(180deg, #2ebd85, #23a06f); color: #04160f;
}
.submit-note { text-align: center; font-size: 11px; color: var(--muted); }

/* ==================== tables ============================================ */

table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th:first-child, tbody td:first-child { padding-left: 14px; }
thead th:last-child, tbody td:last-child { padding-right: 14px; }
thead th {
  text-align: left; font-weight: 600; font-size: 10px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); padding: 9px 7px;
  border-bottom: 1px solid var(--border); background: rgba(255,255,255,.015);
  white-space: nowrap;
}
tbody td { padding: 10px 7px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
td.r, th.r { text-align: right; }
td.num, .mono { font-family: var(--num); }

.sym { font-weight: 650; font-size: 12.5px; white-space: nowrap; }
.size-cell { white-space: nowrap; }
.sym small { display: block; font-weight: 400; font-size: 10.5px; color: var(--muted); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
}
.tag.long  { background: var(--long-dim);  color: var(--long);  }
.tag.short { background: var(--short-dim); color: var(--short); }
.tag.lev   { white-space: nowrap; background: var(--surface-3); color: var(--text-2); font-family: var(--num); letter-spacing: 0; }
.tag.lev.hot  { background: var(--caution-dim); color: var(--caution); }
.tag.lev.max  { background: var(--short-dim); color: var(--short); }
.tag.st-filled { background: var(--long-dim); color: var(--long); }
.tag.st-open   { background: var(--accent-dim); color: var(--accent); }
.tag.st-cancel { background: var(--surface-3); color: var(--muted); }
.tag.role-admin { background: var(--accent-dim); color: var(--accent); }
.tag.role-user  { background: var(--surface-3); color: var(--text-2); }

.up { color: var(--long); }
.down { color: var(--short); }
.warn { color: var(--caution); }
.mute { color: var(--muted); }

/* per-position risk: how much of the posted margin the float has eaten */
.riskbar { width: 92px; }
.riskbar-track { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; position: relative; }
.riskbar-fill { height: 100%; }
.riskbar-fill.pos { background: var(--long); }
.riskbar-fill.neg { background: var(--short); }
.riskbar-cap { font-size: 9.5px; color: var(--muted); margin-top: 4px; line-height: 1.3; }

.pnl-big { font-family: var(--num); font-size: 14px; font-weight: 650; white-space: nowrap; }
.pnl-sub { font-family: var(--num); font-size: 10.5px; opacity: .8; white-space: nowrap; }

/* ==================== admin ============================================= */

.admin-wrap { padding: 14px; display: flex; flex-direction: column; gap: 14px; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .8; }
.kpi.alert::before { background: var(--danger); }
.kpi.warn-k::before { background: var(--caution); }
.kpi-k { font-size: 10px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); }
.kpi-v { font-family: var(--num); font-size: 26px; font-weight: 650; letter-spacing: -.025em; margin-top: 4px; }
.kpi-s { font-size: 11px; color: var(--muted); margin-top: 3px; }

.triage-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
}
.triage-row:last-child { border-bottom: 0; }
.triage-row.sev-1 { background: linear-gradient(90deg, rgba(242,84,91,.10), transparent 60%); box-shadow: inset 3px 0 0 var(--danger); }
.triage-row.sev-2 { background: linear-gradient(90deg, rgba(245,166,35,.08), transparent 60%); box-shadow: inset 3px 0 0 var(--caution); }
.triage-row.sev-3 { box-shadow: inset 3px 0 0 var(--border); }
.triage-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.triage-sev { font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; width: 86px; flex-shrink: 0; }
.triage-who { font-size: 12.5px; font-weight: 600; }
.triage-why { font-size: 11.5px; color: var(--muted); }
.triage-figs { display: flex; gap: 22px; align-items: center; }
.fig { text-align: right; }
.fig-k { font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.fig-v { font-family: var(--num); font-size: 13px; font-weight: 650; }

.admin-tabs { display: flex; gap: 4px; }
.admin-tabs label {
  padding: 8px 14px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
  color: var(--muted); cursor: pointer; border-radius: 7px 7px 0 0;
  border: 1px solid transparent; border-bottom: 0;
}
.admin-tabs label .cnt { color: var(--faint); font-family: var(--num); margin-left: 6px; font-size: 11px; }

.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-track { display: block; width: 78px; height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; flex: none; }
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.danger { background: var(--danger); }
.bar-fill.caution { background: var(--caution); }
.bar-fill.safe { background: var(--long); }

tr.row-danger { background: rgba(242,84,91,.07); box-shadow: inset 2px 0 0 var(--danger); }
tr.row-caution { background: rgba(245,166,35,.055); box-shadow: inset 2px 0 0 var(--caution); }

.audit-line { font-family: var(--num); font-size: 11.5px; color: var(--text-2); }
.audit-actor { color: var(--accent); }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border-soft); }
.pager-info { font-size: 11px; color: var(--muted); }

/* ==================== login ============================================= */

.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr;
}
.auth-left {
  position: relative; overflow: hidden; padding: 56px 60px;
  display: flex; flex-direction: column; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(107,141,255,.16), transparent 62%),
    radial-gradient(700px 500px at 90% 100%, rgba(46,189,133,.10), transparent 60%),
    linear-gradient(160deg, #0d1017, #090b10);
  border-right: 1px solid var(--border);
}
.auth-headline { font-size: 40px; line-height: 1.1; font-weight: 650; letter-spacing: -.03em; max-width: 12ch; }
.auth-headline em { font-style: normal; color: var(--accent); }
.auth-lede { margin-top: 18px; max-width: 46ch; color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.auth-facts { display: grid; grid-template-columns: repeat(3, max-content); gap: 40px; margin-top: 34px; }
.auth-fact .v { font-family: var(--num); font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.auth-fact .k { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }
.auth-foot { font-size: 11.5px; color: var(--faint); margin-top: 40px; }

.auth-ticker { display: flex; gap: 10px; margin-top: 40px; flex-wrap: wrap; }
.tick {
  border: 1px solid var(--border); border-radius: 8px; background: rgba(16,19,25,.7);
  padding: 9px 13px; min-width: 132px;
}
.tick .s { font-size: 11px; color: var(--muted); letter-spacing: .05em; }
.tick .p { font-family: var(--num); font-size: 14.5px; font-weight: 600; margin-top: 1px; }
.tick .c { font-family: var(--num); font-size: 11px; }

.auth-right { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-card { width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 16px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.auth-tabs label { text-align: center; padding: 7px 0; font-size: 12.5px; font-weight: 600; color: var(--muted); border-radius: 6px; cursor: pointer; }
.auth-title { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.auth-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.auth-form { flex-direction: column; gap: 12px; }
.auth-form .input { font-family: var(--ui); font-size: 13px; padding: 11px 12px; }
.auth-hint { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.auth-hint a { color: var(--accent); text-decoration: none; }
.demo-box { border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; font-size: 11.5px; color: var(--muted); }
.demo-box code { font-family: var(--num); color: var(--text-2); }
.risk-note { font-size: 11px; color: var(--faint); line-height: 1.5; }

/* CSS-only tabs: no JS anywhere in this draft, so screenshots are
   deterministic and the mockup opens straight off the filesystem. */
#wl-stock:checked  ~ .wl-tabs [for="wl-stock"],
#wl-crypto:checked ~ .wl-tabs [for="wl-crypto"],
#wl-comm:checked   ~ .wl-tabs [for="wl-comm"] { color: var(--text); border-bottom-color: var(--accent); }
#wl-stock:checked  ~ #pane-stock,
#wl-crypto:checked ~ #pane-crypto,
#wl-comm:checked   ~ #pane-comm { display: block; }

#ad-risk:checked   ~ .panel .admin-tabs [for="ad-risk"],
#ad-users:checked  ~ .panel .admin-tabs [for="ad-users"],
#ad-trades:checked ~ .panel .admin-tabs [for="ad-trades"],
#ad-orders:checked ~ .panel .admin-tabs [for="ad-orders"],
#ad-audit:checked  ~ .panel .admin-tabs [for="ad-audit"] {
  color: var(--text); background: var(--surface); border-color: var(--border);
}
#ad-risk:checked   ~ .panel #pane-risk,
#ad-users:checked  ~ .panel #pane-users,
#ad-trades:checked ~ .panel #pane-trades,
#ad-orders:checked ~ .panel #pane-orders,
#ad-audit:checked  ~ .panel #pane-audit { display: block; }

#au-login:checked ~ .auth-card .auth-tabs [for="au-login"],
#au-reg:checked   ~ .auth-card .auth-tabs [for="au-reg"] { background: var(--accent); color: #fff; }
#au-login:checked ~ .auth-card #pane-login,
#au-reg:checked   ~ .auth-card #pane-reg { display: flex; }

/* =====================================================================
   PHONE LAYOUT  (<= 900px)
   The desktop draft is a 3-column terminal (328 / 1fr / 344 = 672px of
   fixed columns) and simply cannot shrink. Below 900px it becomes one
   column with a CSS-only tab switcher, so exactly one panel group shows
   at a time and the chart gets the full screen width.

   Everything here is inside the media query: the 1600px rendering is
   byte-for-byte the desktop draft.
   ===================================================================== */

.mtabin { position: absolute; opacity: 0; pointer-events: none; }
.mtabs { display: none; }

@media (max-width: 900px) {

  /* ---- topbar: keep the risk facts, drop the chrome ---- */
  /* Topbar scrolls away; only the tab bar sticks. Two stacked sticky elements
     with a hardcoded offset collided as soon as the header wrapped to 2 rows -
     the tabs were painted straight over the margin-level figure. */
  .topbar {
    position: static;
    height: auto;              /* base rule pins 62px; children were spilling onto the tabs */
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
    padding: 10px 12px; align-items: start;
  }
  .topbar .brand { grid-column: 1 / -1; }
  .topbar .btn { grid-column: 1 / -1; justify-self: start; }
  .brand-sub, .user-box, .spacer { display: none; }
  .topbar .btn { margin-left: auto; }
  .hdr-block, .hdr-risk { min-width: 0; }
  .hdr-risk { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
  .hdr-label { white-space: nowrap; font-size: 9.5px; }
  .topbar .btn { grid-column: 1 / -1; justify-self: start; margin-left: 0; }
  .hdr-delta { display: none; }
  .hdr-value { font-size: 17px; }
  .hdr-value.sm { font-size: 14px; }

  /* ---- the tab bar ---- */
  .mtabs {
    display: flex; gap: 6px; padding: 8px 10px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    position: sticky; top: 0; z-index: 39;
    background: var(--surface-1, #10141b);
    border-bottom: 1px solid var(--border-soft);
  }
  .mtabs::-webkit-scrollbar { display: none; }
  .mtabs label {
    flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center;
    padding: 0 16px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border); color: var(--text-2);
    font-size: 13px; font-weight: 600; white-space: nowrap;
  }
  #mt-chart:checked   ~ .mtabs label[for="mt-chart"],
  #mt-markets:checked ~ .mtabs label[for="mt-markets"],
  #mt-trade:checked   ~ .mtabs label[for="mt-trade"],
  #mt-book:checked    ~ .mtabs label[for="mt-book"],
  #mt-account:checked ~ .mtabs label[for="mt-account"] {
    background: var(--accent); border-color: var(--accent); color: #fff;
  }

  /* ---- one column, one visible section ---- */
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .col { gap: 12px; }
  .layout [data-m] { display: none; }
  #mt-chart:checked   ~ .layout [data-m="chart"],
  #mt-markets:checked ~ .layout [data-m="markets"],
  #mt-trade:checked   ~ .layout [data-m="trade"],
  #mt-book:checked    ~ .layout [data-m="book"],
  #mt-account:checked ~ .layout [data-m="account"] { display: block; }

  /* ---- chart gets the full width; SVG already scales via viewBox ---- */
  .chart-wrap { padding: 4px 4px 8px; }
  .chart-head { flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px; }
  .chart-legend { flex-wrap: wrap; gap: 8px 14px; padding: 0 12px 12px; }

  /* ---- touch targets ---- */
  .btn, .seg button, .lev-stop, .side-switch > * { min-height: 44px; }
  .lev-ladder { gap: 6px; }
  .lev-stop { min-width: 44px; }
  .wl-row { padding: 12px 14px; }

  /* ---- wide tables -> stacked cards ----
     Scoped with direct-child chains on purpose: a blanket `table{display:block}`
     also hits any table used for layout elsewhere and silently wrecks it. */
  .panel table { display: block; }
  .panel > table > thead,
  .panel .panel-body > table > thead,
  .panel .tabpane > table > thead { display: none; }
  .panel table > tbody { display: block; }
  .panel table > tbody > tr {
    display: block; padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
  }
  .panel table > tbody > tr > td {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; padding: 3px 0; border: 0; text-align: right;
  }
  .panel table > tbody > tr > td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 10.5px; letter-spacing: .06em;
    text-transform: uppercase; text-align: left; flex: 0 0 auto;
  }
  .panel table > tbody > tr > td:empty { display: none; }

  /* ---- admin: stack the KPI row and the triage rows ---- */
  .kpi-strip { grid-template-columns: 1fr 1fr !important; }
  .triage-row { grid-template-columns: 1fr !important; gap: 8px; }
  .triage-figs { grid-template-columns: repeat(3, 1fr) !important; }
  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tabs label { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; }

  /* ---- login ---- */
  .auth { grid-template-columns: 1fr !important; }
  .auth-left { display: none; }
  /* .auth-right carries 40px padding + a fixed card width; on a 390px phone that
     alone overflowed by 30px. Shrink the padding and let the card be fluid. */
  .auth-right { padding: 24px 16px !important; min-width: 0; }
  .auth-card { width: 100% !important; max-width: 100% !important; min-width: 0; }
  .auth-tabs label, .auth-form button { min-height: 44px; }
}
