:root {
  --bg: #07090d;
  --bg-2: #0c1017;
  --panel: #121722;
  --panel-2: #171e2b;
  --line: #243044;
  --text: #f2f5fa;
  --muted: #8b96ab;
  --green: #3ee09a;
  --red: #ff5d73;
  --amber: #f5c15c;
  --blue: #5ba3ff;
  --back: #1d4ed8;
  --back-bg: #173056;
  --back-fg: #dbeafe;
  --lay: #be185d;
  --lay-bg: #3b1530;
  --lay-fg: #fce7f3;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must actually hide. The UA sheet's [hidden] rule is a
   user-agent declaration, and ANY author declaration beats it - so `.rf { display:
   flex }` silently won and the "Player name" row stayed on screen in every expanded
   card whenever the picker was not "named", showing a field that does nothing and
   costing the row its height. The two [hidden] rules further down (.settings-pane,
   .modal-back) spell this out per-selector; this is the general form. */
[hidden] { display: none !important; }
html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, #152033 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}
body.mode-live {
  box-shadow: inset 0 0 0 4px var(--red);
}
.stale-note {
  background: #3a2a12;
  color: var(--amber);
  text-align: center;
  padding: 6px 12px;
  font-size: 13px;
}
#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  max-width: 320px;
  box-shadow: var(--shadow);
}
.rule-steps { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.rule-steps button { font-size: 12px; }
.rule-card[data-show="entry"] [data-step]:not([data-step="entry"]),
.rule-card[data-show="exit"] [data-step]:not([data-step="exit"]),
.rule-card[data-show="risk"] [data-step]:not([data-step="risk"]),
.rule-card[data-show="advanced"] [data-step]:not([data-step="advanced"]) { display: none; }
body.theme-light {
  --bg: #f4f6f8;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --line: #d5dde6;
  --text: #1c2430;
  --muted: #5c6b7c;
  --shadow: 0 8px 24px rgba(20, 30, 40, 0.08);
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
button, input, select, textarea { font: inherit; }
.chrome {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  background: rgba(8, 11, 16, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.chrome-mid, .chrome-right, .chrome-left { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
/* waiting section removed */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px 8px; }
.icon-btn svg { display: block; }
.icon-btn svg.hide { display: none; }
#btn-mute.muted { color: var(--muted); opacity: 0.5; }
.brand { display: inline-flex; align-items: center; gap: 8px; letter-spacing: -0.02em; font-size: 15px; }
.brand-logo { width: 22px; height: 22px; border-radius: 50%; display: block; }
/* The side rail and the mobile scroller are the SAME markup, restyled by media
   query. Two separate navs (or a JS-built one) would drift: the open-count badge
   updates a single element, and every link's active state has one owner. The rail is
   fixed so it does not scroll with the page, and `main` is offset by the width
   variable so the two collapsed/expanded states share one source of truth. */
:root { --rail-w: 190px; }
body.nav-collapsed { --rail-w: 62px; }
.nav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 30;
  transition: width 0.14s ease;
}
.nav-items { display: flex; flex-direction: column; gap: 2px; }
/* Brand + collapse arrow share one row at the top of the rail, so the logo reads as
   the head of the menu rather than as chrome above it. */
.nav-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 2px 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.nav-brand .brand { color: var(--text); text-decoration: none; min-width: 0;
  flex: 0 1 auto; }
.nav-brand .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.nav-collapsed .nav-brand { justify-content: center; }
body.nav-collapsed .nav-brand .brand span { display: none; }
body.nav-collapsed .nav-brand { flex-direction: column; gap: 8px; }
/* The collapse control. It was a 30px ghost with a muted 1px border on a dark rail,
   which read as decoration rather than a button. Now: a filled chip, a brighter
   glyph, and a bigger hit area. The inner `>` points at the panel the rail will give
   back, and it rotates to `<` once collapsed. */
.nav-collapse {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid #33425c;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.nav-collapse:hover { background: #22314a; border-color: var(--blue); color: #fff; }
.nav-collapse:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.nav-collapse svg { width: 18px; height: 18px; display: block;
  stroke-width: 2.6; transition: transform 0.14s ease; }
body.nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
/* Scoped to `.nav-items a`, not `.nav a`: the product name in the brand row is also an
   anchor, and these item rules (padding, `flex: none`, `white-space: nowrap`) were
   silently applied to it. `flex: none` stopped the name shrinking, so the brand row
   stayed wider than the rail and `.nav`'s `overflow-x: hidden` cropped the collapse
   button down to a sliver. */
.nav-items a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  flex: none;
}
.nav-items a svg { width: 18px; height: 18px; flex: none; }
.nav-items a:hover { color: var(--text); background: var(--panel); }
.nav-items a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
/* An orphan (live exchange order we are not tracking) blocks LIVE arming, so the
   item is tinted amber to draw the eye from any page. Colour plus the count in the
   label, never colour alone — the label carries the number whether or not the
   palette reads true. */
.nav-items a.nav-alert { color: var(--amber); }
.nav-items a.nav-alert.active { background: rgba(245, 193, 92, 0.12); }
/* Collapsed: icons only. The label is hidden rather than removed so the accessible
   name and the title tooltip survive. */
body.nav-collapsed .nav-items a { justify-content: center; padding: 9px 0; }
body.nav-collapsed .nav-items a span { display: none; }
body.nav-collapsed .nav-collapse { align-self: center; }
/* Brand sizing in the rail. The logo is hidden on a phone, where the nav is a
   horizontal icon scroller and a wordmark would just take scroll width. */
.nav-brand .brand-logo { width: 24px; height: 24px; }
.nav-brand .brand { font-size: 13px; gap: 7px; }
#desk-chrome, #banner, main { margin-left: var(--rail-w); }
.chrome { transition: margin-left 0.14s ease; }
.pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: #1c2a40;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.live { background: #3a1520; color: #ffb3bb; }
.mode-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.mode-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.mode-toggle button.on { background: #1c2a40; color: var(--text); }
.mode-toggle #mode-live.on { background: #3a1520; color: #ffb3bb; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
/* Build stamp: deliberately quiet (it is diagnostics, not a control you use every
   day) but always present, so "which build is this?" never needs a guess. */
.build-stamp {
  font-size: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .02em; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--line);
  color: var(--muted); opacity: .65; white-space: nowrap;
}
.build-stamp:hover { opacity: 1; border-color: var(--blue); color: var(--text); }
.stat-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.stat { display: flex; flex-direction: column; justify-content: center; min-width: 88px; padding: 2px 12px 2px 0; }
.stat + .stat { padding-left: 12px; border-left: 1px solid var(--line); }
.stat-k { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat b { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 8ch; }
body.mode-live #bank-k,
body.mode-live #day-k { color: #ffb3bb; }
body.theme-light.mode-live #bank-k,
body.theme-light.mode-live #day-k { color: #9f1239; }
.hb-slot {
  display: inline-block;
  min-width: 5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stat b.hb-v {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hb-v::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.hb.ok .hb-v { color: var(--green); }
.hb.wait .hb-v { color: var(--blue); }
.hb.wait .hb-v::before { animation: hb-pulse 1s ease-in-out infinite; }
@keyframes hb-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.hb.bad .hb-v { color: var(--amber); }
button, .btn {
  background: #223044;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 600;
}
button:hover, .btn:hover { background: #2b3c54; }
button.danger { background: #5a1c26; }
button.danger:hover { background: #6e2430; }
button.ghost.danger { background: transparent; color: #ffb3bb; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.ghost:hover { color: var(--text); background: #151c27; }
a.btn { text-decoration: none; display: inline-block; }
main {
  padding: 20px;
  /* `width: 100%` measures against the BODY, so the `margin-left` that clears the
     fixed rail was added to a full-width box: main's right edge landed at
     viewport + rail-w and `html, body { overflow-x: hidden }` quietly clipped the
     right of every page (tables, action buttons, the last column). `flex: 1` against
     the flex row below sizes main to the space the rail actually leaves. */
  flex: 1 1 auto;
  /* Without this a wide table sets main's min-content width, so the box - and the
     page - grow wider than the viewport instead of letting .table-scroll scroll. */
  min-width: 0;
}
main > #view, main#view { min-width: 0; }
/* The mobile media query cancels the rail offsets and needs no flex row, so this is
   scoped to the desktop rail layout. */
@media (min-width: 721px) {
  body { display: flex; flex-direction: column; min-height: 100vh; }
}
/* Consistent gap between every top-level panel / section on every page */
#view { display: flex; flex-direction: column; gap: 14px; }
.dash, .open-page, .insights {
  display: flex; flex-direction: column; gap: 14px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.kpi .stat-k { display: block; margin-bottom: 4px; }
.kpi b { font-variant-numeric: tabular-nums; font-size: 18px; }
.kpi-sub {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}
.kpi-sub:empty { display: none; }
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dash-feeds { margin-top: 10px; }
.dash .panel {
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: none;
}
.dash .panel h3 { margin: 0 0 2px; font-size: 13px; }
.dash .panel > .muted { margin: 0 0 6px; font-size: 11px; }
.dash .data-table th,
.dash .data-table td { padding: 4px 6px; font-size: 12px; }
.dash .table-scroll { max-height: 200px; }
.dash .m-name { font-size: 12px; }
.dash .m-sub { font-size: 11px; }
.news-list, .tour-list { display: flex; flex-direction: column; gap: 0; }
.dash-feeds .news-list,
.dash-feeds .tour-list { max-height: 200px; overflow-y: auto; }
.news-item {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.news-item:last-child { border-bottom: 0; }
.news-item:hover .news-title { color: var(--blue); }
.news-title { display: block; font-weight: 600; font-size: 12px; line-height: 1.35; }
.tour-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.tour-row:last-child { border-bottom: 0; }
.tour-when { text-align: right; white-space: nowrap; font-size: 11px; }
.kpi-grid { gap: 8px; margin-bottom: 10px; }
.dash .kpi { padding: 7px 9px; border-radius: 10px; }
.dash .kpi b { font-size: 16px; }
.cal-toolbar { align-items: center; gap: 10px; }
.cal-title { margin: 0; font-size: 18px; min-width: 180px; text-align: center; }
.cal-filters { margin: 0 0 0 auto; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-dow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 6px;
}
.cal-cell {
  min-height: 88px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: #3b6ea8; }
.cal-day { display: block; font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.cal-pill {
  display: block;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  padding: 2px 5px;
  border-radius: 6px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-pill.atp { background: #1c2a40; color: #9ec0ea; }
.cal-pill.wta { background: #2a2433; color: #c8bdd8; }
.cal-pill.on { box-shadow: inset 0 0 0 1px var(--green); }
.page-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.page-title { margin: 16px 0 4px; font-size: 15px; }
.page-title:first-child { margin-top: 0; }
.page-note { margin: 0 0 10px; }
.stack-list { display: flex; flex-direction: column; gap: 8px; }
.stack-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.stack-row .m-name { margin-bottom: 2px; }
.log-msg { margin: 8px 0 0; font-size: 13px; }
.card, .panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.panel h3, .card h3 { margin: 0 0 10px; font-size: 14px; letter-spacing: -0.02em; }
.tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: 1px;
}
.tag-bf { background: #1c2a40; color: #9ec0ea; }
.tag-mb { background: #143326; color: #8ee0b5; }
.tag-all { background: #2a2433; color: #c8bdd8; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip {
  background: #141b26;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 9px;
  min-width: 36px;
  font-weight: 700;
  font-size: 12px;
}
.chip:hover { color: var(--text); background: #1b2433; }
.chip.on { background: #223044; color: var(--text); border-color: #3b6ea8; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.card-head h3 { margin: 0; font-size: 14px; }
.card-meta { color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 8px; font-size: 12px; }
.card-tourn { font-size: 11px; margin: -2px 0 6px; }
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.mark-pl {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
}
.meta-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }
.meta-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ec0ea;
  background: #1c2a40;
  padding: 2px 6px;
  border-radius: 6px;
}
.muted { color: var(--muted); }
.why { margin: 8px 0 0; font-size: 12px; }
.row { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.open-table.compact td { padding: 6px 6px; }
/* One line per bet. The row height is what got out of hand: each cell stacked the
   tournament, model, matrix and serve stats, so a single market was six lines tall
   and a few fills filled the screen. The line keeps only what is actionable (match,
   score, trade, prices, if-green) and the rest lives in .open-detail behind the
   expander. The columns that stay are nowrap so nothing wraps the line either. */
.open-page .open-table th, .open-page .open-table td {
  padding: 7px 8px;
  vertical-align: middle;
}
.open-page .open-table th { white-space: nowrap; }
.open-page .open-row > td { white-space: nowrap; }
.open-page .open-row .m-name { font-size: 13px; }
.open-page .open-row .m-sub { font-size: 11px; margin-top: 1px; }
.open-page .open-row .open-trade .m-sub { display: flex; align-items: center; gap: 5px; }
.open-page .ladder.compact { min-width: 132px; gap: 5px; }
.open-page .ladder.compact .ladder-name { max-width: 62px; }
.open-page .ladder.compact .ladder-row {
  grid-template-columns: minmax(44px, 4rem) auto;
}
.open-page .open-row .scoreboard { min-width: 132px; padding: 4px 7px; }
.open-page td.oc-pl { font-size: 15px; font-weight: 800; }
/* Waiting-for-a-slot rows reuse the Open line, so the start time and the surface line
   just need to sit compactly beside the score. */
.wait-time > div:first-child { font-variant-numeric: tabular-nums; }
.wait-market { font-size: 12px; }
.open-page .oc-toggle { width: 1%; padding-right: 0; }
.row-toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-toggle:hover { color: var(--text); background: var(--panel); }
.row-toggle svg { width: 13px; height: 13px; display: block; transition: transform 0.12s ease; }
.open-row.expanded .row-toggle { transform: rotate(90deg); color: var(--text); }
.open-row.expanded > td { border-bottom-color: transparent; }
.open-detail-row > td {
  padding: 0 10px 12px 36px;
  background: rgba(255, 255, 255, 0.02);
}
.open-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 2px solid var(--line);
  padding-left: 12px;
}
.od-top { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.od-book .ladder.compact { min-width: 160px; }
.od-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.od-status { display: flex; align-items: center; }
.od-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr));
  gap: 4px 14px;
}
.player-stats-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0e141e;
}
.player-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.player-stats th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.player-stats th.num, .player-stats td.num { text-align: right; font-variant-numeric: tabular-nums; }
.player-stats td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.player-stats tbody tr:last-child td { border-bottom: none; }
.player-stats .ps-name { font-weight: 650; }
.player-stats tr.is-serving .ps-name { color: var(--text); }
.serve-pip {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 193, 92, 0.18);
  vertical-align: 1px;
}
.player-matches { display: flex; flex-flow: row wrap; gap: 10px; align-items: flex-start; }
.player-match {
  display: flex;
  flex-direction: column;
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e141e;
  padding: 10px 12px;
}
.player-match.player-go { cursor: pointer; }
.player-match.player-go:hover { border-color: #3b6ea8; }
.player-match-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 0;
  min-width: 100%;
  margin-bottom: 8px;
  overflow: hidden;
}
.player-match-meta .pg-event { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players-grid { font-variant-numeric: tabular-nums; }
.pg-row {
  display: grid;
  grid-template-columns: var(--cols);
  column-gap: 8px;
  align-items: center;
  min-height: 1.35rem;
}
.pg-head { margin-bottom: 2px; }
.pg-h {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.pg-row .num, .pg-row .set, .pg-row .pts,
.pg-row .pg-h.num, .pg-row .pg-h.set, .pg-row .pg-h.pts { text-align: center; }
.pg-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-row.is-serving .pg-name { color: var(--text); }
.pg-row .serve-slot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  justify-self: center;
}
.pg-row.is-serving .serve-slot {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 193, 92, 0.18);
}
.pg-row .set { font-weight: 700; color: var(--muted); }
.pg-row .set.is-live { color: var(--text); font-weight: 800; }
.pg-row .pts span {
  display: inline-block;
  min-width: 1.6rem;
  padding: 1px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  background: #1c2a40;
  border-radius: 5px;
}
.players-where { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.od-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; min-width: 0; }
.od-k { color: var(--muted); flex: none; }
.od-v { font-variant-numeric: tabular-nums; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.open-table td.open-score, .data-table td.hist-score {
  white-space: nowrap;
  width: 1%;
  vertical-align: middle;
}
.card .open-score, .stack-row .open-score, .hist-card .open-score {
  margin: 8px 0 6px;
}
.scoreboard {
  display: grid;
  gap: 3px;
  min-width: 148px;
  padding: 6px 8px;
  background: #0e141e;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.scoreboard.empty {
  color: var(--muted);
  font-weight: 650;
  padding: 4px 6px;
}
.sb-row {
  display: grid;
  grid-template-columns: 10px minmax(52px, 4.8rem) auto 30px;
  gap: 6px;
  align-items: center;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.sb-head {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sb-serve {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  justify-self: center;
}
.sb-row.is-server .sb-serve {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 193, 92, 0.18);
}
.sb-name {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-row.is-server .sb-name {
  color: var(--text);
  font-weight: 750;
}
.sb-games {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.sb-set {
  min-width: 14px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.sb-head .sb-set, .sb-head .sb-pts {
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
}
.sb-set.is-live {
  color: var(--text);
  font-weight: 800;
}
.sb-pts {
  min-width: 28px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  background: #1c2a40;
  border-radius: 5px;
  padding: 1px 0;
}
.sb-head .sb-pts {
  background: transparent;
  padding: 0;
}
.sb-row.is-server .sb-pts {
  color: var(--amber);
}
.hist-toolbar {
  justify-content: space-between;
  align-items: flex-end;
}
.hist-toolbar .page-title { margin: 0 0 4px; font-size: 18px; }
.hist-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0 14px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(20, 28, 40, 0.65);
}
.hist-filters-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.hist-filters-toggle:hover .hft-title { color: var(--blue); }
.hft-arrow { display: inline-flex; color: var(--muted); }
.hft-arrow svg { width: 14px; height: 14px; display: block; transition: transform 0.12s ease; }
.hist-filters.open .hft-arrow svg { transform: rotate(90deg); }
.hft-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex: none;
}
.hft-summary {
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-filters-body { display: flex; flex-direction: column; gap: 8px; }
.hist-filters-body[hidden] { display: none !important; }
.hist-clear { align-self: flex-start; }
.hist-filters .chip-line {
  margin: 0;
  align-items: start;
}
.hist-filters .chip-line > span {
  min-width: 52px;
  padding-top: 8px;
}
.hist-filters .chip-row { margin: 0; }
.hist-kpis { margin-bottom: 12px; }
.hist-wrap {
  max-height: calc(100vh - 280px);
  overflow: auto;
}
.hist-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  box-shadow: 0 1px 0 var(--line);
  z-index: 1;
}
.hist-table th, .hist-table td {
  padding: 6px 8px;
  vertical-align: middle;
}
.hist-when {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 68px;
}
.hist-time {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  line-height: 1.1;
}
.hist-day { color: var(--muted); font-size: 11px; }
.hist-when .pill { padding: 1px 7px; font-size: 9px; }
.hist-match .m-name, .hist-trade .m-name { font-size: 13px; }
.side-card {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.side-card.back { background: var(--back-bg); color: var(--back-fg); }
.side-card.lay { background: var(--lay-bg); color: var(--lay-fg); }
.hist-px {
  display: grid;
  gap: 3px;
  min-width: 72px;
}
.hist-px div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.hist-px-k {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.hist-px-v { font-weight: 750; font-variant-numeric: tabular-nums; }
.hist-px-compact {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}
.hist-px-main {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.hist-px-arrow, .hist-dot { color: var(--muted); font-weight: 500; }
.hist-px-meta {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.hist-px-flags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 8px;
  max-width: 240px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}
.hist-flag.bad { color: var(--red); }
.hist-score .scoreboard {
  padding: 3px 6px;
  gap: 1px;
  min-width: 124px;
}
.hist-match .m-sub, .hist-trade .m-sub { margin-top: 1px; line-height: 1.25; }
.hist-edge { color: #7cb5ff; font-size: .8em; }
.hist-table td.hist-px-cell, .hist-table td.hist-closed, .hist-table td.hist-score {
  width: 1%;
  white-space: nowrap;
}
.hist-table td.hist-pl, .hist-card .hist-pl {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hist-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
}
.hist-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.hist-card-foot .card-status { margin: 0; }
.rule-used { color: var(--text); font-weight: 650; }
.m-sub { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* The concentration warning on an Insights rule row. Amber, not red: "40 closes in one
   match" is not an error, it is the answer to why a rule's P/L looks the way it does. */
.m-sub.warn-sub { color: var(--amber, #e8a33d); font-size: 11px; }
.data-table th, .open-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.data-table tbody tr:hover, .open-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.open-table th, .open-table td { vertical-align: middle; }
.open-table td.num, .open-table th.num,
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.open-table td.actions, .open-table th.actions { text-align: right; white-space: nowrap; width: 1%; }
button.chart-btn.on {
  color: var(--text);
  border-color: var(--blue);
  background: #152033;
}
body.theme-light button.chart-btn.on { background: #e7f0fb; }
.tape-chart {
  margin: 0 0 12px;
  padding: 12px 14px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card .tape-chart { margin-top: 10px; }
.tape-chart-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.tape-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.tape-px {
  font-size: 18px;
  font-weight: 720;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.tape-range {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.tape-chart svg { display: block; width: 100%; height: 156px; }
.tape-chart .grid { stroke: var(--line); stroke-width: 1; }
.tape-chart .ylab { fill: var(--muted); font-size: 11px; font-family: inherit; }
.tape-chart .area { stroke: none; }
.tape-chart .line {
  stroke: var(--blue);
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tape-chart .dot { fill: var(--amber); stroke: var(--panel); stroke-width: 1; }
.tape-note { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.why-cell { font-size: 12px; max-width: 220px; }
.status-cell { white-space: nowrap; }
.card-status { margin: 8px 0 0; }
.st {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #243044;
  color: var(--muted);
}
.st-in { background: #123526; color: var(--green); }
.st-unmatched { background: #3a2e14; color: var(--amber); }
.st-watch { background: #1b2433; color: var(--muted); }
.st-wait { background: #1b2433; color: var(--text); }
.badge { display: inline-block; background: var(--line); border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700; margin-left: 6px; vertical-align: middle; }
.chip-atp { display: inline-block; background: #0d2a45; color: #4fa3e0; border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 700; margin-right: 3px; }
.chip-wta { display: inline-block; background: #2a0d2a; color: #d96fd9; border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 700; margin-right: 3px; }
.chip-chal { display: inline-block; background: #1a2a0d; color: #8bc34a; border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 700; margin-right: 3px; }
.chip-itf { display: inline-block; background: #2a220d; color: #c9a227; border-radius: 4px; padding: 1px 5px; font-size: 10px; font-weight: 700; margin-right: 3px; }
.st-unlinked { background: #3a2e14; color: var(--amber); }
.st-info { background: #173056; color: var(--back-fg); }
.st-warn { background: #3a2e14; color: var(--amber); }
.st-stop { background: #3a1520; color: #ffb3bb; }
/* st-ok / st-open were emitted by app.js but never defined, so a healthy score feed,
   a real-price tape row and a "Live" flag all fell back to the neutral .st grey —
   losing the colour that distinguishes them from an inert badge. */
.st-ok { background: #12301f; color: #6ee7a8; }
.st-open { background: #3a2e14; color: var(--amber); }
.ladder {
  display: grid;
  gap: 4px;
  min-width: 180px;
}
.ladder-row {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) auto;
  gap: 4px;
  align-items: center;
}
.ladder-head {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) 46px 46px;
  gap: 4px;
  align-items: center;
}
.ladder.compact { min-width: 168px; }
.ladder-head { color: var(--muted); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }
.ladder-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ladder-row.is-server .ladder-name { color: var(--amber); font-weight: 700; }
.px {
  display: block;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 12px;
  padding: 3px 0;
  border-radius: 6px;
}
.px-back { background: var(--back-bg); color: var(--back-fg); }
.px-lay { background: var(--lay-bg); color: var(--lay-fg); }
.px-empty { background: #151b24; color: var(--muted); font-weight: 600; }
.server-lay {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.server-lay .px { min-width: 54px; }
input, select, textarea {
  background: #0b0f16;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  width: 100%;
}
input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0;
  accent-color: var(--blue);
  flex: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b6ea8;
  box-shadow: 0 0 0 3px rgba(91, 163, 255, 0.15);
}
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; font-weight: 600; }
label.flex { margin-top: 12px; }
label.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 0 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid > div > label { margin-top: 0; }
.check-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
}
.check-stack .check { margin: 0; }
.settings { max-width: 720px; }
.settings-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
button.settings-tab {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
}
button.settings-tab:hover { background: var(--panel); color: var(--text); }
button.settings-tab.on { background: var(--panel); color: var(--text); }
.settings-pane { padding: 18px; }
.settings-pane[hidden] { display: none !important; }
input[type="file"] { width: auto; max-width: 220px; }
.rules-list { display: flex; flex-direction: column; gap: 8px; }
.rule-card { padding: 10px 14px; }
.rule-card.collapsed { padding: 8px 14px; }
.rule-card.collapsed .rule-body { display: none; }
.rule-card.collapsed .rule-head { margin-bottom: 0; }
/* One fixed track per control, in the same order for every card, so the badge,
   trades, toggle and buttons all sit on the same x across rows. This used to be a
   wrapping flex row where the name and summary had different flex-basis (180px vs
   160px), so a longer name shrank the summary more and pushed everything after it
   sideways - no two rows lined up. `1fr` on the (truncating) summary absorbs the
   slack, and the head stays a grid when expanded because only .rule-body is hidden. */
.rule-head {
  display: grid;
  /* Only the NAME flexes. The summary sits in a fixed track: a flexible track's base
     size is raised by its max-content contribution, so a long summary pushed the
     name/summary split wider on that card alone and the stat, badge and buttons
     drifted sideways by 10-20px between rows. The summary is clipped with an
     ellipsis instead of being allowed to size its own column. */
  grid-template-columns: 22px 96px minmax(160px, 1fr) 240px 138px 92px min-content;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  cursor: pointer;
}
.rule-head .rule-name { font-weight: 700; min-width: 0; }
/* min-width:0 lets this track shrink, but `width:100%` from the global input rule
   plus `justify-self: stretch` keeps the field itself full-width rather than
   collapsing to a caret at its zero content-width. */
.rule-head > .rule-name { justify-self: stretch; }
.rule-head .check { margin: 0; }
/* Pin each child to its own track. Grid auto-flow places items in order, so the
   moment `.rule-card:not(.collapsed) .rule-summary { display: none }` removes one,
   every later child slides a track left: on an EXPANDED card the readiness badge
   moved out of its `max-content` track into the wide summary track (63px ->
   296px at 1024px wide, so the pill stretched across the header), the stat and the
   switch shifted with it, and the last track collapsed to 0. That is why an open
   rule stopped lining up with the closed rows above and below it. Explicit placement
   makes the track count irrelevant to where a control lands.
   Order is deliberate: toggle, then the On/Off switch, THEN the name. The switch used
   to sit after the name/summary (sixth track), so on a wide row the control that says
   whether a rule is live was nowhere near the name it belongs to. */
.rule-head > .rule-toggle  { grid-column: 1; }
.rule-head > .switch       { grid-column: 2; }
.rule-head > .rule-name    { grid-column: 3; }
.rule-head > .rule-summary { grid-column: 4; }
.rule-head > .rule-stat    { grid-column: 5; }
.rule-head > .st           { grid-column: 6; justify-self: start; }
.rule-head > .rule-actions { grid-column: 7; }
/* An open card shows no summary, so hand that track to the name rather than leaving
   a hole: the field gets the room, and the stat / badge / buttons stay in exactly the
   columns they occupy on every collapsed row. */
.rule-card:not(.collapsed) .rule-head > .rule-name { grid-column: 3 / span 2; }
/* Hint that the row is clickable, without a background on the whole head (which
   sits inside a card of its own). */
.rule-head:hover .rule-name { text-decoration: underline dotted; text-underline-offset: 3px; }
.switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  flex: none;
}
.switch input { display: none; }
.switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.switch .switch-off.on { background: #1b2433; color: var(--text); }
.switch .switch-on.on { background: #123526; color: var(--green); }
.rule-actions { display: flex; gap: 6px; justify-content: flex-end; }
.rule-summary { font-size: 12px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rule-card:not(.collapsed) .rule-summary { display: none; }
/* Trades and P/L as two mini stat cards, matching the KPI cards used elsewhere. The
   pair is one grid child (a wrapper), so the head's child count stays fixed whether
   or not a verdict exists — the columns cannot shift on the cards with no data.
   Tabular figures so "9" and "76" line up down the column. */
.rule-stat {
  display: inline-flex;
  gap: 6px;
  align-items: stretch;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 0;
}
.rule-stat .rs-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  flex: 1 1 0;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.rule-stat .rs-card b { font-size: 13px; line-height: 1.15; }
.rule-stat .rs-card i {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.rule-toggle {
  width: 32px;
  min-width: 32px;
  padding: 4px 0;
  line-height: 1;
  transition: transform 0.12s ease;
}
.rule-card:not(.collapsed) .rule-toggle { transform: rotate(90deg); }
.rule-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.rule-body { display: flex; flex-direction: column; gap: 8px; }
.rule-compact, .rule-odds {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px 8px;
}
.rf {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  /* Align the control across a grid row. Labels are one or two lines depending on
     whether they carry a "(ticks)"-style hint, and .rf is a grid item so it stretches
     to the tallest cell in the row. Without this, the *inputs* sat at different
     heights and every filter row looked ragged: `space-between` puts the label text
     at the top of the cell and the input at the bottom, so on any row the labels
     start together AND the boxes finish together. */
  justify-content: space-between;
}
/* The muted qualifier that used to be an inline <br/><span style="font-size:10px">
   hack in app.js - one line or two depending on the label, which is what made the
   rows ragged. A real class keeps app.js free of presentation and lets it wrap. */
.rf .hint {
  display: block;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.25;
  opacity: 0.8;
}
.rf input, .rf select { width: 100%; }
.chip-line {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  align-items: start;
}
.chip-line > span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding-top: 4px;
}
.rule-when { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.rule-when .chip-row { margin: 0; gap: 4px; }
.rule-card .chip { padding: 3px 7px; min-width: 28px; font-size: 11px; border-radius: 6px; }
.rule-exits {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin: 0;
  padding: 4px 0 0;
}
.rule-exits .check { margin: 0; font-size: 12px; }
.rule-exits .rf { min-width: 88px; }
.rule-exits .rf input { width: 72px; }
.rule-more {
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.rule-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.rule-more[open] summary { margin-bottom: 8px; }
.rule-foot { margin: 8px 0 0; }
.rules-toolbar select { min-width: 220px; }
.rules-intro { margin: 0 0 10px; }
.rule-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 0 2px;
  padding-left: 1px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}
.rule-section-hint { font-weight: 400; text-transform: none; letter-spacing: 0; opacity: 0.7; }
.template-picker-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.template-blurb { font-size: 11px; max-width: 400px; font-style: italic; }
.rule-blurb {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.banner {
  margin: 10px 20px 0;
  padding: 10px 14px;
  background: #2a2416;
  border: 1px solid var(--amber);
  border-radius: 12px;
}
.missing { color: var(--amber); }
.help { max-width: 760px; }
.help h2 { margin-top: 0; }
.flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pl-pos { color: var(--green); }
.pl-neg { color: var(--red); }
.waiting { margin-top: 18px; }
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-back[hidden] { display: none !important; }
.modal { width: min(460px, 100%); }
.lock-card {
  max-height: calc(100vh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}
.lock-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  text-align: center;
}
.lock-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: block;
}
.lock-name {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
  font-weight: 750;
}
.lock-actions { margin-top: 16px; }
.lock-actions #login-submit { flex: 1; }
.lock-hint { margin: 0 0 12px; font-size: 13px; text-align: center; }
/* Password field with a show/hide eye. The input keeps width:100% inside the
   wrapper, so the button is never pushed outside the card. */
.pw-wrap { position: relative; display: block; }
.pw-wrap input {
  padding-right: 42px;
  width: 100%;
}
.pw-eye {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
.pw-eye:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.pw-eye svg { width: 17px; height: 17px; display: block; }
/* Settings → Connections */
.conn-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }
.conn-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.02);
  min-width: 0;
}
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conn-card > summary.conn-head {
  list-style: none;
  cursor: pointer;
  /* Cover the card padding so a click anywhere on the header row opens it. */
  margin: -14px -14px 0;
  padding: 14px;
}
.conn-card:not([open]) > summary.conn-head { margin-bottom: -14px; }
.conn-card > summary.conn-head::-webkit-details-marker { display: none; }
.conn-card > summary.conn-head::marker { content: ""; }
.conn-sum { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conn-chev {
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  flex: 0 0 auto;
  margin-left: 2px;
}
.conn-card[open] > summary .conn-chev { transform: rotate(45deg); }
.conn-body { margin-top: 4px; }
.market-group {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.market-fit { margin: 8px 0 0; font-size: 13px; line-height: 1.45; }
.conn-who { font-size: 12px; margin: 8px 0 0; line-height: 1.45; }
.conn-note { font-size: 12px; margin: 10px 0 0; line-height: 1.45; }
.conn-card .form-grid { gap: 8px; }
.conn-card input:not([type="checkbox"]),
.conn-card .pw-wrap { width: 100%; min-width: 0; box-sizing: border-box; }
.conn-card label.check {
  display: flex;
  width: auto;
  max-width: 100%;
  white-space: normal;
  align-items: center;
  gap: 8px;
  margin-right: 0;
}
.conn-card label.check input {
  width: auto;
  flex: 0 0 auto;
}
.login-error { color: #ffb3bb; margin: 0 0 8px; }
.login-forgot { margin: 6px 0 0; font-size: 12px; line-height: 1.45; }
.login-forgot a { color: #8ec7ff; text-decoration: underline; }
.login-keep {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 0;
  white-space: normal;
  font-weight: 500;
  max-width: 100%;
}
.login-keep input { margin-top: 2px; flex: 0 0 auto; }
.login-keep span {
  min-width: 0;
  flex: 1;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  font-weight: 500;
}
.login-mfa {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
}
body.locked .chrome,
body.locked .nav,
body.locked .banner,
body.locked #view,
body.locked #desk-chrome,
body.locked #desk-nav { display: none !important; }
body.locked .modal-back {
  background: var(--bg);
  align-items: center;
}
body.locked #login-cancel { display: none; }
@media (max-width: 1100px) {
  .rule-compact, .rule-odds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .rule-grid { grid-template-columns: 1fr 1fr; }
  .rule-compact, .rule-odds { grid-template-columns: 1fr 1fr; }
  .chip-line { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .form-grid, .rule-grid { grid-template-columns: 1fr; }
  html, body { font-size: 16px; }
  .chrome {
    position: static;
    gap: 10px;
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .chrome-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  /* The chrome was 279px tall on a 390px-wide phone — a third of the screen before
     any page content. Three causes: the "PAPER · delayed data" pill repeated what the
     PAPER/LIVE toggle already says, the two stat rows stacked instead of sharing a
     row, and seven action buttons wrapped onto two lines. All three fixed here; the
     button row still scrolls sideways so Kill cannot be pushed off-screen entirely. */
  .chrome-mid {
    flex: 1 1 100%;
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chrome-mid::-webkit-scrollbar { display: none; }
  .chrome-mid .stat-row { flex: 0 0 auto; }
  .chrome-left > .pill { display: none; }
  .chrome-right {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chrome-right::-webkit-scrollbar { display: none; }
  .chrome-right > button { flex: none; }
  .clock { font-size: 12px; }
  .brand { font-size: 14px; }
  .stat-row { max-width: 100%; overflow-x: auto; }
  .stat { min-width: 76px; flex: 0 0 auto; }
  .stat b { font-size: 14px; }
  /* Mobile keeps the same markup but goes back to a horizontal scroller: a rail on a
     phone would eat a third of the width, and the collapse arrow has nothing to do
     once the labels are already visible in a row. The rail offsets on
     chrome/banner/main and the collapsed body state are cancelled here, and the
     collapse button is hidden, so the desktop rail cannot leak into the phone. */
  #desk-chrome, #banner, main { margin-left: 0; }
  .nav, body.nav-collapsed .nav {
    position: sticky;
    top: 0;
    left: auto;
    bottom: auto;
    width: auto;
    overflow-x: auto;
    overflow-y: hidden;
    /* `column` (not `row`): the nav holds the brand row plus the icon row, and a
       row direction would lay those two side by side. `.nav-items` is the row. */
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 6px 10px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    border-right: 0;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-collapse { display: none; }
  /* No wordmark on a phone: the nav is a horizontal icon scroller, and a logo here
     would eat scroll width for nothing (the icons keep their title/aria-label). */
  .nav-brand { display: none; }
  .nav-items { flex-direction: row; gap: 2px; }
  .nav-items a, body.nav-collapsed .nav-items a {
    flex: none;
    min-height: 40px;
    justify-content: flex-start;
    padding: 8px 12px;
    gap: 7px;
  }
  /* Icon-only on a phone saves the width the labels would need; the row still
     scrolls, and each icon keeps its title/aria-label. */
  .nav-items a span { display: none; }
  .nav-items a svg { width: 19px; height: 19px; }
  main {
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .banner { margin: 8px 12px 0; }
  .grid { grid-template-columns: 1fr; gap: 10px; }
  .dash-split { grid-template-columns: 1fr; }
  .cal-filters { margin: 0; }
  .cal-title { min-width: 0; flex: 1; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-pill:nth-child(n+3) { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 16px; }
  .toolbar { gap: 6px; }
  .rules-toolbar select { min-width: 0; width: 100%; flex: 1 1 100%; }
  .rules-toolbar button { flex: 1 1 auto; min-height: 40px; }
  .rule-head { margin-bottom: 10px; }
  /* The 7-track desktop grid cannot shrink this far, so stack it explicitly. Every
     child gets its own row rather than auto-placing, which would drop the stat into
     the 22px toggle column. */
  .rule-head {
    grid-template-columns: 22px minmax(0, 1fr);
    row-gap: 8px;
  }
  .rule-head > .rule-toggle { grid-column: 1; grid-row: 1; }
  .rule-head > .switch { grid-column: 2; grid-row: 1; justify-self: end; }
  /* Neutralise the desktop `3 / span 2` widening, which would invent an implicit
     third column in this 2-track layout. */
  .rule-card:not(.collapsed) .rule-head > .rule-name { grid-column: 1 / -1; grid-row: 2; }
  .rule-head > .rule-name { grid-column: 1 / -1; grid-row: 2; }
  .rule-head > .rule-summary { grid-column: 1 / -1; grid-row: 3; }
  .rule-head > .rule-stat { grid-column: 1 / -1; grid-row: 4; }
  .rule-head > .st { grid-column: 1 / -1; grid-row: 5; justify-self: start; }
  .rule-head > .rule-actions { grid-column: 1 / -1; grid-row: 6; justify-content: flex-start; }
  .rule-compact, .rule-odds { grid-template-columns: 1fr 1fr; }
  .settings-pane { padding: 12px; }
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  button.settings-tab { flex: none; min-height: 40px; }
  .modal-back { padding: 12px; align-items: flex-end; }
  .modal { width: 100%; max-height: calc(100vh - 24px); overflow: auto; }
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  button, .btn { min-height: 40px; }
  .chip { min-height: 36px; padding: 8px 10px; }
  .rule-card .chip { min-height: 36px; padding: 7px 9px; }
  label.check { min-height: 36px; }
  .help { max-width: none; }
}
@media (max-width: 420px) {
  .chrome-right button.ghost:not(#btn-help) { padding: 7px 8px; }
  .brand span, .brand { letter-spacing: -0.03em; }
}
.rule-group { display: flex; flex-direction: column; gap: 8px; }
.rule-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 2px;
}
.rule-group-head h3 { margin: 0; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.rule-group-head .muted { margin-right: auto; }
.ladder-top, .ladder-rungs { display: grid; grid-template-columns: 46px 46px; gap: 4px; }
.ladder-depth { display: grid; gap: 2px; margin-top: 2px; }
.ladder-depth .px { font-size: 10px; font-weight: 700; padding: 1px 0; }
.ladder-depth small { display: block; font-size: 9px; font-weight: 600; opacity: 0.8; }
.insights .eq-svg { width: 100%; height: 140px; display: block; }
.insights .eq-svg polyline { fill: none; stroke: var(--blue); stroke-width: 2; }
.insights .eq-svg .eq-zero { stroke: var(--line); stroke-width: 1; }
/* Bar chart (how a book closed / why doors were declined). A label track and a
   count track are fixed so every bar starts and ends at the same x, and the bar
   track takes the slack — otherwise a long reason name would shorten its own bar
   and the chart would misrepresent the very thing it is showing. */
.bar-chart { display: flex; flex-direction: column; gap: 3px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 108px) minmax(40px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.bar-lab { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; height: 12px; background: rgba(255,255,255,0.05); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--muted); }
.bar-fill.st-stop { background: var(--red); }
.bar-fill.st-warn { background: var(--amber); }
.bar-fill.st-in { background: var(--green); }
.bar-fill.st-open { background: var(--blue); }
.bar-fill.st-info { background: var(--blue); }
.bar-fill.st-wait { background: #5c7392; }
.bar-fill.st-unmatched { background: #8a6cc4; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar-note { margin: 6px 0 0; font-size: 11px; }
.bar-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.insight-row { cursor: pointer; }
.insight-detail > td { padding-top: 6px !important; padding-bottom: 10px !important; }
.insight-detail-box { padding: 2px 0 2px; }
.insight-detail-top {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}
.card-mini {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.insight-eq .eq-svg { height: 44px; width: 100%; display: block; margin-top: 4px; }
.insight-eq-label { font-size: 11px; margin: 0 0 2px; }
.insight-detail .eq-svg { height: 44px; width: 100%; display: block; }
.insight-exits-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.insight-exit { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.insight-exit b { font-variant-numeric: tabular-nums; }
.insight-hold { font-size: 12px; width: 100%; margin-top: 2px; }
.insight-lag { margin-bottom: 12px; }
.lag-list { display: flex; flex-direction: column; gap: 6px; }
.lag-row {
  display: grid;
  grid-template-columns: 88px minmax(80px, 1fr) 4ch 8ch;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.lag-name { color: var(--text); font-weight: 650; }
.lag-track {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.lag-fill { display: block; height: 100%; border-radius: 4px; }
.lag-fill.pos { background: var(--green); }
.lag-fill.neg { background: var(--red); }
.lag-n, .lag-pl { font-variant-numeric: tabular-nums; text-align: right; }
.lag-n { color: var(--muted); }
.insight-slices-panel { margin-bottom: 12px; }
.insight-slices-note { margin: 0 0 8px; font-size: 12px; }
.insight-slices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  align-items: stretch;
}
.insight-slices .insight-break {
  min-height: 168px;
  display: flex;
  flex-direction: column;
}
.insight-slices .insight-break-h { margin: 0 0 4px; }
.insight-slices .insight-break-body { gap: 2px; }
.insight-more {
  display: inline-block;
  margin-top: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: 11px;
  cursor: pointer;
}
.insight-more:hover { text-decoration: underline; }
.insight-breaks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.insight-break { min-height: 100%; }
.insight-break-h {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9eb6d4;
  margin: 0 0 6px;
}
.insight-break-body { display: flex; flex-direction: column; gap: 3px; }
.insight-break-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: baseline;
  font-size: 11px;
  line-height: 1.35;
}
.insight-break-k {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.insight-break-n { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .insight-detail-top { grid-template-columns: 1fr; }
  .insight-breaks,
  .insight-slices { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .insight-breaks,
  .insight-slices { grid-template-columns: 1fr; }
  .lag-row { grid-template-columns: 72px minmax(48px, 1fr) 3.5ch 7ch; gap: 6px; }
}

/* Primary action button */
button.btn-primary { background: #1e4d82; border-color: #3b6ea8; color: #e8f0ff; }
button.btn-primary:hover { background: #265d9e; }
button.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* Replay panel */
.replay-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 4px; }
.replay-label { color: var(--muted); font-size: 12px; }
.replay-bias-input { width: 46px; text-align: center; padding: 3px 6px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; color: var(--text); font-size: 13px; }
.replay-summary { margin-top: 8px; font-size: 13px; }
.replay-running { margin-top: 10px; }
@media (max-width: 720px) {
  .replay-controls { gap: 8px; }
}

/* ── Backtest page ─────────────────────────────────────────────────── */
/* Layout notes, because this page was rebuilt for height:
   - The page used to be one column: 399 match cards, then the strategy chips, then
     the run button, then a result several thousand pixels tall, then 50 saved runs.
     Setting up a run meant scrolling past the result of the last one.
   - Now: a fixed header, a tab bar (Set up / Results / Saved runs) and ONE pane.
   - Set up itself is two columns on a desktop (matches | strategies) with the run
     bar pinned across the top, so the button is always on screen.
   - Match cards render 60 at a time behind a search box; result tables show 25 rows
     before a "Show all". Both are capped in JS as well, so the DOM stays small. */
.bt-panel { padding: 18px 22px 22px; }

/* Header — title line, then the tabs. Deliberately shallow: every pixel here is
   taken from the list below it. */
.bt-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bt-header-text { min-width: 0; }
.bt-title { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.bt-sub { margin: 1px 0 0; font-size: 12px; }
.bt-tape-note { font-size: 11px; }
.bt-rec-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 2px; }
.bt-rec-label { font-size: 13px; font-weight: 650; }
.bt-venue { white-space: nowrap; font-size: 12px; }
.bt-rec-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel-2); user-select: none; transition: border-color .15s; }
.bt-rec-toggle:hover { border-color: var(--blue); }
.bt-rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #4b5563; flex-shrink: 0; }
.bt-rec-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); animation: rec-pulse 2s ease-in-out infinite; }
@keyframes rec-pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(34,197,94,.2); } 50% { box-shadow: 0 0 0 5px rgba(34,197,94,.05); } }

/* Tabs */
.bt-tabs { display: flex; gap: 4px; margin: 12px 0 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bt-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 8px 12px; border-radius: 8px 8px 0 0; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.bt-tab:hover { color: var(--text); background: var(--panel-2); }
.bt-tab.on { color: var(--text); border-bottom-color: var(--blue); }
.bt-tab-n {
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  padding: 1px 6px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.bt-tab.on .bt-tab-n { border-color: var(--blue); color: var(--blue); }
.bt-tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); animation: rec-pulse 1s ease-in-out infinite; }
.bt-pane { min-width: 0; }

/* Run bar — first thing in the Set up pane, so it is never below the fold.
   Deliberately NOT sticky: the app chrome is already sticky, and a second sticky
   layer would either hide under it or need its height hard-coded from JS. The
   match list scrolls inside its own box, so the page itself barely moves. */
.bt-runbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px;
}
.bt-runbar-what { min-width: 0; }
.bt-runbar-line { display: block; font-size: 13px; }
.bt-runbar-note { display: block; font-size: 11px; margin-top: 2px; }
.bt-run-btn { padding: 9px 22px; font-size: 14px; font-weight: 600; border-radius: 8px; white-space: nowrap; flex: none; }

/* One column. A side-by-side split gave the match table and the strategy list half a
   screen each, so names wrapped, descriptions were cut mid-word, and two scrollbars
   sat next to each other. Strategies come first, one line each; the table uses the
   full width underneath. */
.bt-setup { display: flex; flex-direction: column; gap: 0; }
.bt-col { min-width: 0; }
.bt-col + .bt-col { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.bt-col-h { display: flex; align-items: baseline; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.bt-col-sub { font-weight: 400; font-size: 12px; min-width: 0; color: var(--muted); }
.bt-step-toolbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.bt-step-toolbar button { font-size: 12px; padding: 4px 10px; }
.bt-filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.bt-search {
  flex: 1 1 180px; min-width: 0;
  font-size: 13px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.bt-search::placeholder { color: var(--muted); }
.bt-search:focus { outline: none; border-color: var(--blue); }
.bt-hint { font-size: 11px; margin: 0 0 8px; }
.bt-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--blue); font-size: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}
.bt-link:hover { color: var(--text); }
.bt-limit-picker { display: flex; align-items: center; gap: 5px; margin-left: 4px; }
.bt-limit-picker select {
  font-size: 12px; padding: 3px 6px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel-2); color: inherit;
}

/* Match table — a bounded scroller with a sticky head, so the column never grows
   the page. Cards were four per row with no shared columns: nothing lined up and
   399 matches read as a wall rather than a list. */
.bt-match-scroll { max-height: 46vh; overflow: auto; overscroll-behavior: contain; }
.bt-match-table { width: 100%; table-layout: auto; }
.bt-match-table thead th { position: sticky; top: 0; background: var(--panel); z-index: 2; padding-top: 6px; padding-bottom: 6px; }
.bt-match-table td { padding: 5px 6px; }
.bt-match-table tbody tr { cursor: pointer; }
.bt-match-table tbody tr.on { background: rgba(59,130,246,.06); }
.bt-match-table tbody tr.on:hover { background: rgba(59,130,246,.10); }
.bt-mcheck { width: 1%; white-space: nowrap; padding-right: 2px !important; }
.bt-mcheck input { width: 14px; height: 14px; accent-color: var(--blue); cursor: pointer; vertical-align: middle; }
.bt-mname { font-size: 12px; min-width: 180px; }
.bt-msurf { font-size: 12px; color: var(--muted); white-space: nowrap; text-transform: capitalize; }
.bt-sort {
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
  font-weight: inherit; display: inline-flex; align-items: center; gap: 3px;
}
.bt-sort:hover { color: var(--text); }
.bt-sort-mk { opacity: .35; font-size: 10px; }
.bt-sort-mk.on { opacity: 1; color: var(--blue); }
/* NOT a flex container: each text run between the <strong>s became its own flex
   item, so "Showing 60 of 399" stacked one word per line. */
.bt-list-foot {
  font-size: 11px; color: var(--muted);
  padding: 8px 2px 0; margin-top: 4px;
}
.bt-list-foot strong { color: var(--text); }
.bt-no-hits { padding: 14px 2px; font-size: 12px; }
.bt-surface-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.bt-tour-badge { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; text-transform: uppercase; }
.bt-tour-badge.bt-tour-atp { background: rgba(59,130,246,.2); color: #60a5fa; }
.bt-tour-badge.bt-tour-wta { background: rgba(236,72,153,.2); color: #f472b6; }
.bt-tour-badge.bt-tour-challenger { background: rgba(245,158,11,.2); color: #fbbf24; }
.bt-cov-high { color: #22c55e; font-size: 11px; font-weight: 600; }
.bt-cov-mid  { color: #f59e0b; font-size: 11px; font-weight: 600; }
.bt-cov-low  { color: #6b7280; font-size: 11px; font-weight: 600; }

/* Empty state */
.bt-empty { text-align: center; padding: 28px 16px; }
.bt-empty-icon { font-size: 32px; margin-bottom: 8px; }
.bt-empty-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.bt-empty-sub { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 12px; }
.bt-empty-hint { margin-top: 8px; }
.bt-empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Strategy cards. A full-width row turned 38 descriptions into a wall. A small card
   is something you tick: the name, two lines of what it does, and whether it is on. */
.bt-rules-scroll { max-height: 340px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.bt-filter-row .bt-step-toolbar { margin: 0; flex: none; }
.bt-rg { margin-bottom: 12px; }
.bt-rg:last-child { margin-bottom: 0; }
.bt-rg-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700;
  color: var(--text); padding: 2px 2px 8px;
}
.bt-rg-n { font-size: 11px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.bt-rg-acts { margin-left: auto; display: flex; gap: 6px; }
.bt-rg-acts .bt-link { font-size: 11px; }
.bt-rg-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.bt-rule {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  margin: 0; padding: 10px 10px 9px; min-height: 0;
  border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2);
  transition: border-color .12s, background .12s;
}
.bt-rule:hover { border-color: rgba(59,130,246,.55); }
.bt-rule.on { border-color: var(--blue); background: rgba(59,130,246,.14); }
.bt-rule-top { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.bt-rule input { width: 15px; height: 15px; margin-top: 1px; accent-color: var(--blue); cursor: pointer; flex: none; }
.bt-rule-name { font-size: 13px; font-weight: 650; line-height: 1.3; display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.bt-rule-name-txt {
  min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal;
}
.bt-rule-blurb {
  font-size: 12px; color: var(--muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; white-space: normal;
}
.bt-rule.bt-rule-off .bt-rule-name { color: var(--muted); }
.bt-rule-state {
  flex: none; font-size: 9px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px;
}
/* Group all/none: real buttons, not underlined 12px text. Sized for a finger as well
   as a cursor: tablets get this layout too, and a 21px-tall "All" is a coin flip. */
.bt-rg-btn {
  font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none;
  min-height: 0; padding: 2px 8px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.bt-rg-btn:hover { border-color: var(--blue); color: var(--text); }
.bt-rg-btn[aria-pressed="true"] { border-color: var(--blue); color: var(--text); background: rgba(59,130,246,.15); }
.bt-rg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Strategy shortcut in the run bar. Only shown on a phone, where the Strategies
   column is dropped — otherwise it would just repeat the count that already sits two
   lines up. */
.bt-runbar-strat { display: none; }

/* The strategy sheet. Full-screen on a phone, a centred panel on anything wider.
   A dialog is the only way to get a 25-row list into a thumb's reach without a
   second scrollbar fighting the page. */
.bt-sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--panel);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
body.bt-sheet-open { overflow: hidden; }
.bt-sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); flex: none;
}
.bt-sheet-title { font-weight: 700; font-size: 16px; }
.bt-sheet-n { margin-left: auto; font-size: 12px; color: var(--muted); }
.bt-sheet-x {
  width: 40px; height: 40px; flex: none; font-size: 16px; line-height: 1;
  border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.bt-sheet-x:hover { border-color: var(--blue); }
.bt-sheet-bar { padding: 10px 14px 6px; flex: none; display: flex; flex-direction: column; gap: 8px; }
/* `.bt-search` is `flex: 1 1 180px` for the row it normally lives in. In a column
   flex container that basis becomes 180px of height, which is how the sheet search
   came out 180px tall. */
.bt-sheet-bar .bt-search { flex: 0 0 auto; width: 100%; min-height: 44px; }
.bt-sheet-bar .bt-step-toolbar { margin: 0; }
.bt-sheet-bar .bt-step-toolbar button { min-height: 34px; }
.bt-sheet-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 0 14px 12px;
}
.bt-sheet-list .bt-rg-h { padding: 8px 2px 6px; }
.bt-sheet-foot {
  flex: none; padding: 10px 14px; border-top: 1px solid var(--line);
  background: var(--panel);
}
.bt-sheet-done { width: 100%; min-height: 46px; font-size: 15px; font-weight: 600; }

/* Running indicator */
.bt-running { display: flex; align-items: flex-start; gap: 10px; padding: 16px; background: rgba(59,130,246,.07); border-radius: 8px; color: var(--muted); font-size: 13px; }
.bt-running-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); animation: rec-pulse 1s ease-in-out infinite; flex-shrink: 0; margin-top: 4px; }
.bt-progress-copy { flex: 1; min-width: 0; }
.bt-progress-bar { height: 8px; background: rgba(59,130,246,.15); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bt-progress-fill { height: 100%; width: 0; background: var(--blue); border-radius: 999px; transition: width .25s ease; }
.bt-progress-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.bt-progress-foot .bt-cancel-btn { margin-left: auto; font-size: 11px; padding: 3px 12px; flex: none; }
.bt-cancel-btn:not(:disabled):hover { border-color: #c0392b; color: #e05c4b; }

/* Results */
.bt-results-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-weight: 600; font-size: 15px; flex-wrap: wrap; }
.bt-results-actions { display: flex; align-items: center; gap: 6px; }
.bt-csv-btn { font-size: 11px; padding: 3px 10px; text-decoration: none; display: inline-block; }
.bt-clear-btn { font-size: 11px; padding: 3px 10px; }

/* The verdict — the answer to "did it make money?", stated before the evidence.
   Coloured by tone so a loss reads as a loss before you parse the number. */
.bt-verdict { border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--panel-2); border-left-width: 4px; }
.bt-verdict-head { font-size: 16px; font-weight: 700; line-height: 1.3; }
.bt-verdict-body { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 3px; }
.bt-verdict-good { border-left-color: #2ecc71; background: rgba(46,204,113,.07); }
.bt-verdict-good .bt-verdict-head { color: #2ecc71; }
.bt-verdict-bad { border-left-color: #e05c4b; background: rgba(224,92,75,.07); }
.bt-verdict-bad .bt-verdict-head { color: #e05c4b; }
.bt-verdict-thin { border-left-color: #e5a94a; background: rgba(229,169,74,.07); }
.bt-verdict-thin .bt-verdict-head { color: #e5a94a; }
.bt-verdict-neutral { border-left-color: var(--muted); }
.bt-verdict-partial { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 11px; color: #e5a94a; line-height: 1.45; }

/* Research caveat. Used to be the tail of a grey paragraph; it changes how every
   number below it should be read, so it gets its own line. */
.bt-research-banner { font-size: 12px; line-height: 1.45; color: var(--muted); background: rgba(229,169,74,.06); border: 1px solid rgba(229,169,74,.28); border-radius: 6px; padding: 8px 11px; margin-bottom: 10px; }
.bt-research-banner strong { color: #e5a94a; }

.bt-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.bt-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; text-align: center; min-width: 68px; flex: 1; }
/* The headline tile: wider and taller so the eye lands on P/L first and the
   other five tiles read as supporting detail rather than peers. */
.bt-stat-lead { flex: 1.6; min-width: 120px; border-color: rgba(59,130,246,.35); background: rgba(59,130,246,.08); }
.bt-stat-lead .bt-stat-val { font-size: 24px; }
.bt-stat-val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bt-stat-lbl { font-size: 10px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.bt-stat-sub { font-size: 10px; color: var(--muted); margin-top: 1px; opacity: .85; }
/* Voided/Doors/Matches are context, not headlines — one quiet line under the tiles. */
.bt-secondary { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11px; margin-bottom: 10px; padding: 0 2px; }
.bt-secondary b { color: var(--text); font-variant-numeric: tabular-nums; }

/* Term + tooltip. A small "?" so a tap on a phone has a target, and the native
   title on the wrapper so hover still works on a desktop. */
.bt-term { position: relative; cursor: help; border-bottom: 1px dotted rgba(255,255,255,.25); }
.bt-term-i { display: inline-block; margin-left: 3px; font-size: 8px; width: 11px; height: 11px; line-height: 11px; text-align: center; border-radius: 50%; background: var(--line); color: var(--muted); vertical-align: middle; font-weight: 700; }
.bt-term:focus-visible { outline: 1px solid var(--blue); outline-offset: 2px; }
.bt-term:hover .bt-term-i, .bt-term:focus .bt-term-i { background: var(--blue); color: #fff; }

.bt-split-charts { margin: 8px 0 4px; }
.bt-chart { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; overflow-x: auto; }

/* Result tables — capped height, sticky header, so detail never runs off the page */
.bt-table-block { margin-top: 12px; }
.bt-table-h { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.bt-table-h .muted { font-weight: 400; letter-spacing: 0; text-transform: none; }
.bt-table-scroll { max-height: 44vh; overflow: auto; overscroll-behavior: contain; }
.bt-table-scroll thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.bt-more { margin-top: 6px; font-size: 12px; }

/* Saved runs — one full tab, scrollable, so 50 runs are not 1,800px of page */
.bt-saved { min-width: 0; }
.bt-saved-h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.bt-saved-scroll { max-height: 62vh; overflow: auto; overscroll-behavior: contain; }
.bt-saved-table tbody tr { cursor: pointer; }
.bt-saved-table tbody tr:hover { background: rgba(255, 255, 255, .04); }
.bt-saved-table tbody tr.open { background: rgba(59, 130, 246, .12); }
.bt-src-chip { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 5px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.bt-saved-del {
  font-size: 11px; padding: 2px 8px; border-radius: 4px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.bt-saved-del:hover { border-color: #c0392b; color: #e05c4b; }

/* Compare — tick two saved runs in the first column, then Compare N. */
.bt-saved-h-acts { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.bt-cmp-tip { font-weight: 400; font-size: 11px; }
.bt-cmp-go { font-size: 11px; font-weight: 600; padding: 3px 12px; border-radius: 4px; cursor: pointer; background: var(--blue); border: 1px solid var(--blue); color: #fff; }
.bt-cmp-go:hover { filter: brightness(1.1); }
.bt-cmp-cell { width: 30px; padding-left: 4px !important; padding-right: 0 !important; }
.bt-cmp-box { width: 15px; height: 15px; accent-color: var(--blue); cursor: pointer; }
.bt-saved-table tbody tr.cmp { background: rgba(59, 130, 246, .07); }
.bt-cmp-table { width: 100%; }
.bt-cmp-table td, .bt-cmp-table th { vertical-align: middle; }
.bt-cmp-hero td { font-size: 17px; font-weight: 700; padding-top: 8px; padding-bottom: 8px; }
.bt-cmp-hero td:first-child { font-size: 12px; font-weight: 600; color: var(--muted); }
.bt-cmp-split td { padding: 0; height: 10px; border-bottom: 1px solid var(--line); }
.bt-cmp-meta td { font-size: 12px; color: var(--muted); }
.bt-cmp-meta td:first-child { font-weight: 600; white-space: nowrap; }

/* Readiness badge on a strategy row in the picker. Sits at the end of the row so
   the tick-box and the name keep a straight left edge on every row. */
.bt-rule-badge { flex: none; margin-left: auto; align-self: center; }
.bt-rule-badge .st { font-size: 9px; padding: 1px 5px; white-space: nowrap; }


/* ── Phone: 720px and below ──────────────────────────────────────────────────
   Thumbs, not cursors. The inline strategy list is swapped for a summary plus a
   full-screen sheet, every control gets a 44px target, and the page is kept short
   enough that the run button is reachable without a long drag. */
@media (max-width: 720px) {
  .bt-panel { padding: 14px 12px 20px; }

  /* The build stamp is diagnostics, not something you need on a phone every day —
     but it must still be reachable, so it stays in the header, just quieter. */
  .build-stamp { font-size: 9px; padding: 1px 4px; }

  /* The header cost 105px: a 26px title, a two-line marketing sentence, and a
     recording chip on its own row. Title and chip share a row, the sentence is
     dropped (it is orientation prose you read once), and the setup columns lose
     their redundant "1 Matches" heading because the pane is already one column. */
  .bt-header { gap: 6px; margin-bottom: 8px; align-items: center; }
  .bt-title { font-size: 19px; }
  .bt-sub { display: none; }
  .bt-tape-note { display: none; }
  .bt-rec-toggle { margin-left: auto; }
  .bt-col-h { padding-bottom: 4px; }
  .bt-col-sub { font-size: 11px; }

  /* The run bar becomes a fixed bottom action bar. `sticky; bottom: 0` looked right
     and did nothing: sticky only stops an element leaving the viewport, it never
     pulls one in early, so the bar stayed at the end of a 1,500px page. Fixed is the
     only thing that keeps Run under the thumb while you tick matches. */
  .bt-pane { display: flex; flex-direction: column; padding-bottom: 104px; }
  .bt-setup { order: 1; }
  .bt-runbar {
    order: 2;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    margin: 0; border-radius: 12px 12px 0 0; border-width: 1px 0 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    display: flex; flex-wrap: wrap; gap: 8px;
    background: var(--panel);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .5);
  }
  /* One row of actions. The "why is Run disabled" note only appears when Run
     actually is disabled, so the steady state is a 66px bar, not a 153px one. */
  .bt-runbar .bt-runbar-line { display: none; }
  .bt-runbar-what { order: 1; flex: 0 0 auto; min-width: 0; }
  .bt-runbar-note { display: none; }
  .bt-runbar.needs-attention { flex-wrap: wrap; }
  .bt-runbar.needs-attention .bt-runbar-what { order: 0; flex: 1 1 100%; }
  .bt-runbar.needs-attention .bt-runbar-note { display: block; font-size: 11px; line-height: 1.3; }
  .bt-run-btn { order: 3; flex: 0 0 auto; width: auto; min-height: 46px; padding: 0 16px; font-size: 15px; }

  /* Strategies stay on the page as cards. Two across when there is room, one when
     there is not, each tall enough for a thumb. */
  .bt-rules-scroll { max-height: 46vh; }
  .bt-rg-cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

  /* Touch targets. A checkbox a thumb cannot hit is the same as no checkbox. */
  .bt-rule { min-height: 52px; padding: 10px; gap: 8px; align-items: stretch; }
  .bt-rule input { width: 22px; height: 22px; margin-top: 0; }
  .bt-rule-name { font-size: 14px; }
  .bt-rule-blurb { font-size: 12px; }
  .bt-rule-state { font-size: 10px; padding: 1px 5px; }
  .bt-rg-h { flex-wrap: wrap; row-gap: 4px; padding: 10px 2px 6px; }
  .bt-rg-name { font-size: 11px; }
  .bt-rg-acts { margin-left: auto; gap: 6px; }
  .bt-rg-btn { font-size: 11px; padding: 6px 12px; min-height: 32px; }

  .bt-search { min-height: 44px; font-size: 16px; }  /* 16px stops iOS zoom-on-focus */
  .bt-step-toolbar { gap: 8px; }
  .bt-step-toolbar button { min-height: 40px; font-size: 13px; }
  .bt-limit-picker select { min-height: 40px; font-size: 14px; }

  /* Match table: keep the columns that identify a row, drop the rest. The name,
     date and coverage are what you select on. */
  .bt-match-scroll { max-height: 44vh; }
  .bt-match-table .bt-msurf,
  .bt-match-table th:nth-child(3),
  .bt-match-table td:nth-child(3),
  .bt-match-table th:nth-child(4),
  .bt-match-table td:nth-child(4),
  .bt-match-table th:last-child,
  .bt-match-table td:last-child { display: none; }
  .bt-match-table td { padding: 9px 6px; }
  .bt-mname { font-size: 13px; min-width: 0; }
  .bt-mcheck input { width: 20px; height: 20px; }
  /* A row is a tap target too, so give it room to be one. */
  .bt-match-table tbody tr { min-height: 48px; }

  .bt-runbar { padding: 12px; gap: 10px; }
  /* Strategies, reachable without scrolling to the bottom of the match list. */
  .bt-runbar-strat {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 auto; min-width: 0;
    min-height: 46px; padding: 0 12px;
    border-radius: 8px; cursor: pointer; font-size: 13px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  }
  .bt-runbar-strat-n { margin-left: auto; font-size: 13px; color: var(--muted); }
  .bt-runbar-strat-n strong { color: var(--text); }
  .bt-runbar-strat-edit { font-size: 12px; color: var(--blue); font-weight: 600; }
  /* The toolbar used to wrap into 123px because four controls plus a count do not fit
     in 340px. Make it two deliberate rows: select/clear/count, then the run size and
     refresh. The "Run on" caption is redundant next to a select that says "100
     matches". */
  /* Row 1: All / None / run size / Refresh (308px of the 340px available). Row 2:
     the count, which is the only item that needs the full width. The old wrap put
     five items on three rows and cost 96px before the table started. */
  .bt-step-toolbar { flex-wrap: wrap; row-gap: 4px; gap: 6px; margin-bottom: 6px; }
  .bt-step-toolbar button { min-height: 34px; padding: 4px 10px; }
  .bt-limit-picker { order: 1; margin-left: auto; }
  .bt-limit-picker > .muted { display: none; }
  .bt-limit-picker select { min-height: 34px; font-size: 13px; }
  .bt-step-toolbar > button[onclick*="Refresh"] { order: 2; margin-left: 0; min-height: 34px; }
  .bt-step-toolbar #bt-match-sel {
    order: 3; flex: 1 1 100%;
    font-size: 11px; white-space: nowrap;
  }
  .bt-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .bt-tab { flex: none; min-height: 44px; font-size: 14px; }
  .bt-summary { gap: 6px; }
  .bt-stat { padding: 8px 10px; min-width: 56px; }
  .bt-stat-val { font-size: 16px; }
  .bt-stat-lead { flex: 1 1 100%; min-width: 0; }
  .bt-stat-lead .bt-stat-val { font-size: 22px; }
  .bt-table-scroll { max-height: 50vh; }
  .bt-saved-scroll { max-height: 60vh; }
  .bt-saved-del { min-height: 36px; padding: 6px 12px; font-size: 12px; }
  /* Saved runs on a phone: the date, matches and P/L identify a run. The source
     chip and the strategy list wrap to two lines and pushed P/L off the edge, so
     they go — the strategies are on the Comparison view and in the reopened run. */
  .bt-saved-table th:nth-child(3),
  .bt-saved-table td:nth-child(3),
  .bt-saved-table th:nth-child(5),
  .bt-saved-table td:nth-child(5) { display: none; }
  .bt-saved-table td, .bt-saved-table th { padding: 8px 4px; }

  /* Results on a phone: the verdict is the first thing after the header, and the
     two header buttons keep a 34px target. */
  .bt-verdict { padding: 11px 12px; }
  .bt-verdict-head { font-size: 15px; }
  .bt-results-actions { gap: 6px; }
  .bt-csv-btn, .bt-clear-btn { min-height: 32px; padding: 5px 10px; font-size: 12px; }
  .bt-progress-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .bt-progress-foot .bt-cancel-btn { margin-left: 0; min-height: 38px; font-size: 13px; }

  /* Compare: the four columns do not fit 340px, so the metric label takes its own
     row and the two runs share the width beneath it. */
  .bt-cmp-table thead { display: none; }
  .bt-cmp-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .bt-cmp-table tbody tr td { border: none !important; padding: 2px 0; display: block; }
  .bt-cmp-table tbody tr td:first-child { grid-column: 1 / -1; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .bt-cmp-table tbody tr td:nth-child(2)::before { content: "Left "; font-size: 10px; color: var(--muted); }
  .bt-cmp-table tbody tr td:nth-child(3)::before { content: "Right "; font-size: 10px; color: var(--muted); }
  .bt-cmp-table tbody tr td:nth-child(4) { grid-column: 1 / -1; }
  .bt-cmp-table tbody tr td:nth-child(4)::before { content: "Change "; font-size: 10px; color: var(--muted); }
  .bt-cmp-table .bt-cmp-split { display: none; }
  /* The metadata rows are one named value each, not a left/right pair, so they
     must not pick up the two-column grid or the Left/Right prefixes. */
  .bt-cmp-table tbody tr.bt-cmp-meta { display: block; padding: 6px 0; }
  .bt-cmp-table tbody tr.bt-cmp-meta td { font-size: 12px; color: var(--muted); }
  .bt-cmp-table tbody tr.bt-cmp-meta td:first-child { text-transform: none; letter-spacing: 0; font-weight: 600; }
  .bt-cmp-table tbody tr.bt-cmp-meta td::before { content: none !important; }
  .bt-cmp-hero td:nth-child(2), .bt-cmp-hero td:nth-child(3) { font-size: 18px; }
  .bt-cmp-box { width: 20px; height: 20px; }
  .bt-cmp-cell { width: 34px; }
}

/* On a tablet/laptop the sheet is a centred panel rather than a full-screen takeover;
   the list is long but the screen is wide enough for a two-column sheet to breathe. */
@media (min-width: 721px) {
  .bt-sheet {
    inset: auto; position: fixed;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(560px, 92vw); max-height: 86vh;
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0,0,0,.55);
  }
  body.bt-sheet-open::before {
    content: ""; position: fixed; inset: 0; z-index: 59;
    background: rgba(0,0,0,.55);
  }
}

.h2h-page { display: flex; flex-direction: column; gap: 16px; padding: 4px 2px 28px; max-width: 980px; }
.h2h-page h2 { margin: 0; }
.h2h-note { margin: 0; max-width: 62ch; }
.h2h-pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; }
.h2h-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.h2h-field input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit;
}
.h2h-vs { padding-top: 28px; font-weight: 700; color: var(--muted); }
.h2h-picks { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.h2h-picks button, .h2h-score button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; font: inherit;
}
.h2h-board {
  display: flex; align-items: center; justify-content: center; gap: 28px;
  padding: 18px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.h2h-who { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 120px; text-align: center; }
.h2h-who .n { font-size: 40px; font-weight: 720; font-variant-numeric: tabular-nums; line-height: 1; }
.h2h-who span { font-weight: 650; }
.h2h-mid { color: var(--muted); font-size: 13px; text-align: center; }
.h2h-surfaces { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0; }
.h2h-surfaces span {
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; color: var(--muted); font-size: 12px;
}
.h2h-table { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.h2h-table table { width: 100%; border-collapse: collapse; }
.h2h-table th, .h2h-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.h2h-empty { margin: 0; }
@media (max-width: 720px) {
  .h2h-pick { grid-template-columns: 1fr; }
  .h2h-vs { display: none; }
  .h2h-board { gap: 16px; }
  .h2h-who { min-width: 0; }
  .h2h-who .n { font-size: 32px; }
}
