/* ============================================================================
   OCTOPUSTRADE — trading terminal
   A dense, hairline-ruled terminal. Colour is semantic, never decorative:
   orange is the product, green/red are P&L, everything else is greyscale.
   ========================================================================= */

:root {
  /* surfaces — cool near-black, four elevation steps */
  --bg:        #0a0b0d;
  --s1:        #0e1013;
  --s2:        #14161a;
  --s3:        #1b1e23;
  --s4:        #23272e;

  /* hairlines */
  --line:      rgba(255, 255, 255, 0.065);
  --line-2:    rgba(255, 255, 255, 0.11);
  --line-3:    rgba(255, 255, 255, 0.18);

  /* type */
  --text:      #e9ebee;
  --text-2:    #a4abb4;
  --text-3:    #6d747d;
  --text-4:    #474d55;

  /* brand */
  --brand:     #ff6b1a;
  --brand-dim: #b8480e;
  --brand-wash:rgba(255, 107, 26, 0.10);
  --brand-line:rgba(255, 107, 26, 0.32);

  /* semantics — real trading colours */
  --up:        #1fc77d;
  --up-wash:   rgba(31, 199, 125, 0.11);
  --down:      #f0485a;
  --down-wash: rgba(240, 72, 90, 0.11);
  --warn:      #f0b429;
  --info:      #4aa8ff;

  /* agent tints — desaturated, they sit in a greyscale UI */
  --a-scout:  #5ab0e8;
  --a-quote:  #e8705a;
  --a-sizer:  #e0b341;
  --a-exec:   #46c98a;
  --a-hedge:  #a882e0;
  --a-ledger: #8592a3;
  --a-vault:  #e8913f;
  --a-cull:   #e0699f;

  /* Space Grotesk for anything read as language, Geist Mono for anything read
     as a number. Grotesk has real character in its terminals and its 'g'
     without tipping into novelty; Geist Mono is tight and properly tabular,
     which is what dense figures actually need. */
  --mono:  'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ui:    'Space Grotesk', system-ui, -apple-system, sans-serif;
  --serif: 'Space Grotesk', system-ui, sans-serif;

  --rail: 52px;
  --top:  46px;
  --foot: 26px;
  --r:    5px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 12.5px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; background: none; border: 0; margin: 0; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, p, ol, ul { margin: 0; }

/* every number in this app is tabular */
.mono, .num, td.num, input[type="number"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'zero' 1;
}

.up   { color: var(--up); }
.down { color: var(--down); }
.dim  { color: var(--text-3); }
.dim2 { color: var(--text-4); }
.spacer { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }

::selection { background: var(--brand); color: #0a0b0d; }

/* scrollbars — thin, unobtrusive, always the same */
* { scrollbar-width: thin; scrollbar-color: var(--s4) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--s4); border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #333941; background-clip: content-box; }

/* focus — visible, never a default blue halo */
:focus { outline: none; }
:focus-visible { outline: 1px solid var(--brand); outline-offset: 1px; }

/* ============================================================== app shell */

.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  grid-template-rows: var(--top) minmax(0, 1fr) var(--foot);
  grid-template-areas:
    "rail top"
    "rail main"
    "rail foot";
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------------ rail */

.rail {
  grid-area: rail;
  background: var(--s1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 0 9px;
  gap: 2px;
  z-index: 40;
}

.rail-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--r);
  background: var(--brand);
  color: #0a0b0d;
  margin-bottom: 9px;
  flex: none;
}
.rail-mark svg { width: 17px; height: 17px; }

.rail-btn {
  width: 38px; height: 36px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: var(--r);
  color: var(--text-4);
  position: relative;
  transition: color .12s, background .12s;
  flex: none;
}
.rail-btn svg { width: 16px; height: 16px; stroke-width: 1.7; }
.rail-btn small {
  font-size: 7.5px; letter-spacing: .06em; font-weight: 600;
  text-transform: uppercase;
}
.rail-btn:hover { color: var(--text-2); background: var(--s2); }
.rail-btn[aria-current="true"] { color: var(--text); background: var(--s3); }
.rail-btn[aria-current="true"]::before {
  content: ''; position: absolute; left: -7px; top: 50%; transform: translateY(-50%);
  width: 2px; height: 16px; border-radius: 0 2px 2px 0; background: var(--brand);
}
.rail-btn .badge {
  position: absolute; top: 3px; right: 4px;
  min-width: 13px; height: 13px; padding: 0 3px;
  border-radius: 7px; background: var(--brand); color: #0a0b0d;
  font-family: var(--mono); font-size: 8px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

/* ---------------------------------------------------------------- topbar */

.top {
  grid-area: top;
  background: var(--s1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  z-index: 30;
}

.top-brand {
  display: flex; align-items: center; gap: 7px;
  padding: 0 13px 0 12px;
  border-right: 1px solid var(--line);
  font-weight: 700; font-size: 12.5px; letter-spacing: .015em;
  flex: none;
}
.top-brand em { font-style: normal; color: var(--brand); }
.top-brand span {
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  color: var(--text-4); letter-spacing: .08em;
  border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 4px;
}

/* the instrument the desk is on */
.top-sym {
  display: flex; align-items: center; gap: 11px;
  height: 100%; overflow: hidden;
  padding: 0 14px;
  border-right: 1px solid var(--line);
  min-width: 0; flex: none;
  transition: background .12s;
  text-align: left;
}
.top-sym .id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.top-sym:hover { background: var(--s2); }
.top-sym .tick {
  font-family: var(--mono); font-weight: 700; font-size: 13px; letter-spacing: .01em;
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-sym .venue {
  font-family: var(--mono); font-size: 8.5px; color: var(--text-4);
  letter-spacing: .05em; text-transform: uppercase;
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.top-sym .last {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 14px;
}
.top-sym .chg {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: 600;
  padding: 1.5px 5px; border-radius: 3px;
}
.top-sym .chg.up { background: var(--up-wash); }
.top-sym .chg.down { background: var(--down-wash); }
.top-sym .caret { color: var(--text-4); font-size: 9px; }
.top-sym.no-mkt .tick { color: var(--text-3); font-weight: 500; }

/* live stat readouts across the bar */
.top-stats { display: flex; align-items: stretch; min-width: 0; overflow: hidden; }
.top-stat {
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 13px; border-right: 1px solid var(--line);
  min-width: 0; flex: none;
}
.top-stat label {
  font-size: 8.5px; letter-spacing: .085em; text-transform: uppercase;
  color: var(--text-4); font-weight: 600; line-height: 1.3;
}
.top-stat b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; line-height: 1.25;
}

.top-right { display: flex; align-items: center; gap: 6px; padding: 0 11px 0 12px; flex: none; }

/* -------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 25px; padding: 0 9px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--s2);
  color: var(--text-2);
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--s3); color: var(--text); border-color: var(--line-3); }
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 12px; height: 12px; stroke-width: 2; }
.btn.on { background: var(--brand-wash); border-color: var(--brand-line); color: var(--brand); }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #0a0b0d; }
.btn.brand:hover { background: #ff7d34; border-color: #ff7d34; color: #0a0b0d; }
.btn.long { color: var(--up); border-color: rgba(31,199,125,.3); background: var(--up-wash); }
.btn.long:hover { background: rgba(31,199,125,.2); border-color: var(--up); color: var(--up); }
.btn.short { color: var(--down); border-color: rgba(240,72,90,.3); background: var(--down-wash); }
.btn.short:hover { background: rgba(240,72,90,.2); border-color: var(--down); color: var(--down); }
.btn.ghost { background: none; border-color: transparent; }
.btn.ghost:hover { background: var(--s2); border-color: var(--line-2); }
.btn.sm { height: 21px; padding: 0 7px; font-size: 9px; }
.btn.wide { width: 100%; justify-content: center; height: 30px; font-size: 11px; }
.btn:disabled { opacity: .35; pointer-events: none; }

/* a live/degraded indicator that actually means something */
.feedpill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 25px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-3);
}
.feedpill i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-4); flex: none; }
.feedpill.live { color: var(--up); border-color: rgba(31,199,125,.28); }
.feedpill.live i { background: var(--up); animation: beat 2.4s ease-in-out infinite; }
.feedpill.stale { color: var(--warn); border-color: rgba(240,180,41,.28); }
.feedpill.stale i { background: var(--warn); }
.feedpill.sim { color: var(--brand); border-color: var(--brand-line); background: var(--brand-wash); }
.feedpill.sim i { background: var(--brand); }

