/* ============================================================
   Garmin Dashboard — design system
   Light is the default token set; [data-theme="dark"] overrides.
   ============================================================ */
:root {
  /* Brand */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-border: #c7dafe;
  --on-accent: #ffffff;

  /* Surfaces */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --elevated: #ffffff;

  /* Lines & text */
  --border: #e4e8ef;
  --border-strong: #d3d9e3;
  --text: #0f172a;
  --text-muted: #5a6678;
  --text-subtle: #8a94a6;

  /* Semantic */
  --good: #059669; --good-soft: #e7f6ef;
  --warn: #b45309; --warn-soft: #fbf1e3;
  --bad: #dc2626;  --bad-soft: #fdecec;

  /* Chart palette (legible on both themes) */
  --c-rhr: #ef4444; --c-hrv: #06b6d4; --c-sleep: #3b82f6;
  --c-stress: #f59e0b; --c-ready: #10b981; --c-steps: #8b5cf6; --c-load: #6366f1;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 2px 6px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.12);

  /* Shape */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --sidebar-w: 248px;
}

[data-theme="dark"] {
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #16243f;
  --accent-border: #294066;
  --on-accent: #ffffff;

  --bg: #0b0f17;
  --surface: #131927;
  --surface-2: #1a2130;
  --elevated: #1c2434;

  --border: #263144;
  --border-strong: #344256;
  --text: #e8edf5;
  --text-muted: #9aa6b8;
  --text-subtle: #6b7686;

  --good: #34d399; --good-soft: #11271f;
  --warn: #fbbf24; --warn-soft: #2a2310;
  --bad: #f87171;  --bad-soft: #2c1717;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,.35), 0 12px 32px rgba(0,0,0,.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--text-muted); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark { font-size: 22px; }
.brand-name { font-size: 17px; font-weight: 500; letter-spacing: -.02em; }
.brand-name strong { font-weight: 700; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: none; background: none;
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  border-radius: var(--r-md); cursor: pointer; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 20px; height: 20px; flex-shrink: 0; }
.ico { fill: currentColor; }

.sidebar-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.conn {
  font-size: 12px; color: var(--text-muted); padding: 8px 10px;
  background: var(--surface-2); border-radius: var(--r-sm); line-height: 1.35;
  display: flex; align-items: center; gap: 7px;
}
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-subtle); flex-shrink: 0; }
.conn.ok::before { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.conn.err::before { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.theme-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); border-radius: var(--r-md); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .ico-sun, .theme-toggle .ico-moon { width: 18px; height: 18px; }
.theme-toggle .ico-moon { display: none; }
[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: block; }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 600; }
.panels { padding: 28px 32px 56px; max-width: 1180px; width: 100%; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); margin: 30px 0 14px; font-weight: 600; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.cards .card, .metric-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); transition: box-shadow .18s, transform .18s, border-color .18s;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.metric-card .label { font-size: 11px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.metric-card.st-good { border-left: 3px solid var(--good); }
.metric-card.st-warn { border-left: 3px solid var(--warn); }
.metric-card.st-bad { border-left: 3px solid var(--bad); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.good { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.metric-card .value { font-size: 27px; font-weight: 700; margin-top: 7px; letter-spacing: -.02em; }
.metric-card .value small { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.metric-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Today card ---------- */
.today { background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--accent-border); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm); }
.today.loading-today { display: flex; justify-content: center; align-items: center; min-height: 90px; }
.today-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.today-label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.today-ready { font-size: 13px; color: var(--text-muted); }
.today-ready b { font-size: 16px; color: var(--text); }
.today-rec { font-size: 16px; font-weight: 600; line-height: 1.45; color: var(--text); }
.today-planned { margin-top: 12px; font-size: 13px; }
.planned-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 5px 12px; font-weight: 600; }
.today-planned a { color: var(--accent); text-decoration: none; }
.today-alerts { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ---------- Flags ---------- */
.flags { display: flex; flex-direction: column; gap: 8px; margin: 18px 0; }
.flag { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.flag .metric { font-weight: 600; min-width: 112px; }
.flag.good { border-left: 3px solid var(--good); }
.flag.warn { border-left: 3px solid var(--warn); }
.flag.bad  { border-left: 3px solid var(--bad); }
.flag.info { border-left: 3px solid var(--text-subtle); }

/* ---------- Buttons ---------- */
.btn {
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent;
  padding: 9px 16px; border-radius: var(--r-md); font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Toolbar / chips / segmented ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 18px 0 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  padding: 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s; text-transform: capitalize;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg { border: none; background: none; color: var(--text-muted); font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-family: inherit; transition: all .15s; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- Activity lists ---------- */
.recent-list, .workout-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .1s, box-shadow .15s;
}
.activity-item:hover { border-color: var(--accent-border); transform: translateX(2px); box-shadow: var(--shadow-md); }
.activity-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.activity-item .icon { font-size: 22px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border-radius: var(--r-sm); flex-shrink: 0; }
.activity-item .info { flex: 1; min-width: 0; }
.activity-item .info .name { font-weight: 600; font-size: 14px; }
.activity-item .info .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }
.activity-item .stats { text-align: right; font-size: 13px; white-space: nowrap; color: var(--text-muted); }
.activity-item .stats b { font-size: 15px; color: var(--text); }

/* ---------- Workout detail ---------- */
.workouts-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.workout-detail { padding: 22px; position: sticky; top: 92px; }
.detail-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px,1fr)); gap: 14px; margin: 16px 0; }
.detail-stat .label { font-size: 11px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.detail-stat .value { font-size: 18px; font-weight: 700; margin-top: 3px; }
.detail-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); margin: 20px 0 10px; font-weight: 600; }

