:root {
  --navy: #122b42;
  --navy-2: #1b3b57;
  --blue: #2f6b8a;
  --teal: #2a8c82;
  --teal-soft: #dff1ed;
  --purple: #70509a;
  --purple-soft: #eee7f6;
  --gold: #c89532;
  --gold-soft: #fff3d6;
  --red: #b64a43;
  --red-soft: #fce8e6;
  --ink: #17212b;
  --muted: #63717e;
  --line: #dce4ea;
  --surface: #ffffff;
  --bg: #f2f6f8;
  --shadow: 0 18px 45px rgba(18, 43, 66, .08);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select {
  font: inherit;
  touch-action: manipulation;
}

.hero {
  color: white;
  background:
    radial-gradient(circle at 83% 8%, rgba(42, 140, 130, .35), transparent 28%),
    linear-gradient(130deg, var(--navy), #173b57 72%, #18504f);
  padding: 34px clamp(20px, 5vw, 72px);
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 32px;
}

.eyebrow, .label {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
  color: var(--blue);
}

.hero .eyebrow { color: #a9d8d2; }
.hero h1 { margin: 0; font-size: clamp(38px, 6vw, 70px); line-height: .95; letter-spacing: -.045em; }
.hero h1 span { color: #8fd3ca; }
.subtitle { margin: 13px 0 0; color: #d6e4ec; font-size: 16px; }

.sync-card {
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
}

.sync-card strong, .sync-card small { display: block; }
.sync-card small { margin-top: 3px; color: #c9dbe5; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #7de0a4; box-shadow: 0 0 0 6px rgba(125,224,164,.12); }

main { width: min(1480px, calc(100% - 32px)); margin: 28px auto 70px; }

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid rgba(18,43,66,.07);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.top-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.25fr 1fr;
  gap: 18px;
}

.gauge-card, .week-card, .fitness-card, .race-prediction-card, .assessments-card, .baseline-card, .volume-card, .hr-zone-card { padding: 24px; }
.card-heading, .section-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.muted { color: var(--muted); line-height: 1.5; }

.icon-button, .nav-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid var(--line);
  color: var(--navy);
  background: white;
  cursor: pointer;
}
.icon-button:hover, .nav-button:hover { background: var(--teal-soft); border-color: #a9d8d2; }

.gauge-wrap { display: grid; place-items: center; padding: 16px 0 8px; }
.gauge {
  --score: 0deg;
  width: 156px;
  height: 156px;
  padding: 14px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) var(--score), #e6ecef 0);
  transition: background .5s ease;
}
.gauge-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: white;
  display: grid;
  place-content: center;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--line);
}
.gauge-inner strong { font-size: 42px; line-height: .9; color: var(--navy); }
.gauge-inner span { color: var(--muted); font-size: 12px; margin-top: 8px; }

.readiness-trend {
  margin-top: 8px;
  padding: 13px 14px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafb;
}
.trend-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.trend-heading span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.trend-heading strong { font-size: 12px; }
.trend-heading .positive { color: #247365; }
.trend-heading .negative { color: var(--red); }
.trend-heading .neutral { color: var(--muted); }
.readiness-sparkline { height: 82px; margin-top: 3px; }
.readiness-sparkline svg, .training-state-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trend-guide { stroke: #dfe7ea; stroke-width: 1; stroke-dasharray: 3 4; }
.readiness-line { fill: none; stroke: var(--teal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.readiness-placeholder { stroke: #b9cac8; stroke-width: 2; stroke-dasharray: 5 5; }
.readiness-dot { fill: white; stroke: var(--teal); stroke-width: 2.5; }
.trend-date { fill: var(--muted); font-size: 9px; }
.readiness-trend > small { display: block; margin-top: 1px; color: var(--muted); line-height: 1.35; }

.breakdown { display: grid; gap: 8px; margin-top: 12px; }
.breakdown-row { display: grid; grid-template-columns: 1fr 86px 30px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mini-track, .progress-track { height: 7px; background: #e8edf0; border-radius: 999px; overflow: hidden; }
.mini-fill, .progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--teal)); }

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 24px 0 14px;
}
.metric-row div { padding: 16px 12px; background: #f6f9fa; border-radius: 14px; }
.metric-row strong, .metric-row span { display: block; }
.metric-row strong { font-size: 28px; color: var(--navy); }
.metric-row span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.progress-track { height: 10px; }
.progress-fill { width: 0; transition: width .5s ease; }

.week-zone-summary { margin-top: 18px; padding: 14px; border-radius: 14px; background: #f8fafb; border: 1px solid var(--line); }
.week-zone-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.week-zone-heading span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.week-zone-heading strong { color: var(--navy); font-size: 12px; }
.week-zone-bar { display: flex; width: 100%; height: 13px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: #e8edf0; }
.week-zone-segment { min-width: 0; height: 100%; transition: width .45s ease; }
.week-zone-empty { width: 100%; background: repeating-linear-gradient(135deg, #e6ecef, #e6ecef 7px, #f3f6f7 7px, #f3f6f7 14px); }
.week-zone-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.week-zone-legend span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.week-zone-legend i { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; }
.week-zone-legend b { display: block; margin: 2px 0 0 10px; color: var(--navy); font-size: 10px; }
.week-zone-summary > small { display: block; margin-top: 9px; color: var(--muted); font-size: 10px; }

.key-sessions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.key-sessions-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.key-session-list { display: grid; gap: 9px; margin-top: 10px; }
.key-session-item { padding: 11px 12px; border: 1px solid var(--line); border-left: 3px solid var(--teal); border-radius: 12px; background: #fbfcfd; }
.key-session-item.completed { border-left-color: #43a78f; background: #f3faf8; }
.key-session-item.pending { border-left-color: #d1a74b; background: #fffbf1; }
.key-session-item.missed { border-left-color: var(--red); background: #fff8f7; }
.key-session-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.key-session-topline span { color: var(--muted); font-size: 11px; }
.key-session-topline em { padding: 3px 7px; border-radius: 999px; color: #315b75; background: #eaf2f8; font-size: 9px; font-style: normal; font-weight: 800; }
.key-session-item.completed em { color: #226057; background: var(--teal-soft); }
.key-session-item.pending em { color: #76571d; background: var(--gold-soft); }
.key-session-item.missed em { color: #8d332d; background: var(--red-soft); }
.key-session-item strong, .key-session-item small { display: block; }
.key-session-item strong { margin-top: 5px; color: var(--navy); font-size: 13px; }
.key-session-item small { margin-top: 3px; color: var(--muted); line-height: 1.35; }

.training-state-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.training-state-chip { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; color: var(--muted); background: #edf1f3; font-size: 10px; font-weight: 800; }
.training-state-chip.building { color: #226057; background: var(--teal-soft); }
.training-state-chip.risk { color: #8d332d; background: var(--red-soft); }
.training-state-chip.balanced { color: #54616c; background: #edf1f3; }
.training-state-chip.fresh { color: #315b75; background: #eaf2f8; }
.training-state-chip.transition { color: #76571d; background: var(--gold-soft); }
.training-state-chart { height: 166px; margin: 13px 0 10px; }
.zone-transition { fill: #fff3d6; }
.zone-fresh { fill: #e5f0f8; }
.zone-balanced { fill: #edf1f3; }
.zone-building { fill: #dff1ed; }
.zone-risk { fill: #fce8e6; }
.state-zone-label { fill: var(--muted); font-size: 9px; }
.state-zero { stroke: #9aa7b0; stroke-width: 1; stroke-dasharray: 4 4; }
.state-line { fill: none; stroke: var(--navy); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.state-dot { fill: white; stroke: var(--navy); stroke-width: 3; }
.state-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.state-metrics div { padding: 10px; border-radius: 11px; background: #f6f9fa; }
.state-metrics span, .state-metrics strong { display: block; }
.state-metrics span { color: var(--muted); font-size: 10px; line-height: 1.25; }
.state-metrics strong { margin-top: 4px; color: var(--navy); font-size: 17px; }
.fitness-card > .muted { margin-bottom: 0; font-size: 12px; }

.race-prediction-card { grid-column: 1 / -1; }
.prediction-heading { align-items: center; }
.prediction-subtitle { margin: 6px 0 0; font-size: 12px; }
.prediction-confidence { display: flex; align-items: center; gap: 9px; }
.prediction-confidence > span {
  padding: 6px 10px;
  border-radius: 999px;
  color: #315b75;
  background: #eaf2f8;
  font-size: 10px;
  font-weight: 800;
}
.prediction-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.prediction-item { padding: 15px 16px 12px; border: 1px solid var(--line); border-radius: 15px; background: #fbfcfd; }
.prediction-topline { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.prediction-topline span, .prediction-topline strong { display: block; }
.prediction-topline span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.prediction-topline strong { margin-top: 4px; color: var(--navy); font-size: 27px; line-height: 1; }
.prediction-topline em { color: var(--teal); font-size: 11px; font-style: normal; font-weight: 800; white-space: nowrap; }
.prediction-chart { height: 76px; margin-top: 7px; }
.prediction-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.prediction-line { fill: none; stroke: var(--purple); stroke-width: 2.7; stroke-linecap: round; stroke-linejoin: round; }
.prediction-placeholder { stroke: #c7b9d7; stroke-width: 2; stroke-dasharray: 5 5; }
.prediction-dot { fill: white; stroke: var(--purple); stroke-width: 2.3; }
.prediction-item > small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; }
.prediction-item > small.improving { color: #247365; }
.prediction-item > small.regressing { color: var(--red); }
.prediction-model-note { margin: 14px 0 0; font-size: 11px; }

.hr-zone-card { margin-top: 18px; }
.zone-calibration { min-width: 116px; padding: 10px 13px; border-radius: 13px; background: #f6f9fa; text-align: right; }
.zone-calibration strong, .zone-calibration span { display: block; }
.zone-calibration strong { color: var(--navy); font-size: 18px; }
.zone-calibration span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.hr-zone-overview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.hr-zone-item {
  position: relative;
  min-height: 96px;
  padding: 14px 13px 12px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}
.hr-zone-item::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--zone-color); }
.hr-zone-number { min-width: 30px; color: var(--navy); font-size: 20px; line-height: 1; font-weight: 850; }
.hr-zone-item strong, .hr-zone-item span, .hr-zone-item small { display: block; }
.hr-zone-item strong { color: var(--navy); font-size: 14px; }
.hr-zone-item span { margin-top: 3px; color: var(--ink); font-size: 12px; }
.hr-zone-item small { grid-column: 2; color: var(--muted); font-size: 10px; }
.zone-note { margin: 13px 0 0; font-size: 12px; }

.volume-card { margin-top: 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 17px; height: 4px; border-radius: 9px; display: inline-block; }
.legend .core { background: var(--blue); }
.legend .stretch { background: var(--purple); }
.legend .actual { background: var(--teal); }
.volume-chart { min-height: 240px; margin-top: 18px; overflow-x: auto; }
.volume-chart svg { width: 100%; min-width: 800px; height: 240px; }
.volume-dot { stroke-width: 2.3; }
.volume-dot.core { fill: white; stroke: var(--blue); }
.volume-dot.stretch { fill: white; stroke: var(--purple); }
.volume-dot.actual { fill: white; stroke: var(--teal); }

.chart-point {
  cursor: crosshair;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .12s ease, stroke-width .12s ease;
}
.chart-point:hover, .chart-point:focus {
  transform: scale(1.65);
  stroke-width: 3.2;
  outline: none;
}
.chart-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(310px, calc(100vw - 20px));
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px;
  color: white;
  background: rgba(18, 43, 66, .96);
  box-shadow: 0 10px 26px rgba(18, 43, 66, .24);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  pointer-events: none;
}
.chart-tooltip[hidden] { display: none; }

.schedule-section { margin-top: 34px; }
.schedule-heading { align-items: end; }
.week-controls { display: flex; align-items: center; gap: 8px; }
.week-controls select { height: 38px; border-radius: 11px; border: 1px solid var(--line); color: var(--navy); background: white; padding: 0 34px 0 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.filter { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 8px 13px; color: var(--muted); cursor: pointer; }
.filter.active { color: white; background: var(--navy); border-color: var(--navy); }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(170px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.day-card {
  min-height: 270px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease;
}
.day-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.day-card.key { border-top: 4px solid var(--teal); }
.day-card.add-on { border-top: 4px solid var(--purple); }
.day-card.missed { border-color: #e5aaa6; background: #fffafa; }
.day-card.hidden { display: none; }
.day-top { display: flex; justify-content: space-between; gap: 10px; }
.day-name { font-size: 12px; font-weight: 800; color: var(--navy); text-transform: uppercase; letter-spacing: .08em; }
.day-date { font-size: 12px; color: var(--muted); }
.status {
  margin: 13px 0 10px;
  width: max-content;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.status.upcoming { color: #315b75; background: var(--pale-blue, #eaf2f8); }
.status.completed { color: #226057; background: var(--teal-soft); }
.status.pending { color: #76571d; background: var(--gold-soft); }
.status.missed { color: #8d332d; background: var(--red-soft); }
.status.rest { color: var(--muted); background: #edf1f3; }
.status.partial { color: #76571d; background: var(--gold-soft); }
.planned-title { margin: 0; font-size: 16px; color: var(--navy); line-height: 1.25; }
.planned-meta { margin: 7px 0; color: var(--teal); font-weight: 750; font-size: 12px; }
.planned-detail { color: var(--muted); font-size: 12px; line-height: 1.45; }
.actual-block { margin-top: auto; padding-top: 13px; border-top: 1px solid var(--line); }
.actual-block strong { font-size: 13px; color: var(--navy); }
.swap-note { margin-top: 6px; color: #226057; font-size: 10px; font-weight: 750; line-height: 1.35; }
.actual-metrics { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.assessment-toggle { margin-top: 9px; padding: 0; border: 0; background: none; color: var(--blue); font-size: 12px; font-weight: 750; cursor: pointer; text-align: left; }
.inline-assessment { display: none; margin-top: 10px; padding: 11px; background: #f6f9fa; border-radius: 11px; color: #44515d; font-size: 11px; line-height: 1.45; }
.inline-assessment.open { display: block; }

.lower-grid { margin-top: 28px; display: grid; grid-template-columns: 1.65fr .8fr; gap: 18px; }
.assessment-list { margin-top: 18px; display: grid; gap: 12px; }
.assessment-item { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.assessment-summary { width: 100%; border: 0; background: white; display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; padding: 15px; text-align: left; cursor: pointer; }
.assessment-summary:hover { background: #f8fafb; }
.assessment-summary time { color: var(--muted); font-size: 12px; }
.assessment-summary strong { color: var(--navy); }
.verdict { padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #226057; background: var(--teal-soft); }
.assessment-body { display: none; border-top: 1px solid var(--line); padding: 16px; background: #fbfcfd; }
.assessment-body.open { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.assessment-body div { padding: 12px; background: white; border-radius: 11px; border: 1px solid #e6ecef; }
.assessment-body span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 800; }
.assessment-body p { margin: 5px 0 0; font-size: 12px; line-height: 1.5; }
.baseline-list { margin-top: 18px; display: grid; gap: 10px; }
.baseline-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.baseline-row:last-child { border-bottom: 0; }
.baseline-row span, .baseline-row strong { display: block; }
.baseline-row span { color: var(--muted); font-size: 11px; }
.baseline-row strong { margin-top: 4px; color: var(--navy); font-size: 14px; }

dialog { width: min(560px, calc(100% - 32px)); border: 0; border-radius: 20px; padding: 28px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(9, 26, 39, .55); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 12px; right: 14px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--muted); }

@media (max-width: 1050px) {
  .top-grid { grid-template-columns: 1fr 1fr; }
  .fitness-card { grid-column: 1 / -1; }
  .prediction-grid { grid-template-columns: 1fr 1fr; }
  .hr-zone-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calendar { grid-template-columns: repeat(7, 230px); }
}

@media (max-width: 720px) {
  .hero { align-items: start; flex-direction: column; }
  .sync-card { width: 100%; }
  main { width: min(100% - 20px, 1480px); }
  .top-grid, .lower-grid { grid-template-columns: 1fr; }
  .fitness-card { grid-column: auto; }
  .section-heading.schedule-heading { align-items: start; flex-direction: column; }
  .week-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
  }
  .week-controls .nav-button {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }
  .week-controls select {
    width: 100%;
    min-width: 0;
    height: 44px;
    font-size: 16px;
  }
  .metric-row { grid-template-columns: 1fr; }
  .training-state-heading { align-items: start; flex-direction: column; }
  .prediction-heading { align-items: start; }
  .prediction-grid { grid-template-columns: 1fr; }
  .state-metrics { grid-template-columns: 1fr; }
  .hr-zone-overview { grid-template-columns: 1fr 1fr; }
  .hr-zone-card .section-heading { align-items: start; }
  .zone-calibration { min-width: 105px; }
  .assessment-summary { grid-template-columns: 76px 1fr; }
  .assessment-summary .verdict { grid-column: 2; width: max-content; }
  .assessment-body.open { grid-template-columns: 1fr; }
  .calendar {
    grid-template-columns: repeat(7, minmax(280px, calc(100vw - 40px)));
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pinch-zoom;
    scrollbar-width: none;
  }
  .calendar::-webkit-scrollbar { display: none; }
  .day-card { scroll-snap-align: start; }
  .volume-chart {
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pinch-zoom;
  }
}
