:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-alt: #fffaf0;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-border: rgba(37, 51, 69, 0.12);
  --text: #122033;
  --muted: #5f6b7a;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --shadow: 0 18px 50px rgba(40, 54, 71, 0.12);
  --radius: 24px;
  --radius-sm: 14px;
  --line: rgba(18, 32, 51, 0.1);
  --grid: rgba(18, 32, 51, 0.07);
  --chip-bg: rgba(18, 32, 51, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.22), transparent 32%),
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 28%),
    linear-gradient(180deg, #fffdf7 0%, var(--bg) 100%);
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.lead {
  margin-top: 12px;
  max-width: 760px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  min-width: 260px;
}

.stat-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.stat-card {
  padding: 16px 18px;
  border-radius: 18px;
}

.stat-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-card strong {
  font-size: 1.55rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 2fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  padding: 18px 18px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.search {
  display: grid;
  gap: 6px;
  min-width: 200px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.search input {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
  outline: none;
}

.search input:focus {
  border-color: rgba(217, 119, 6, 0.6);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.status-line {
  min-height: 22px;
  padding: 10px 18px 0;
  color: var(--accent);
  font-size: 0.92rem;
}

.athlete-list {
  max-height: min(74vh, 1000px);
  overflow: auto;
  padding: 10px 10px 14px;
}

.athlete-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.athlete-row:hover {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(18, 32, 51, 0.08);
  transform: translateY(-1px);
}

.athlete-row.selected {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.24);
}

.athlete-row:focus-visible,
.search input:focus-visible {
  outline: 3px solid rgba(217, 119, 6, 0.3);
  outline-offset: 2px;
}

.athlete-main {
  display: grid;
  gap: 4px;
}

.athlete-name {
  font-weight: 700;
}

.athlete-meta,
.athlete-time {
  color: var(--muted);
  font-size: 0.9rem;
}

.athlete-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.chart-panel {
  min-height: 720px;
}

.chart-head {
  align-items: start;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: end;
  max-width: 42%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 0.82rem;
  max-width: 100%;
}

.chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.chart-wrap {
  position: relative;
  width: 100%;
  padding: 10px 12px 12px;
  aspect-ratio: 1200 / 760;
}

svg {
  width: 100%;
  height: 100%;
  display: block;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.axis-title {
  fill: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis-line {
  stroke: var(--line);
  stroke-width: 1.2;
}

.series-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.2;
}

.series-point {
  stroke: #fff;
  stroke-width: 1.8;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 3;
  background: rgba(18, 32, 51, 0.96);
  color: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 18px 40px rgba(18, 32, 51, 0.26);
  transform: translate(14px, -50%);
  opacity: 0;
  transition: opacity 120ms ease;
  max-width: 240px;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

@media (max-width: 980px) {
  .hero {
    flex-direction: column;
    align-items: start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    min-height: 640px;
  }

  .chart-wrap {
    aspect-ratio: 1.15;
  }

  .chips {
    max-width: 100%;
    justify-content: start;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 18px, 1440px);
    padding-top: 16px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-stats {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .athlete-list {
    max-height: 48vh;
  }

  .chart-panel {
    min-height: 540px;
  }

  .chart-wrap {
    aspect-ratio: 0.92;
  }
}
