/* Comp Odds: a betting-slip feel. Ink and cool greys, teal for controls,
   gold kept for one thing only: the value stub. */
:root {
  color-scheme: light dark;
  --bg: #eef1f4; --surface: #ffffff; --surface-2: #e4e9ef; --line: #d2d9e1;
  --ink: #1b2430; --muted: #5a6575; --teal: #0e7c7b; --teal-ink: #ffffff; --teal-soft: #dff1f0;
  --gold: #e9ad00; --gold-soft: #fff3c7; --gold-ink: #4d3a00; --red: #c4334a; --bar: #9fb0c3;
  @media (prefers-color-scheme: dark) {
    --bg: #11151b; --surface: #181e26; --surface-2: #212934; --line: #2d3644;
    --ink: #e7ebf0; --muted: #98a3b3; --teal: #43b9b5; --teal-ink: #06201f; --teal-soft: #14302f;
    --gold: #f5c542; --gold-soft: #3a3112; --gold-ink: #ffe08a; --red: #ff6b7d; --bar: #4d5b6d;
  }
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --radius: 10px;
  accent-color: var(--teal);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; padding: 0 16px 48px; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font); max-width: 1180px; margin-inline: auto;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- header ---------- */
.masthead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 0 10px; }
h1 { font: 700 26px/1 var(--num); letter-spacing: .01em; margin: 0; }
.fresh { margin: 0; font-size: 13px; color: var(--muted); text-align: right; }
.fresh::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-right: 6px; vertical-align: 1px; }
.fresh.is-stale::before { background: var(--red); }
.banner { background: var(--red); color: #fff; padding: 8px 12px; border-radius: 8px; margin: 0 0 8px; font-weight: 600; font-size: 14px; }

.search input {
  width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: 16px;
}

/* ---------- category chips ---------- */
.cats { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button, .seg button, .toggles button {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 500;
}
.cats button[aria-pressed="true"], .seg button[aria-pressed="true"], .toggles button[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}

/* ---------- sticky control bar ---------- */
.controlbar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line);
}
.spend { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
.spend-label { font-size: 13px; color: var(--muted); padding: 0 6px 0 8px; }
.spend button { min-width: 44px; min-height: 34px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font: 600 16px var(--num); }
.spend button[aria-pressed="true"] { background: var(--teal); color: var(--teal-ink); }
.spend .custom { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 8px; font: 600 16px var(--num); border-radius: 7px; }
.spend .custom:has(input.is-on) { background: var(--teal); color: var(--teal-ink); }
.spend input { width: 4.2em; height: 32px; border: 0; background: transparent; font: 600 16px var(--num); }
.spend input::placeholder { color: var(--muted); font-weight: 500; }
.spend input.is-on::placeholder { color: var(--teal-ink); }
.sortrow { display: flex; gap: 8px; margin-left: auto; }
.sort select, .filters-btn {
  height: 42px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 12px; cursor: pointer; font-weight: 500;
}
.filters-btn { display: inline-flex; align-items: center; gap: 8px; }
.count[hidden] { display: none; }
@media (max-width: 600px) {
  .sortrow { width: 100%; margin-left: 0; }
  .sortrow .sort { flex: 1; }
  .sortrow .sort select { width: 100%; }
  .spend { width: 100%; justify-content: space-between; }
}
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--teal); color: var(--teal-ink); font: 600 13px var(--num); }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
.active-filters:empty { display: none; }
.pill-x { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--teal); background: var(--teal-soft); color: var(--ink); cursor: pointer; font-size: 13px; font-weight: 500; }
.pill-x span { color: var(--teal); font-weight: 700; }
.linkish { border: 0; background: none; color: var(--teal); font-weight: 600; cursor: pointer; font-size: 13px; padding: 0 6px; }

.summary { margin: 14px 0 8px; color: var(--muted); font-size: 14px; }

/* ---------- results ---------- */
.table-wrapper { container-type: inline-size; }
table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
thead th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 0 10px; white-space: nowrap; }
thead th button { all: unset; cursor: pointer; padding: 4px 0; }
thead th button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
thead th[aria-sort] { color: var(--ink); font-weight: 600; }
thead th[aria-sort="ascending"] button::after { content: " ↑"; }
thead th[aria-sort="descending"] button::after { content: " ↓"; }

tbody tr { background: var(--surface); }
tbody th, tbody td { padding: 10px; vertical-align: middle; text-align: left; font-weight: 400; }
tbody th { border-radius: var(--radius) 0 0 var(--radius); }
tbody td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.c-title { min-width: 0; }
.open { all: unset; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.open:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.thumb { width: 52px; height: 40px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-2); }
.t { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 42ch; }
.open:hover .t { text-decoration: underline; text-underline-offset: 3px; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 12.5px; color: var(--muted); margin: 2px 0 0 64px; }
.meta > span { white-space: nowrap; }
.bolt { color: var(--gold); font-weight: 700; }