@keyframes beat { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------------------------ main */

.main { grid-area: main; min-width: 0; min-height: 0; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; min-width: 0; min-height: 0; }
.view[data-active] { display: block; }

/* --------------------------------------------------------------- statusbar */

.foot {
  grid-area: foot;
  background: var(--s1);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 0;
  padding: 0 10px 0 0;
  font-family: var(--mono); font-size: 9.5px;
  color: var(--text-4);
  letter-spacing: .03em;
  overflow: hidden;
  z-index: 30;
}
.foot-cell {
  display: flex; align-items: center; gap: 5px;
  padding: 0 10px; height: 100%;
  border-right: 1px solid var(--line);
  white-space: nowrap; flex: none;
}
.foot-cell b { color: var(--text-2); font-weight: 600; }
.foot-cell i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-4); }
.foot-cell i.ok { background: var(--up); }
.foot-cell i.warn { background: var(--warn); }
.foot-cell i.err { background: var(--down); }
.foot-cell.right { border-right: 0; border-left: 1px solid var(--line); margin-left: auto; }

/* ============================================================ panel system */

.pane {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  overflow: hidden;
}

.pane-head {
  display: flex; align-items: center; gap: 8px;
  height: 27px; padding: 0 9px;
  border-bottom: 1px solid var(--line);
  background: var(--s2);
  flex: none;
}
.pane-head h3 {
  font-size: 9.5px; font-weight: 700; letter-spacing: .095em; text-transform: uppercase;
  color: var(--text-2); white-space: nowrap;
}
.pane-head .sub {
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pane-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.pane-body.pad { padding: 9px; }
.pane-foot {
  flex: none; border-top: 1px solid var(--line);
  padding: 5px 9px; background: var(--s2);
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
  display: flex; align-items: center; gap: 8px;
}

/* tiny segmented control, used everywhere */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; flex: none; }
.seg button {
  padding: 0 7px; height: 19px;
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .04em;
  color: var(--text-4); border-right: 1px solid var(--line-2);
  transition: background .1s, color .1s;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text-2); background: var(--s3); }
.seg button.on { background: var(--s4); color: var(--text); }
.seg.brand button.on { background: var(--brand); color: #0a0b0d; }

.empty {
  display: grid; place-items: center; gap: 7px;
  padding: 26px 18px; text-align: center;
  color: var(--text-4); font-size: 11.5px; height: 100%;
  align-content: center;
}
.empty b { color: var(--text-2); font-size: 12.5px; font-weight: 600; }
.empty svg { width: 22px; height: 22px; stroke-width: 1.5; opacity: .5; }

/* ========================================================== terminal grid */

.term {
  height: 100%;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 260px;
  grid-template-rows: minmax(0, 1fr) 196px;
  grid-template-areas:
    "watch chart ticket"
    "watch tape  ticket";
  gap: 7px;
  padding: 7px;
}
.term > .watch  { grid-area: watch; }
.term > .chartp { grid-area: chart; }
.term > .tape   { grid-area: tape; }
.term > .ticket { grid-area: ticket; }

/* ------------------------------------------------------------- watchlist */

.wl-find {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); flex: none;
}
.wl-find input {
  flex: 1; min-width: 0; height: 23px;
  background: var(--s2); border: 1px solid var(--line-2); border-radius: 4px;
  padding: 0 7px; font-family: var(--mono); font-size: 10.5px; color: var(--text);
}
.wl-find input::placeholder { color: var(--text-4); }
.wl-find input:focus { border-color: var(--brand-line); background: var(--s3); }

.wl-chains { display: flex; gap: 3px; padding: 6px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.wl-chains button {
  padding: 0 6px; height: 18px; border-radius: 3px;
  border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 8.5px; font-weight: 600; letter-spacing: .05em;
  color: var(--text-4); transition: all .1s;
}
.wl-chains button:hover { color: var(--text-2); border-color: var(--line-3); }
.wl-chains button.on { background: var(--s4); color: var(--text); border-color: var(--line-3); }

.wl-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 7px;
  padding: 5px 9px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.wl-row:hover { background: var(--s2); }
.wl-row.on { background: var(--brand-wash); }
.wl-row.on::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--brand); }
.wl-sym { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.wl-sym b { font-family: var(--mono); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-sym .chain {
  font-family: var(--mono); font-size: 7.5px; font-weight: 600; letter-spacing: .05em;
  color: var(--text-4); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 2.5px; flex: none;
}
.wl-px { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 10.5px; color: var(--text-2); text-align: right; }
.wl-chg { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 10px; font-weight: 600; text-align: right; min-width: 48px; }
.wl-spark { grid-column: 1 / -1; height: 0; overflow: hidden; }

/* --------------------------------------------------------------- chart */

.chart-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 0 9px; height: 29px;
  border-bottom: 1px solid var(--line); background: var(--s2); flex: none;
  overflow-x: auto; overflow-y: hidden;
}
.chart-bar::-webkit-scrollbar { height: 0; }

.chart-wrap { flex: 1 1 auto; min-height: 0; position: relative; background: var(--s1); }
/* direct child only — the empty state nests its own icon svg in here */
.chart-wrap > svg { display: block; width: 100%; height: 100%; }

.chart-ohlc {
  position: absolute; top: 7px; left: 9px; z-index: 5;
  display: flex; gap: 9px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 9.5px; color: var(--text-3);
  pointer-events: none; text-shadow: 0 1px 3px var(--bg);
}
.chart-ohlc b { color: var(--text); font-weight: 600; }
.chart-ohlc .k { color: var(--text-4); }

.xhair-lbl {
  position: absolute; z-index: 6; pointer-events: none;
  background: var(--s4); border: 1px solid var(--line-3);
  color: var(--text); font-family: var(--mono); font-size: 9.5px;
  padding: 1px 4px; border-radius: 2px; white-space: nowrap;
}

/* ---------------------------------------------------------- order book */

.book { display: flex; flex-direction: column; min-height: 0; }
.book-hd {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 3px 9px; flex: none;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .06em;
  color: var(--text-4); text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.book-hd span:nth-child(2) { text-align: right; }
.book-hd span:nth-child(3) { text-align: right; }

.book-side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.book-side.bids { justify-content: flex-start; }
.book-side.asks { justify-content: flex-end; }

.book-lvl {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  padding: 1.5px 9px;
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 10px;
  position: relative; cursor: pointer;
}
.book-lvl:hover { background: var(--s3); }
.book-lvl span { position: relative; z-index: 2; }
.book-lvl span:nth-child(2), .book-lvl span:nth-child(3) { text-align: right; color: var(--text-3); }
.book-lvl .depth { position: absolute; top: 0; bottom: 0; right: 0; z-index: 1; }
.book-lvl.ask span:first-child { color: var(--down); }
.book-lvl.ask .depth { background: var(--down-wash); }
.book-lvl.bid span:first-child { color: var(--up); }
.book-lvl.bid .depth { background: var(--up-wash); }

.book-mid {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 9px; flex: none;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--s2);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.book-mid .m { font-size: 13px; font-weight: 700; }
.book-mid .s { font-size: 9px; color: var(--text-4); }

/* -------------------------------------------------------- order ticket */

.tk { display: flex; flex-direction: column; gap: 7px; padding: 8px; }

.tk-side { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.tk-side button {
  height: 29px; border-radius: 4px; border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .07em;
  color: var(--text-3); transition: all .12s;
}
.tk-side button:hover { border-color: var(--line-3); color: var(--text); }
.tk-side button.on.buy { background: var(--up); border-color: var(--up); color: #06180f; }
.tk-side button.on.sell { background: var(--down); border-color: var(--down); color: #1d0508; }

.tk-field { display: flex; flex-direction: column; gap: 3px; }
.tk-field label {
  font-size: 8.5px; letter-spacing: .085em; text-transform: uppercase;
  color: var(--text-4); font-weight: 600;
  display: flex; align-items: center; gap: 5px;
}
.tk-field label .spacer { flex: 1; }
.tk-field label b { font-family: var(--mono); color: var(--text-3); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 9.5px; }
.tk-input {
  display: flex; align-items: center;
  height: 27px; border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--s2); padding: 0 8px; gap: 5px;
}
.tk-input:focus-within { border-color: var(--brand-line); background: var(--s3); }
.tk-input input {
  flex: 1; min-width: 0; background: none;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 11.5px; color: var(--text);
}
.tk-input input::-webkit-outer-spin-button,
.tk-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tk-input input[type=number] { -moz-appearance: textfield; }
.tk-input .unit { font-family: var(--mono); font-size: 9.5px; color: var(--text-4); flex: none; }

.tk-pct { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tk-pct button {
  height: 20px; border: 1px solid var(--line-2); border-radius: 3px;
  font-family: var(--mono); font-size: 9px; font-weight: 600; color: var(--text-4);
  transition: all .1s;
}
.tk-pct button:hover { color: var(--text); border-color: var(--line-3); background: var(--s3); }

.tk-readout {
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--s2); padding: 6px 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.tk-readout div { display: flex; align-items: baseline; gap: 8px; font-size: 10px; }
.tk-readout div span { color: var(--text-4); }
.tk-readout div b {
  margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 10.5px; color: var(--text-2);
}
.tk-readout div.hi b { color: var(--text); font-size: 11.5px; }

/* the live position card */
.pos {
  border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden;
}
.pos.long { border-color: rgba(31,199,125,.32); }
.pos.short { border-color: rgba(240,72,90,.32); }
.pos-hd {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .06em;
}
.pos.long .pos-hd { background: var(--up-wash); color: var(--up); }
.pos.short .pos-hd { background: var(--down-wash); color: var(--down); }
.pos-hd .spacer { flex: 1; }
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.pos-grid div { background: var(--s1); padding: 5px 8px; display: flex; flex-direction: column; gap: 1px; }
.pos-grid label { font-size: 8px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-4); font-weight: 600; }
.pos-grid b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 600; }

/* risk bar: stop ---- entry ---- target */
.riskbar { padding: 7px 8px; display: flex; flex-direction: column; gap: 4px; background: var(--s1); }
.riskbar .track { height: 4px; border-radius: 3px; background: var(--s4); position: relative; overflow: hidden; }
.riskbar .track i { position: absolute; top: 0; bottom: 0; display: block; }
.riskbar .track i.loss { background: var(--down); left: 0; }
.riskbar .track i.gain { background: var(--up); right: 0; }
.riskbar .track u {
  position: absolute; top: -2px; width: 2px; height: 8px; background: var(--text); border-radius: 1px;
}
.riskbar .ends { display: flex; font-family: var(--mono); font-size: 8.5px; color: var(--text-4); }

/* ============================================================ swarm strip */

.swarm { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 1px; background: var(--line); }

.ag {
  background: var(--s1); padding: 6px 7px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0; cursor: pointer; position: relative;
  transition: background .12s;
  border-top: 1.5px solid transparent;
}
.ag:hover { background: var(--s2); }
.ag.act { background: var(--s2); border-top-color: var(--tint); }

.ag-top { display: flex; align-items: center; gap: 5px; min-width: 0; }
.ag-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tint); flex: none; opacity: .35; transition: opacity .2s; }
.ag.act .ag-dot { opacity: 1; box-shadow: 0 0 6px var(--tint); }
.ag-name {
  font-family: var(--mono); font-size: 9.5px; font-weight: 700; letter-spacing: .07em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ag-state {
  font-family: var(--mono); font-size: 8.5px; color: var(--text-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 12px;
}
.ag.act .ag-state { color: var(--tint); }
.ag-load { height: 2px; background: var(--s4); border-radius: 2px; overflow: hidden; }
.ag-load i { display: block; height: 100%; background: var(--tint); opacity: .7; transition: width .5s ease; }

/* ======================================================= tables / blotter */

.tabs { display: flex; align-items: center; gap: 0; border-bottom: 1px solid var(--line); background: var(--s2); flex: none; }
.tabs button {
  padding: 0 11px; height: 27px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-4); border-bottom: 1.5px solid transparent;
  transition: color .12s;
  display: flex; align-items: center; gap: 5px;
}
.tabs button:hover { color: var(--text-2); }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); }
.tabs button .n {
  font-family: var(--mono); font-size: 8.5px; color: var(--text-4);
  background: var(--s4); border-radius: 2px; padding: 0 3px;
}
.tabs .spacer { flex: 1; }
.tabs .tools { display: flex; align-items: center; gap: 5px; padding-right: 8px; }