.zones { display: flex; flex-direction: column; gap: 7px; }
.zone-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.zone-lab { color: var(--text-muted); }
.zone-bar { background: var(--surface-2); border-radius: var(--r-sm); height: 16px; overflow: hidden; }
.zone-fill { height: 100%; border-radius: var(--r-sm); }
.zone-val { color: var(--text-muted); white-space: nowrap; }
.str-totals { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; font-size: 13px; color: var(--text-muted); }
.str-totals b { color: var(--text); font-size: 15px; }
.str-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.str-table th { text-align: right; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-subtle); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.str-table th:first-child, .str-table td:first-child { text-align: left; }
.str-table td { padding: 7px 6px; border-bottom: 1px solid var(--border); text-align: right; }
.str-table tr:last-child td { border-bottom: none; }
.str-table .ex-cell { font-weight: 600; }

.splits { display: flex; align-items: flex-end; gap: 4px; height: 84px; padding-top: 6px; overflow-x: auto; }
.split-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.split-bar { width: 14px; background: linear-gradient(180deg, var(--accent), var(--accent-hover)); border-radius: 4px 4px 0 0; }
.split-lab { font-size: 10px; color: var(--text-subtle); }

/* ---------- Claude panel (top of Health) ---------- */
.claude-panel { background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--r-lg); padding: 16px 20px; margin-bottom: 22px; }
.claude-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.claude-title { font-size: 14px; font-weight: 700; color: var(--accent); }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.claude-panel .commentary { background: transparent; border: none; box-shadow: none; padding: 4px 0 0; margin: 0; }

/* ---------- Markdown / commentary ---------- */
.commentary, .insight-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 18px 22px; margin: 16px 0; font-size: 14px; box-shadow: var(--shadow-sm); }
.commentary:empty, .insight-box:empty { display: none; }
.commentary h1, .commentary h2, .commentary h3 { font-size: 15px; margin: 16px 0 6px; }
.commentary strong { color: var(--accent); font-weight: 600; }
.commentary ul { margin: 6px 0; padding-left: 20px; }
.commentary li { margin: 3px 0; }
.commentary code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; font-size: 13px; }

