/* ===== Fitness Tracker — theme-aware, responsive, dependency-free ===== */
:root {
  --bg: #0b1120;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #16223f 0%, transparent 60%), radial-gradient(900px 500px at -10% 0%, #10203a 0%, transparent 55%);
  --surface: #121a2e;
  --surface-2: #1a2540;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e9eef8;
  --muted: #94a3b8;
  --track: rgba(148, 163, 184, 0.16);
  --cell-border: rgba(148, 163, 184, 0.22);
  --accent: #38bdf8;
  --good: #22c55e;
  --bad: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
}
:root[data-theme="light"] {
  --bg: #eef2f9;
  --bg-grad: radial-gradient(1000px 500px at 85% -10%, #dbe7ff 0%, transparent 60%), radial-gradient(800px 450px at -10% 0%, #e6eefc 0%, transparent 55%);
  --surface: #ffffff;
  --surface-2: #f1f5fc;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --muted: #5c6b82;
  --track: rgba(15, 23, 42, 0.08);
  --cell-border: rgba(15, 23, 42, 0.14);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; min-height: 100vh; }
.muted { color: var(--muted); }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.88em; }
a { color: var(--accent); }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; padding: 14px 0 8px; background: linear-gradient(var(--bg) 70%, transparent); backdrop-filter: blur(6px); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3)); }
.brand h1 { font-size: 20px; }
.brand p { margin: 2px 0 0; font-size: 13px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---- layout ---- */
.view { padding-top: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.section-title { font-size: 16px; margin: 6px 2px; display: flex; align-items: center; gap: 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 16px 18px 0; }
.card-title { font-size: 15px; }
.card-sub { font-size: 13px; }
.card-body { padding: 16px 18px 18px; }

/* ---- hero ---- */
.hero { background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.hero-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.hero-title { font-size: 22px; }
.hero-progress { text-align: right; }
.hero-days strong { font-size: 20px; }
.progress-track { margin-top: 14px; height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #38bdf8, #a855f7, #fb7185); border-radius: 999px; transition: width 0.4s; }

/* ---- people grid ---- */
.people-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.person-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent); }
.person-head h3 { font-size: 17px; }
.pdot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, transparent); flex: 0 0 auto; }
.tag { font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px; }
.tag.watch { color: var(--accent); }

.ring-row { display: flex; gap: 12px; justify-content: space-around; flex-wrap: wrap; }
.ring-wrap { text-align: center; max-width: 190px; }
.ring-wrap .ring { width: 128px; height: 128px; }
.ring-caption { font-size: 12px; margin-top: 4px; }

/* ---- tiles ---- */
.tiles { display: grid; gap: 10px; margin-top: 16px; }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; }
.tile-value { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.tile-unit { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }
.tile-sub { font-size: 11px; }

/* ---- vitals mini ---- */
.vital-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.vital-mini { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.vital-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.vital-value { font-size: 18px; font-weight: 700; }
.vital-sub { font-size: 11px; }
.vital-spark { width: 90px; height: 34px; flex: 0 0 auto; }
.vital-spark .spark { width: 100%; height: 100%; }

/* ---- calendars ---- */
.cal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.mini-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.chart-box { width: 100%; overflow-x: auto; }
.calendar { max-width: 260px; height: auto; }

/* ---- charts (shared) ---- */
.chart { width: 100%; height: auto; display: block; }
.chart-empty { fill: var(--muted); font-size: 13px; }
.grid { stroke: var(--border); stroke-width: 1; }
.tick-label { fill: var(--muted); font-size: 10px; }
.legend-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.bar-value { fill: var(--text); font-size: 11px; font-weight: 700; }
.target-line { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.8; }
.target-label { fill: var(--good); font-size: 10px; font-weight: 600; opacity: 0.9; }
.ring-main { font-size: 26px; font-weight: 800; }
.ring-sub { fill: var(--muted); font-size: 12px; font-weight: 600; }
.cal-dow { fill: var(--muted); font-size: 10px; font-weight: 600; }
.cal-num { font-size: 11px; font-weight: 600; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- log / forms ---- */
.log-controls { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
input, select { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; }
input[type="color"] { padding: 4px; height: 40px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field-hint { font-size: 11px; }
.field-hint.watch, .tag.watch { color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 8px 13px; border-radius: 999px; font-weight: 600; cursor: pointer; }
.seg-btn.active { color: var(--text); border-color: var(--accent, var(--border-strong)); background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }

.toggle-group { display: flex; gap: 10px; }
.toggle { flex: 1; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 14px; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; font-size: 15px; }
.toggle.yes.on { background: color-mix(in srgb, var(--good) 22%, transparent); border-color: var(--good); color: var(--text); }
.toggle.no.on { background: color-mix(in srgb, var(--bad) 20%, transparent); border-color: var(--bad); color: var(--text); }

.weights-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.weight-row { display: grid; grid-template-columns: 2fr 0.8fr 0.8fr 0.9fr auto; gap: 8px; align-items: center; }
.row-del { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; width: 34px; height: 38px; cursor: pointer; font-size: 18px; }
.row-del:hover { color: var(--bad); border-color: var(--bad); }
.compute { margin-top: 10px; font-size: 13px; color: var(--muted); }
.compute-out { color: var(--text); font-weight: 700; }
.done-line, .check-line { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.done-line input, .check-line input { width: auto; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.primary-btn { background: var(--accent); color: #06121f; border: none; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 700; cursor: pointer; text-decoration: none; display: inline-block; }
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.ghost-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; }
.ghost-btn:hover { border-color: var(--border-strong); }
.danger-btn { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; }
.danger-btn:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }

.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.recent-item { display: flex; justify-content: space-between; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--surface-2); border-radius: 8px; }
.recent-date { font-weight: 600; }
.recent-bits { font-size: 13px; }

/* ---- import ---- */
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps li { padding-left: 4px; }
.file-input { padding: 9px; }
.import-status { font-size: 13px; color: var(--muted); min-height: 18px; }
.import-status.busy::before { content: "⏳ "; }
.import-result { display: flex; flex-direction: column; gap: 12px; }
.result-ok { color: var(--good); }
.result-err { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 30%, transparent); padding: 12px; border-radius: var(--radius-sm); }
.result-hint { font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }

/* ---- misc ---- */
.empty-state { text-align: center; padding: 50px 20px; }
.empty-emoji { font-size: 44px; }
.empty-state h3 { margin: 12px 0 6px; }
.loading { text-align: center; color: var(--muted); padding: 60px; }
.footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow); padding: 12px 18px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { border-color: var(--good); }
.toast.error { border-color: var(--bad); }

/* ---- responsive ---- */
@media (max-width: 780px) {
  .people-grid, .chart-grid, .cal-grid, .vital-row { grid-template-columns: 1fr; }
  .tiles.four { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .log-controls { grid-template-columns: 1fr; }
  .hero-row { flex-direction: column; }
  .hero-progress { text-align: left; }
  .calendar { max-width: 320px; }
}