table.tbl { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 10.5px; }
table.tbl thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--s2);
  padding: 4px 9px; text-align: right;
  font-size: 8.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-4); white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-family: var(--ui);
}
table.tbl thead th:first-child, table.tbl thead th.l { text-align: left; }
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--text-2); }
table.tbl thead th .ar { color: var(--brand); }
table.tbl tbody td {
  padding: 3.5px 9px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
}
table.tbl tbody td:first-child, table.tbl tbody td.l { text-align: left; }
table.tbl tbody tr:hover td { background: var(--s2); }
table.tbl tbody td.sym { color: var(--text); font-weight: 600; }
table.tbl tbody tr.clickable { cursor: pointer; }

.chip {
  display: inline-block; padding: 0 4px; border-radius: 2px;
  font-size: 8.5px; font-weight: 700; letter-spacing: .05em;
}
.chip.long { background: var(--up-wash); color: var(--up); }
.chip.short { background: var(--down-wash); color: var(--down); }
.chip.grey { background: var(--s4); color: var(--text-3); }
.chip.brand { background: var(--brand-wash); color: var(--brand); }

/* ------------------------------------------------------------------- log */

.log { font-family: var(--mono); font-size: 10px; }
.log-row {
  display: grid; grid-template-columns: 52px 56px minmax(0, 1fr) auto;
  gap: 8px; align-items: baseline;
  padding: 2.5px 9px;
  border-bottom: 1px solid var(--line);
}
.log-row:hover { background: var(--s2); }
.log-row time { color: var(--text-4); font-size: 9.5px; }
.log-row .who { font-weight: 700; font-size: 9px; letter-spacing: .05em; color: var(--tint, var(--text-3)); }
.log-row .what { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-row .what em { font-style: normal; color: var(--text-4); }
.log-row .amt { font-weight: 600; font-size: 10px; }

/* ====================================================== analytics / cards */

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 7px; }

.stat {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--s1); padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.stat label {
  font-size: 8.5px; letter-spacing: .085em; text-transform: uppercase;
  color: var(--text-4); font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.stat b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 600; line-height: 1.2;
}
.stat small { font-family: var(--mono); font-size: 9.5px; color: var(--text-4); }
.stat .bar { height: 3px; border-radius: 2px; background: var(--s4); overflow: hidden; margin-top: 3px; }
.stat .bar i { display: block; height: 100%; background: var(--brand); transition: width .4s ease; }

/* an explanatory footnote under a metric — what makes this feel authored */
.hint {
  font-size: 10px; color: var(--text-4); line-height: 1.5;
}
.hint code {
  font-family: var(--mono); font-size: 9.5px; color: var(--text-3);
  background: var(--s2); border: 1px solid var(--line); border-radius: 2px; padding: 0 3px;
}

/* histogram of trade outcomes */
.histo { display: flex; align-items: flex-end; gap: 2px; height: 78px; padding: 0 2px; }
.histo i { flex: 1; border-radius: 1px 1px 0 0; min-height: 1px; background: var(--s4); transition: height .3s; }
.histo i.w { background: var(--up); }
.histo i.l { background: var(--down); }

/* ============================================================== docs view */

.docs { display: grid; grid-template-columns: 218px minmax(0, 1fr); height: 100%; min-height: 0; }

.docs-nav {
  border-right: 1px solid var(--line); background: var(--s1);
  overflow: auto; padding: 10px 0 20px;
}
.docs-nav .grp {
  font-size: 8.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-4); padding: 12px 14px 5px;
}
.docs-nav a {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 14px; color: var(--text-3);
  font-family: var(--ui); font-size: 12px; text-decoration: none; cursor: pointer;
  border-left: 2px solid transparent;
  transition: color .1s, background .1s;
}
.docs-nav a:hover { color: var(--text); background: var(--s2); }
.docs-nav a.on { color: var(--text); background: var(--s2); border-left-color: var(--brand); font-weight: 500; }
.docs-nav a .n {
  font-family: var(--mono); font-size: 9px; color: var(--text-4); margin-left: auto;
}

