:root {
  --bg: #0b0f14;
  --surface: #141b24;
  --surface-2: #1c2733;
  --line: #26333f;
  --text: #e8eef5;
  --muted: #8ea0b2;
  --accent: #4cc2ff;
  --accent-2: #2b7fff;
  --ok: #3ddc84;
  --err: #ff5d6c;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% -10%, #16324a 0%, var(--bg) 60%);
}
.login-card {
  width: 100%; max-width: 340px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 22px; text-align: center; display: flex; flex-direction: column; gap: 12px;
}
.login-card .logo { font-size: 44px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 6px; }
input, .select {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-size: 16px; outline: none;
}
input:focus, .select:focus { border-color: var(--accent); }
button {
  cursor: pointer; border: none; border-radius: 12px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #04101c; font-weight: 700; font-size: 16px; padding: 13px 14px;
}
button.ghost { background: none; color: var(--muted); font-size: 20px; padding: 4px 8px; }
.err { color: var(--err); font-size: 13px; }

/* ---------- App shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: rgba(11,15,20,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-size: 18px; font-weight: 700; }
#main { flex: 1; padding: 14px 14px calc(84px + var(--safe-b)); max-width: 640px; width: 100%; margin: 0 auto; }

/* ---------- Day tabs ---------- */
.daytabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.daytabs button {
  flex: 0 0 auto; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line); font-weight: 600; font-size: 13px; padding: 9px 14px; border-radius: 999px;
}
.daytabs button.active { background: var(--accent); color: #04101c; border-color: var(--accent); }
.daytabs button.rest { opacity: .5; }
.dayinfo { color: var(--muted); font-size: 13px; margin: 0 2px 12px; }
.dayinfo.rest {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 12px;
  padding: 22px; text-align: center; color: var(--muted); font-size: 15px;
}

/* ---------- Cards ---------- */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card .name { font-weight: 700; font-size: 16px; }
.card .scheme { color: var(--accent); font-size: 12px; font-weight: 700; white-space: nowrap; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.card .last { color: var(--muted); font-size: 12px; margin-top: 8px; }
.card .last b { color: var(--text); }
.row { display: flex; gap: 8px; margin-top: 10px; align-items: stretch; }
.row .field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.row .field span { font-size: 11px; color: var(--muted); padding-left: 2px; }
.row input { padding: 11px 12px; }
.row .save { flex: 0 0 auto; align-self: flex-end; padding: 12px 16px; }
.card.saved { border-color: var(--ok); }

/* ---------- Progress ---------- */
.chart-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin: 12px 0; height: 260px;
}
.stats { display: flex; gap: 10px; margin-bottom: 12px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; text-align: center;
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }
.history { display: flex; flex-direction: column; gap: 6px; }
.hrow {
  display: flex; justify-content: space-between; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.hrow .d { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* ---------- Supplements ---------- */
.supp .name { font-weight: 700; font-size: 16px; }
.supp .dose { color: var(--accent); font-size: 13px; font-weight: 700; margin-top: 2px; }
.supp .when { color: var(--text); font-size: 13px; margin-top: 6px; }
.supp .why { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: rgba(11,15,20,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; background: none; color: var(--muted); font-weight: 600; font-size: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0;
}
.tabbar button span { font-size: 11px; }
.tabbar button.active { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%);
  background: var(--ok); color: #04220f; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; z-index: 20; transition: opacity .2s;
}
.toast.err { background: var(--err); color: #2a0007; }
