:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --local: #138a4b;
  --local-bg: #eaf8f0;
  --draw: #d97706;
  --draw-bg: #fff7e6;
  --away: #2563eb;
  --away-bg: #edf4ff;
  --danger: #b42318;
  --danger-bg: #fff1f0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(100%, 880px);
  margin: 0 auto;
  padding: 0 16px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 2px 14px;
}
.topbar h1 { margin: 0; font-size: 1.6rem; letter-spacing: -.03em; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.35rem;
  box-shadow: 0 5px 18px rgba(15, 23, 42, .06);
}
.icon-btn:focus-visible, select:focus-visible, input:focus-visible, .match-card:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .25);
  outline-offset: 2px;
}

.hero {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px;
  border-radius: 22px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0; font-size: clamp(1.3rem, 4vw, 2rem); letter-spacing: -.03em; }
.hero-kicker { margin: 0 0 7px; color: #bfdbfe; font-weight: 800; font-size: .82rem; }
.hero-copy { margin: 10px 0 0; max-width: 620px; color: #cbd5e1; font-size: .92rem; line-height: 1.5; }
.status-pill {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: #e2e8f0;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.ok { background: rgba(34,197,94,.16); color: #bbf7d0; }
.status-pill.bad { background: rgba(239,68,68,.16); color: #fecaca; }

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.filters label { min-width: 0; }
.filters label span {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
}
.filters select, .filters input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  font-size: 16px;
}
.search-field { grid-column: 1 / -1; }

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-bottom: 22px;
}
.summary article {
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}
.summary span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; }
.summary strong { display: block; margin-top: 3px; font-size: 1.35rem; }

.list-section { margin-top: 6px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2, .section-head h3 { margin: 0; letter-spacing: -.02em; }
.section-head.compact { align-items: center; }
.muted { color: var(--muted); font-size: .84rem; }
.matches-list { display: grid; gap: 10px; }

.match-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  box-shadow: 0 5px 16px rgba(15, 23, 42, .04);
}
.match-card:hover { border-color: #cbd5e1; }
.match-card h3 { margin: 5px 0 7px; font-size: 1rem; letter-spacing: -.015em; }
.match-meta { display: flex; flex-wrap: wrap; gap: 6px 9px; color: var(--muted); font-size: .78rem; }
.match-side { min-width: 92px; text-align: right; }
.confidence { display: block; margin-top: 7px; font-size: .78rem; color: var(--muted); }
.stability { display: block; margin-top: 3px; font-size: .72rem; color: var(--muted); }

.pick-badge {
  display: inline-grid;
  min-width: 38px;
  min-height: 30px;
  place-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 900;
}
.pick-badge.local { color: var(--local); background: var(--local-bg); }
.pick-badge.draw { color: var(--draw); background: var(--draw-bg); }
.pick-badge.away { color: var(--away); background: var(--away-bg); }
.pick-badge.neutral { color: var(--muted); background: #f1f5f9; }

.state-card {
  padding: 22px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: rgba(255,255,255,.6);
  color: var(--muted);
  text-align: center;
}
.state-card.error { color: var(--danger); background: var(--danger-bg); border-color: #fecaca; }

footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px 0 5px;
  color: var(--muted);
  font-size: .72rem;
}

.detail-dialog {
  width: min(760px, calc(100% - 18px));
  max-height: calc(100% - 18px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
}
.detail-dialog::backdrop { background: rgba(15,23,42,.68); backdrop-filter: blur(3px); }
.dialog-card {
  max-height: calc(100vh - 18px);
  overflow: auto;
  background: var(--bg);
  border-radius: 24px;
  padding: 18px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.dialog-head h2 { margin: 0 0 5px; font-size: 1.25rem; }

.final-pick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  padding: 14px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.final-pick > div { min-width: 0; }
.final-pick span, .comparison-card span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; }
.final-pick strong { display: block; margin-top: 4px; font-size: 1.05rem; }
.final-pick.local { border-left: 5px solid var(--local); }
.final-pick.draw { border-left: 5px solid var(--draw); }
.final-pick.away { border-left: 5px solid var(--away); }

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.model-card {
  padding: 15px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.model-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.model-title h3 { margin: 0; font-size: .9rem; letter-spacing: .06em; }
.prob-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin-top: 13px; }
.prob {
  padding: 9px 5px;
  border-radius: 12px;
  background: var(--panel-2);
  text-align: center;
}
.prob span { display: block; font-size: .7rem; color: var(--muted); font-weight: 900; }
.prob strong { display: block; margin-top: 2px; font-size: .96rem; }
.model-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 11px; color: var(--muted); font-size: .72rem; }
.model-meta b { color: var(--text); }

.comparison-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.comparison-card strong { display: block; margin-top: 4px; font-size: .88rem; overflow-wrap: anywhere; }

.heuristic-section {
  margin-top: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.legend { display: flex; gap: 11px; flex-wrap: wrap; color: var(--muted); font-size: .72rem; font-weight: 800; }
.dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; margin-right: 4px; }
.dot.local { background: var(--local); }
.dot.away { background: var(--away); }
.heuristics { display: grid; gap: 7px; }
.heur-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 11px;
  border-radius: 12px;
  background: var(--panel-2);
}
.heur-row span { font-size: .84rem; }
.heur-row strong { font-size: .86rem; }
.heur-row.local { background: var(--local-bg); color: #0b6b39; }
.heur-row.away { background: var(--away-bg); color: #1d4ed8; }
.heur-row.neutral { color: var(--muted); }

@media (max-width: 620px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .hero { align-items: flex-start; flex-direction: column; padding: 18px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .summary { gap: 6px; }
  .summary article { padding: 11px 6px; border-radius: 13px; }
  .match-card { padding: 14px; }
  .model-grid { grid-template-columns: 1fr; }
  .dialog-card { padding: 14px; }
}

@media (max-width: 390px) {
  .filters { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .final-pick, .comparison-card { grid-template-columns: 1fr 1fr; }
  .comparison-card > div:last-child { grid-column: 1 / -1; }
  .match-card { grid-template-columns: minmax(0, 1fr) 80px; gap: 8px; }
  .summary strong { font-size: 1.15rem; }
}