.docs-body { overflow: auto; min-width: 0; }
.doc {
  max-width: 700px; margin: 0 auto; padding: 36px 38px 96px;
  font-family: var(--ui);
  font-size: 14.5px; line-height: 1.72; color: var(--text-2);
}
.doc .kpi, .doc table, .doc pre, .doc code, .doc .spec { font-family: var(--ui); }

.doc .eyebrow {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--brand);
  margin-bottom: 10px;
}
.doc h1 {
  font-family: var(--serif);
  font-size: 31px; line-height: 1.2; font-weight: 600; color: var(--text);
  letter-spacing: -.012em; margin-bottom: 11px;
}
.doc .standfirst {
  font-family: var(--ui);
  font-size: 16px; line-height: 1.6; color: var(--text-3);
  padding-bottom: 22px; margin-bottom: 28px; border-bottom: 1px solid var(--line);
}
.doc h2 {
  font-family: var(--serif);
  font-size: 19px; font-weight: 600; color: var(--text);
  letter-spacing: -.005em; margin: 38px 0 12px;
  padding-top: 20px; border-top: 1px solid var(--line);
}
.doc h2:first-of-type { border-top: 0; padding-top: 0; }
.doc h3 { font-family: var(--serif); font-size: 15.5px; font-weight: 600; color: var(--text); margin: 24px 0 7px; }
.doc p { margin-bottom: 15px; }
.doc a { color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--brand-line); }
.doc a:hover { border-bottom-color: var(--brand); }
.doc strong, .doc b { color: var(--text); font-weight: 600; }
.doc ul, .doc ol { margin: 0 0 15px; padding-left: 19px; }
.doc li { margin-bottom: 7px; }
.doc li::marker { color: var(--text-4); }
.doc code {
  font-family: var(--mono); font-size: 11.5px; color: var(--brand);
  background: var(--s2); border: 1px solid var(--line); border-radius: 3px; padding: .5px 4px;
}
.doc pre {
  font-family: var(--mono); font-size: 11px; line-height: 1.62;
  background: var(--s1); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; overflow-x: auto; margin: 0 0 17px; color: var(--text-2);
}
.doc pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }

.doc blockquote {
  margin: 4px 0 20px; padding: 13px 17px;
  border-left: 2px solid var(--brand);
  background: var(--brand-wash);
  color: var(--text-2); font-size: 15.5px; font-style: italic; line-height: 1.6;
}
.doc blockquote p:last-child { margin-bottom: 0; }

.doc table {
  font-size: 11.5px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.doc table th {
  background: var(--s2); text-align: left; padding: 7px 11px;
  font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--line);
}
.doc table td {
  padding: 7px 11px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.doc table tr:last-child td { border-bottom: 0; }
.doc table td:first-child { color: var(--text); font-family: var(--mono); font-size: 11px; white-space: nowrap; }

.doc .kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 8px; margin-bottom: 20px; }
.doc .kpi > div {
  border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--s1);
}
.doc .kpi label { display: block; font-size: 8.5px; letter-spacing: .085em; text-transform: uppercase; color: var(--text-4); font-weight: 600; margin-bottom: 3px; }
.doc .kpi b { font-family: var(--mono); font-size: 17px; font-weight: 600; color: var(--text); }

.doc .note {
  border: 1px solid var(--line-2); border-left: 2px solid var(--warn);
  background: var(--s1); border-radius: var(--r);
  padding: 13px 16px; margin-bottom: 19px; font-size: 14px; line-height: 1.6;
}
.doc .note b { display: block; margin-bottom: 3px; color: var(--warn); }

/* an agent spec block in the docs */
.spec {
  border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 11px; overflow: hidden; background: var(--s1);
}
.spec-hd {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--s2); border-bottom: 1px solid var(--line);
}
.spec-hd .m { width: 17px; height: 17px; color: var(--tint); flex: none; }
.spec-hd .m svg { width: 100%; height: 100%; }
.spec-hd b { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--tint); }
.spec-hd .role {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .07em;
  color: var(--text-4); border: 1px solid var(--line-2); border-radius: 2px; padding: 0 4px;
}
.spec-bd { padding: 11px 13px; font-size: 12px; }
.spec-bd p { margin-bottom: 9px; }
.spec-io { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; margin-top: 9px; }
.spec-io > div { border-top: 1px solid var(--line); padding-top: 7px; }
.spec-io label { display: block; font-size: 8px; letter-spacing: .085em; text-transform: uppercase; color: var(--text-4); font-weight: 700; margin-bottom: 3px; }
.spec-io span { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); display: block; line-height: 1.55; }

/* ============================================== markets view (full board) */

.mkt { height: 100%; display: flex; flex-direction: column; padding: 7px; gap: 7px; min-height: 0; }
.mkt-bar { display: flex; align-items: center; gap: 7px; flex: none; flex-wrap: wrap; }
.mkt-bar input.find {
  height: 26px; width: 190px;
  background: var(--s1); border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 0 9px; font-family: var(--mono); font-size: 11px;
}
.mkt-bar input.find:focus { border-color: var(--brand-line); }

/* ============================================================ modal layer */

.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 6, 8, .72);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; z-index: 91;
  left: 50%; top: 50%; transform: translate(-50%, -48%);
  width: min(620px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  background: var(--s1); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: 0 22px 60px rgba(0,0,0,.6);
  display: none; flex-direction: column; overflow: hidden;
  opacity: 0; transition: opacity .16s, transform .16s;
}
.modal.on { display: flex; opacity: 1; transform: translate(-50%, -50%); }
.modal.wide { width: min(900px, calc(100vw - 32px)); }

.modal-hd {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.modal-hd h2 { font-size: 13.5px; font-weight: 700; letter-spacing: -.005em; }
.modal-hd .sub { font-size: 11px; color: var(--text-4); }
.modal-bd { overflow: auto; min-height: 0; padding: 14px; }
.modal-ft {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 14px; border-top: 1px solid var(--line); background: var(--s2); flex: none;
}

/* command palette / symbol search */
.cmd { padding: 0; }
.cmd-in {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 15px; border-bottom: 1px solid var(--line); flex: none;
}
.cmd-in svg { width: 15px; height: 15px; color: var(--text-4); flex: none; }
.cmd-in input {
  flex: 1; min-width: 0; font-size: 15px;
  font-family: var(--mono); color: var(--text);
}
.cmd-in input::placeholder { color: var(--text-4); }
.cmd-in kbd {
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
  border: 1px solid var(--line-2); border-radius: 3px; padding: 1px 5px; flex: none;
}
.cmd-list { max-height: 400px; overflow: auto; padding: 5px 0; }
.cmd-grp {
  font-size: 8.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-4); padding: 9px 15px 4px;
}
.cmd-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 15px; cursor: pointer; min-width: 0;
}
.cmd-row:hover, .cmd-row.cur { background: var(--s3); }
.cmd-row .ic { width: 15px; color: var(--text-4); flex: none; display: grid; place-items: center; }
.cmd-row .ic svg { width: 14px; height: 14px; }
.cmd-row b { font-family: var(--mono); font-size: 12px; font-weight: 600; flex: none; }
.cmd-row .d { font-size: 11px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-row .r { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--text-3); flex: none; }

kbd {
  font-family: var(--mono); font-size: 9.5px;
  background: var(--s3); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 3px;
  padding: 1px 5px; color: var(--text-2); white-space: nowrap;
}

/* ================================================================= toasts */

.toasts {
  position: fixed; right: 12px; bottom: calc(var(--foot) + 12px); z-index: 95;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--s3); border: 1px solid var(--line-2);
  border-left: 2px solid var(--brand);
  border-radius: var(--r); padding: 8px 12px;
  box-shadow: 0 8px 26px rgba(0,0,0,.5);
  font-size: 11.5px; max-width: 340px;
  animation: toastIn .2s cubic-bezier(.2,.8,.3,1);
}
.toast.up { border-left-color: var(--up); }
.toast.down { border-left-color: var(--down); }
.toast b { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .06em; flex: none; }
.toast span { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.out { animation: toastOut .18s forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(14px); } }

/* ============================================================== onboarding */

