@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #0e0f12;
  --surface: #1a1b21;
  --surface-2: #2a2c34;
  --ink: #f4f4f0;
  --ink-2: #c4c6cd;
  --muted: #a3a6af;
  --on-accent: #0e0f12;
  --accent: #c8f560;
  --accent-soft: #1f2a10;
  --violet: #a99bff;
  --violet-soft: #241f3d;
  --cyan: #7be0ff;
  --orange: #ffb27a;
  --pink: #ff8fb1;
  --yellow: #f4e07a;
  --grey: #8a8d96;
  --radius: 24px;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.15; margin: 0; }
h1 { font: 700 28px/1.1 var(--display); letter-spacing: -0.02em; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
a.plain-link { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.neg { color: var(--orange); }
.pos { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button { font: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none;
}
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--orange); padding: 0; min-height: 44px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 0; border-radius: 14px; min-height: 48px; padding: 0 14px;
}

/* ---- login ---- */
.login { max-width: 420px; margin: 0 auto; padding: 14vh 20px 40px; display: grid; gap: 16px; }
.logo { font: 700 40px/1 var(--display); letter-spacing: -0.04em; }
.logo span { color: var(--accent); }
.login form { display: grid; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 20px; }
.login label { font-weight: 600; color: var(--ink-2); font-size: 14px; }

/* ---- shell ---- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 20px 120px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 26px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: var(--violet-soft); color: #c9c0ff;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button {
  border: 0; border-radius: 999px; min-height: 40px; min-width: 44px; padding: 0 14px;
  background: transparent; color: var(--muted); font-weight: 700; font-size: 13px;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg.wide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
#btn-sync:disabled svg { animation: spin 1s linear infinite; }
.icon-btn:disabled:not(#btn-sync) { opacity: 0.35; cursor: default; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #btn-sync:disabled svg { animation: none; } }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 5;
  display: flex; justify-content: space-between; gap: 4px;
  background: var(--surface); border-radius: 28px; padding: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.nav a {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 54px; border-radius: 20px; text-decoration: none;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.nav a[aria-current="page"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.status {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 18px; background: #3a2a1e; color: var(--orange); font-weight: 600;
}
.view { display: flex; flex-direction: column; gap: 14px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cols { display: grid; gap: 14px; }

/* ---- cards ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.tight { padding: 6px 18px; gap: 0; }
.hero { border-radius: 28px; padding: 22px; display: flex; flex-direction: column; gap: 6px; color: var(--on-accent); background: var(--accent); }
.hero.violet { background: var(--violet); }
.hero .label { font-size: 13px; font-weight: 700; }
.hero .big { font: 700 46px/1 var(--display); letter-spacing: -0.03em; }
.hero .sub { font-size: 13px; font-weight: 600; }
.hero-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.pair > div { background: rgba(14, 15, 18, 0.08); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.pair .k { font-size: 12px; font-weight: 600; }
.pair .v { font: 700 20px/1.2 var(--display); }
.big-num { font: 700 42px/1 var(--display); letter-spacing: -0.03em; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.hero .label { color: inherit; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font: 700 22px/1.2 var(--display); }
.kpi .sub { font-size: 12px; color: var(--muted); }
a.kpi:hover { background: var(--surface-2); }

.insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.insight { text-decoration: none; color: var(--ink); background: var(--surface); border-radius: 20px; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }
.tip-card { background: var(--violet-soft); border-radius: 20px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.45; }
.tip-card svg { color: var(--violet); margin-top: 1px; }
.tip-card a { color: #c9c0ff; font-weight: 700; }

.actions-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.action { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-align: center; }
.action span.ic { width: 56px; height: 56px; border-radius: 18px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--accent); }

/* progress bars */
.meter { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: flex; }
.meter.thin { height: 10px; }
.meter > div { height: 100%; background: var(--accent); }
.meter > div.over { background: var(--orange); }
.meter > div.violet { background: var(--violet); }
.stack { display: flex; gap: 3px; height: 18px; }
.stack > div { border-radius: 4px; min-width: 4px; }

/* list rows */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.row-item:last-child { border-bottom: 0; }
.row-item.conn { flex-wrap: wrap; }
.row-item.conn .actions { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row-item .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-item .title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .meta { font-size: 12px; color: var(--muted); }
.row-item .amt { font: 600 16px/1.2 var(--display); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.row-item .amt small { display: block; font: 500 12px Inter, sans-serif; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 14px; background: var(--surface-2); flex: none; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #3a2a1e; color: var(--orange); margin-left: 6px; vertical-align: 1px; }

/* ask Claude */
.ask-wrap { display: flex; flex-direction: column; gap: 10px; }
.ask { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 999px; padding: 6px 6px 6px 16px; }
.ask > svg { color: var(--violet); }
.ask input { flex: 1; min-width: 0; background: transparent; padding: 0; min-height: 44px; }
.ask .send { background: var(--violet); color: var(--on-accent); }
.answer { background: var(--violet-soft); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.answer .q { font-weight: 700; }
.answer .a { white-space: pre-line; line-height: 1.5; }

/* lists, filters, tables */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; align-self: flex-start; }
.chip-link svg { width: 18px; height: 18px; color: var(--accent); }
.filters, .form { display: grid; gap: 8px; }
.filters .seg, .form .seg { margin-top: 4px; }
.seg.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.date-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 14px 0 2px; }
.date-chip { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); flex: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 10px; text-transform: uppercase; color: var(--muted); line-height: 1.1; }
.date-chip b { font: 700 16px var(--display); color: var(--ink); }
.dim { opacity: 0.6; }
.pad { padding: 14px 0; }
.btn.small { min-height: 44px; font-size: 14px; align-self: flex-start; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--surface-2); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--display); font-variant-numeric: tabular-nums; }
tfoot th { color: var(--ink); font-size: 14px; border-bottom: 0; }

