/* Layout idea: a polymer banknote on a phone. One engraved note holds the balance, everything else stays quiet. */
:root {
  color-scheme: light;
  --paper: #edf2ef;
  --surface: #fbfdfb;
  --ink: #10302f;
  --muted: #55706c;
  --line: #cfdcd7;
  --note: #0f4f4a;
  --note-2: #0f6e63;
  --gold: #ffc83d;
  --good: #0f7a58;
  --bad: #bf3029;
  --warn-bg: #fff3d1;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar: 66px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

.page { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--tabbar) + env(safe-area-inset-bottom) + 28px); display: flex; flex-direction: column; gap: 14px; }
.page.plain { padding-bottom: 32px; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 34px; }
.brand { font: 800 15px/1 var(--display); letter-spacing: .02em; color: var(--note); }
.page-title { font-size: 30px; font-weight: 800; }
.lede { color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 8px; }
.section-head h2 { font-size: 20px; font-weight: 700; }

.note { position: relative; overflow: hidden; color: #f2fbf6; background: var(--note); border-radius: 18px; padding: 18px 18px 16px; min-height: 182px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; }
.note svg.guilloche { position: absolute; inset: -30% -30% auto auto; width: 118%; height: auto; pointer-events: none; }
.note > * { position: relative; }
.note .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.note .label { font: 600 13px/1.2 var(--body); opacity: .85; }
.note .amount { font: 800 clamp(44px, 14vw, 62px)/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.note .serial { font: 500 12px/1 var(--body); letter-spacing: .14em; opacity: .75; }
.note .foot { display: flex; justify-content: space-between; align-items: end; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.note .foot b { color: var(--gold); font-weight: 700; }
.note.negative .amount { color: #ffc2bd; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.tiles:has(.tile:nth-child(4)) { grid-template-columns: 1fr 1fr; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.tile span { font-size: 13px; color: var(--muted); }
.tile b { font: 700 20px/1.1 var(--display); font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font-size: 18px; font-weight: 700; }
.card .explain { font-size: 14px; color: var(--muted); }
.card .big { font: 800 34px/1 var(--display); font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions > .btn { flex: 1 1 130px; }

.btn { border: 0; border-radius: 11px; padding: 11px 14px; min-height: 44px; font-weight: 700; background: var(--note); color: #fff; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.alt { background: transparent; color: var(--note); box-shadow: inset 0 0 0 1.5px var(--note); }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 14px; }
.btn.link { background: none; color: var(--note); padding: 4px 0; min-height: 32px; font-size: 14px; text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: default; }

.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .s { font-size: 13px; color: var(--muted); }
.amt { font: 700 16px/1.2 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.in { color: var(--good); }
.amt.out { color: var(--bad); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--paper); color: var(--muted); white-space: nowrap; }
.pill.go { background: #d8f0e4; color: var(--good); }
.pill.wait { background: var(--warn-bg); color: #7a5a00; }
.pill.stop { background: #fbdeda; color: var(--bad); }
.empty { padding: 16px 14px; color: var(--muted); font-size: 15px; }

.bar { height: 10px; background: var(--paper); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--note-2); border-radius: 99px; }
.gauge { position: relative; height: 10px; border-radius: 99px; background: linear-gradient(90deg, #d4483f, #eba62e 45%, #1a9a70); }
.gauge i { position: absolute; top: -4px; width: 6px; height: 18px; margin-left: -3px; background: var(--ink); border-radius: 3px; box-shadow: 0 0 0 2px var(--surface); }

.spark { width: 100%; height: 56px; display: block; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar .in { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; max-width: 560px; }
.tabbar button { background: none; border: 0; height: var(--tabbar); font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; position: relative; }
.tabbar button[aria-current="page"] { color: var(--note); font-weight: 800; }
.tabbar button[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--note); border-radius: 0 0 3px 3px; }
.tabbar .badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 6px; margin-left: 3px; }

#sheet-layer { position: fixed; inset: 0; background: rgba(9, 34, 32, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
#sheet-layer[hidden] { display: none; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 22px; font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea { font-size: 16px; font-weight: 400; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; width: 100%; }
.field textarea { min-height: 170px; line-height: 1.35; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--note); }
.err { color: var(--bad); font-weight: 600; font-size: 14px; }
.err:empty { display: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: calc(env(safe-area-inset-top) + 24px) 20px 24px; max-width: 420px; margin: 0 auto; }
.auth h1 { font-size: 36px; font-weight: 800; color: var(--note); text-align: center; }
.dots { display: flex; gap: 12px; height: 18px; justify-content: center; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--note); }
.dots i.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pad button { height: 76px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font: 700 26px var(--display); cursor: pointer; }
.pad button.ok { background: var(--note); color: #fff; border: 0; font-size: 16px; }
.pad button.clear { font-size: 15px; }
.form { display: flex; flex-direction: column; gap: 12px; width: 100%; }

.quiz-opt { width: 100%; text-align: left; padding: 14px; min-height: 54px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }
.quiz-opt[aria-pressed="true"] { border-color: var(--note); background: #dcefe9; }
.quiz-opt.right { border-color: var(--good); background: #d8f0e4; }
.quiz-opt.wrong { border-color: var(--bad); background: #fbdeda; }
.q-prompt { font: 700 24px/1.2 var(--display); }
.progress { font-size: 14px; font-weight: 700; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 16px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 15px; opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; z-index: 40; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