.hero-bd { padding: 0; }
.hero-top { padding: 26px 30px 22px; border-bottom: 1px solid var(--line); }
.hero-top .eyebrow {
  font-family: var(--mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--brand); margin-bottom: 10px;
}
.hero-top h1 { font-size: 25px; line-height: 1.22; letter-spacing: -.018em; margin-bottom: 9px; }
.hero-top p { font-size: 13.5px; line-height: 1.62; color: var(--text-3); max-width: 60ch; }
.hero-top p b { color: var(--text); font-weight: 600; }

.hero-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); }
.hero-steps > div { background: var(--s1); padding: 15px 18px; }
.hero-steps .n {
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--brand);
  border: 1px solid var(--brand-line); border-radius: 3px;
  width: 19px; height: 19px; display: grid; place-items: center; margin-bottom: 8px;
}
.hero-steps h4 { font-size: 12.5px; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.hero-steps p { font-size: 11.5px; color: var(--text-4); line-height: 1.55; }

.hero-arms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.hero-arms > div { background: var(--s1); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.hero-arms .r { display: flex; align-items: center; gap: 6px; }
.hero-arms .r i { width: 6px; height: 6px; border-radius: 50%; background: var(--tint); flex: none; }
.hero-arms b { font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--tint); }
.hero-arms small { font-size: 10.5px; color: var(--text-4); line-height: 1.45; }

/* ================================================================ helpers */

.flash { animation: fl .42s ease-out; }
@keyframes fl { 0% { background: var(--brand-wash); } 100% { background: transparent; } }

.tick-up { animation: tup .5s ease-out; }
.tick-down { animation: tdn .5s ease-out; }
@keyframes tup { 0% { color: var(--up); } 100% { color: inherit; } }
@keyframes tdn { 0% { color: var(--down); } 100% { color: inherit; } }

.skel {
  background: linear-gradient(90deg, var(--s2) 25%, var(--s3) 50%, var(--s2) 75%);
  background-size: 200% 100%;
  animation: sk 1.2s linear infinite; border-radius: 3px;
}
@keyframes sk { to { background-position: -200% 0; } }

.hidden { display: none !important; }
[hidden] { display: none !important; }

/* =========================================================== responsive */

@media (max-width: 1280px) {
  .term { grid-template-columns: 206px minmax(0, 1fr) 238px; }
}

@media (max-width: 1080px) {
  .term {
    grid-template-columns: minmax(0, 1fr) 238px;
    grid-template-rows: minmax(0, 1fr) 176px;
    grid-template-areas: "chart ticket" "tape ticket";
  }
  .term > .watch { display: none; }
  .docs { grid-template-columns: 176px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  body { font-size: 12px; }

  /* One column that scrolls as a page. Grid is wrong here: `auto` rows inside a
     definite-height grid distribute free space rather than growing to content,
     so the ticket gets compressed and its buy button ends up out of reach.
     Flex with natural heights lets each panel be as tall as it needs to be. */
  .term {
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* flex follows DOM order, so state it explicitly: chart, then the ticket you
     act on, then the tape you read */
  .term > .watch { display: none; }
  .term > .chartp { flex: none; height: 264px; order: 1; }
  .term > .ticket { flex: none; order: 2; }
  .term > .tape   { flex: none; order: 3; }
  .term > .ticket .pane-body { overflow: visible; }
  .term > .tape .pane-body { max-height: 300px; }

  /* the OHLC readout wraps into the right-hand price scale on narrow screens,
     so drop the derived stats and keep the four bar values */
  .chart-ohlc { max-width: 60%; row-gap: 0; font-size: 9px; gap: 7px; }
  .chart-ohlc span:nth-child(n+5) { display: none; }

  /* the top bar scrolls sideways instead of crushing its controls */
  .top { overflow-x: auto; overflow-y: hidden; }
  .top::-webkit-scrollbar { height: 0; }
  .top-stats { display: none; }
  .top > .spacer { display: none; }
  .top-right { padding-left: 8px; }

  /* eight agents across 375px is four illegible characters each */
  .swarm { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .foot { overflow-x: auto; }
  .foot::-webkit-scrollbar { height: 0; }

  .docs { grid-template-columns: minmax(0, 1fr); }
  .docs-nav { display: none; }
  .doc { padding: 22px 18px 70px; }
  .doc h1 { font-size: 21px; }
  .doc .standfirst { font-size: 13.5px; }
  .doc table { display: block; overflow-x: auto; }
  .hero-steps, .hero-arms { grid-template-columns: 1fr 1fr; }
  .modal { max-height: 86vh; }
}

@media (max-width: 460px) {
  .hero-steps, .hero-arms { grid-template-columns: 1fr; }
  .swarm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   THE FLOOR — the swarm as one screen
   ======================================================================== */

.fl {
  height: 100%;
  overflow: auto;
  padding: 9px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.fl .pane-head .dia {
  width: 7px; height: 7px; flex: none;
  background: var(--brand);
  transform: rotate(45deg);
  border-radius: 1px;
}
.fl .pane-head h3 { letter-spacing: .11em; }

/* ------------------------------------------------------------ ticker */

.fl-strip {
  position: relative;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--s1);
  overflow: hidden;
  flex: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 34px, #000 calc(100% - 34px), transparent);
}
.fl-run {
  display: flex; flex-direction: row; flex-wrap: nowrap;
  align-items: center; gap: 24px;
  height: 100%; width: max-content;
  padding-left: 14px;
  animation: run 68s linear infinite;
}
.fl-strip:hover .fl-run { animation-play-state: paused; }
@keyframes run { to { transform: translateX(-50%); } }

.fl-run .tk {
  display: inline-flex; flex-direction: row; align-items: baseline;
  gap: 7px; white-space: nowrap; flex: 0 0 auto;
}
.fl-run .tk b {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  color: var(--text-2); letter-spacing: .04em;
}
.fl-run .tk u {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 10px; text-decoration: none; color: var(--text-4);
}

/* -------------------------------------------------------------- kpis */

.fl-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 224px;
  gap: 9px;
  flex: none;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, var(--s2), var(--s1));
  padding: 11px 14px 12px;
  display: flex; flex-direction: column; gap: 5px;
  min-width: 0;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
}
.kpi > label {
  font-size: 8.5px; font-weight: 600; letter-spacing: .13em;
  text-transform: uppercase; color: var(--text-4);
}
.kpi-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi-row b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 24px; font-weight: 500; letter-spacing: -.02em;
  line-height: 1.1; white-space: nowrap;
}
.kpi-spark { flex: 1; min-width: 0; opacity: .8; }
.kpi > small {
  font-family: var(--mono); font-size: 9.5px; color: var(--text-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------------------------------------------- balance + log */

.fl-mid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 9px;
  flex: none;
}
.fl-mid .pane { min-height: 186px; }
.fl-mid .pane-body.pad { padding: 10px 12px 12px; position: relative; }

.balance { display: block; width: 100%; height: 150px; }
.balance-tag {
  position: absolute; top: 12px; right: 14px;
  display: flex; align-items: baseline; gap: 7px;
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
  letter-spacing: .08em; text-transform: uppercase;
  pointer-events: none;
}
.balance-tag b { font-size: 11.5px; letter-spacing: 0; text-transform: none; }

/* activity rows */
.act {
  display: grid;
  grid-template-columns: 56px 58px minmax(0, 1fr) 72px auto;
  align-items: center; gap: 9px;
  padding: 5.5px 12px;
  border-bottom: 1px solid var(--line);
}

/* Bracketed event tags. The colour is the event kind, not the agent — at a
   glance you want to know a stop fired, not who fired it. */
.act .tag {
  font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: .04em; color: var(--text-4);
}
.act .tag.t-fill   { color: var(--up); }
.act .tag.t-book   { color: #4fd1c5; }
.act .tag.t-risk   { color: #a882e0; }
.act .tag.t-halt   { color: var(--down); }
.act .tag.t-signal { color: var(--info); }
.act .tag.t-feed   { color: #5ab0e8; }
.act .tag.t-size   { color: var(--warn); }
.act .tag.t-bot    { color: var(--brand); }
.act .tag.t-desk   { color: var(--text-3); }
.act:last-child { border-bottom: 0; }
.act b {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .06em; color: var(--tint);
}
.act .amt {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 10.5px; font-weight: 500; text-align: right;
}
.act .what {
  font-family: var(--mono); font-size: 10px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.act time { font-family: var(--mono); font-size: 9px; color: var(--text-4); }

/* ------------------------------------------------------- swarm core */

.fl-core { flex: 1 1 auto; min-height: 430px; }

.core-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 418px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 54% 62% at 50% 46%, rgba(255,107,26,.07), transparent 70%),
    var(--s1);
}

.mech {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ---- the mech ----------------------------------------------------------
   Solid, armoured, cartoon-heavy. Colour is carried by the body and the
   suckers; the plates stay pale so the limbs read at a glance against a dark
   stage. */

.mech .grid line   { stroke: rgba(255, 255, 255, .028); stroke-width: 1; }
.mech .grid circle { stroke: rgba(255, 255, 255, .022); stroke-width: 1; }

/* armour plates */
.mech .armour {
  fill: #e6e8ec;
  stroke: rgba(0, 0, 0, .30);
  stroke-width: 1.4;
  transition: fill .45s ease;
}
.mech .sucker {
  fill: var(--brand);
  stroke: rgba(0, 0, 0, .22);
  stroke-width: .9;
  transition: fill .45s ease;
}
.mech .limb { opacity: .88; transition: opacity .45s ease; }

/* a working arm brightens and takes its agent's colour at the suckers */
.mech .limb.live { opacity: 1; }
.mech .limb.live .armour { fill: #f7f9fb; }
.mech .limb.live .sucker {
  fill: var(--tint);
  filter: drop-shadow(0 0 4px var(--tint));
}
.mech .limb.surge { animation: surge 1.5s cubic-bezier(.3,0,.2,1); }
@keyframes surge { 0% { opacity: .88; } 20% { opacity: 1; } 100% { opacity: 1; } }

/* carapace */
.mech .shell    { fill: var(--brand); stroke: rgba(0,0,0,.34); stroke-width: 2.4; }
.mech .shell-hi { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 1.2; transform: scale(.93); transform-origin: center; transform-box: fill-box; }
.mech .bolt     { fill: #b9c0c9; stroke: rgba(0,0,0,.3); stroke-width: 1.2; }
.mech .mouth    { fill: rgba(0,0,0,.34); }

.mech .core-glow { fill: #ffb066; opacity: .18; animation: corePulse 3.2s ease-in-out infinite; }
.mech .core-ring { fill: #d8641f; }
.mech .core-mid  { fill: #ff8b3d; }
.mech .core-hot  { fill: #ffd9ab; animation: corePulse 3.2s ease-in-out infinite; }
@keyframes corePulse { 0%,100% { opacity: .82; } 50% { opacity: 1; } }

/* head */
.mech .skull { fill: #f2f4f7; stroke: rgba(0,0,0,.26); stroke-width: 2; }
.mech .visor { fill: #12151a; }
.mech .pupil { fill: #ffffff; animation: blink 6.4s infinite; transform-box: fill-box; transform-origin: center; }
@keyframes blink { 0%,95%,100% { transform: scaleY(1); } 97.5% { transform: scaleY(.08); } }
.mech .spark { fill: rgba(255,255,255,.5); }
.mech .ant     { stroke: #b9c0c9; stroke-width: 3.6; stroke-linecap: round; }
.mech .ant-tip { fill: var(--brand); animation: corePulse 2.2s ease-in-out infinite; }

/* agent cards around the mech */
.ag-card {
  position: absolute;
  width: 176px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: rgba(14, 16, 19, .92);
  backdrop-filter: blur(3px);
  padding: 7px 9px 6px;
  display: flex; flex-direction: column; gap: 5px;
  cursor: pointer;
  transition: border-color .25s, box-shadow .25s, transform .18s;
  z-index: 3;
}
.ag-card:hover { transform: translateY(-1.5px); border-color: var(--line-3); }
.ag-card::after {
  content: ''; position: absolute; top: 50%; width: 7px; height: 7px;
  margin-top: -3.5px; border-radius: 50%;
  background: var(--tint); opacity: .45;
  box-shadow: 0 0 7px var(--tint);
  transition: opacity .4s ease, transform .4s ease;
}
.ag-card.live::after { opacity: 1; transform: scale(1.25); }

.ag-card.on-left::after  { right: -4px; }
.ag-card.on-right::after { left: -4px; }

.ag-card.live {
  border-color: var(--tint);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tint) 26%, transparent), 0 6px 22px rgba(0,0,0,.4);
}

.ag-card-hd { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ag-card-hd .m { width: 14px; height: 14px; color: var(--tint); flex: none; }
.ag-card-hd .m svg { width: 100%; height: 100%; display: block; }
.ag-card-hd b {
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: .07em; color: var(--tint);
}
.ag-card-hd .role {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-4);
}

.ag-card-viz { height: 46px; color: var(--tint); }
.ag-card-viz .mc { display: block; width: 100%; height: 100%; }
.ag-card-viz .mh { display: flex; flex-direction: column; gap: 2px; justify-content: center; height: 100%; }
.ag-card-viz .mh-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center; gap: 5px;
}
.ag-card-viz .mh-row span {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: .04em;
  color: var(--text-4); text-transform: uppercase;
}
.ag-card-viz .mh-row i { display: block; height: 4px; border-radius: 2px; transition: width .6s ease; }
.ag-card-viz .mh-row b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 8px; color: var(--text-3); font-weight: 500;
}
.mc-empty {
  display: grid; place-items: center; height: 100%;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .06em;
  color: var(--text-4); text-transform: uppercase;
}

.ag-card-ft {
  display: flex; align-items: baseline; gap: 6px;
  font-family: var(--mono); font-size: 8.5px;
  color: var(--text-4); letter-spacing: .05em; text-transform: uppercase;
}
.ag-card-ft b {
  font-size: 10px; letter-spacing: 0; text-transform: none;
  font-variant-numeric: tabular-nums;
}
.ag-card.live .ag-card-ft span:first-child { color: var(--tint); }

/* ring positions — a card per arm */
[data-ag-card="scout"]  { top: 3%;  left: 21%; }
[data-ag-card="quote"]  { top: 3%;  right: 21%; }
[data-ag-card="sizer"]  { top: 29%; left: 1.5%; }
[data-ag-card="exec"]   { top: 29%; right: 1.5%; }
[data-ag-card="hedge"]  { top: 59%; left: 1.5%; }
[data-ag-card="ledger"] { top: 59%; right: 1.5%; }
[data-ag-card="vault"]  { bottom: 3%; left: 21%; }
[data-ag-card="cull"]   { bottom: 3%; right: 21%; }

.core-corner {
  position: absolute; z-index: 2;
  display: flex; flex-direction: column; gap: 3px;
  width: 88px;
}
.core-corner.tl { left: 12px; bottom: 14px; }
.core-corner.br { right: 12px; bottom: 14px; }
.core-corner label {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-4);
}
.core-corner div { display: flex; flex-direction: column; gap: 2.5px; }
.core-corner i {
  display: block; height: 4px; border-radius: 2px; opacity: .72;
  transition: width .6s ease;
}

.core-foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 6px 10px;
  text-align: center;
  font-family: var(--mono); font-size: 8.5px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-4);
}
.core-foot span { color: var(--brand); }
.core-foot .dot { color: var(--text-4); }

/* ------------------------------------------------------------- tiles */

.fl-tiles {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  flex: none;
}

.tile {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--s1);
  padding: 8px 9px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  cursor: pointer; min-width: 0;
  transition: border-color .25s, background .2s, transform .18s;
}
.tile:hover { transform: translateY(-1.5px); border-color: var(--line-3); }
.tile.run {
  border-color: var(--tint);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint) 7%, var(--s1)), var(--s1));
}

.tile-hd { display: flex; align-items: center; gap: 5px; width: 100%; }
.tile-hd .n { font-family: var(--mono); font-size: 8px; color: var(--text-4); }
.tile-hd .led { width: 5px; height: 5px; border-radius: 50%; background: var(--text-4); flex: none; }
.tile.run .tile-hd .led { background: var(--tint); box-shadow: 0 0 6px var(--tint); }
.tile-hd .st {
  font-family: var(--mono); font-size: 8px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-4);
}
.tile.run .tile-hd .st { color: var(--tint); }

.tile-m { width: 34px; height: 34px; color: var(--tint); margin: 1px 0; }
.tile-m svg { width: 100%; height: 100%; display: block; }

.tile-name {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: .07em; color: var(--tint);
}
.tile > small {
  font-size: 8px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--text-4);
}
.tile-bar { width: 100%; height: 3px; border-radius: 2px; background: var(--s4); overflow: hidden; }
.tile-bar i { display: block; height: 100%; background: var(--tint); transition: width .6s ease; }
.tile-pct {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 10px; font-weight: 500;
}

/* --------------------------------------------------------- consensus */

.fl-cons {
  display: flex; align-items: center; gap: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--s1);
  padding: 9px 14px;
  flex: none;
}
.fl-cons label {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-4); flex: none;
}
.cons-track {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--s4); overflow: hidden;
}
.cons-track i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--up), #4fd1c5 46%, var(--brand));
  transition: width .9s cubic-bezier(.4,0,.2,1);
}
.fl-cons b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 10px; color: var(--text-3); flex: none; letter-spacing: .04em;
}

