﻿/* Margin Bench â€” test product
   Palette: ink ground, parchment text, brass for our book.
   One deliberate flourish: the margin rail that places each book inside the
   ES range. Everything else stays quiet. */

:root {
  color-scheme: dark;
  --bg: #101419;
  --panel: #151a21;
  --panel-2: #1a2029;
  --panel-3: #202732;
  --line: #2a313b;
  --line-soft: #222831;
  --text: #e9e4d9;
  --soft: #c3c8cf;
  --muted: #98a2ae;
  --faint: #6f7a87;
  --brass: #d3a24b;
  --brass-soft: rgba(211, 162, 75, 0.14);
  --red: #cf7b6d;
  --red-soft: rgba(207, 123, 109, 0.12);
  --green: #86a888;
  --green-soft: rgba(134, 168, 136, 0.12);
  --blue: #8aa9c9;
  --blue-soft: rgba(138, 169, 201, 0.12);
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html { font-size: 15px; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 78% -8%, rgba(211, 162, 75, 0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }

button, input { font: inherit; color: inherit; }

a { color: var(--blue); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--brass);
  color: #1a1408;
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 100;
  font-weight: 700;
}
.skip:focus { left: 12px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 10px 22px;
  background: rgba(16, 20, 25, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--brass);
  color: #171207;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1.02rem; letter-spacing: 0.01em; }
.brand-text small { color: var(--faint); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }

.top-meta { display: flex; align-items: center; gap: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill[data-mode="demo"] { color: var(--brass); border-color: rgba(211, 162, 75, 0.35); }
.pill[data-mode="live"] { color: var(--green); border-color: rgba(134, 168, 136, 0.4); }

.freshness { display: flex; flex-direction: column; line-height: 1.2; }
.freshness-label { color: var(--faint); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; }
.freshness strong { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--soft); }

.button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.button:hover:not(:disabled) { background: var(--panel-3); border-color: #3a4350; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

.demo-note {
  max-width: none;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(211, 162, 75, 0.05);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}
.demo-note strong { color: var(--brass); font-weight: 700; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 348px minmax(0, 1fr);
  min-height: calc(100vh - 150px);
}

.rail {
  border-right: 1px solid var(--line);
  padding: 18px 16px 28px;
  position: sticky;
  top: 64px;
  align-self: start;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.stage { padding: 24px 26px 40px; min-width: 0; }

/* ---------- Search ---------- */

.search-block { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#q {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
}
#q::placeholder { color: var(--faint); }
#q:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }

.hint { color: var(--faint); font-size: 0.7rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 12px; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: #3a4350; color: var(--text); }
.chip.is-active { background: var(--brass-soft); border-color: rgba(211, 162, 75, 0.5); color: var(--brass); }

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 6px 2px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.events { list-style: none; margin: 0; padding: 0; }

.event-card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
  padding: 11px 8px 11px 12px;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease;
}
.event-card:hover { background: rgba(255, 255, 255, 0.025); }
.event-card[aria-current="true"] {
  background: rgba(211, 162, 75, 0.07);
  border-left-color: var(--brass);
}

.event-card .teams {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}
.event-card .teams span:last-child { color: var(--soft); font-weight: 500; }

.event-card .card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
  color: var(--faint);
  font-size: 0.68rem;
}
.event-card .card-meta .kick { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.events-empty { color: var(--faint); font-size: 0.8rem; padding: 18px 6px; }

/* ---------- Event header ---------- */

.event-league {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brass);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.event-league .dot { color: var(--faint); }

.match-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 6px;
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.match-title em { font-size: 0.62em; color: var(--faint); font-style: italic; }

.event-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  color: var(--faint);
  font-size: 0.72rem;
}
.event-sub .mono { color: var(--muted); letter-spacing: 0.02em; }
.portal-link { text-decoration: none; border-bottom: 1px solid rgba(138, 169, 201, 0.35); }
.portal-link:hover { color: #a8c2dd; }
.captured { margin-left: auto; }
.event-source { color: var(--muted); font-size: 0.68rem; padding-left: 10px; border-left: 1px solid var(--line); }

/* ---------- Market tabs ---------- */

.market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 20px 0 16px;
  border-bottom: 1px solid var(--line);
}

.market-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 13px 11px;
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
.market-tab:hover { color: var(--text); }
.market-tab[aria-selected="true"] { color: var(--text); }
.market-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  background: var(--brass);
}
.market-tab .tab-gap {
  margin-left: 7px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
}
.market-tab[aria-selected="true"] .tab-gap { color: var(--brass); }

/* ---------- Summary ---------- */

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  padding: 13px 15px 12px;
  min-width: 0;
}
.stat .stat-label {
  display: block;
  color: var(--faint);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.stat .stat-value {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 1.32rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat .stat-sub { display: block; margin-top: 2px; color: var(--faint); font-size: 0.68rem; }

.stat.is-ours { background: linear-gradient(180deg, rgba(211, 162, 75, 0.1), transparent 70%), var(--panel); }
.stat.is-ours .stat-value { color: var(--brass); }

.stat-value.is-negative { color: var(--red); }
.stat-value.is-positive { color: var(--green); }

/* ---------- Comparison table ---------- */

.table-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.compare caption {
  text-align: left;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.compare thead th {
  background: var(--panel);
  color: var(--faint);
  font-size: 0.63rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: right;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.compare thead th:first-child { text-align: left; }
.compare thead th.rail-head { width: 156px; }

.compare tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--soft);
}
.compare tbody tr:last-child td { border-bottom: 0; }
.compare tbody td:first-child { text-align: left; font-family: var(--sans); }

.compare tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.book-cell { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.book-dot { width: 3px; height: 26px; border-radius: 2px; background: var(--line); flex: none; }
.book-name { display: flex; flex-direction: column; line-height: 1.2; }
.book-name b { font-size: 0.82rem; font-weight: 650; color: var(--text); }
.book-name small { color: var(--faint); font-size: 0.63rem; letter-spacing: 0.04em; }

tr.is-ours td { background: rgba(211, 162, 75, 0.055); }
tr.is-ours .book-dot { background: var(--brass); }
tr.is-ours .book-name b { color: var(--brass); }
tr.is-ours td:first-child { box-shadow: inset 2px 0 0 var(--brass); }

.margin-value { font-weight: 700; color: var(--text); }
tr.is-ours .margin-value { color: var(--brass); }

.gap {
  display: inline-block;
  min-width: 54px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
}
.gap[data-tone="warn"] { color: var(--brass); background: var(--brass-soft); }
.gap[data-tone="negative"] { color: var(--red); background: var(--red-soft); }
.gap[data-tone="positive"] { color: var(--green); background: var(--green-soft); }
.gap[data-tone="info"] { color: var(--blue); background: var(--blue-soft); }
.gap[data-tone="neutral"] { color: var(--muted); background: rgba(255, 255, 255, 0.04); }

/* The margin rail: one glance shows whether a book sits inside the ES range. */
.rail-cell { width: 156px; }
.margin-rail {
  position: relative;
  height: 18px;
  margin-left: auto;
  width: 132px;
}
.margin-rail .track {
  position: absolute;
  left: 0;
  right: 0;
  top: 8px;
  height: 2px;
  background: linear-gradient(90deg, rgba(154, 164, 175, 0.12), rgba(154, 164, 175, 0.5), rgba(154, 164, 175, 0.12));
  border-radius: 2px;
}
.margin-rail .dot {
  position: absolute;
  top: 4px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--soft);
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.margin-rail .dot.is-ours { background: var(--brass); width: 12px; height: 12px; top: 3px; }
.margin-rail .rail-min,
.margin-rail .rail-max {
  position: absolute;
  top: 14px;
  font-family: var(--mono);
  font-size: 0.56rem;
  color: var(--faint);
}
.margin-rail .rail-min { left: 0; }
.margin-rail .rail-max { right: 0; }

.no-margin { color: var(--faint); font-family: var(--sans); font-size: 0.72rem; }

/* ---------- Legend and footer ---------- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  color: var(--faint);
  font-size: 0.7rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch.ours { background: var(--brass); }
.swatch.es { background: var(--muted); }

.page-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: 0.68rem;
}

/* ---------- States ---------- */

.empty {
  max-width: 560px;
  padding: 54px 4px;
}
.empty-kicker {
  color: var(--brass);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.empty h1 {
  margin: 8px 0 10px;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}
.empty p { color: var(--muted); font-size: 0.86rem; max-width: 52ch; }
.empty .button { margin-top: 18px; }

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 40px 4px;
  color: var(--muted);
  font-size: 0.85rem;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ---------- Market history ---------- */

.brand { color: inherit; text-decoration: none; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }

.history-main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 132px);
}

.hist-rail {
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: rgba(21, 26, 33, 0.6);
}

.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.hist-foot {
  margin-top: 16px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--faint);
}

.hist-stage { padding: 20px 22px 30px; min-width: 0; }

.hist-stage .event-head { margin-bottom: 14px; }

.chart-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 16px 10px;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.chart-head h2 { font-size: 1rem; letter-spacing: 0.01em; }
.chart-head p { margin-top: 3px; font-size: 0.78rem; color: var(--muted); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.72rem;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.chart-host { margin-top: 8px; }
.chart-svg { display: block; width: 100%; height: auto; }

.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-grid-v { stroke-dasharray: 2 4; }
.chart-axis { fill: var(--faint); font-size: 10px; font-family: var(--mono); }
.chart-ko { stroke: var(--brass); stroke-dasharray: 3 4; stroke-opacity: 0.65; }
.chart-label { fill: var(--brass); font-size: 11px; font-family: var(--mono); }
.chart-dot { fill: var(--brass); }

.hist-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.hist-stat {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.hist-stat span {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.hist-stat strong {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
}

.hist-table { margin-top: 12px; }
.hist-table tr.median td { color: var(--blue); }
.hist-table tr.ours td { color: var(--brass); font-weight: 600; }

@media (max-width: 900px) {
  .history-main { grid-template-columns: 1fr; }
  .hist-rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .hist-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hist-stage { padding: 16px 14px 26px; }
  .chart-head { flex-direction: column; }
}

/* ---------- Oddspedia board ---------- */

.board {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  overflow: hidden;
}

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.board-head h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.board-head p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.board-tag {
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.board-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.board-frame {
  display: block;
  width: 100%;
  height: 480px;
  border: 0;
  background: #fff;
}

.board-note {
  margin: 0;
  padding: 9px 14px 11px;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}

@media (max-width: 520px) {
  .board-frame { height: 420px; }
  .board-head { flex-direction: column; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare thead th.rail-head, .compare td.rail-cell { display: none; }
}

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; min-height: 58px; }
  .freshness { display: none; }
  .demo-note { padding: 9px 14px; }
  .layout { display: block; }
  .rail {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 14px 10px;
  }
  .events { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
  .events li { flex: 0 0 220px; scroll-snap-align: start; }
  .event-card {
    height: 100%;
    border: 1px solid var(--line);
    border-left: 2px solid transparent;
    border-radius: 8px;
    background: var(--panel);
  }
  .event-card[aria-current="true"] { border-left-color: var(--brass); }
  .stage { padding: 18px 14px 30px; }
  .match-title { font-size: 1.6rem; }
  .captured { margin-left: 0; }
  .page-foot { padding: 12px 14px 18px; }
}

@media (max-width: 520px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .stat { padding: 11px 12px; }
  .stat .stat-value { font-size: 1.1rem; }
  .compare { font-size: 0.76rem; }
  .compare thead th, .compare tbody td { padding: 8px 8px; }
  .book-cell { min-width: 118px; }
  .market-tab { padding: 8px 10px 10px; font-size: 0.74rem; }
}

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

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
