:root {
  --ink: #eeeeee;
  --muted: #b3b3b3;
  --line: #505050;
  --paper: #222222;
  --panel: #2e2e2e;
  --accent: #8c8c8c;
  --accent-dark: #707070;
  --ahead: #63c174;
  --behind: #ef6b6b;
  --goal-met: #3f8f5f;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui;
}

a { color: var(--ink); }

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
}

h1 {
  margin: 24px 0 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.96;
  letter-spacing: 0;
  font-weight: 400;
}

.intro {
  max-width: 520px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.status {
  min-height: 1.3em;
  margin: 12px 0;
  color: var(--muted);
  font: 0.9rem/1.4 system-ui;
}

.status.error { color: var(--behind); }
.status.success { color: var(--ahead); }

input, select, button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: 1rem system-ui;
}

input, select {
  width: 150px;
  padding: 8px 10px;
  color: var(--ink);
  background: #303030;
}

input:focus, select:focus {
  outline: 3px solid rgba(220, 220, 220, 0.25);
  border-color: var(--accent);
}

button {
  padding: 8px 16px;
  color: #161616;
  background: var(--accent);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.6; cursor: wait; }

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  min-height: 52px;
}

.site-brand {
  font-weight: 700;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.site-nav a {
  padding: 6px 10px;
  border-radius: 3px;
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] {
  color: var(--ink);
  background: #3a3a3a;
}

.site-account {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

button.link-button {
  min-height: 0;
  padding: 4px 8px;
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
  font-weight: 400;
  font-size: 0.9rem;
}

button.link-button:hover { background: #3a3a3a; }

h2 {
  margin: 32px 0 12px;
  font-size: 1.3rem;
  font-weight: 400;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.card {
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card .total {
  margin: 6px 0 2px;
  font-size: 2.2rem;
  line-height: 1.1;
}

.card .range { color: var(--muted); font-size: 0.9rem; }

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  color: var(--ink);
}

.split-label { color: var(--muted); }

.goal { margin-top: 14px; }

.sport-label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sport-total {
  margin: 0 0 6px;
  font-size: 2.2rem;
  line-height: 1.1;
}

.goal-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.goal-bar {
  display: block;
  width: 100%;
  height: 10px;
  margin: 6px 0 4px;
  border: 0;
  border-radius: 5px;
  background: #3f3f3f;
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
}

.goal-bar::-webkit-progress-bar { background: #3f3f3f; }
.goal-bar::-webkit-progress-value { background: var(--accent); }
.goal-bar::-moz-progress-bar { background: var(--accent); }

.goal-pace { font-size: 0.9rem; }
.goal-pace.ahead { color: var(--ahead); }
.goal-pace.behind { color: var(--behind); }

.goal-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.workouts {
  width: 100%;
  border-collapse: collapse;
}

.workouts th,
.workouts td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.workouts th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.workouts .num { text-align: right; white-space: nowrap; }

@media (max-width: 700px) {
  .workouts thead { display: none; }

  .workouts,
  .workouts tbody,
  .workouts tr,
  .workouts td { display: block; }

  .workouts tr {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 3px;
  }

  .workouts td,
  .workouts .num {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    text-align: right;
  }

  .workouts td::before {
    content: attr(data-label);
    color: var(--muted);
    text-align: left;
  }
}

.goals-page .controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.goals-page .year-picker {
  width: fit-content;
  margin: 16px 0 10px;
}

.goals-page .year-picker .status {
  margin: 0;
  min-height: 0;
  align-self: center;
}

.goals-page .goal-controls { margin: 18px 0 32px; }

.goals-page label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font: 700 0.72rem/1.1 system-ui;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.goals-page .table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.goals-page table.progress {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.progress th,
.progress td {
  padding: 4px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.progress th {
  color: var(--muted);
  background: #3a3a3a;
  font: 700 0.72rem/1.2 system-ui;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.progress th:nth-child(-n+2),
.progress td:nth-child(-n+2) { text-align: left; }

.progress tbody tr:hover { background: #353535; }
.progress .ahead { color: var(--ahead); font-weight: 700; }
.progress .behind { color: var(--behind); font-weight: 700; }
.progress .empty { color: #8f8f8f; }
.progress tbody td.goal-met,
.progress tbody tr:hover td.goal-met { color: #f1fff4; background: var(--goal-met); }

@media (max-width: 760px) {
  .goals-page .controls { align-items: stretch; }
  .goals-page label,
  .goals-page input,
  .goals-page select,
  .goals-page button { width: 100%; }
  .goals-page .year-picker { width: 100%; }
  .goals-page .year-picker .status { width: 100%; }
}