/* ------------------------------------------------------- responsive */

@media (max-width: 1240px) {
  .ag-card { width: 146px; }
  [data-ag-card="scout"], [data-ag-card="vault"] { left: 14%; }
  [data-ag-card="quote"], [data-ag-card="cull"]  { right: 14%; }
}

@media (max-width: 1040px) {
  .fl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fl-mid { grid-template-columns: minmax(0, 1fr); }
  .fl-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .core-stage { min-height: 400px; }
  .ag-card { width: 132px; }
  .ag-card-viz { height: 34px; }
}

@media (max-width: 760px) {
  /* the ring collapses: the mech stays, the cards stack under it */
  .fl-core { min-height: 0; }
  .core-stage { min-height: 300px; }
  .mech { width: 94%; }
  .ag-card { display: none; }
  .fl-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fl-kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi-row b { font-size: 21px; }
  .core-corner { display: none; }
}

/* ============================================================== bot view */

.bot {
  height: 100%;
  display: flex; flex-direction: column;
  gap: 9px; padding: 9px 10px;
  overflow: auto;
}

.bot-head {
  display: flex; align-items: stretch; gap: 9px;
  flex: none; flex-wrap: wrap;
}
.bot-stat {
  border: 1px solid var(--line); border-radius: 7px;
  background: linear-gradient(180deg, var(--s2), var(--s1));
  padding: 10px 14px; min-width: 150px;
  display: flex; flex-direction: column; gap: 2px;
}
.bot-stat label {
  font-size: 8.5px; font-weight: 600; letter-spacing: .13em;
  text-transform: uppercase; color: var(--text-4);
}
.bot-stat b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 500; letter-spacing: -.015em;
}
.bot-stat small { font-family: var(--mono); font-size: 9px; color: var(--text-4); }
.bot-head > .btn { align-self: center; height: 30px; }

