:root {
  --red: #b81237;
  --red-dark: #8f0d2a;
  --charcoal: #2c383e;
  --silver: #b0b7bb;
  --bar: #c9ced1;
  --bg: #f3f4f5;
  --card: #ffffff;
  --ink: #1d2529;
  --ink-2: #4a565c;
  --muted: #6b767c;
  --line: #e2e5e7;
  --good-bg: #dcf1e2;
  --good-ink: #17643a;
  --bad-bg: #fbe0e0;
  --bad-ink: #a31b1b;
  --same-bg: #eceff1;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 22px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.footnote { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

/* Masthead */
.masthead { background: #fff; border-top: 6px solid var(--red); }
.masthead-inner { display: flex; align-items: center; gap: 20px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; }
.logo { height: 78px; width: auto; }
.titles { flex: 1; min-width: 220px; }
.titles h1 { font-size: 32px; font-style: italic; font-weight: 800; letter-spacing: -0.5px; color: var(--charcoal); }
.titles p { margin: 2px 0 0; color: var(--ink-2); }
.session { display: flex; flex-direction: column; }
.session-pill { border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; font-size: 14px; background: #fafafa; }
.btn { font: inherit; font-weight: 700; font-size: 15px; border: 2px solid var(--charcoal); background: #fff; color: var(--charcoal); padding: 9px 16px; border-radius: 4px; cursor: pointer; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn:disabled { opacity: .6; cursor: progress; }
.tabs { background: var(--charcoal); border-bottom: 4px solid var(--red); }
.tabs .wrap { display: flex; gap: 4px; padding-top: 8px; }
.tab { font: inherit; font-weight: 700; color: #fff; background: transparent; border: 0; padding: 11px 18px; cursor: pointer; border-radius: 4px 4px 0 0; }
.tab:hover { background: rgba(255,255,255,.1); }
.tab.active { background: #fff; color: var(--red); }

main { padding-top: 24px; padding-bottom: 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 22px 22px; margin-bottom: 22px; }
.card h3 { font-size: 19px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.grid2 .card { margin-bottom: 0; }
@media (max-width: 1020px) { .grid2 { grid-template-columns: 1fr; } }

select { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #cfd4d7; border-radius: 4px; min-width: 280px; background: #fff; }

/* Athlete card */
.athlete-card { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; }
.athlete-left h2 { font-size: 38px; font-style: italic; font-weight: 800; letter-spacing: -0.5px; margin-top: 10px; }
.kpis { display: flex; gap: 30px; border-left: 4px solid var(--red); padding-left: 24px; align-self: center; }
.kpi { display: flex; flex-direction: column; }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--red); line-height: 1.1; }
.kpi-label { font-size: 13px; color: var(--ink-2); }
.summary { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.summary h3 { font-size: 16px; color: var(--charcoal); }
.summary p { margin: 6px 0 12px; max-width: 980px; }
.chips { display: flex; gap: 40px; flex-wrap: wrap; }
.chip-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); }
.chip-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list li { font-size: 13px; padding: 3px 10px; border-radius: 12px; }
.chip-list.good li { background: var(--good-bg); color: var(--good-ink); }
.chip-list.bad li { background: var(--bad-bg); color: var(--bad-ink); }
.chip-list li.none { background: var(--same-bg); color: var(--ink-2); }
.missed { margin-top: 14px; background: #fff6e5; border-left: 4px solid #d08a00; padding: 9px 12px; font-size: 14px; border-radius: 0 4px 4px 0; }
@media (max-width: 760px) { .athlete-card { grid-template-columns: 1fr; } .kpis { border-left: 0; padding-left: 0; } }

/* Bar charts */
.barchart { margin-top: 18px; position: relative; }
.bar-row { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 10px; height: 28px; cursor: pointer; }
.bar-row:hover .bar-name { color: var(--red); }
.bar-name { text-align: right; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { position: relative; height: 20px; display: flex; align-items: center; }
.bar { height: 20px; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-val { font-size: 12.5px; color: var(--ink-2); margin-left: 4px; padding: 0 3px; white-space: nowrap; position: relative; z-index: 2; background: rgba(255,255,255,.85); border-radius: 3px; }
.bar-row.sel .bar { background: var(--red); }
.bar-row.sel .bar-name, .bar-row.sel .bar-val { font-weight: 700; color: var(--ink); }
.bar-row:hover .bar { filter: brightness(.92); }
.avg-line { z-index: 1; position: absolute; top: -18px; bottom: 0; border-left: 2px dashed var(--charcoal); pointer-events: none; }
.avg-label { position: absolute; top: -20px; transform: translateX(-50%); font-size: 12px; white-space: nowrap; background: #fff; padding: 0 4px; color: var(--charcoal); }
.chart-pad { padding-top: 26px; margin-top: 8px; }
.missing-list { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* Comparison table */
table.cmp { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
.cmp th { white-space: nowrap; text-align: left; font-size: 13px; color: var(--ink-2); border-bottom: 2px solid var(--charcoal); padding: 8px 8px; }
.cmp td { padding: 8px 8px; border-bottom: 1px solid var(--line); }
.cmp .num { text-align: right; font-variant-numeric: tabular-nums; }
.cmp .unit { color: var(--muted); font-size: 12px; margin-left: 3px; }
.cmp tr.grp td { background: #f1f2f3; color: var(--red); font-weight: 700; font-size: 13px; padding-top: 10px; }
.pill { display: inline-block; white-space: nowrap; min-width: 84px; text-align: center; font-weight: 700; padding: 3px 8px; border-radius: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.pill.better { background: var(--good-bg); color: var(--good-ink); }
.pill.worse { background: var(--bad-bg); color: var(--bad-ink); }
.pill.same { background: var(--same-bg); color: var(--ink-2); }
.pill.missing { background: #fff6e5; color: #8a5a00; font-weight: 600; }
.legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-2); margin-top: 12px; flex-wrap: wrap; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.better { background: var(--good-bg); border: 1px solid var(--good-ink); }
.sw.worse { background: var(--bad-bg); border: 1px solid var(--bad-ink); }

/* Glossary */
.gloss-sec { margin-top: 22px; }
.gloss-sec h4 { color: var(--red); font-size: 17px; margin: 0 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.gloss-row { display: grid; grid-template-columns: 260px 1fr; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.gloss-term { font-weight: 700; }
.gloss-unit { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }
@media (max-width: 700px) { .gloss-row { grid-template-columns: 1fr; gap: 4px; } }

.tooltip { position: fixed; z-index: 10; background: var(--charcoal); color: #fff; font-size: 12.5px; padding: 5px 9px; border-radius: 4px; pointer-events: none; white-space: nowrap; }

/* Export dialog */
dialog { border: 0; border-radius: 8px; padding: 0; width: min(520px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,28,32,.5); }
.dialog-body { padding: 22px; }
.dialog-actions-top { display: flex; gap: 14px; margin: 14px 0 6px; }
.link { background: none; border: 0; color: var(--red); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }
.export-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; }
.export-list label { display: flex; gap: 8px; padding: 5px 0; font-size: 14px; cursor: pointer; }
.mode { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
