:root {
  --bg: #f2f2f7; --card: #ffffff; --text: #1c1c1e; --muted: #6b6b70; --line: #e5e5ea;
  --accent: #128C7E; --accent-soft: rgba(18,140,126,.12);
  --red: #d70015; --orange: #c75100; --purple: #a020c0; --green: #248a3d;
  --red-soft: rgba(215,0,21,.10); --orange-soft: rgba(255,149,0,.15); --purple-soft: rgba(175,82,222,.13);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #98989f; --line: #38383a;
          --accent: #2fc1ad; --accent-soft: rgba(47,193,173,.16);
          --red: #ff6961; --orange: #ffb340; --purple: #da8fff; --green: #30d158; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
.page { max-width: 720px; margin: 0 auto; padding: 16px 16px 96px; }

/* Header: title, profile, then one line under it (same on every tab) */
.header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 10px; }
.header-row { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.header h1 { font-size: 32px; line-height: 1.1; margin: 0; flex: 1; letter-spacing: -.5px; }
.header-sub { min-height: 28px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 15px; }
.progress { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 16px; border: 0; cursor: pointer; overflow: hidden; padding: 0; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.menu { position: absolute; right: 0; top: 56px; background: var(--card); border-radius: 14px; min-width: 240px;
  box-shadow: 0 10px 40px rgba(0,0,0,.18); padding: 6px; z-index: 10; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none;
  border-radius: 9px; text-align: left; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.check { width: 18px; color: var(--accent); font-weight: 700; }

/* Lists like iOS grouped lists */
.section-title { color: var(--muted); font-size: 14px; font-weight: 600; margin: 18px 16px 6px; }
.card { background: var(--card); border-radius: 16px; overflow: hidden; }
.row { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.name { font-weight: 500; }
.sub { color: var(--muted); font-size: 14px; }
.purpose { color: var(--accent); font-size: 14px; }
.tick { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: none; cursor: pointer;
  display: grid; place-items: center; flex: none; color: #fff; font-size: 16px; }
.tick.done { background: var(--accent); border-color: var(--accent); }
.tick.auto { border-style: dashed; cursor: default; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge.low { color: var(--red); background: var(--red-soft); }
.badge.owes { color: var(--purple); background: var(--purple-soft); }
.badge.rdv { color: var(--orange); background: var(--orange-soft); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.error { color: var(--red); background: var(--red-soft); padding: 10px 14px; border-radius: 12px; margin: 12px 0; }

/* Bottom tab bar */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; display: flex; gap: 4px;
  background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 999px; padding: 6px; box-shadow: 0 6px 30px rgba(0,0,0,.12); }
.tabs button { border: 0; background: none; padding: 10px 18px; border-radius: 999px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

/* Sign-in */
.signin { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.signin img { width: 72px; height: 72px; border-radius: 18px; }
.signin h1 { margin: 14px 0 4px; }
.field { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 17px; margin-top: 18px; }
.primary { width: 100%; padding: 14px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 600; font-size: 17px; margin-top: 10px; cursor: pointer; }
.primary:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; margin-top: 14px; }
.note { color: var(--muted); font-size: 14px; margin-top: 14px; }

/* --- Batch 2: tabs, sheets, forms --- */
.tabs button { padding: 10px 14px; }
@media (max-width: 420px) { .tabs { left: 12px; right: 12px; transform: none; justify-content: space-between; } .tabs button { padding: 10px 8px; font-size: 14px; } }
.segmented { display: flex; flex: 1; background: var(--line); border-radius: 9px; padding: 2px; }
.segmented button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.search { width: 100%; margin-top: 10px; padding: 10px 12px; border-radius: 12px; border: 0; background: var(--line); color: var(--text); font-size: 16px; }
.header-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowbtn { width: 100%; background: none; border: 0; text-align: left; cursor: pointer; border-top: 1px solid var(--line); }
.card > .rowbtn:first-child { border-top: 0; }
.rowbtn:hover { background: color-mix(in srgb, var(--line) 40%, transparent); }
.chev { color: var(--muted); font-size: 22px; }
.plainbtn { background: none; border: 0; padding: 0; cursor: pointer; }
.left { text-align: left; }
.center { text-align: center; }
.indent { margin: 4px 16px; }
.red { color: var(--red) !important; }
.orange { color: var(--orange) !important; }
.blue { color: #0a84ff !important; }
.expired { color: var(--red); }
.soon { color: var(--orange); }
.link.small, a.link { font-size: 14px; display: inline-block; margin-top: 4px; padding: 0; text-decoration: none; }
.link.strong { font-weight: 600; margin: 0; }
.stepper { display: flex; background: var(--line); border-radius: 999px; }
.stepper button { border: 0; background: none; width: 40px; height: 32px; font-size: 20px; cursor: pointer; }
.stepper button + button { border-left: 1px solid var(--bg); }
.form .row { gap: 12px; }
.form input, .form select { border: 0; background: none; color: var(--text); font-size: 16px; text-align: right; max-width: 60%; }
.form input.plain { text-align: left; max-width: none; width: 100%; }
.form input:focus, .form select:focus { outline: none; }
.code { font: 700 34px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 5px; margin: 6px 0; }
.primary.small { width: auto; padding: 10px 18px; font-size: 15px; }
.more { position: relative; }
.more summary { list-style: none; cursor: pointer; padding: 4px 10px; font-size: 20px; color: var(--muted); }
.more summary::-webkit-details-marker { display: none; }
.menu.small { top: 32px; min-width: 180px; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; }
@media (min-width: 640px) { .sheet { border-radius: 18px; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet-head > :first-child { justify-self: start; margin: 0; }
.sheet-head > :last-child { justify-self: end; }
.sheet-body { overflow: auto; padding: 8px 16px 24px; }

/* --- Batch 3: medicine details --- */
.purpose { color: var(--accent); font-size: 14px; }
.label { flex: none; min-width: 96px; }
.right { text-align: right; }
.bullet { padding-left: 16px; position: relative; margin: 4px 0; }
.bullet::before { content: "•"; position: absolute; left: 2px; color: var(--muted); }
.para { margin: 4px 0; }