/* ---------- Charts ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px,1fr)); gap: 14px; margin-bottom: 24px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px 8px; box-shadow: var(--shadow-sm); transition: box-shadow .18s, transform .18s; }
.chart-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.chart-title { font-size: 11px; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.chart-now { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.chart-now small { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.chart-now em { font-size: 12px; font-style: normal; margin-left: 6px; color: var(--accent); font-weight: 600; }
#health-charts { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.axis-chart { display: block; }
.ax-grid { stroke: var(--border); stroke-width: 1; opacity: .6; }
.ax-y, .ax-x { fill: var(--text-subtle); font-size: 9px; font-family: inherit; }
.chart-card.big { padding-bottom: 12px; }

/* ---------- Sleep & recovery ---------- */
.sleep-bar { display: flex; height: 22px; border-radius: var(--r-sm); overflow: hidden; margin: 10px 0 10px; background: var(--surface-2); }
.sleep-seg { height: 100%; }
.sleep-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted); }
.sleep-key { display: inline-flex; align-items: center; gap: 5px; }
.sleep-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* ---------- Training load ---------- */
.load-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 14px; }
.metric-card.acwr.good { border-left: 3px solid var(--good); }
.metric-card.acwr.warn { border-left: 3px solid var(--warn); }
.metric-card.acwr.info { border-left: 3px solid var(--text-subtle); }
.vol-head { font-size: 13px; margin: 20px 0 12px; font-weight: 600; }
.vol-list { display: flex; flex-direction: column; gap: 9px; }
.vol-row { display: grid; grid-template-columns: 132px 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.vol-label { color: var(--text-muted); text-transform: capitalize; }
.vol-bar { background: var(--surface-2); border-radius: var(--r-sm); height: 16px; overflow: hidden; }
.vol-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--c-steps)); border-radius: var(--r-sm); }
.vol-val { color: var(--text-muted); white-space: nowrap; }

/* ---------- Trend grid ---------- */
.trend { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px,1fr)); gap: 10px; }
.trend-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 13px; font-size: 12px; box-shadow: var(--shadow-sm); }
.trend-day .date { color: var(--text-subtle); margin-bottom: 9px; font-weight: 600; }
.trend-day .row { display: flex; justify-content: space-between; padding: 2px 0; }
.trend-day .row span:first-child { color: var(--text-muted); }
.trend-day .row span:last-child { font-weight: 600; }

/* ---------- Plan ---------- */
.plan-controls { display: flex; gap: 12px; padding: 16px; align-items: center; flex-wrap: wrap; }
.plan-controls input[type=text] { flex: 1; min-width: 220px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 11px 14px; border-radius: var(--r-md); font-size: 14px; font-family: inherit; }
.plan-controls input[type=text]:focus { border-color: var(--accent); }
.race-label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.race-label input[type=date] { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 10px; border-radius: var(--r-md); font-family: inherit; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 14px; margin-top: 18px; }
.plan-summary { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 22px; box-shadow: var(--shadow-sm); }
.phase-badge { display: inline-block; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: var(--r-pill); text-transform: capitalize; margin-bottom: 10px; letter-spacing: .02em; }
.plan-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); }
.plan-day .day-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.pd-row { display: flex; gap: 6px; margin: 8px 0; }
.plan-day select, .pd-title, .pd-details { width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-sm); padding: 7px 9px; font-size: 13px; font-family: inherit; }
.plan-day select { text-transform: capitalize; cursor: pointer; }
.plan-day select:focus, .pd-title:focus, .pd-details:focus { border-color: var(--accent); }
.pd-title { font-weight: 600; margin-bottom: 6px; }
.pd-details { resize: vertical; }
.exercises { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.ex-head { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-subtle); font-weight: 600; margin-bottom: 6px; }
.ex-row { display: flex; align-items: center; gap: 4px; margin-bottom: 5px; }
.ex-name { flex: 1 1 100%; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-sm); padding: 5px 7px; font-size: 12px; font-family: inherit; }
.ex-num { width: 38px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-sm); padding: 5px 3px; font-size: 12px; text-align: center; font-family: inherit; }
.ex-x, .ex-unit { color: var(--text-subtle); font-size: 11px; }
.ex-row { flex-wrap: wrap; }
.ex-del { background: none; border: none; color: var(--text-subtle); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 4px; }
.ex-del:hover { color: var(--bad); background: var(--bad-soft); }
.ex-add { background: none; border: 1px dashed var(--border); color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 5px 10px; border-radius: var(--r-sm); width: 100%; margin-top: 2px; font-family: inherit; }
.ex-add:hover { border-color: var(--accent); color: var(--accent); }

