:root {
  --bg: #f6f7f5; --card: #ffffff; --ink: #1b1f1d; --muted: #5d6662; --line: #dde2df;
  --accent: #1f6f5c; --accent-ink: #ffffff;
  --green: #1d7a3e; --green-bg: #e3f3e8;
  --amber: #8a5a00; --amber-bg: #fdf0d2;
  --red: #b3261e; --red-bg: #fbe3e1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121514; --card: #1c201f; --ink: #eef1ef; --muted: #9aa5a0; --line: #2e3432;
    --accent: #4fb596; --accent-ink: #0d1110;
    --green: #6fd394; --green-bg: #173322;
    --amber: #f3c364; --amber-bg: #3a2c0c;
    --red: #ff8a80; --red-bg: #431a17;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
header { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 6px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 20px; margin: 0 0 2px; }
.muted { color: var(--muted); font-size: 14px; }
nav { display: flex; gap: 6px; margin: 6px 0 14px; }
nav button { flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; font: inherit; font-size: 15px; }
nav button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.med { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.med-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.med-name { font-weight: 600; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.green { color: var(--green); background: var(--green-bg); }
.amber { color: var(--amber); background: var(--amber-bg); }
.red { color: var(--red); background: var(--red-bg); }
.btns { display: flex; gap: 8px; margin-top: 10px; }
.give { flex: 1; min-height: 56px; border-radius: 12px; border: 2px solid currentColor; font: inherit; font-weight: 700;
  font-size: 17px; cursor: pointer; }
.give small { display: block; font-weight: 500; font-size: 13px; }
.banner { border-radius: 12px; padding: 12px; margin-bottom: 14px; border: 2px solid var(--red); background: var(--red-bg); color: var(--ink); }
.banner b { color: var(--red); }
.banner.warn { border-color: var(--amber); background: var(--amber-bg); }
.btn { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); font-weight: 700; }
.btn.full { width: 100%; min-height: 54px; margin-top: 10px; }
.sheet { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet.hidden, .hidden { display: none; }
.sheet-body { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.reason { padding: 8px 10px; border-radius: 8px; margin: 6px 0; font-size: 15px; }
.reason.info { background: var(--bg); color: var(--muted); }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea { width: 100%; padding: 10px; font: inherit; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.hist { list-style: none; padding: 0; margin: 0; }
.hist li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.hist .void { text-decoration: line-through; color: var(--muted); }
.seg { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.seg button { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; }
.seg button.on { background: var(--ink); color: var(--bg); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); max-width: 528px; margin: 0 auto;
  background: var(--ink); color: var(--bg); padding: 12px 14px; border-radius: 10px; z-index: 20; }