/* edit sheet, rules */
dialog.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 48px); overflow: auto;
  border: 0; border-radius: 24px; padding: 20px; background: var(--surface); color: var(--ink);
  display: grid; gap: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.6); }
.picker { display: grid; gap: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin-top: 1px; accent-color: var(--accent); flex: none; }
.row-btn { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--surface-2); color: inherit;
  text-align: left; font: inherit; cursor: pointer; border-radius: 0; }
.row-btn:hover { background: rgba(255, 255, 255, 0.03); }
.pill.kind-income, .pill.kind-refund { background: var(--accent-soft); color: var(--accent); }
.pill.kind-saving, .pill.kind-investment { background: #1b2e36; color: var(--cyan); }
.pill.kind-transfer, .pill.kind-card_payment, .pill.kind-loan_payment, .pill.kind-ignore { background: var(--surface-2); color: var(--ink-2); }
.rule-text { font-size: 15px; font-weight: 600; line-height: 1.4; }
.block { display: block; }
select { width: 100%; }

/* privacy policy page */
.doc { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; display: grid; gap: 12px; line-height: 1.6; }
.doc h2 { margin-top: 18px; }
.doc ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.doc hr { border: 0; border-top: 1px solid var(--surface-2); margin: 32px 0; }

/* budget */
.ring-card { flex-direction: row; align-items: center; gap: 18px; }
.ring { flex: none; }
.ring-label { fill: var(--ink); font: 700 22px var(--display); }
.ring-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.streak { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-radius: 18px; padding: 12px 14px; font-size: 14px; font-weight: 600; }
.streak svg { color: var(--accent); }
.ink { color: var(--ink); }
.grow { flex: 1; }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 64px; text-align: left; color: var(--ink);
  background: var(--surface-2); border: 2px solid transparent; border-radius: 18px; padding: 10px 14px;
}
.choice .main { display: flex; flex-direction: column; gap: 2px; }
.choice .title { font-size: 15px; font-weight: 700; }
.choice .meta { font-size: 12px; color: var(--muted); }
.choice .radio { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--muted); flex: none; }
.choice[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.choice[aria-pressed="true"] .radio { border-color: var(--accent); background: var(--accent); }
.amount-input { width: 110px; text-align: right; font: 600 16px var(--display); }
label.main { cursor: pointer; }

/* debt cards / plan */
.debt { background: var(--surface); border-radius: 22px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.debt .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.debt .facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plan li { display: flex; align-items: center; gap: 12px; border-radius: 20px; padding: 14px; background: var(--surface); }
.plan li .n { width: 36px; height: 36px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center; font: 700 16px var(--display); background: var(--surface-2); }
.plan li .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.plan li .main span:first-child { font-weight: 700; }
.plan li .main span:last-child { font-size: 12px; font-weight: 600; opacity: 0.85; }
.plan li .amt { font: 700 16px var(--display); }
.plan li.first { background: var(--accent); color: var(--on-accent); }
.plan li.first .n { background: var(--on-accent); color: var(--accent); }

/* charts */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; align-items: center; gap: 10px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 14px; }
.bar-row .amt { font-family: var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 14px; }
.track { height: 14px; }
.fill { height: 14px; border-radius: 6px; background: var(--accent); min-width: 3px; }
.fill.s2 { background: var(--orange); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .s1 { background: var(--accent); }
.legend .s2 { background: var(--violet); }
.legend .s3 { background: var(--orange); }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .gridline { stroke: var(--surface-2); stroke-width: 1; }
svg.chart .baseline { stroke: #3a3c45; stroke-width: 1; }
svg.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .s1 { fill: var(--accent); }
svg.chart .s2 { fill: var(--violet); }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
svg.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover, svg.chart .hit:focus { fill: rgba(255, 255, 255, 0.06); }

.empty { text-align: left; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 12px; line-height: 1.45; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }

#tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 280px;
  background: var(--ink); color: var(--page); font-size: 13px; padding: 8px 10px; border-radius: 10px;
  white-space: pre-line; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* ---- wide screens: side nav, two columns ---- */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); column-gap: 32px; padding-bottom: 48px; }
  .top { grid-column: 1 / -1; }
  .nav {
    position: sticky; top: 16px; align-self: start; grid-row: 2 / span 2;
    flex-direction: column; justify-content: flex-start; box-shadow: none; padding: 10px;
  }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 16px; min-height: 48px; font-size: 14px; }
  .status, .view { grid-column: 2; }
  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .cols > .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .hero .big { font-size: 40px; }
  .bar-row { grid-template-columns: minmax(90px, 40%) 1fr; }
  .bar-row .amt { grid-column: 1 / -1; justify-self: end; margin-top: -6px; font-size: 13px; }
}

