/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:         #0b0b12;
  --surface:    #13131f;
  --surface2:   #1a1a28;
  --border:     #252538;
  --accent:     #7c6aff;
  --accent-glow:#7c6aff33;
  --teal:       #00d4aa;
  --teal-glow:  #00d4aa22;
  --orange:     #ffb347;
  --red:        #ff5555;
  --text:       #e0e0f0;
  --muted:      #8888aa;
  --dim:        #44445a;
  --radius:     10px;
  --nav-h:      52px;
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Auth overlay ──────────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
#auth-overlay.hidden { display: none; }
.auth-card {
  display: flex; flex-direction: column; gap: 12px;
  width: 280px; padding: 40px 32px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px;
}
.auth-logo {
  font-size: 28px; font-weight: 700; letter-spacing: -1px;
  color: var(--accent); text-align: center; margin-bottom: 8px;
}
#pw-input {
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 15px; outline: none;
  transition: border-color .2s;
}
#pw-input:focus { border-color: var(--accent); }
#pw-btn {
  padding: 10px; border-radius: var(--radius); border: none;
  background: var(--accent); color: #fff; font-size: 15px;
  font-weight: 600; cursor: pointer; transition: opacity .2s;
}
#pw-btn:hover { opacity: .85; }
#pw-error { color: var(--red); font-size: 13px; text-align: center; }

/* ─── Nav ───────────────────────────────────────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h); z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; padding: 0 20px;
}
.nav-logo {
  font-size: 17px; font-weight: 700; letter-spacing: -.5px;
  color: var(--accent); margin-right: 12px; flex-shrink: 0;
}
.nav-links {
  display: flex; gap: 2px; flex: 1; overflow-x: auto;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-btn {
  padding: 6px 13px; border-radius: 7px; border: none;
  background: transparent; color: var(--muted); font-size: 13.5px;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active { color: var(--accent); background: var(--accent-glow); font-weight: 600; }
.nav-logout {
  margin-left: auto; flex-shrink: 0;
  background: transparent; border: none; color: var(--dim);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: color .15s;
}
.nav-logout:hover { color: var(--red); }

/* ─── Main layout ───────────────────────────────────────────────────────── */
main {
  max-width: 1100px; margin: 0 auto;
  padding: calc(var(--nav-h) + 24px) 20px 48px;
}
.view { display: none; }
.view.active { display: block; }

/* ─── Utility ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap8   { gap: 8px; }
.gap16  { gap: 16px; }
.mt16   { margin-top: 16px; }
.mt24   { margin-top: 24px; }
.center { text-align: center; }

/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.card-sm { padding: 16px; }
.card-title {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 12px;
}
.big-num {
  font-size: 52px; font-weight: 800; line-height: 1;
  letter-spacing: -2px; color: var(--text);
}
.big-num.accent { color: var(--accent); }
.big-num.teal   { color: var(--teal); }
.big-num.orange { color: var(--orange); }
.label   { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ─── Grid layouts ──────────────────────────────────────────────────────── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* ─── Page titles ───────────────────────────────────────────────────────── */
.page-title {
  font-size: 22px; font-weight: 700; letter-spacing: -.5px;
  margin-bottom: 20px; color: var(--text);
}
.page-title span { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 8px; }