.num { font: 600 17px/1.15 var(--num); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sub { display: block; font: 400 12.5px/1.3 var(--font); color: var(--muted); white-space: nowrap; }
.soon .num { color: var(--red); }
.bar { display: block; width: 72px; height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--bar); }
.tag { display: inline-block; font: 500 12px/1.4 var(--font); padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; margin-left: 4px; }
.tk { display: none; }

/* the value stub: the one loud element */
.stub {
  display: inline-block; min-width: 92px; padding: 6px 12px 6px 14px; text-align: right;
  background: var(--gold-soft); color: var(--gold-ink); border-radius: 8px;
  border-left: 2px dashed var(--gold);
}
.stub b { display: block; font: 700 21px/1 var(--num); }
.stub small { font-size: 12px; opacity: .8; }
.stub.none { background: var(--surface-2); color: var(--muted); border-left-color: var(--line); }
.stub.none b { font-size: 17px; }
.nobuy { font-size: 13px; color: var(--muted); white-space: normal; max-width: 22ch; display: block; }

/* phone / narrow: compact two-row cards */
@container (width < 760px) {
  table, tbody { display: block; }
  thead { display: none; }
  table { border-spacing: 0; }
  tbody tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    grid-template-areas: "title title title value" "ends sold price odds";
    gap: 8px 10px; padding: 12px; margin-bottom: 8px; border-radius: var(--radius);
  }
  tbody th, tbody td { padding: 0; border-radius: 0 !important; }
  .c-title { grid-area: title; }
  .c-value { grid-area: value; align-self: start; }
  .c-ends { grid-area: ends; } .c-sold { grid-area: sold; } .c-price { grid-area: price; }
  .c-odds { grid-area: odds; text-align: right; }
  .c-tix { display: none; }
  .c-ends::before, .c-sold::before, .c-price::before, .c-odds::before {
    content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 1px;
  }
  .thumb { width: 44px; height: 44px; }
  .meta { margin-left: 56px; }
  .t { -webkit-line-clamp: 2; max-width: none; }
  .bar { width: 100%; max-width: 72px; }
  .so { display: none; }
  .tk { display: block; }
  .stub { min-width: 0; padding: 5px 9px 5px 10px; }
  .stub b { font-size: 19px; }
  .num { font-size: 16px; }
  .nobuy { text-align: right; }
}
@container (width < 400px) {
  tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; grid-template-areas: "title title value" "ends sold odds"; }
  .c-price { display: none; }
}

.empty { text-align: center; padding: 32px 0; color: var(--muted); }
.btn { min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: var(--teal-ink); }
.btn.ghost { background: transparent; }

.explainer { margin-top: 24px; color: var(--muted); font-size: 14px; max-width: 72ch; }
.explainer summary { cursor: pointer; font-weight: 600; color: var(--ink); }

/* ---------- sheets (filters, detail) ---------- */
dialog.sheet {
  width: min(520px, 100vw); max-height: min(88dvh, 760px); padding: 0; border: 0;
  border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop { background: rgb(10 14 20 / .55); overflow: hidden; overscroll-behavior: contain; }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(16px); opacity: 0; } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 4px 20px; }
.sheet-head h2 { font: 700 22px var(--num); margin: 0; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 18px; }
.icon-btn:hover { background: var(--surface-2); }
.sheet-body { overflow-y: auto; padding: 4px 20px 16px; }
.sheet-foot { display: flex; gap: 10px; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--line); }
.sheet-foot .primary { flex: 1; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.seg, .toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.switches { display: grid; gap: 12px; }
.switch { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }

/* detail */
.detail-hero { width: 100%; height: 190px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.detail h2 { font: 700 22px/1.15 var(--num); margin: 12px 0 4px; }
.detail .lede { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.headline { display: flex; gap: 10px; align-items: stretch; margin: 6px 0 14px; }
.headline .stub { flex: 1; text-align: left; }
.headline .odds-box { flex: 1; padding: 6px 12px; border-radius: 8px; background: var(--surface-2); }
.headline .odds-box b { display: block; font: 700 21px/1 var(--num); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.odds-table { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font-size: 14px; }
.odds-table th, .odds-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; font-weight: 400; }
.odds-table th:first-child { text-align: left; color: var(--muted); }
.odds-table thead th { color: var(--muted); font-weight: 500; }
.odds-table td { font: 600 16px var(--num); }
.spark { width: 100%; height: 56px; display: block; }
.spark path { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.basis { font-size: 13px; color: var(--muted); }
.site-link { display: flex; align-items: center; justify-content: center; margin-top: 12px; text-decoration: none; }