/* Debts typed by hand: an Edit button next to the row / card. */
.row-wrap { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--surface-2); }
.row-wrap:last-child { border-bottom: 0; }
.row-wrap .row-item { flex: 1; min-width: 0; border-bottom: 0; }
.debt > .btn.small { align-self: flex-start; }

/* Connect by email */
.inbox-addr { display: block; margin: 6px 0 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2);
  font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; color: var(--ink); }
ol.steps { margin: 8px 0 12px; padding-left: 20px; display: grid; gap: 8px; }
details.guide { border-bottom: 1px solid var(--surface-2); padding: 12px 0; }
details.guide:last-child { border-bottom: 0; }
details.guide summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details.guide p { margin: 8px 0 0; }
.card.suggest h2 { display: flex; align-items: center; gap: 8px; }
ul.suggest-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
ul.suggest-list li { display: grid; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--surface-2); }
ul.suggest-list li:last-child { border-bottom: 0; padding-bottom: 0; }
details.guides > summary.guides-summary { cursor: pointer; display: grid; gap: 4px; list-style: none; }
details.guides > summary.guides-summary::-webkit-details-marker { display: none; }
details.guides > summary.guides-summary strong::after { content: " ›"; color: var(--muted); }
details.guides[open] > summary.guides-summary strong::after { content: " ⌄"; }
.suggest .chips { margin-top: 4px; }
.suggest .chip-link { min-height: 40px; padding: 0 12px; background: var(--surface-2); font-size: 14px; }
.card.form.narrow { max-width: 560px; }

/* Amount fields: "$ 27,041.59", "0.99 %" */
.money-wrap { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); }
.money-wrap:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.money-wrap input { flex: 1; min-width: 0; background: transparent; padding: 0; border-radius: 0; font-variant-numeric: tabular-nums; }
.money-wrap input:focus-visible { outline: none; }
.money-affix { color: var(--muted); font-weight: 600; }
.commit { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--surface-2); }
.commit h3 { margin: 0; }
