:root {
  --bg: #0d0d0d;
  --panel: #161616;
  --text: #d2d2d2;
  --muted: #8a8a8a;
  --grid: #373737;
  --green: #00b050;
  --red: #ff4136;
  --blue: #5494f5;
  --green-bg: rgba(0, 176, 80, 0.28);
  --red-bg: rgba(255, 65, 54, 0.28);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", system-ui, sans-serif;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
  background: var(--panel);
  position: sticky;
  top: 0;
}
h1 { font-size: 16px; margin: 0; }
h1 .unit { color: var(--muted); font-weight: normal; font-size: 12px; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  /* Transparent for the same reason as the class toggles: these sit on the
     header's --panel, so --bg would render as a slightly darker pill. */
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--grid);
  border-radius: 5px;
  padding: 4px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tabs button.active { color: var(--text); border-color: var(--blue); }
/* Inactive tabs read as clickable on hover without taking a fill, which stays
   reserved for the active tab's blue border. */
.tabs button:not(.active):hover { color: var(--text); border-color: var(--muted); }
.hidden { display: none !important; }
.conn { color: var(--red); font-size: 14px; }
.conn.ok { color: var(--green); }
.controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.controls label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
input, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 3px 6px;
  font: inherit;
  width: 110px;
}
select { width: auto; }
/* Global asset-class filter. Button-style rather than checkboxes so it reads as a
   distinct control from the venue checkboxes sitting next to it. */
.class-toggles { display: flex; gap: 4px; }
.class-toggles button {
  /* Transparent, not var(--bg): these sit on the header's --panel, so painting
     them --bg would show as a darker pill instead of an outline. */
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 2px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
/* Selected = filled with the same blue as the border, so "on" is readable at a
   glance rather than from a border-colour change alone. Dark text on this blue
   beats white for contrast. Multi-select: any combination may be lit, and all
   three are lit by default. */
.class-toggles button.active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--bg);
  font-weight: 600;
}
.class-toggles button:not(.active):hover { color: var(--text); border-color: var(--muted); }
.venue-toggles { display: flex; gap: 8px; flex-wrap: wrap; }
.venue-toggles label { color: var(--text); cursor: pointer; user-select: none; }
.venue-toggles input { width: auto; accent-color: var(--blue); }
.csv { color: var(--blue); text-decoration: none; font-size: 12px; }
.csv:hover { text-decoration: underline; }

main { padding: 14px 16px; max-width: 1500px; }
#viewFunding { max-width: 1100px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.toolbar label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.toolbar .note { color: var(--muted); font-size: 11px; }
/* How many tokens survive the filters — so a shrinking list never looks like
   lost data. */
.toolbar .count { color: var(--text); font-size: 12px; white-space: nowrap; }
#search, #spreadFilter { width: 190px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--grid);
  border-radius: 12px;
  padding: 2px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.chips button.active { color: var(--text); border-color: var(--blue); }
/* Same hover as the tabs and class toggles: an unselected chip brightens its text
   and border so it reads as clickable, without taking a fill. */
.chips button:not(.active):hover { color: var(--text); border-color: var(--muted); }
/* Funding table: every column centred, headers included. The id selector beats
   the .sym / global right-align rules. */
#fundingTable th, #fundingTable td { text-align: center; }
/* ...except the group banner, which is a sentence rather than a column value. */
#fundingTable tr.group-row td { text-align: left; }

tr.group-row td {
  background: #1b2333;
  font-weight: 600;
  text-align: left;
}
tr.group-row .legs { color: var(--muted); font-weight: normal; margin-left: 12px; }
/* Star column: a bookmark toggle, left of Symbol. Outline when off, blue when on. */
th.star, td.star { width: 1%; padding: 2px 6px; text-align: center; }
button.fav {
  background: none;
  border: 0;
  color: var(--grid);
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
button.fav:hover { color: var(--muted); }
button.fav.on { color: var(--blue); }
/* ── Spread view ── */
/* One slot per universe symbol. Slots always exist (so the scroll height is
 * right); the block inside is mounted only when it nears the viewport, which is
 * what the min-height placeholder stands in for. */
.slot { min-height: 1px; }
.block {
  border: 1px solid var(--grid);
  border-radius: 6px;
  background: var(--panel);
  padding: 10px 14px 14px;
  margin-bottom: 18px;
}
.block h2 { margin: 0 0 8px; font-size: 15px; }
.block h2 .ts { color: var(--muted); font-weight: normal; font-size: 12px; margin-left: 10px; }
.block h2 .rank { color: var(--muted); font-weight: normal; }
.block h2 .score { color: var(--blue); font-weight: normal; font-size: 12px; margin-left: 8px; }
/* Run sits at the end of the block header, sized down to match the 15px title. */
.block h2 button.run { margin-left: 12px; padding: 1px 12px; font-size: 12px; vertical-align: 1px; }
.block table { width: auto; margin-bottom: 10px; }
.block th, .block td { padding: 3px 9px; font-size: 12px; }
.block td.vn, .block th.vn { text-align: left; font-weight: 600; }
.block td.vn.stale { color: var(--red); }
/* Venue below the Min OI threshold: shown, but struck out and valueless. */
.block td.vn.filtered { color: var(--muted); text-decoration: line-through; }
/* Venue whose "index" is really an oracle mid (Ostium) or a mark (Variational):
   it ranks, but the basis it produces is not a two-sided one. Hover for why. */
.block td.vn.proxy { border-left: 2px solid var(--blue); }
.block h2 .score[title] { cursor: help; }
.mtxrow { display: flex; gap: 18px; flex-wrap: wrap; }
.mtx caption { color: var(--muted); font-size: 12px; text-align: left; padding-bottom: 3px; }
.mtx td.blk { background: #000; }
.mtx td.hl { background: rgba(255, 215, 0, 0.28); }
table { border-collapse: collapse; width: 100%; }
th, td {
  border: 1px solid var(--grid);
  padding: 4px 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th { background: var(--panel); font-weight: 600; }
td.sym, th.sym { text-align: left; font-weight: 600; }
td.lo { background: var(--green-bg); }
td.hi { background: var(--red-bg); }
td.stale { color: var(--red); }
td.arb { font-weight: 600; }
td.runcell { text-align: center; }
button.run {
  background: #4472c4;
  color: #fff;
  border: 0;
  border-radius: 5px;
  padding: 2px 14px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
button.run:hover { filter: brightness(1.15); }
button.run:disabled { background: var(--grid); cursor: default; }
button.swap {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 5px;
  padding: 2px 10px;
  font: inherit;
  cursor: pointer;
}
button.swap:hover { border-color: var(--blue); }
#btSymbol { width: 110px; }
/* Informational by default (e.g. "Variational can't be backtested — testing X/Y
   instead"); red only when it is an error that blocks the run. */
#viewBacktest .toolbar .note { color: var(--muted); }
#viewBacktest .toolbar .note.error { color: var(--red); }

.backtest {
  margin-top: 22px;
  border: 1px solid var(--grid);
  border-radius: 6px;
  background: var(--panel);
  padding: 12px 16px;
}
.backtest.hidden { display: none; }
.backtest h2 { margin: 0 0 4px; font-size: 14px; }
.backtest .note { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.backtest .error { color: var(--red); }
.chart { width: 100%; height: 330px; margin-top: 10px; }
.chart:empty { display: none; }
.note.hidden { display: none; }
dl { display: grid; grid-template-columns: max-content max-content auto; gap: 3px 18px; margin: 8px 0; }
dt { color: var(--muted); }
dd { margin: 0; font-variant-numeric: tabular-nums; }
dd.extra { color: var(--muted); }