/* ─── Dashboard ─────────────────────────────────────────────────────────── */
.compliance-dots {
  display: flex; gap: 8px; align-items: center; margin-top: 10px;
}
.dot {
  width: 32px; height: 32px; border-radius: 7px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-size: 10px; color: var(--muted);
  gap: 2px;
}
.dot-day  { font-size: 9px; text-transform: uppercase; }
.dot.hit  { background: var(--teal-glow); border: 1px solid var(--teal); }
.dot.miss { background: #ff555522; border: 1px solid var(--red); }
.dot.none { background: var(--surface2); border: 1px solid var(--border); }
.dot.hit  .dot-mark { color: var(--teal); font-size: 14px; }
.dot.miss .dot-mark { color: var(--red); font-size: 14px; }
.dot.none .dot-mark { color: var(--dim); font-size: 14px; }

.window-bar {
  height: 6px; border-radius: 3px;
  background: var(--surface2); overflow: hidden; margin-top: 10px;
}
.window-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width .5s ease;
}

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-open   { background: var(--teal-glow); color: var(--teal); border: 1px solid var(--teal); }
.badge-pre    { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--accent); }
.badge-closed { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ─── Log form ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-bottom: 7px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 15px;
  outline: none; transition: border-color .2s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-select option { background: var(--surface2); }
.form-textarea { resize: vertical; min-height: 80px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.toggle-label { font-size: 15px; }
.toggle {
  width: 44px; height: 24px; border-radius: 12px;
  background: var(--dim); border: none; cursor: pointer;
  position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle.on { background: var(--teal); }
.toggle::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle.on::after { transform: translateX(20px); }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  padding: 10px 20px; border-radius: var(--radius); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-teal    { background: var(--teal);   color: #0b0b12; }
.btn-ghost   {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn:hover { opacity: .85; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ─── Workout card ──────────────────────────────────────────────────────── */
.workout-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.workout-type-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 20px;
}
.badge-gym  { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--accent); }
.badge-swim { background: var(--teal-glow);   color: var(--teal);   border: 1px solid var(--teal); }
.badge-rest { background: var(--surface2);    color: var(--muted);  border: 1px solid var(--border); }

.exercise-list { list-style: none; }
.exercise-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: none; }
.ex-info { flex: 1; }
.ex-name  { font-weight: 600; font-size: 15px; }
.ex-sets  { font-size: 13px; color: var(--accent); margin-top: 2px; }
.ex-tip   { font-size: 12px; color: var(--muted); margin-top: 3px; font-style: italic; }
.ex-num   {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  background: var(--accent-glow); color: var(--accent);
  font-size: 12px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; margin-top: 2px;
}

.swim-set {
  padding: 12px; border-radius: 8px; background: var(--surface2);
  margin-bottom: 8px;
}
.swim-label { font-weight: 600; font-size: 13px; color: var(--teal); }
.swim-dist  { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -1px; }
.swim-note  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.swim-rest  { font-size: 11px; color: var(--orange); margin-top: 3px; }

.week-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.week-day {
  padding: 8px 4px; border-radius: 8px; text-align: center;
  border: 1px solid var(--border); font-size: 11px;
}
.week-day .wd-name  { color: var(--muted); font-weight: 600; text-transform: uppercase; }
.week-day .wd-type  { font-size: 12px; margin-top: 4px; font-weight: 600; }
.week-day.wk-gym    { border-color: var(--accent); background: var(--accent-glow); }
.week-day.wk-swim   { border-color: var(--teal);   background: var(--teal-glow); }
.week-day.wk-rest   { opacity: .45; }
.week-day.wk-today  { box-shadow: 0 0 0 2px var(--accent); }
.week-day.wk-done   { opacity: .55; }
.week-day.wk-done .wd-type::after { content: ' ✓'; }

/* ─── Dinner guide ──────────────────────────────────────────────────────── */
.food-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.food-row:last-child { border-bottom: none; }
.food-info { flex: 1; }
.food-name { font-weight: 600; font-size: 15px; }
.food-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.food-amounts { text-align: right; flex-shrink: 0; margin-left: 16px; }
.food-grams { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -1px; }
.food-cals  { font-size: 12px; color: var(--muted); }

.macro-pill {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.mp-protein { background: var(--accent); }
.mp-veggies { background: var(--teal); }
.mp-cheese  { background: var(--orange); }
.mp-fruit   { background: #ff7eb3; }
.mp-yoghurt { background: #6ce0ff; }

.tip-box {
  padding: 12px 16px; border-radius: var(--radius); font-size: 14px;
  margin-bottom: 20px; border-left: 3px solid;
}
.tip-pre    { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }
.tip-open   { background: var(--teal-glow);   border-color: var(--teal);   color: var(--teal); }
.tip-closed { background: var(--surface2);    border-color: var(--dim);    color: var(--muted); }

.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 14px; margin-top: 4px;
  border-top: 2px solid var(--border);
}
.total-label { font-weight: 700; font-size: 15px; }
.total-cals  { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -1px; }

/* ─── Charts ────────────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-lg { height: 280px; }

/* ─── Progress bars ─────────────────────────────────────────────────────── */
.prog-bar {
  height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden;
}
.prog-fill {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width .6s ease;
}

/* ─── Stat rows ─────────────────────────────────────────────────────────── */
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-key   { color: var(--muted); }
.stat-val   { font-weight: 700; }
.stat-val.accent { color: var(--accent); }
.stat-val.teal   { color: var(--teal); }
.stat-val.orange { color: var(--orange); }

/* ─── Settings ──────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin-bottom: 14px;
}

/* ─── Loading / empty states ────────────────────────────────────────────── */
.loading { color: var(--dim); font-size: 14px; padding: 40px; text-align: center; }
.empty   { color: var(--muted); font-size: 14px; padding: 24px; text-align: center; }

/* ─── Projection card ───────────────────────────────────────────────────── */
.proj-highlight {
  background: linear-gradient(135deg, var(--accent-glow), var(--teal-glow));
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.proj-date  { font-size: 32px; font-weight: 800; letter-spacing: -1px; color: var(--text); }
.proj-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