.bot-new { flex: none; }
.bot-form { display: flex; gap: 9px; align-items: flex-end; }

.bot-picker {
  display: flex; align-items: center; gap: 7px;
  height: 27px; width: 100%;
  border: 1px solid var(--line-2); border-radius: 4px;
  background: var(--s2); padding: 0 9px;
  font-family: var(--mono); font-size: 11px;
  transition: border-color .12s, background .12s;
}
.bot-picker:hover { border-color: var(--line-3); background: var(--s3); }
.bot-picker b { font-weight: 600; }

.bot-presets {
  display: flex; align-items: center; gap: 5px;
  margin-top: 9px; flex-wrap: wrap;
}
.bot-presets button {
  height: 22px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 4px;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: var(--text-3); transition: all .12s;
}
.bot-presets button:hover { color: var(--text); border-color: var(--line-3); background: var(--s2); }
.bot-presets button.on { background: var(--brand-wash); border-color: var(--brand-line); color: var(--brand); }

@media (max-width: 900px) {
  .bot-form { flex-wrap: wrap; }
  .bot-form .tk-field { width: 100% !important; }
  .bot-stat { min-width: 132px; flex: 1; }
}

/* the bot's state — it runs by default, so this reads as a status, not a switch */
.btn.bot-state { gap: 6px; border-color: rgba(31,199,125,.3); background: var(--up-wash); color: var(--up); }
.btn.bot-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--up); flex: none; animation: beat 2.4s ease-in-out infinite; }
.btn.bot-state:hover { background: rgba(31,199,125,.2); border-color: var(--up); color: var(--up); }
.btn.bot-state.paused { border-color: rgba(240,180,41,.32); background: rgba(240,180,41,.1); color: var(--warn); }
.btn.bot-state.paused i { background: var(--warn); animation: none; }
.btn.bot-state.halted { border-color: rgba(240,72,90,.34); background: var(--down-wash); color: var(--down); }
.btn.bot-state.halted i { background: var(--down); animation: none; }


/* ---- hit-rate ring ---------------------------------------------------- */

.kpi-donut .kpi-row { gap: 14px; }
.kpi-donut .donut { width: 56px; height: 56px; flex: none; display: block; }
.kpi-donut .donut .ring { width: 56px; height: 56px; display: block; }
.kpi-donut .donut-side { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kpi-donut .donut-side b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 500;
}
.kpi-donut .donut-side small { font-family: var(--mono); font-size: 9.5px; color: var(--text-4); }

/* the target bar turns amber when the book is below where it started */
.cons-track i.behind { background: linear-gradient(90deg, var(--down), var(--warn)); }

@media (max-width: 1040px) {
  .fl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* GeckoTerminal's embedded pool chart */
.gt-embed {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0; display: block;
  background: var(--s1);
}
.chart-bar .seg button:disabled { opacity: .3; pointer-events: none; }

/* said over the venue's chart when it is standing in for ours */
.chart-note {
  position: absolute; left: 10px; bottom: 8px; z-index: 4;
  font-family: var(--mono); font-size: 9px; letter-spacing: .05em;
  color: var(--text-4); background: rgba(10,11,13,.78);
  border: 1px solid var(--line); border-radius: 3px; padding: 2px 6px;
  pointer-events: none;
}

/* ---- touching a chart lights its arm ------------------------------------
   The agent's tint is already the colour of the chart inside its card, so
   lighting the limb in that tint is what makes the link between the two
   legible without drawing a label. */

/* the seven that are not being pointed at step back */
.core-stage.focusing .limb            { opacity: .26; }
.core-stage.focusing .limb .sucker    { fill: #6c757f; }
.core-stage.focusing .mech-head,
.core-stage.focusing .mech-body       { opacity: .72; }

/* and the one that is takes its chart's colour, whole */
.mech .limb.focus {
  opacity: 1;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--tint) 55%, transparent));
}
.mech .limb.focus .armour {
  fill: color-mix(in srgb, var(--tint) 28%, #f4f6f9);
  stroke: color-mix(in srgb, var(--tint) 55%, rgba(0,0,0,.34));
}
.mech .limb.focus .sucker {
  fill: var(--tint);
  filter: drop-shadow(0 0 5px var(--tint));
}

/* the card answers back, so the pair reads as one object */
.ag-card.focus {
  border-color: var(--tint);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tint) 34%, transparent),
              0 8px 28px rgba(0,0,0,.5);
  transform: translateY(-2px);
}
.ag-card.focus::after { opacity: 1; transform: scale(1.4); }

.core-stage .limb, .core-stage .mech-head, .core-stage .mech-body {
  transition: opacity .22s ease, filter .22s ease;
}
.mech .armour, .mech .sucker { transition: fill .22s ease, stroke .22s ease, filter .22s ease; }

@media (prefers-reduced-motion: reduce) {
  .ag-card.focus { transform: none; }
}

/* ---- the X account ------------------------------------------------------ */

.rail-social { text-decoration: none; }
.rail-social svg { width: 14px; height: 14px; }
.rail-social:hover { color: var(--text); background: var(--s2); }

.foot-link {
  text-decoration: none;
  transition: color .12s;
  gap: 5px;
}
.foot-link:hover { color: var(--text-2); }
.foot-link:hover b { color: var(--brand); }
.foot-link svg { flex: none; opacity: .8; }

/* ==========================================================================
   BACKTEST LAB — the floor banner, the comms feed, and the Lab view
   ======================================================================== */

.fl-lab { flex: none; overflow: hidden; }
.fl-lab .pane-head .chip { margin-left: 2px; }
.fl-lab .pane-head .btn { margin-left: 8px; }

