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

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --surface:   #161b27;
  --card:      #1a2035;
  --border:    #1e2a3d;
  --hover:     #202838;

  --text:      #e2e8f0;
  --muted:     #8892a4;
  --faint:     #4a5568;

  --green:     #10b981;
  --blue:      #3b82f6;
  --amber:     #f59e0b;
  --purple:    #8b5cf6;
  --red:       #ef4444;
  --gray:      #6b7280;

  --radius:    12px;
  --radius-sm: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Nav ────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  user-select: none;
}

.nav-logo {
  width: 22px;
  height: 22px;
  color: var(--green);
  flex-shrink: 0;
}

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

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-family: var(--font);
  cursor: pointer;
  transition: color .15s, background .15s;
  user-select: none;
}

.nav-link:hover  { color: var(--text); background: var(--hover); }
.nav-link.active { color: var(--text); background: var(--border); }

/* ─── Main layout ────────────────────────────────────────────────────────── */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 28px 80px;
}

/* ─── Sections ───────────────────────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

/* ─── Stats grid ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color .15s, transform .15s;
}

.stat-card:hover {
  border-color: var(--faint);
  transform: translateY(-1px);
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 4px;
  letter-spacing: -.02em;
}

.stat-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--faint);
  margin-top: 3px;
}

.accent-green  { color: var(--green); }
.accent-blue   { color: var(--blue); }
.accent-red    { color: var(--red); }
.accent-purple { color: var(--purple); }
.accent-amber  { color: var(--amber); }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-hint {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

/* ─── Charts layout ──────────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-container {
  position: relative;
  height: 260px;
}

/* ─── Filter tabs ────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
}

.filter-tab:hover  { border-color: var(--faint); color: var(--text); }
.filter-tab.active { background: var(--green); border-color: var(--green); color: #fff; }

/* ─── Data table ─────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 14px;
  color: var(--faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.data-table td:first-child { color: var(--text); font-weight: 500; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--hover); }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-run      { background: rgba(16,185,129,.15); color: var(--green); }
.badge-row      { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-strength { background: rgba(245,158,11,.15);  color: var(--amber); }
.badge-swim     { background: rgba(139,92,246,.15);  color: var(--purple); }
.badge-recovery { background: rgba(107,114,128,.15); color: var(--gray); }
.badge-other    { background: rgba(107,114,128,.15); color: var(--gray); }

/* ─── Upload zone ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 20px;
  user-select: none;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--green);
  background: rgba(16,185,129,.04);
}

.upload-icon {
  color: var(--faint);
  margin-bottom: 16px;
  transition: color .2s;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon { color: var(--green); }

.upload-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.upload-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 20px;
}

.btn-upload {
  display: inline-block;
  padding: 8px 22px;
  background: var(--green);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.btn-upload:hover { opacity: .85; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity .15s;
}

.btn-primary:hover { opacity: .85; }

.btn-danger {
  display: inline-block;
  padding: 5px 14px;
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-danger:hover { background: rgba(239,68,68,.08); border-color: var(--red); }

/* ─── Info list ──────────────────────────────────────────────────────────── */
.info-list {
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 2.2;
}

.info-list strong { color: var(--text); }

/* ─── Data info content ──────────────────────────────────────────────────── */
#data-info-content .info-row {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

#data-info-content .info-row strong { color: var(--text); }

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}

.empty-icon {
  font-size: 52px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  transform: translateY(8px);
  opacity: 0;
  transition: transform .3s, opacity .3s;
  z-index: 999;
  max-width: 320px;
}

.toast.show           { transform: translateY(0); opacity: 1; }
.toast-success        { border-left: 3px solid var(--green); }
.toast-error          { border-left: 3px solid var(--red); }
.toast-info           { border-left: 3px solid var(--blue); }

/* ─── Loading spinner (for upload zone) ─────────────────────────────────── */
.upload-zone.loading { pointer-events: none; opacity: .6; }

/* ─── Profile form ───────────────────────────────────────────────────────── */
.profile-form {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.profile-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--faint);
  font-size: 10px;
}

.profile-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 7px 12px;
  width: 140px;
  transition: border-color .15s;
  -moz-appearance: textfield;
}

.profile-input:focus { outline: none; border-color: var(--green); }
.profile-input::-webkit-outer-spin-button,
.profile-input::-webkit-inner-spin-button { -webkit-appearance: none; }

select.profile-input { cursor: pointer; }

/* ─── HR zones ───────────────────────────────────────────────────────────── */
.zones-wrap  { border-top: 1px solid var(--border); padding-top: 12px; }

.zones-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-bottom: 10px;
}

.zones-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.zone-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
}

.zone-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zone-label { font-size: 12px; color: var(--muted); }
.zone-bpm   { font-size: 12px; color: var(--text); font-weight: 600; }

/* ─── Insight card ───────────────────────────────────────────────────────── */
.insight-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.insight-header {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
}

.insight-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insight-line {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.insight-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
  min-width: 68px;
  margin-right: 6px;
}

.insight-advice-line { color: var(--text); }
.insight-tag-advice  { color: var(--amber); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .nav { padding: 0 16px; }
  .nav-brand span { display: none; }
  .main { padding: 16px 16px 60px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 26px; }
}