.pd-dur { font-size: 12px; color: var(--accent); margin-top: 10px; display: flex; align-items: center; gap: 6px; }
.pd-target { margin-top: 8px; display: inline-block; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: var(--r-pill); padding: 3px 10px; }
.pd-dur input { width: 64px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-sm); padding: 5px 7px; font-family: inherit; }

.push-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 20px; box-shadow: var(--shadow-sm); }
.push-bar label { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.push-bar input[type=date] { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: var(--r-sm); font-family: inherit; }
.replace-label { white-space: nowrap; }

/* ---------- Loading ---------- */
.loading { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; z-index: 100; }
.loading.hidden { display: none; }
.loading span { color: var(--text-muted); font-size: 14px; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.asof { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); padding: 8px 14px; border-radius: var(--r-md); margin-bottom: 16px; display: none; }
.asof.show { display: block; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast { background: var(--elevated); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md); padding: 12px 16px; font-size: 13.5px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .22s, transform .22s; }
.toast.show { opacity: 1; transform: none; }
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
@media (max-width: 720px) { .toasts { left: 14px; right: 14px; max-width: none; bottom: 14px; } }

/* ---------- Skeletons ---------- */
.metric-card.skeleton { pointer-events: none; }
.sk-line { height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; margin: 6px 0; }
.sk-line.big { height: 22px; width: 60%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.empty { text-align: center; color: var(--text-muted); padding: 44px 20px; grid-column: 1 / -1; width: 100%; }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

/* ---------- Sidebar footer (profile / logout / theme) ---------- */
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile-chip { font-size: 12px; color: var(--text-muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.foot-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); border-radius: var(--r-md); cursor: pointer; padding: 8px 10px; font-size: 14px; line-height: 1; }
.foot-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Overlays (auth / garmin / admin) ---------- */
.overlay { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 75%, #000); backdrop-filter: blur(6px); }
.overlay.hidden { display: none; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.auth-card.wide { max-width: 460px; }
.auth-brand { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.auth-brand .brand-mark { font-size: 22px; }
.auth-card h2 { font-size: 20px; }
.auth-card h3 { font-size: 14px; margin-top: 8px; }
.auth-card input { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--r-md); padding: 11px 13px; font-size: 14px; font-family: inherit; width: 100%; }
.auth-card input:focus { border-color: var(--accent); }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn { width: 100%; padding: 11px; }
.form-err { font-size: 13px; color: var(--bad); min-height: 1em; }
.link-btn { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 4px; align-self: center; }
.link-btn:hover { color: var(--text); }
.auth-head { display: flex; align-items: center; justify-content: space-between; }
.x { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.x:hover { color: var(--text); }
.admin-h { color: var(--text-subtle); text-transform: uppercase; letter-spacing: .05em; font-size: 11px; }
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; font-size: 14px; }
.badge-admin { font-size: 10px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); padding: 1px 7px; border-radius: var(--r-pill); font-weight: 700; text-transform: uppercase; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .workouts-layout { grid-template-columns: 1fr; }
  .workout-detail { position: static; }
}
@media (max-width: 720px) {
  :root { --sidebar-w: 100%; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 20; flex-direction: row; align-items: center; padding: 10px 14px; gap: 8px; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand-name { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 2px; }
  .nav-item span { display: none; }
  .nav-item { padding: 10px; }
  .sidebar-foot { flex-direction: row; border-top: none; padding-top: 0; }
  .conn { display: none; }
  .topbar { padding: 16px 18px; }
  .panels { padding: 18px; }
  /* Denser, dashboard-style metric grid on phones */
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-card { padding: 13px 14px; }
  .metric-card .value { font-size: 23px; }
  .load-grid { grid-template-columns: 1fr; }
  .workout-detail { position: static; }
}
