:root {
  --bg: #f4f4f1;
  --card: #ffffff;
  --card-2: #f8f8f5;
  --text: #17181a;
  --muted: #6e7076;
  --line: #e7e6e1;
  --track: #ecebe6;
  --accent: #2f7d76;          /* the one accent: calm teal */
  --accent-soft: #e3f0ee;
  --accent-text: #ffffff;
  --good: #3c8d5a;
  --warn: #c98a12;
  --bad: #c8463c;
  --in: #2f8a55;
  --chip-necessary: #6e7076;
  --chip-fine: #3c8d5a;
  --chip-impulsive: #d0661c;
  --chip-unsure: #7b5cc7;
  --shadow: 0 1px 2px rgba(20, 20, 18, .04), 0 4px 16px rgba(20, 20, 18, .04);
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315;
    --card: #1b1e21;
    --card-2: #22262a;
    --text: #eceef0;
    --muted: #9a9ea5;
    --line: #2b2f34;
    --track: #2b2f34;
    --accent: #5fb8ad;
    --accent-soft: #1f3533;
    --accent-text: #0d1716;
    --good: #5cbf80;
    --warn: #e2a93b;
    --bad: #ee7a6f;
    --in: #62c88a;
    --chip-necessary: #a3a7ae;
    --chip-fine: #5cbf80;
    --chip-impulsive: #f08a45;
    --chip-unsure: #a98bf0;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --card: #1b1e21; --card-2: #22262a; --text: #eceef0; --muted: #9a9ea5; --line: #2b2f34;
  --track: #2b2f34; --accent: #5fb8ad; --accent-soft: #1f3533; --accent-text: #0d1716; --good: #5cbf80;
  --warn: #e2a93b; --bad: #ee7a6f; --in: #62c88a; --chip-necessary: #a3a7ae; --chip-fine: #5cbf80;
  --chip-impulsive: #f08a45; --chip-unsure: #a98bf0; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 32px);
}
h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0; font-weight: 700; }
h2 { font-size: 1rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.eyebrow { font-size: .8rem; color: var(--muted); font-weight: 500; }
.note { font-size: .85rem; color: var(--muted); margin: 6px 0 4px; }
.error { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin-top: 8px; }

.top { display: flex; justify-content: space-between; align-items: flex-end; margin: 4px 2px 18px; }
.actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); color: var(--muted);
  display: grid; place-items: center; box-shadow: var(--shadow); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }

/* hero */
.hero {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 24px;
  padding: 22px 20px 18px;
  margin-bottom: 14px;
}
.hero-label { font-size: .9rem; opacity: .85; font-weight: 500; }
.hero-amount { font-size: 3.2rem; font-weight: 750; letter-spacing: -.035em; line-height: 1.05; margin: 6px 0 6px; }
.hero-sub { font-size: .95rem; opacity: .9; }
.hero-facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.fact { background: rgba(255, 255, 255, .16); border-radius: 12px; padding: 7px 11px; font-size: .8rem; }
.fact b { display: block; font-size: .95rem; font-weight: 650; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fact { background: rgba(0, 0, 0, .14); } }

/* verdict */
.chat { display: flex; gap: 10px; align-items: flex-start; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: .85rem;
}
.bubble {
  background: var(--card-2); border-radius: 4px 18px 18px 18px; padding: 12px 14px; white-space: pre-wrap;
  font-size: .93rem; min-width: 0; overflow-wrap: anywhere;
}
.solution {
  margin-top: 10px; background: var(--accent-soft); border-radius: 14px; padding: 10px 12px; font-size: .92rem;
  border-left: 3px solid var(--accent); white-space: normal;
}
.solution b { color: var(--accent); display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }

/* pace chart */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .actual { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .pace { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.legend { display: flex; gap: 16px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legend i.dash { border-top: 1.5px dashed var(--muted); }
.pill { font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill.good { color: var(--good); }
.pill.bad { color: var(--bad); }

/* categories */
.cats { list-style: none; margin: 0; padding: 0; }
.cats li { padding: 12px 0; border-top: 1px solid var(--line); }
.cats li:first-child { border-top: 0; padding-top: 4px; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.cat-name { font-weight: 550; }
.cat-left { font-size: .88rem; font-weight: 600; white-space: nowrap; }
.cat-sub { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.bar { height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar.thin { height: 6px; }
.bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); }
.ok .bar span { background: var(--good); }
.near .bar span { background: var(--warn); }
.over .bar span { background: var(--bad); }
.none .bar span { background: var(--muted); opacity: .45; }
.ok .cat-left { color: var(--good); }
.near .cat-left { color: var(--warn); }
.over .cat-left { color: var(--bad); }
.none .cat-left { color: var(--muted); font-weight: 500; }

/* tax and savings */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair .card { margin: 0 0 14px; display: flex; flex-direction: column; }
.pair h2 { margin-bottom: 10px; }
.ring { display: grid; place-items: center; margin: 2px 0 6px; }
.ring svg { width: 112px; height: 112px; }
.ring .track { fill: none; stroke: var(--track); stroke-width: 10; }
.ring .fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .6s; }
.ring .v { fill: var(--text); font-size: 17px; font-weight: 700; text-anchor: middle; }
.ring .k { fill: var(--muted); font-size: 10px; text-anchor: middle; }
.mini { margin-top: auto; padding-top: 10px; }
.mini-row { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); gap: 6px; margin-top: 4px; }
.mini-row span:last-child { color: var(--text); font-weight: 600; }
.big { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; margin-top: 8px; }
@media (max-width: 340px) { .pair { grid-template-columns: 1fr; } }

/* transactions */
.day { font-size: .78rem; font-weight: 650; color: var(--muted); margin: 18px 0 2px; text-transform: uppercase; letter-spacing: .04em; }
.day:first-child { margin-top: 4px; }
.tx { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.day + .tx { border-top: 0; }
.tx .l { min-width: 0; }
.tx .m { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .c { font-size: .78rem; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx .r { text-align: right; white-space: nowrap; }
.tx .a { font-weight: 650; }
.tx .a.in { color: var(--in); }
.tx .a.quiet { color: var(--muted); font-weight: 500; }
.tx .t { font-size: .72rem; color: var(--chip-impulsive); }
.chip { font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--card-2); }
.chip.necessary { color: var(--chip-necessary); }
.chip.fine { color: var(--chip-fine); }
.chip.impulsive { color: var(--chip-impulsive); }
.chip.unsure { color: var(--chip-unsure); }
.chip.plain { color: var(--muted); font-weight: 500; }

/* forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 14px; }
input, select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 12px; appearance: none;
}
button { font: inherit; cursor: pointer; }
button.primary {
  width: 100%; min-height: 48px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  font-weight: 650; font-size: 1rem;
}
button.link { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: .88rem; padding: 6px 0; }
button:disabled { opacity: .6; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 48px 0 24px; }
.login-icon { border-radius: 16px; }

dialog {
  border: 0; padding: 0; width: min(520px, 100%); max-height: 88vh; background: var(--card); color: var(--text);
  border-radius: 24px 24px 0 0; margin: auto auto 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog form { padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px); }
.fields { margin-top: 12px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.field span { font-weight: 550; }
.field input { width: 120px; margin: 0; text-align: right; }
.add-row { margin: 8px 0 4px; }
