:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1c2433;
  --muted: #6b7585;
  --line: #e4e8f0;
  --accent: #2f6df0;
  --accent-soft: #e7f0ff;
  --good: #1f9d57;
  --good-soft: #e3f7ec;
  --bad: #d23f3f;
  --bad-soft: #fbe6e6;
  --gold: #f2b705;
  --shadow: 0 1px 3px rgba(20,30,60,.08), 0 6px 18px rgba(20,30,60,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.8rem; margin: .2em 0 .1em; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 1.2em 0 .5em; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.topbar nav { display: flex; gap: 1.2rem; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--accent); text-decoration: none; }

main { max-width: 1040px; margin: 0 auto; padding: 1.5rem; }
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem 3rem; }

.sub { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 700; }
.r { text-align: right; }
.crumb { color: var(--muted); font-size: .85rem; margin: 0 0 .3rem; }
.empty { color: var(--muted); font-style: italic; }

/* hero / upload */
.hero {
  background: linear-gradient(135deg, #2f6df0, #5b46e0);
  color: #fff; border-radius: 16px; padding: 2rem; box-shadow: var(--shadow);
}
.hero h1 { color: #fff; margin-top: 0; }
.hero .sub { color: #dfe7ff; }
.upload { display: flex; gap: .8rem; margin-top: 1.2rem; flex-wrap: wrap; }
.drop {
  flex: 1 1 320px; position: relative; display: flex; flex-direction: column;
  justify-content: center; gap: .3rem; min-height: 84px; padding: .8rem 1rem;
  background: rgba(255,255,255,.14); border: 2px dashed rgba(255,255,255,.55);
  border-radius: 12px; cursor: pointer; text-align: center;
}
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-text { font-weight: 600; }
.drop-files { font-size: .82rem; color: #e7ecff; word-break: break-all; }
.upload button {
  padding: 0 1.5rem; min-height: 84px; border: 0; border-radius: 12px;
  background: #fff; color: var(--accent); font-weight: 700; font-size: 1rem; cursor: pointer;
}
.upload button:hover { background: #eef3ff; }
.upload-hint { color: #dfe7ff; font-size: .82rem; margin: .9rem 0 0; }

/* flashes */
.flashes { margin-bottom: 1rem; display: grid; gap: .5rem; }
.flash { padding: .7rem 1rem; border-radius: 10px; font-size: .92rem; }
.flash-success { background: var(--good-soft); color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); }

/* date-range filter */
.datefilter {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: .6rem .85rem; box-shadow: var(--shadow); margin: 1rem 0 .4rem;
  font-size: .9rem;
}
.datefilter .df-label { font-weight: 600; color: var(--ink); }
.datefilter label { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); }
.datefilter input[type=date] {
  font: inherit; padding: .3rem .5rem; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: #fff;
}
.datefilter button {
  padding: .35rem 1.1rem; border: 0; border-radius: 8px; background: var(--accent);
  color: #fff; font-weight: 600; cursor: pointer; font: inherit;
}
.datefilter button:hover { background: #2459c8; }
.df-reset { font-size: .85rem; }
.df-range { margin-left: auto; }
.df-note { margin: 0 0 1.1rem; }

/* stat strip */
.stat-strip { display: flex; gap: 1rem; margin: 1.4rem 0; flex-wrap: wrap; }
.stat {
  flex: 1 1 120px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: .9rem 1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; color: var(--muted); font-size: .82rem;
}
.stat .big { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1.1; }

/* kpi cards */
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1.2rem 0; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .2rem;
}
.kpi-val { font-size: 1.5rem; font-weight: 700; }
.kpi-lbl { color: var(--muted); font-size: .8rem; }

/* cards + grid */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } .upload button { min-height: 52px; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th { text-align: left; color: var(--muted); font-weight: 600; font-size: .8rem;
  padding: .35rem .5rem; border-bottom: 2px solid var(--line); }
table.grid th.r { text-align: right; }
table.grid td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.grid tbody tr:hover { background: var(--accent-soft); }
.big-grid { font-size: .9rem; }

/* click-to-sort headers */
table.grid th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.grid th.sortable:hover { color: var(--accent); }
table.grid th.sortable::after { content: '↕'; margin-left: .35em; font-size: .9em; opacity: .3; }
table.grid th.sort-asc::after { content: '▲'; opacity: .85; }
table.grid th.sort-desc::after { content: '▼'; opacity: .85; }

.place-badge {
  background: var(--accent-soft); color: var(--accent); font-size: .8rem;
  padding: .1rem .5rem; border-radius: 20px; margin-left: .4rem; font-weight: 600;
}
.tag { background: var(--good-soft); color: var(--good); font-size: .7rem;
  padding: .05rem .4rem; border-radius: 6px; vertical-align: middle; }

/* synchron: discipline badge + Sync accent cell (purple, ties to the hero) */
.disc-badge {
  display: inline-block; background: #ece7fb; color: #5b46e0; font-size: .72rem;
  font-weight: 700; padding: .12rem .55rem; border-radius: 20px;
  margin-left: .45rem; vertical-align: middle; letter-spacing: .01em;
}
/* doppelmini: own discipline accent (teal), distinct from synchron's purple */
.disc-badge.dmt { background: #d8f3ee; color: #0f8a73; }
td.sync { background: #f4f0ff; color: #5b46e0; font-weight: 700; }
table.grid tbody tr:hover td.sync { background: #ebe4ff; }
.final-row { background: #fcfbf3; }
.final-row:hover { background: #f7f3df; }
.result-group { margin-bottom: 1.4rem; }
.result-group h3 a { color: var(--ink); }
.medals-line { display: flex; gap: 1.4rem; font-size: 1.2rem; margin: 0; }
.mini { font-size: .82rem; }

/* tabbed views (per-discipline tables on team & athlete pages) */
.tabs { margin-top: .2rem; }
.tab-bar {
  display: flex; gap: .25rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); margin-bottom: 1.1rem;
}
.tab-btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: inherit; color: var(--muted); font-weight: 600;
  padding: .5rem .9rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
  display: inline-flex; align-items: center; gap: .45rem;
}
.tab-btn:hover { color: var(--ink); background: var(--accent-soft); }
.tab-btn.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  background: var(--line); border-radius: 20px;
  padding: .05rem .45rem; min-width: 1.5em; text-align: center;
}
.tab-btn.is-active .tab-count { background: var(--accent-soft); color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.tab-note { margin: -.4rem 0 1rem; }
.tab-stats { margin: .1rem 0 .9rem; }
.tab-stats .stat { flex: 1 1 95px; padding: .7rem .85rem; }
.tab-stats .stat .big { font-size: 1.35rem; }
.tab-medals { font-size: 1.05rem; gap: 1.2rem; margin: 0 0 1.3rem; }

/* sparkline */
.sparkline { width: 100%; height: auto; }
.sparkline .axis { stroke: var(--line); stroke-width: 1; }
.sparkline .spark { stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.sparkline .dot { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.sparkline .ax { fill: var(--muted); font-size: 11px; }
