/* Brad Health OS — mobile-first dark UI */
:root {
  --bg: #0a0c10;
  --bg-elev: #0e1116;
  --surface: #14171d;
  --surface-2: #1b1f27;
  --border: #262b33;
  --border-soft: #1e232b;
  --text: #e9edf3;
  --muted: #8b94a3;
  --faint: #5b626e;
  --accent: #3ee08f;
  --accent-dim: #1d3b2c;
  --good: #3ee08f;
  --warn: #ffb547;
  --bad: #ff5d6c;
  --info: #5aa9ff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); }

/* App shell */
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; }

header.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(10,12,16,0));
  display: flex; align-items: center; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar .logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.topbar .title { font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.topbar .subtitle { font-size: 11px; color: var(--muted); margin-top: -2px; }

.profile-switch { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.profile-switch button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
}
.profile-switch button.active { background: var(--accent); color: #06140d; }

main { padding: 4px 16px calc(var(--nav-h) + var(--safe-bottom) + 24px); }

/* Screens */
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.screen-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 8px 0 2px; }
.screen-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.card.tight { padding: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-h h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 0; }
.card-h .chip { font-size: 11px; color: var(--muted); }

/* Hero weight block */
.hero { background: radial-gradient(120% 140% at 50% 0%, #16201a 0%, var(--surface) 55%); }
.hero .big {
  font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1;
  display: flex; align-items: baseline; gap: 8px;
}
.hero .big .unit { font-size: 20px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.hero .targetline { display: flex; justify-content: space-between; margin-top: 14px; font-size: 13px; color: var(--muted); }
.hero .targetline b { color: var(--text); }

.progressbar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 12px 0 4px; }
.progressbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #79f0b4); border-radius: 999px; transition: width .5s ease; }

/* Score grid */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 13px 14px; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.stat .value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat .sub { font-size: 11px; color: var(--faint); margin-top: 2px; }
.stat.good .value { color: var(--good); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }

/* Ring score */
.ring-row { display: flex; gap: 12px; }
.ring { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.ring svg { width: 74px; height: 74px; }
.ring .rlabel { font-size: 11px; color: var(--muted); text-align: center; }

/* Coach */
.coach-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.coach-item:last-child { border-bottom: 0; }
.coach-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--info); }
.coach-item.good .dot { background: var(--good); }
.coach-item.warn .dot { background: var(--warn); }
.coach-item.bad .dot { background: var(--bad); }
.coach-item .ctext { font-size: 14px; }
.coach-item .ctext b { color: var(--text); }
.coach-headline { font-size: 15px; font-weight: 600; line-height: 1.4; }

/* Lists / rows */
.row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.row:last-child { border-bottom: 0; }
.row .rlabel { font-size: 14px; }
.row .rsub { font-size: 12px; color: var(--muted); }

/* Inputs */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.input, input[type=number], input[type=text], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 13px 14px; font-size: 16px; outline: none;
}
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.inline-num { display: flex; align-items: center; gap: 10px; }
.inline-num input { text-align: center; font-size: 20px; font-weight: 700; }

/* Quick-add buttons */
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 600;
}
.quick button:active { background: var(--accent-dim); border-color: var(--accent); }

.bigbtn {
  width: 100%; border: 0; border-radius: var(--radius-sm); padding: 16px;
  font-size: 15px; font-weight: 700; background: var(--accent); color: #06140d;
}
.bigbtn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.bigbtn:active { filter: brightness(.95); }
.btn-sm { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 7px 12px; font-size: 12px; font-weight: 600; }

/* Steppers (mood/energy/quality) */
.scale { display: flex; gap: 8px; }
.scale button {
  flex: 1; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  border-radius: 10px; padding: 12px 0; font-size: 15px; font-weight: 700;
}
.scale button.sel { background: var(--accent); color: #06140d; border-color: var(--accent); }

/* Checkboxes (supplements) */
.check { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.check:last-child { border-bottom: 0; }
.check .box {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex: none; transition: .15s;
}
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check .box svg { opacity: 0; }
.check.on .box svg { opacity: 1; }
.check .cmain { flex: 1; }
.check .cmain .cname { font-size: 14px; font-weight: 600; }
.check .cmain .cdose { font-size: 12px; color: var(--muted); }
.slot-label { font-size: 11px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .6px; margin: 16px 0 2px; }

/* Workout / exercises */
.exrc { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 13px; margin-bottom: 10px; }
.exrc .ex-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.exrc .ex-name { font-weight: 700; font-size: 15px; }
.exrc .ex-target { font-size: 12px; color: var(--muted); }
.exrc .ex-last { font-size: 12px; color: var(--accent); margin-bottom: 10px; }
.setrow { display: grid; grid-template-columns: 28px 1fr 1fr 34px; gap: 8px; align-items: center; margin-bottom: 7px; }
.setrow .sidx { font-size: 12px; color: var(--faint); text-align: center; }
.setrow input { padding: 10px; font-size: 15px; text-align: center; background: var(--surface); }
.setrow .sdone { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 16px; }
.setrow .sdone.on { background: var(--accent); color: #06140d; border-color: var(--accent); }
.daypick { display: flex; gap: 8px; margin-bottom: 16px; }
.daypick button { flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 12px; padding: 13px 0; font-weight: 700; font-size: 14px; }
.daypick button.sel { background: var(--accent); color: #06140d; border-color: var(--accent); }
.daypick button .dsub { display: block; font-size: 10px; font-weight: 600; opacity: .8; }

/* Meal plan */
.meal { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin-bottom: 14px; }
.meal .mt { font-weight: 700; font-size: 14px; }
.meal .mi { font-size: 13px; color: var(--muted); }
.meal .mp { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 2px; }

/* Chart */
.chart-wrap { width: 100%; overflow: hidden; }
svg.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* Bottom nav */
nav.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(14,17,22,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-soft);
  display: flex; max-width: 560px; margin: 0 auto;
}
nav.tabbar button {
  flex: 1; background: none; border: 0; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; font-weight: 600;
}
nav.tabbar button svg { width: 22px; height: 22px; }
nav.tabbar button.active { color: var(--accent); }

.empty { text-align: center; color: var(--faint); font-size: 13px; padding: 24px 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  background: var(--accent); color: #06140d; font-weight: 700; font-size: 13px;
  padding: 11px 18px; border-radius: 999px; z-index: 60; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }
.helprow { font-size: 12px; color: var(--faint); margin-top: 8px; }
