*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #f97316;
  --pace: #60a5fa;
  --hr: #f87171;
  --elev: #a3e635;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Nav */
.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.nav-logo { color: var(--accent); font-weight: 700; font-size: 16px; text-decoration: none; }
.nav-link { color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--text); }

/* Main */
.main-content { flex: 1; padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }

.page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* Table */
.activities-table-wrap { overflow-x: auto; }

.activities-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.activities-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.activities-table th.num { text-align: right; }

.activities-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #1e1e1e;
  vertical-align: middle;
}

.activities-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.activities-table td.pace { color: var(--pace); }
.activities-table td.date { color: var(--muted); white-space: nowrap; }
.activities-table td.gear { color: var(--muted); }

.activity-row { cursor: pointer; }
.activity-row:hover td { background: var(--surface); }

.activity-name { font-weight: 500; }

/* Badges */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-race { background: #7c2d12; color: #fed7aa; }
.badge-long { background: #1e3a5f; color: #bfdbfe; }
.badge-workout { background: #1a2e1a; color: #bbf7d0; }

/* States */
.loading { color: var(--muted); padding: 40px 0; }
.error { color: var(--hr); padding: 40px 0; }

/* Weekly view */
.weeks { display: flex; flex-direction: column; gap: 2px; }

.week-block {
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.week-current { border-color: #333; }

.week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.week-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.week-total { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Week note */
.week-note {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
  white-space: pre-wrap;
}
.week-note.owner { cursor: pointer; }
.week-note.owner:hover { color: var(--text); background: #161616; }
.week-note.add-note { color: #333; cursor: pointer; }
.week-note.add-note:hover { color: var(--muted); }
.week-note.editing { padding: 0; }
.note-textarea {
  width: 100%;
  background: #161616;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 12px;
  resize: none;
  outline: none;
  display: block;
  overflow: hidden;
  field-sizing: content;
  min-height: calc(1.5em * 2 + 12px);
}

/* Progress bars */
.progress-bars { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; }
.prog-row { display: flex; align-items: center; gap: 8px; }
.prog-label { color: var(--muted); font-size: 10px; width: 80px; flex-shrink: 0; }
.prog-track { flex: 1; height: 4px; background: #222; border-radius: 2px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 2px; transition: width 0.3s ease; }
.prog-value { color: var(--muted); font-size: 10px; width: 80px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Activity rows inside week */
.week-activities { min-height: 200px; }
.week-empty { height: 200px; }

.activity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  border-bottom: 1px solid #141414;
  cursor: pointer;
  font-size: 12px;
}
.activity-row:hover { background: var(--surface); }
.act-date { color: var(--muted); width: 88px; flex-shrink: 0; }
.act-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-dist { width: 56px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.act-pace { width: 72px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.act-hr { width: 56px; text-align: right; flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.pace { color: var(--pace); }

/* Nav owner indicator */
.nav-spacer { flex: 1; }
.nav-owner-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 8px; }
.nav-owner-btn:hover { color: var(--text); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 120px; }
.login-form { display: flex; flex-direction: column; gap: 8px; width: 220px; }
.login-field { display: flex; }
.login-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}
.login-input:focus { border-color: var(--accent); }
.login-input:disabled { opacity: 0.5; }
.login-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  padding: 7px;
  transition: color 0.1s, border-color 0.1s;
}
.login-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.login-btn:disabled { opacity: 0.4; cursor: default; }
.login-error { color: var(--hr); font-size: 11px; padding-top: 2px; }

/* Activity Detail */
.back-link { color: var(--muted); text-decoration: none; font-size: 12px; display: inline-block; margin-bottom: 16px; }
.back-link:hover { color: var(--text); }

.activity-header { margin-bottom: 20px; }
.activity-title { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.activity-date { color: var(--muted); font-size: 12px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 24px;
}
.stat-box {
  background: var(--surface);
  padding: 12px 14px;
}
.stat-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-value { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat-value.pace { color: var(--pace); }
.stat-value.hr { color: var(--hr); }
.stat-value.elev { color: var(--elev); }

/* Charts */
.charts { margin-bottom: 28px; }
.chart-row { margin-bottom: 4px; }
.chart-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.chart-area { background: var(--surface); border-radius: 3px; overflow: hidden; }
.charts-loading { color: var(--muted); font-size: 12px; padding: 20px 0; }
.charts-missing { color: var(--muted); font-size: 12px; padding: 8px 0; }

/* Splits table */
.section-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.splits-section { margin-top: 8px; }
.splits-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.splits-table th { text-align: left; color: var(--muted); font-weight: 400; padding: 4px 10px; border-bottom: 1px solid var(--border); }
.splits-table th.num { text-align: right; }
.splits-table td { padding: 6px 10px; border-bottom: 1px solid #1a1a1a; font-variant-numeric: tabular-nums; }
.splits-table td.num { text-align: right; }
.splits-table td.pace { color: var(--pace); }
.splits-table td.muted { color: var(--muted); }
.split-row.zone-1 td:first-child { border-left: 2px solid #3b82f6; }
.split-row.zone-2 td:first-child { border-left: 2px solid #22c55e; }
.split-row.zone-3 td:first-child { border-left: 2px solid #f59e0b; }
.split-row.zone-4 td:first-child { border-left: 2px solid #ef4444; }
.split-row.zone-5 td:first-child { border-left: 2px solid #a855f7; }
