:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #17201d;
  --muted: #5f6b66;
  --border: #e3e7e4;
  --accent: #0f766e;
  --ok: #15803d;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --low: #b91c1c;
  --low-bg: #fee2e2;
  --ok-bg: #dcfce7;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --surface: #18201d;
    --text: #e8eeeb;
    --muted: #97a39e;
    --border: #2a3430;
    --accent: #2dd4bf;
    --ok: #4ade80;
    --warn: #fbbf24;
    --warn-bg: #3a2a0a;
    --low: #f87171;
    --low-bg: #3b1414;
    --ok-bg: #0f2e1b;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 32px);
}
button { font: inherit; color: inherit; }
h1 { font-size: 28px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); margin: 0; }
.center { text-align: center; margin-top: 32px; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.top .muted { font-size: 14px; }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); cursor: pointer;
}
.icon-btn.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  margin: 0 0 12px; padding: 10px 12px;
  border-radius: 10px; font-size: 14px;
  background: var(--warn-bg); color: var(--warn);
}
.banner.error { background: var(--low-bg); color: var(--low); }

.total {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px; margin-bottom: 12px;
  background: var(--accent); color: #fff; border-radius: 16px;
}
.total .muted { color: rgb(255 255 255 / .85); font-size: 14px; }
.total strong { font-size: 32px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .total { color: #04201d; } .total .muted { color: rgb(4 32 29 / .8); } }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card {
  width: 100%; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-left-width: 5px;
  border-radius: 14px; box-shadow: var(--shadow);
  text-align: left; cursor: pointer;
}
.card:active { transform: scale(.99); }
.card .name { font-weight: 600; display: flex; flex-direction: column; }
.card .name small { font-weight: 400; color: var(--muted); font-size: 13px; }
.card .amt {
  font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; align-items: flex-end;
}
.card .amt small { font-size: 12px; font-weight: 600; }
.lvl-ok { border-left-color: var(--ok); }
.lvl-warn { border-left-color: var(--warn); }
.lvl-warn .flag { color: var(--warn); }
.lvl-low { border-left-color: var(--low); }
.lvl-low .amt, .lvl-low .flag { color: var(--low); }
.lvl-unknown { border-left-color: var(--border); }
.cards.small .card { min-height: 52px; }
.cards.small .amt { font-size: 17px; }

.link {
  display: block; margin: 16px auto 8px; padding: 10px;
  background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer;
}

/* passcode gate */
.gate { text-align: center; padding-top: 12vh; display: grid; justify-items: center; gap: 8px; }
.gate img { border-radius: 16px; }
.gate form { display: grid; gap: 10px; width: min(280px, 100%); margin-top: 8px; }
.gate input {
  font-size: 22px; text-align: center; letter-spacing: .3em;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
}
.error { color: var(--low); }
.primary {
  padding: 12px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .primary { color: #04201d; } }

/* bottom sheet */
.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .4); animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto; max-height: 90vh; overflow-y: auto;
  padding: 8px 20px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--surface); border-radius: 20px 20px 0 0;
  animation: rise .2s ease-out;
}
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 12px; }
.sheet header { display: flex; align-items: center; justify-content: space-between; }
.big { font-size: 40px; font-weight: 700; margin: 4px 0 16px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: 14px; color: var(--muted); }
.money-input {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
}
.money-input:focus-within { border-color: var(--accent); }
.money-input span { color: var(--muted); font-size: 20px; }
.money-input input {
  flex: 1; min-width: 0; padding: 14px 0; border: 0; outline: 0; background: none;
  font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums;
}
.verdict { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; font-size: 17px; }
.verdict.yes { background: var(--ok-bg); color: var(--ok); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.no { background: var(--low-bg); color: var(--low); }
details { border-top: 1px solid var(--border); padding-top: 12px; }
summary { cursor: pointer; font-weight: 600; padding: 4px 0 12px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.small-print { font-size: 13px; margin-top: 8px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
