:root {
  --bg: #fff; --fg: #1f2328; --muted: #6b7280; --border: #d0d7de; --panel: #f6f8fa; --accent: #e8344e;
  --hl: #dbe7ff; --up: #1a7f37; --down: #cf222e; --group: #57606a;
  --w-bg: #c6efce; --w-fg: #006100; --d-bg: #ffeb9c; --d-fg: #9c6500; --l-bg: #ffc7ce; --l-fg: #9c0006;
  --none-bg: #f0f0f0; --none-fg: #999;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117; --fg: #e6e8eb; --muted: #9aa0a6; --border: #30363d; --panel: #161b22; --hl: #2b3d5c;
    --up: #3fb950; --down: #f85149; --group: #8b949e;
    --w-bg: #1f4d2b; --w-fg: #9be9a8; --d-bg: #4d4113; --d-fg: #f2cc60; --l-bg: #5c1f24; --l-fg: #ffa198;
    --none-bg: #1c2128; --none-fg: #6e7681;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; display: flex; min-height: 100vh; }
a { color: inherit; }
nav { width: 230px; flex: none; background: var(--panel); border-right: 1px solid var(--border); padding: 1.2rem .8rem; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; justify-content: space-between; }
nav .nav-links a { display: block; padding: .45rem .7rem; border-radius: 6px; text-decoration: none; }
nav .nav-links a:hover { background: var(--border); }
nav .nav-links a.active { background: var(--border); font-weight: 600; }
.nav-legal { font-size: 12px; color: var(--muted); padding: 1rem .7rem 0; }
main { flex: 1; min-width: 0; padding: 1.5rem 2rem 4rem; max-width: 1300px; }
h1 { margin-top: 0; } h2, h3 { margin-top: 2rem; } h2.flush { margin-top: 0; }
h3 .logo { margin-right: .3rem; }
.caption { color: var(--muted); font-size: 13px; margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; margin: .6rem 0; }
.row > label, .field { display: flex; flex-direction: column; gap: .2rem; font-size: 13px; color: var(--muted); }
.field-label { font-size: 13px; color: var(--muted); }
select, input { background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 6px; padding: .4rem .6rem; font: inherit; min-width: 12rem; }
select.wide { min-width: min(34rem, 80vw); }
.range { display: flex; gap: .4rem; align-items: center; } .range select { min-width: 7rem; }
input[type=range] { padding: 0; width: 100%; min-width: 16rem; accent-color: var(--accent); }
.slider-wrap { flex: 1; min-width: 18rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: .45rem 1rem; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.linklike { background: none; border: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin: .3rem 0 .6rem; flex-wrap: wrap; }
.segmented button { background: var(--bg); color: var(--fg); border: none; border-right: 1px solid var(--border); padding: .4rem .85rem; font: inherit; font-size: 14px; cursor: pointer; }
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--accent); color: #fff; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; margin-top: 1rem; }
.card { display: flex; flex-direction: column; gap: .3rem; border: 1px solid var(--border); border-radius: 10px; padding: 1rem; text-decoration: none; background: var(--panel); }
.card span { color: var(--muted); font-size: 14px; }
.card:hover { border-color: var(--accent); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-top: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: .5rem .9rem; cursor: pointer; font: inherit; }
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab-panel { padding-top: .8rem; }

/* interactive tables */
.dt { margin: .6rem 0 1rem; }
.dt-bar { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; margin-bottom: .4rem; }
.dt-select { min-width: 0; padding: .25rem .5rem; font-size: 13px; }
.dt-search { min-width: min(19rem, 100%); padding: .3rem .6rem; font-size: 14px; }
.dt-count { color: var(--muted); font-size: 13px; margin-left: auto; }
.dt-btn { background: none; border: 1px solid var(--border); color: var(--fg); border-radius: 6px; padding: .25rem .6rem; font: inherit; font-size: 13px; cursor: pointer; list-style: none; }
.dt-btn:hover { border-color: var(--accent); }
.dt-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dt-cols { position: relative; border: none; padding: 0; margin: 0; }
.dt-cols summary::-webkit-details-marker { display: none; }
.dt-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .8rem; display: flex; flex-direction: column; gap: .2rem; max-height: 320px; overflow: auto; white-space: nowrap; font-size: 13px; box-shadow: 0 4px 16px #0004; }
.dt-menu label { display: flex; gap: .4rem; align-items: center; cursor: pointer; }
.dt-menu input { min-width: 0; }
table.data th sup { font-size: 9px; margin-left: 1px; }
.table-wrap { overflow: auto; max-height: 640px; border: 1px solid var(--border); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data thead { position: sticky; top: 0; z-index: 2; }
table.data th { background: var(--panel); text-align: left; padding: .4rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data thead tr:not(:last-child) th { border-bottom: none; padding-bottom: .2rem; }
table.data .dt-filters th { padding: 0 .35rem .35rem; font-weight: normal; }
.dt-cf { width: 100%; min-width: 4.2rem; box-sizing: border-box; padding: .15rem .35rem; font-size: 12px; border-radius: 4px; }
.dt-cf:not(:placeholder-shown) { border-color: var(--accent); }
table.data tr.dt-more td { text-align: center; color: var(--muted); padding: .6rem; font-size: 13px; }
:is(table.data, table.h2h) th.sortable { cursor: pointer; user-select: none; }
:is(table.data, table.h2h) th.sortable:hover { color: var(--accent); }
:is(table.data, table.h2h) th .arrow { margin-left: .3rem; font-size: 10px; color: var(--muted); }
:is(table.data, table.h2h) th.sorted .arrow { color: var(--accent); }
table.data td { padding: .3rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.empty { text-align: center; color: var(--muted); padding: 1rem; }
table.data tr.hl td { background: var(--hl); }
table.data tr.click { cursor: pointer; } table.data tr.click:hover td { background: var(--panel); } table.data tr.click.hl:hover td { background: var(--hl); }
table.data tr.zone-top td:first-child { box-shadow: inset 3px 0 #2ca02c; }
table.data tr.zone-bottom td:first-child { box-shadow: inset 3px 0 #d62728; }
table.data td.best { background: #1b7a3d; color: #fff; } table.data td.worst { background: #a11d2b; color: #fff; }
table.data td.sel { background: var(--hl); }
.up { color: var(--up); font-weight: 600; } .down { color: var(--down); font-weight: 600; }
.logo { height: 20px; width: 20px; object-fit: contain; vertical-align: middle; }
.bar { position: relative; min-width: 90px; text-align: left; padding-left: .35rem; } .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #e8344e44; border-radius: 2px; } .bar span { position: relative; }
.form { display: inline-flex; gap: 2px; }
.form b, .pill { display: inline-block; min-width: 1.35em; text-align: center; border-radius: 4px; font-size: 11px; line-height: 1.6; font-weight: 700; }
.W { background: var(--w-bg); color: var(--w-fg); font-weight: 600; } .D { background: var(--d-bg); color: var(--d-fg); font-weight: 600; }
.L { background: var(--l-bg); color: var(--l-fg); font-weight: 600; } .none { background: var(--none-bg); color: var(--none-fg); }

/* head-to-head results grid */
.grid-wrap { max-height: 70vh; }
table.h2h { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
table.h2h th, table.h2h td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: .25rem .5rem; text-align: center; white-space: nowrap; }
table.h2h thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); }
table.h2h td.club, table.h2h th.club { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--bg); }
table.h2h thead th.club { z-index: 3; background: var(--panel); }
table.h2h td.group-end, table.h2h tr.group-end td { border-bottom: 2px solid var(--group); }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .7rem 1rem; }
.metric .label { color: var(--muted); font-size: 13px; } .metric .value { font-size: 1.7rem; font-weight: 600; } .metric .sub { color: var(--muted); font-size: 12px; }
.metric .delta { font-size: 13px; color: var(--up); } .metric .delta.neg { color: var(--down); }
.alert { border-radius: 8px; padding: .7rem 1rem; margin: 1rem 0; background: #1f6feb22; } .alert.warn { background: #d4a72c33; } .alert.err { background: #d6272833; }
details.faq { border: 1px solid var(--border); border-radius: 8px; padding: .6rem 1rem; margin: .5rem 0; } details.faq summary { cursor: pointer; font-weight: 600; }
.chips { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
.chip { background: var(--accent); color: #fff; border: none; border-radius: 14px; padding: .1rem .6rem; font: inherit; font-size: 13px; cursor: pointer; }
.chart { width: 100%; }
.scroll-x { overflow-x: auto; }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose { max-width: 760px; }
@media (max-width: 800px) {
  body { flex-direction: column; }
  nav { width: auto; height: auto; position: static; }
  nav .nav-links { display: flex; flex-wrap: wrap; }
  main { padding: 1rem; }
  select, input { min-width: 0; max-width: 100%; }
  .slider-wrap, input[type=range] { min-width: 0; }
}
