/* Till Debt Do Us Part — OD green, cream and brass */
:root {
  --bg: #f3efe4;
  --surface: #fbf9f3;
  --surface-2: #efeadc;
  --ink: #1e2217;
  --muted: #6a6d5c;
  --line: #e0dac8;
  --od: #4b5320;          /* olive drab */
  --od-deep: #2f3519;
  --od-soft: #dfe1cc;
  --on-od: #f6f2e4;
  --brass: #a8834a;
  --brass-soft: #efe2c9;
  --good: #4b5320;
  --warn: #b7791f;
  --bad: #a23b2a;
  --shadow: 0 1px 2px rgba(47, 53, 25, .06), 0 8px 24px rgba(47, 53, 25, .06);
  --radius: 20px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #12150d; --surface: #1b1f15; --surface-2: #23281b; --ink: #ece8d9; --muted: #a2a390; --line: #2f3524;
    --od: #8a9757; --od-deep: #3a4220; --od-soft: #2a3019; --on-od: #f6f2e4; --brass: #c9a46a; --brass-soft: #3a3020;
    --good: #a3b36a; --warn: #e0a64a; --bad: #e07a63; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #12150d; --surface: #1b1f15; --surface-2: #23281b; --ink: #ece8d9; --muted: #a2a390; --line: #2f3524;
  --od: #8a9757; --od-deep: #3a4220; --od-soft: #2a3019; --on-od: #f6f2e4; --brass: #c9a46a; --brass-soft: #3a3020;
  --good: #a3b36a; --warn: #e0a64a; --bad: #e07a63; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; }
body { min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); font-optical-sizing: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; letter-spacing: .02em; }
.caps { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 600; color: var(--muted); }

/* ---------- shell ---------- */
.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 12px; background: linear-gradient(var(--bg) 75%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand svg { flex: none; }
.brand b { font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.greet { margin: 4px 0 16px; }
.greet h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; line-height: 1.1; margin: 0 0 4px; letter-spacing: -.02em; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs nav { display: flex; width: 100%; max-width: 560px; justify-content: space-between; }
.tab { flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; font-size: 11px; font-weight: 500; color: var(--muted); position: relative; }
.tab[aria-current='page'] { color: var(--od); }
.tab[aria-current='page']::before { content: ''; position: absolute; top: -9px; width: 28px; height: 3px; border-radius: 3px; background: var(--od); }
.tab .dot { position: absolute; top: 2px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--brass); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; font-weight: 600; margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.link { background: none; border: 0; color: var(--od); font-weight: 600; font-size: 13px; padding: 4px 0; }
.big { font-family: var(--serif); font-size: 40px; line-height: 1; font-weight: 500; letter-spacing: -.02em; }
.mid { font-family: var(--serif); font-size: 26px; line-height: 1.1; font-weight: 500; letter-spacing: -.01em; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .card { margin-bottom: 0; }
.stack > * + * { margin-top: 10px; }

.hero { background: radial-gradient(120% 140% at 100% 0%, #5d6729 0%, var(--od) 45%, var(--od-deep) 100%);
  color: var(--on-od); border: 0; position: relative; overflow: hidden; }
.hero .caps, .hero .muted { color: color-mix(in srgb, var(--on-od) 72%, transparent); }
.hero::after { content: ''; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%;
  border: 1px solid rgba(201, 164, 106, .35); box-shadow: 0 0 0 18px rgba(201, 164, 106, .06); }
.hero .ring-track { stroke: rgba(246, 242, 228, .18); }
.hero .ring-bar { stroke: #d9b979; }

.ring { transform: rotate(-90deg); }
.ring-track { stroke: var(--surface-2); }
.ring-bar { stroke: var(--od); transition: stroke-dashoffset .6s ease; }

.bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: var(--od); transition: width .6s ease; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.bar.brass > i { background: var(--brass); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--od-soft); color: var(--od); }
.pill.brass { background: var(--brass-soft); color: var(--brass); }
.pill.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; margin-bottom: 14px;
  background: var(--brass-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brass) 30%, transparent); }
.banner.bad { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner b { display: block; margin-bottom: 2px; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list .item:first-child { border-top: 0; padding-top: 4px; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item .amt { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.amt.in { color: var(--good); }
.badge { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--od-soft); color: var(--od); }
.badge.brass { background: var(--brass-soft); color: var(--brass); }
.tap { width: 100%; color: inherit; background: none; border: 0; text-align: left; padding: 0; display: flex; align-items: center; gap: 12px; }

.check { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; background: var(--surface); }
.check.on { background: var(--od); border-color: var(--od); color: var(--on-od); }
.paid .t { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 10px; }
.section-title h3 { font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 0; }

.steps { display: flex; gap: 6px; margin: 4px 0 14px; }
.steps div { flex: 1; }
.steps i { display: block; height: 4px; border-radius: 4px; background: var(--surface-2); margin-bottom: 6px; }
.steps .done i { background: var(--od); }
.steps .now i { background: linear-gradient(90deg, var(--od) var(--p, 50%), var(--surface-2) var(--p, 50%)); }
.steps span { font-size: 11px; color: var(--muted); }
.steps .now span { color: var(--ink); font-weight: 600; }

.target { border: 1.5px solid var(--brass); background: linear-gradient(var(--surface), color-mix(in srgb, var(--brass-soft) 60%, var(--surface))); }

/* ---------- forms + sheets ---------- */
.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 600; background: var(--od); color: var(--on-od); width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.btn:disabled { opacity: .5; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none; }
.input:focus { border-color: var(--od); box-shadow: 0 0 0 3px color-mix(in srgb, var(--od) 18%, transparent); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 28px; background: var(--surface-2); border: 1px solid var(--line); position: relative; transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked { background: var(--od); border-color: var(--od); }
.switch input:checked::after { transform: translateX(18px); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; font-weight: 500; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; }
.chip.on { background: var(--od); color: var(--on-od); border-color: var(--od); }

.scrim { position: fixed; inset: 0; background: rgba(18, 21, 13, .45); z-index: 20; animation: fade .2s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92dvh; overflow: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2,.8,.2,1);
  max-width: 560px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 5px; background: var(--line); margin: 6px auto 14px; }
.sheet h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0 0 16px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 9;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--brass); color: #fff; box-shadow: 0 8px 24px rgba(168,131,74,.4);
  display: grid; place-items: center; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  background: var(--od-deep); color: var(--on-od); padding: 12px 18px; border-radius: 14px; font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow); animation: up .25s ease; max-width: calc(100% - 32px); }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 32px 24px; }
.auth .mark { margin: 0 auto 18px; }
.auth h1 { font-family: var(--serif); font-weight: 500; text-align: center; font-size: 32px; margin: 0 0 6px; letter-spacing: -.02em; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 28px; }
.qr { background: #fff; border-radius: 16px; padding: 14px; width: 220px; margin: 0 auto 16px; }
.qr img { width: 100%; display: block; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 24px; font-variant-numeric: tabular-nums; }
.err { color: var(--bad); font-size: 14px; margin: -4px 0 14px; }
.demo-flag { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 40; }

.empty { text-align: center; padding: 18px 8px; color: var(--muted); font-size: 14px; }
@media (min-width: 600px) { .app { padding-top: 12px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.card.tap { background: var(--surface); border: 1px solid var(--line); padding: 18px; text-align: left; }
:root[data-theme='dark'] .hero { background: radial-gradient(120% 140% at 100% 0%, #4f5826 0%, #3a4220 50%, #23281a 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .hero { background: radial-gradient(120% 140% at 100% 0%, #4f5826 0%, #3a4220 50%, #23281a 100%); } }
