:root {
  --bg: #f7f5f0; --ink: #1f2328; --muted: #6b6f76; --line: #e4dfd4;
  --money: #1f4f7f; --money-bg: #eef5fc; --money-line: #cfe0f0;
  --self: #2f6b2a; --self-bg: #f1f8ee; --self-line: #d3e8cd;
  --health: #9a4f1c; --health-bg: #fcf3ec; --health-line: #f0d9c8;
  --ok: #2f6b2a; --near: #a86a00; --below: #b42318;
  --tabs-h: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, "Sukhumvit Set", "Thonburi", "Noto Sans Thai", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); }
h1 { font-size: 23px; margin: 4px 0 2px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 19px; margin: 0 0 10px; }
p { margin: 6px 0; }
.loading, .muted { color: var(--muted); }
.muted { font-size: 15px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.top .when { color: var(--muted); font-size: 15px; text-align: right; }

.card { border-radius: 16px; padding: 14px 14px 12px; margin: 12px 0; border: 1px solid var(--line); background: #fff; }
.card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.card .sub { color: var(--muted); font-size: 14px; text-align: right; }
.card.money { background: var(--money-bg); border-color: var(--money-line); } .card.money h2 { color: var(--money); }
.card.self { background: var(--self-bg); border-color: var(--self-line); } .card.self h2 { color: var(--self); }
.card.health { background: var(--health-bg); border-color: var(--health-line); } .card.health h2 { color: var(--health); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; }
.row b { font-size: 18px; white-space: nowrap; }
.hint { color: var(--muted); font-size: 14px; margin: 3px 0 0; }
.ok { color: var(--ok); } .near { color: var(--near); } .below { color: var(--below); }
.bar { height: 10px; border-radius: 6px; background: #e7e3da; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: 6px; }
.money .bar i { background: var(--money); } .self .bar i { background: var(--self); } .health .bar i { background: var(--health); }
.dots { display: flex; gap: 6px; margin-top: 8px; }
.dots button { flex: 1; min-width: 0; height: 40px; border-radius: 10px; border: 1px solid var(--self-line); background: #fff; color: var(--muted); font: inherit; font-size: 14px; padding: 0; }
.dots button.on { background: var(--self); border-color: var(--self); color: #fff; font-weight: 600; }
.dots button.today { outline: 2px solid var(--self); outline-offset: 1px; }
.dots button:disabled { opacity: .45; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button { font: inherit; }
.actions button, button.primary, button.ghost, button.danger {
  flex: 1 1 auto; min-height: 46px; border-radius: 12px; padding: 8px 14px; font-size: 16px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.money .actions button { border-color: var(--money-line); color: var(--money); }
.self .actions button { border-color: var(--self-line); color: var(--self); }
.health .actions button { border-color: var(--health-line); color: var(--health); }
button.primary { background: var(--money); border-color: var(--money); color: #fff; }
button.big { width: 100%; margin-top: 8px; }
button.danger { color: var(--below); border-color: #f1c4bf; }
button.link { background: none; border: 0; color: var(--money); text-decoration: underline; padding: 8px 0; font-size: 15px; }
.banner { border-radius: 14px; padding: 12px 14px; margin: 10px 0; background: #fff6df; border: 1px solid #f0dca5; font-size: 15px; }
.banner.warn { background: #fdecea; border-color: #f1c4bf; }
.banner .actions { margin-top: 8px; }

.hero { padding-top: 12px; }
.hero .logo { font-size: 44px; }
.steps { padding-left: 22px; } .steps li { margin: 8px 0; }
textarea, input[type=text], input[type=number], input[type=date] {
  width: 100%; font: inherit; font-size: 17px; padding: 11px 12px; border-radius: 12px; border: 1px solid #cfc9bc; background: #fff; color: var(--ink);
}
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 14px; word-break: break-all; }
label { display: block; font-size: 15px; color: var(--muted); margin: 12px 0 5px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; }
label.check input { width: 22px; height: 22px; }
.err { color: var(--below); font-size: 15px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 42px; padding: 6px 14px; border-radius: 21px; border: 1px solid #cfc9bc; background: #fff; font-size: 16px; color: var(--ink); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.wk { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.wk.cur { border: 2px solid var(--money); }
.wk.future { opacity: .55; }
.wk .h { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.wk .h small { color: var(--muted); font-weight: 400; font-size: 14px; }
.wk .g { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 15px; margin-top: 4px; }
.mnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 4px; }
.mnav button { min-width: 46px; min-height: 42px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 20px; }
.stat { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
pre.summary { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: 15px/1.5 -apple-system, "Sukhumvit Set", "Thonburi", sans-serif; margin: 8px 0; }
.list .it { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.list .it .d { color: var(--muted); width: 58px; flex: none; font-size: 14px; }
.list .it .x { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .it button { flex: none; min-height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 2px 10px; font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv span:nth-child(odd) { color: var(--muted); }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  padding: 4px 6px env(safe-area-inset-bottom);
}
#tabs button { flex: 1; max-width: 140px; border: 0; background: none; color: var(--muted); font-size: 13px; padding: 6px 0 8px; min-height: var(--tabs-h); }
#tabs button .ti { display: block; font-size: 22px; line-height: 1.2; filter: grayscale(1); opacity: .7; }
#tabs button.on { color: var(--money); font-weight: 600; }
#tabs button.on .ti { filter: none; opacity: 1; }
#sheet { position: fixed; inset: 0; z-index: 10; }
#sheet .backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
#sheet .panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88vh; overflow: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); z-index: 20;
  background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 22px; font-size: 15px; max-width: 90vw; text-align: center;
}
[hidden] { display: none !important; }