.lab-wall {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.lab-cell {
  background: linear-gradient(180deg, var(--s2), var(--s1));
  padding: 11px 13px 12px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.lab-cell label {
  font-size: 8.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-cell b {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lab-cell.hero b { font-size: 30px; color: var(--brand); letter-spacing: -.03em; }
.lab-cell small {
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.lab-prog { height: 2px; background: var(--s3); position: relative; overflow: hidden; flex: none; }
.lab-prog i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .5s ease; }
.lab-prog.run::after {
  content: ''; position: absolute; inset: 0; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255,176,102,.7), transparent);
  animation: labSweep 1.3s linear infinite;
}
@keyframes labSweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* floor middle row: balance · activity · comms */
.fl-mid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) minmax(0, 1fr); }
.fl-mid .pane-body[data-fl-comms] { max-height: 232px; }

.live-dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none; margin-left: 2px;
  background: var(--up); box-shadow: 0 0 8px var(--up);
  animation: beat 1.6s ease-in-out infinite;
}

.comms { font-family: var(--mono); font-size: 10px; overflow: hidden; }
.cm {
  display: grid;
  grid-template-columns: 74px 50px minmax(0, 1fr);
  gap: 8px; align-items: baseline;
  padding: 4px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
}
.cm time { color: var(--text-4); font-size: 9px; font-variant-numeric: tabular-nums; }
.cm time i { font-style: normal; opacity: .55; }
.cm b { color: var(--tint); font-size: 9.5px; font-weight: 600; letter-spacing: .06em; }
.cm span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm span.up { color: var(--up); }
.cm span.down { color: var(--down); }
.cm span.warn { color: var(--warn); }
.cm.new { animation: cmIn .5s ease-out; }
/* a highlight, never a fade-in: a row must be readable even if the animation
   never gets a frame (background tabs throttle them) */
@keyframes cmIn {
  from { background: color-mix(in srgb, var(--tint) 18%, transparent); }
  to   { background: transparent; }
}

@media (max-width: 1280px) {
  .lab-wall { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fl-mid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fl-mid .fl-comms { grid-column: 1 / -1; }
}
@media (max-width: 1040px) {
  .fl-mid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .lab-wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-cell.hero, .lab-cell:last-child { grid-column: 1 / -1; }
  .fl-lab .pane-head .sub { display: none; }
  .cm { grid-template-columns: 50px 44px minmax(0, 1fr); gap: 6px; padding: 4px 9px; }
  .cm time i { display: none; }
}

/* ---- the Lab view ------------------------------------------------------- */

.lab {
  height: 100%; overflow: auto;
  padding: 9px 10px 18px;
  display: flex; flex-direction: column; gap: 9px;
}
.lab > .pane, .lab-row > .pane { flex: none; }
.lab .pane-body { overflow: auto; }
.lab-title {
  display: flex; gap: 16px; align-items: flex-start; justify-content: space-between;
  padding: 14px 16px 13px; flex-wrap: wrap;
}
.lab-title .eyebrow {
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--brand); margin-bottom: 6px;
}
.lab-title h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin: 0 0 6px; }
.lab .stat b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lab-title p { font-size: 12px; line-height: 1.6; color: var(--text-3); max-width: 78ch; margin: 0; }
.lab-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.lab .grid-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.lab .stat b { font-size: 17px; }

.lab-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 9px; }
.lab-row.flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
.lab-row .pane-body { max-height: 380px; }

.lab-tbl tr.sel td { background: var(--brand-wash); }
.lab-tbl tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--brand); }
.lab-tbl tr.live td { font-weight: 600; }

.histo.tall { height: 150px; }
.histo-axis {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-family: var(--mono); font-size: 9px; color: var(--text-4);
}

.lab-notes p { font-size: 12px; line-height: 1.6; color: var(--text-3); margin: 0 0 8px; max-width: 96ch; }
.lab-notes p:last-child { margin-bottom: 0; }
.lab-notes b { color: var(--text-2); }

@media (max-width: 1040px) {
  .lab-row, .lab-row.flip { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .lab { padding: 7px 7px 16px; }
  .lab-title { padding: 12px; }
  .lab-title h2 { font-size: 16px; }
}

/* ---- bot trades, top of the floor -------------------------------------- */

.fl-trades { flex: none; }
.fl-trades .pane-head .chip { margin-left: 4px; }
.fl-trades .pane-head .btn { margin-left: 8px; }
.fl-trades .pane-body { max-height: 300px; }
.fl-trades-tbl td small { font-size: 9px; color: var(--text-4); margin-left: 3px; }
.fl-trades-tbl tr.open td { background: rgba(255, 107, 26, 0.035); }
.fl-trades-tbl tr.new td { animation: tradeIn 1.6s ease-out; }
@keyframes tradeIn { from { background: rgba(255, 107, 26, 0.22); } }
@media (max-width: 620px) {
  .fl-trades .pane-head .chip { display: none; }
  .fl-trades .pane-body { overflow-x: auto; }
}

/* ---- the official bot, top of the floor -------------------------------- */

.fl-official { flex: none; border-color: var(--brand-line); box-shadow: 0 0 0 1px rgba(255, 107, 26, 0.08), 0 8px 30px rgba(255, 107, 26, 0.05); }
.fl-official[hidden] { display: none; }
.fl-official .pane-head .chip { margin-left: 4px; }
.fl-official .pane-head .btn { margin-left: 8px; text-decoration: none; }
.fl-official .pane-body { max-height: 320px; }
.live-dot.off { background: var(--text-4); box-shadow: none; animation: none; }
.off-stats {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px; background: var(--line); border-bottom: 1px solid var(--line);
}
.off-stats > div { background: linear-gradient(180deg, var(--s2), var(--s1)); padding: 10px 13px; min-width: 0; }
.off-stats label {
  display: block; font-size: 8.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-4); margin-bottom: 4px;
}
.off-stats b {
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
@media (max-width: 900px) { .off-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) {
  .off-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fl-official .pane-head .chip { display: none; }
  .fl-official .pane-body { overflow-x: auto; }
}

/* ---- header: contract address and the X call to action ------------------ */

.top-ca {
  display: flex; align-items: center; gap: 8px; align-self: center;
  margin-left: 12px; height: 30px; padding: 0 10px;
  border: 1px solid var(--brand-line); border-radius: 6px;
  background: var(--brand-wash); color: var(--text-2);
  cursor: pointer; min-width: 0; position: relative;
  font-family: var(--mono); transition: border-color .12s, background .12s;
}
.top-ca[hidden] { display: none; }
.top-ca:hover { border-color: var(--brand); background: rgba(255, 107, 26, 0.16); }
.top-ca label { font-size: 9px; font-weight: 700; letter-spacing: .1em; color: var(--brand); cursor: pointer; }
.top-ca code { font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.top-ca svg { width: 12px; height: 12px; flex: none; color: var(--text-3); }
.top-ca .ok {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 6px;
  background: var(--brand); color: #0a0b0d; font-size: 10px; font-weight: 700; letter-spacing: .1em;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.top-ca.copied .ok { opacity: 1; }

.top-x {
  display: flex; align-items: center; gap: 9px; align-self: center;
  height: 30px; padding: 0 12px; margin-right: 2px;
  border: 1px solid var(--line-2); border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 107, 26, 0.10), rgba(255, 255, 255, 0.02));
  color: var(--text-2); text-decoration: none; white-space: nowrap; flex: none;
  transition: border-color .12s, color .12s, transform .12s;
}
.top-x:hover { border-color: var(--brand); color: var(--text); transform: translateY(-1px); }
.top-x .t { font-size: 11.5px; }
.top-x .t b { color: var(--text); }
.top-x .h { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--brand); }
.top-x svg { width: 12px; height: 12px; flex: none; }
.top-x .live-dot { margin-left: 0; }

@media (max-width: 1500px) { .top-x .t { display: none; } }
@media (max-width: 1180px) { .top-x .h { display: none; } .top-x { padding: 0 9px; } }
@media (max-width: 860px) { .top-ca code { max-width: 90px; } }
.x-post { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; color: var(--text-3); border: 1px solid var(--line-2); }
.x-post svg { width: 10px; height: 10px; }
.x-post:hover { color: var(--text); border-color: var(--brand); background: var(--brand-wash); }
