:root {
  --bg: #0d0f14; --surface: #151923; --raised: #1c2130; --line: #262c3d;
  --text: #e8eaf0; --muted: #8a92a6; --mint: #5eead4; --violet: #a78bfa;
  --warn: #fbbf24; --over: #fb7185; --ink: #0d0f14;
  --sans: "Space Grotesk", system-ui, sans-serif; --mono: "Space Mono", ui-monospace, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  /* Mint green and light purple on a soft lavender-white. */
  --bg: #f6f4fc; --surface: #ffffff; --raised: #efebfa; --line: #e1daf3;
  --text: #1c1a2e; --muted: #655f7d; --mint: #12a883; --violet: #8f73f2;
  --warn: #b7791f; --over: #d6336c; --ink: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--mint); }
h1, h2, h3 { margin: 0; font-weight: 600; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* header */
header { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar { max-width: 1040px; margin: 0 auto; padding: 10px 16px 0; }
.brand { font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mark { height: 1.5em; width: 1.5em; vertical-align: -0.4em; margin-right: 0.15em; border-radius: 24%; }
.search { flex: 1; min-width: 0; max-width: 300px; margin-left: auto; }
.themes { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.themes button { border: 0; background: none; border-radius: 999px; width: 30px; height: 26px; cursor: pointer; color: var(--muted); }
.themes button[aria-pressed="true"] { background: var(--raised); color: var(--text); }
nav { display: flex; gap: 2px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
nav a.on { color: var(--text); border-color: var(--mint); }
nav a .badge { margin-left: 6px; }

main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 90px; }
section + section, .stack > * + * { margin-top: 16px; }

/* controls */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"],
input[type="search"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; width: 100%; }
textarea { min-height: 120px; font-family: var(--mono); font-size: 12px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--violet); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); }
.btn { border: 1px solid var(--line); background: var(--raised); border-radius: 9px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--mint); border-color: var(--mint); color: var(--ink); font-weight: 600; }
.btn.quiet { background: none; }
.btn.danger { color: var(--over); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; background: none; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--violet); border-color: var(--violet); color: var(--ink); font-weight: 600; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; background: var(--raised); color: var(--muted); white-space: nowrap; }
.badge.mint { background: color-mix(in srgb, var(--mint) 18%, transparent); color: var(--mint); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.over { background: color-mix(in srgb, var(--over) 18%, transparent); color: var(--over); }
.badge.violet { background: color-mix(in srgb, var(--violet) 20%, transparent); color: var(--violet); }
/* A tag: the household's own label. Outlined, so it never reads as a status. */
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-size: 12px; color: var(--text); white-space: nowrap; margin-left: 4px; }
.tag::before { content: "#"; color: var(--muted); margin-right: 1px; }
.item .s .tag, .item .n .tag { margin-left: 0; }
.plainlist { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 5px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .v { font: 700 24px/1.2 var(--mono); margin-top: 4px; }
.stat .v.good { color: var(--mint); } .stat .v.bad { color: var(--over); }
.stat .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.period { display: flex; align-items: center; gap: 8px; }
.period h2 { font-size: 18px; }
.block-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 2px 8px; display: flex; justify-content: space-between; }

.budget { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; overflow: hidden; }
.budget.drop { border-color: var(--mint); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mint) 30%, transparent); }
.budget > button { all: unset; box-sizing: border-box; width: 100%; cursor: pointer; padding: 11px 14px; display: block; }
.budget .top { display: flex; align-items: baseline; gap: 8px; }
.budget .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget .amt { margin-left: auto; font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.budget .amt .of { color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--raised); margin-top: 8px; position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--mint); border-radius: 3px; }
.meter.close i { background: var(--warn); } .meter.over i { background: var(--over); }
.meter b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: 0.6; }
.items { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; border-top: 1px solid var(--line); }
.items .item:first-child { border-top: 0; }
.item:hover { background: var(--raised); }
.item .d { color: var(--muted); font-size: 12px; width: 44px; flex: none; font-family: var(--mono); }
.item .t { min-width: 0; flex: 1; }
.item .t .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 1px; }
.item .a { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.item.out .n, .item.out .a { text-decoration: line-through; color: var(--muted); }
.item.dragging { opacity: 0.4; }
.empty { color: var(--muted); padding: 22px 8px; text-align: center; }

details.fold { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
details.fold > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "›"; color: var(--muted); transition: transform 0.15s; display: inline-block; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > summary .right { margin-left: auto; font-weight: 400; }
details.fold > .body { border-top: 1px solid var(--line); padding: 12px 14px; }
details.fold > .body.flush { padding: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px; white-space: nowrap; }
td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; }
.scroll-x { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.code { font-family: var(--mono); font-size: 13px; background: var(--raised); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; user-select: all; }
ol.steps { margin: 8px 0 0; padding-left: 20px; } ol.steps li { margin-top: 6px; }
pre.body { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 var(--mono); max-height: 50vh; overflow: auto; background: var(--raised); border-radius: 8px; padding: 10px; margin: 0; }

/* sign in */
.auth { max-width: 380px; margin: 9vh auto 0; padding: 0 16px; }
.auth h1 { font-size: 28px; letter-spacing: -0.02em; } .auth h1 span { color: var(--mint); }
.auth form { margin-top: 18px; display: grid; gap: 12px; }
.error { color: var(--over); font-size: 13px; min-height: 18px; }

/* sheet */
dialog { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 16px; padding: 0; overflow: hidden;
  width: min(520px, calc(100vw - 24px)); max-height: calc((100dvh - 24px) / var(--zoom, 1)); }
/* The sheet scrolls inside itself, so its top and its buttons are always on screen however long it gets. */
.sheet-in { padding: 18px 18px 0; overflow: auto; max-height: calc((100dvh - 26px) / var(--zoom, 1)); overscroll-behavior: contain; }
.sheet-in > :last-child:not(.actions) { margin-bottom: 18px; }
.sheet-in > .actions { position: sticky; bottom: 0; margin: 16px -18px 0; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--line); z-index: 1; }
dialog::backdrop { background: rgba(5, 7, 12, 0.6); }
dialog h3 { font-size: 17px; overflow-wrap: anywhere; }
dialog .form { display: grid; gap: 12px; margin-top: 14px; }
dialog .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
dialog .actions .spacer { flex: 1; }

#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; display: none;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px; gap: 10px; align-items: center;
  max-width: calc(100vw - 24px); box-shadow: 0 8px 30px rgba(0,0,0,0.35); }
#toast.show { display: flex; }
#toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 2px 4px; white-space: nowrap; }

@media (max-width: 560px) {
  .brand { max-width: 46vw; }
  .item .d { width: 38px; }
  .stat .v { font-size: 20px; }
  dialog { margin-bottom: 12px; }
}

main > * + * { margin-top: 14px; }
.row > select, .row > input[type="checkbox"], td select { width: auto; }
td input[type="text"] { min-width: 90px; }
.item select.pick { width: auto; max-width: 42%; flex: none; }
label.row { color: var(--text); font-size: 14px; }
label.row > input { margin-top: 0; }

.changed { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 9px 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; color: var(--muted); }
.changed strong { color: var(--text); }
.hbar { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 8px; align-items: center; margin-top: 6px; }
.hbar .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hbar .meter { margin-top: 0; display: block; }

@media (max-width: 560px) {
  .bar > .row { flex-wrap: wrap; }
  .brand { flex: 1; max-width: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  main h2.grow { flex-basis: 100%; }
}

/* views */
body.compact .item { padding: 5px 12px; } body.compact .budget > button { padding: 7px 12px; }
body.compact .stat { padding: 8px 12px; } body.compact .stat .v { font-size: 19px; } body.compact main > * + * { margin-top: 9px; }
body.compact .budget { margin-top: 5px; } body.compact .block-title { margin: 10px 2px 5px; }
body.roomy .item { padding: 13px 16px; } body.roomy .budget > button { padding: 15px 16px; }
body.roomy main > * + * { margin-top: 20px; } body.roomy .budget { margin-top: 11px; }
.card.flush { padding: 0; overflow: hidden; }
.card.note { margin-bottom: 0; }
.viewcard { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.viewcard.on { border-color: var(--mint); }
.viewcard .badge { margin-left: 8px; }
.blockrow { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; display: grid; gap: 6px; }
.blockrow select, .blockrow input[type="text"] { width: auto; flex: 1; min-width: 120px; }
input.short { width: 110px; }
textarea.plainarea { font: inherit; min-height: 84px; }
input[type="checkbox"] { width: auto; }
dialog .form > div > label { margin-bottom: 4px; }

/* ask */
.chat { display: grid; gap: 10px; }
.msg { border-radius: 14px; padding: 10px 14px; max-width: 46em; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { background: var(--raised); justify-self: end; }
.msg.assistant { background: var(--surface); border: 1px solid var(--line); justify-self: start; }
.msg.failed { color: var(--over); }
body.roomy .budget .top { flex-wrap: wrap; }
body.roomy .budget .name { white-space: normal; }

/* charts: a validated eight-hue palette, stepped separately for each theme */
:root { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --so: #6b7285; --grid: #262c3d; --axis: #3a4257; }
:root[data-theme="light"] { --s1: #8f73f2; --s2: #f08a5d; --s3: #17b890; --s4: #eda100; --s5: #e87ba4; --s6: #2aa9c9; --s7: #5b47c9; --so: #b3adc9; --grid: #ebe6f7; --axis: #cfc7e6; }
.s1 { fill: var(--s1); background: var(--s1); } .s2 { fill: var(--s2); background: var(--s2); } .s3 { fill: var(--s3); background: var(--s3); }
.s4 { fill: var(--s4); background: var(--s4); } .s5 { fill: var(--s5); background: var(--s5); } .s6 { fill: var(--s6); background: var(--s6); }
.s7 { fill: var(--s7); background: var(--s7); } .other { fill: var(--so); background: var(--so); }
.card.chart { padding: 14px 16px; }
.chead { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.cbody { min-height: 40px; }
svg.plot { display: block; max-width: 100%; overflow: visible; }
.plot .grid { stroke: var(--grid); stroke-width: 1; } .plot .axis { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--muted); font: 11px var(--mono); } .plot .val { fill: var(--text); font: 600 11px var(--mono); }
.plot .line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .area { fill: var(--s1); opacity: 0.1; } .plot .dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.plot .cross { stroke: var(--axis); stroke-width: 1; opacity: 0; } .plot .cross.on { opacity: 1; }
.plot .hit { fill: transparent; outline: none; } .plot .hit.pick { cursor: pointer; }
.plot .hit:hover, .plot .hit:focus-visible { fill: color-mix(in srgb, var(--text) 7%, transparent); }
.cbars { display: grid; gap: 7px; }
.cbar { display: grid; grid-template-columns: minmax(84px, 30%) 1fr auto; gap: 10px; align-items: center; border-radius: 6px; padding: 2px 4px; margin: 0 -4px; }
.cbar.pick { cursor: pointer; } .cbar:hover, .cbar:focus-visible { background: var(--raised); }
.cbar .cl { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbar .ct { height: 14px; display: block; }
.cbar .ct i { display: block; height: 100%; min-width: 2px; background: var(--s1); border-radius: 0 4px 4px 0; } .cbar .ct i.other { background: var(--so); }
.cbar .cv { font: 13px var(--mono); white-space: nowrap; }
.seg { display: flex; gap: 2px; height: 28px; }
.segb { min-width: 3px; flex-basis: 0; border-radius: 4px; color: #fff; font: 600 12px var(--mono); display: flex; align-items: center; padding-left: 7px; overflow: hidden; white-space: nowrap; }
.segb.s4 { color: #0b0b0b; } .segb.pick { cursor: pointer; } .segb:hover, .segb:focus-visible { filter: brightness(1.12); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.tip { position: fixed; z-index: 40; pointer-events: none; opacity: 0; background: var(--text); color: var(--bg); border-radius: 9px; padding: 7px 10px; font-size: 12px; max-width: 260px; box-shadow: 0 6px 24px rgba(0,0,0,0.35); }
.tip.on { opacity: 1; }
.tiprow { display: flex; align-items: center; gap: 7px; white-space: nowrap; } .tiprow strong { font-family: var(--mono); }
.tiprow .key { width: 12px; height: 3px; border-radius: 2px; }
table.ctable td, table.ctable th { padding: 5px 8px; font-size: 13px; }

/* explore */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input { width: auto; flex: 0 1 auto; max-width: 100%; }
table.xtable th { padding: 0; }
table.xtable td { font-size: 14px; }
table.xtable tbody tr { cursor: pointer; } table.xtable tbody tr:hover, table.xtable tbody tr:focus-visible { background: var(--raised); }
table.xtable tr.out td { color: var(--muted); } table.xtable td .badge { margin-left: 6px; }
button.sort { all: unset; cursor: pointer; display: block; padding: 9px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; box-sizing: border-box; width: 100%; }
th.r button.sort { text-align: right; } button.sort.on { color: var(--text); font-weight: 600; } button.sort:focus-visible { outline: 2px solid var(--violet); }
.chat .card.chart { justify-self: stretch; }

/* setup */
.setgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.setcard { display: grid; gap: 6px; align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--text); text-decoration: none; }
.setcard:hover, .setcard:focus-visible { border-color: var(--mint); }
.setcard strong { font-size: 16px; } .setcard .badge { justify-self: start; margin-top: 4px; white-space: normal; }
.setup { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; align-items: start; }
.setnav { display: grid; gap: 2px; position: sticky; top: 110px; }
.setnav a { padding: 8px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; }
.setnav a:hover { color: var(--text); background: var(--surface); }
.setnav a.on { color: var(--text); background: var(--raised); font-weight: 600; }
.setnav a.back { color: var(--mint); margin-bottom: 6px; }
.setpanel h2 { font-size: 22px; } .setpanel h2 + p { margin: 4px 0 0; }
.setpanel h3, .card h3 { font-size: 16px; } .card h3 + p { margin: 3px 0 0; }
.stack.tight > * + * { margin-top: 8px; }
.editrow > input[type="text"], .editrow > select { flex: 1; min-width: 0; width: auto; }
.editrow > input.short { flex: 0 0 96px; }
input.swatch { width: 44px; flex: none; padding: 2px; height: 38px; }
.item.plain { cursor: default; } .item.plain:hover { background: none; }
table.edit td { padding: 5px 4px; border-top: 0; } table.edit input.short { width: 96px; }
table.edit td:first-child input { min-width: 150px; } table.edit td:nth-child(6) input { min-width: 170px; }
.btn.add { margin-left: 4px; }
@media (max-width: 760px) {
  .setup { grid-template-columns: 1fr; gap: 14px; }
  .setnav { position: static; display: block; }
  .setnav a:not(.back) { display: none; }
  .setnav a.back { display: inline-block; padding-left: 0; margin: 0; }
}
@media (max-width: 560px) { .btn.add { order: 2; } }
.item.plain .n { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 760px) { .setup { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- simpler shell */
.row.top { min-height: 40px; }
nav a { padding: 10px 14px; font-weight: 500; }
.segctl { display: inline-flex; background: var(--raised); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.segctl button { border: 0; background: none; color: var(--muted); padding: 7px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 500; }
.segctl button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.period h2 { font-size: 20px; }
p.asof { text-align: center; margin-top: 22px; }
.card.order { overflow: hidden; }
.ohead { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.ohead:hover, .ohead:focus-visible { background: var(--raised); }
.ohead .num { font-family: var(--mono); white-space: nowrap; }
.card.order .items { border-top: 1px solid var(--line); }
button.choice { all: unset; box-sizing: border-box; display: grid; gap: 4px; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
button.choice:hover, button.choice:focus-visible { border-color: var(--mint); }
button.choice.on { border-color: var(--mint); background: color-mix(in srgb, var(--mint) 12%, var(--surface)); }
button.choice strong { font-size: 16px; }

/* setup */
.setup { grid-template-columns: 200px minmax(0, 1fr); }
.setnav { top: 112px; }
.setpick { display: none; }
.note { border-left: 3px solid var(--warn); padding-left: 10px; }
.toggles { display: grid; }
label.toggle { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text); font-size: 15px; cursor: pointer; }
label.toggle:first-child { border-top: 0; }
label.toggle .grow { display: grid; gap: 2px; }
label.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
label.toggle input:checked + .switch { background: var(--mint); }
label.toggle input:checked + .switch::after { transform: translateX(18px); }
label.toggle input:focus-visible + .switch { outline: 2px solid var(--violet); outline-offset: 2px; }
details.opts > summary { cursor: pointer; list-style: none; } details.opts > summary::-webkit-details-marker { display: none; }
details.opts[open] > summary { margin-bottom: 8px; }
@media (max-width: 760px) {
  .setup { grid-template-columns: minmax(0, 1fr); }
  .setnav { display: none; }
  .setpick { display: block; }
}

/* onboarding */
main.onboard { max-width: 620px; padding-top: 6vh; }
.obcard h1 { font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; }
.obcard .lead { font-size: 17px; color: var(--muted); }
.brand.big { font-size: 18px; } .brand.big span { color: var(--mint); }
.btn.big { padding: 12px 22px; font-size: 16px; }
.choices { display: grid; gap: 10px; }
.obdots { display: flex; gap: 6px; } .obdots i { width: 28px; height: 4px; border-radius: 2px; background: var(--line); } .obdots i.on { background: var(--mint); }
ol.obhome { margin: 0; padding-left: 22px; } ol.obhome li { margin-top: 4px; }

/* helper */
.helperbtn { position: fixed; right: 18px; bottom: 18px; z-index: 30; border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 700;
  background: var(--violet); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.3); cursor: pointer; font-size: 15px; }
.helperbtn:hover { filter: brightness(1.08); }
.helper { position: fixed; z-index: 31; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,0.25); }
.helper[hidden], .helperbtn[hidden] { display: none; }
.hhead { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.hlog { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 10px; align-content: start; }
.hlog .msg { max-width: 100%; }
.hform { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.hform textarea { min-height: 44px; max-height: 140px; font-family: var(--sans); font-size: 15px; resize: vertical; }
.hbtns { display: grid; gap: 6px; }
/* The Speak button. Red while listening, so it's plain the microphone is on. */
.btn.mic.on { border-color: var(--over); color: var(--over); }
.btn.mic.on::before { content: "● "; }
.changes { border: 1px solid var(--violet); border-radius: 12px; padding: 12px; display: grid; gap: 8px; background: var(--surface); }
.changes.done { border-color: var(--mint); } .changes .bad { color: var(--over); }
label.change { align-items: flex-start; font-size: 14px; color: var(--text); } label.change input { margin-top: 3px; }
@media (max-width: 760px) {
  .helper { top: auto; height: 86dvh; width: 100vw; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; }
}
@media (min-width: 1300px) { body:has(.helper:not([hidden])) main { margin-right: 440px; } }
@media (max-width: 760px) { #toast { bottom: 80px; } }
.btn { max-width: 100%; white-space: normal; text-align: center; }
.btn.sm, nav a, .chip { white-space: nowrap; }

/* Categories on a phone: one card per category, each field labelled, nothing off to the side. */
@media (max-width: 640px) {
  table.catedit thead { display: none; }
  table.catedit, table.catedit tbody { display: block; }
  table.catedit tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.catedit td { display: block; padding: 0; }
  table.catedit td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  table.catedit td:first-child, table.catedit td:nth-child(6) { grid-column: 1 / -1; }
  table.catedit td input, table.catedit td select { width: 100%; min-width: 0 !important; }
  table.catedit td:last-child { grid-column: 1 / -1; justify-self: end; }
}

/* Accounts */
.acct-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.acct-head .num { font-family: var(--mono); }
.item.dim { opacity: 0.55; }
.item .s .good { color: var(--mint); } .item .s .bad { color: var(--over); }

/* Sign-in, consent and the privacy page */
.agree { align-items: flex-start; gap: 8px; } .agree input { width: auto; margin-top: 3px; }
.policy { max-width: 720px; margin: 0 auto; padding: 24px 16px 64px; line-height: 1.6; }
.policy h1 { font-size: 30px; margin: 8px 0 4px; } .policy h2 { font-size: 19px; margin: 28px 0 6px; }
.policy ul { padding-left: 20px; } .policy li { margin: 6px 0; }

/* Sign in with Google / Apple */
.auth .social { display: grid; gap: 10px; margin: 18px 0 6px; }
.auth .social .btn { justify-content: center; text-align: center; text-decoration: none; }
.auth .social .apple { background: #000; color: #fff; border-color: #000; }
.auth .social .or { text-align: center; margin: 6px 0 0; }
.qr { display: flex; justify-content: center; margin: 8px 0; }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }

/* Choosing a plan */
.auth.plans { max-width: 640px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 18px 0; }
.plan.card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.plan.card .btn { margin-top: auto; }
.plan .price { font-size: 2rem; font-weight: 700; margin: 0; }
.plan .price span { font-size: 1rem; font-weight: 400; }

/* The household's own tabs, the import questions and the setup conversation */
.pagefoot { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
.pad { padding: 8px 14px; }
.block { display: block; }
.sheetlist { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.planq { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); flex-wrap: wrap; }
.planq select { flex: none; }
.planrow { align-items: flex-start; gap: 10px; }
.planrow input[type="checkbox"] { margin-top: 4px; flex: none; }
main.onboard.wide { max-width: 760px; }
.oblog { display: grid; gap: 10px; }
.choices.small .choice { padding: 10px 12px; }
.tiles { display: grid; gap: 10px; }
.tile { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; cursor: pointer; color: inherit; font: inherit; }
.tile:hover, .tile:focus-visible { border-color: var(--violet); }
.tile .dot { width: 10px; height: 10px; border-radius: 3px; margin: 0; flex: none; }
.tile .name { font-weight: 600; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.tile .amt { display: grid; justify-items: end; gap: 2px; flex: none; }
.tile .amt .a { font-family: var(--mono); font-size: 15px; }
.tile.goal { flex-wrap: wrap; } .tile .meter { flex: 0 0 100%; margin-top: 0; } .tile .ci { font-size: 18px; flex: none; }
.stat .v.accent { color: var(--violet); }
.fold.more { margin-top: 14px; }

/* flow, pace, calendar, compare */
.csay { font-size: 15px; margin: 2px 0 12px; }
.plot .name { fill: var(--text); font: 12px var(--sans); } .plot .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.plot .band { opacity: 0.38; outline: none; } .plot .band:hover, .plot .band:focus-visible { opacity: 0.7; } .plot .band.pick { cursor: pointer; }
.plot .good { fill: var(--mint); } .plot .node { opacity: 0.95; }
.plot .plan { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 2 4; }
.plot .before { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 4; }
.plot .line.hot { stroke: var(--over); } .plot .area.hot, .plot .dot.hot { fill: var(--over); }
.key.dash { height: 0; border-top: 2px dashed var(--muted); background: none; } .key.dots { height: 0; border-top: 2px dotted var(--muted); background: none; }
.key.tickmark { width: 2px; height: 12px; background: var(--text); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calh { font: 11px var(--mono); color: var(--muted); text-align: center; }
.cald { aspect-ratio: 1.25; min-height: 34px; border-radius: 8px; padding: 4px 6px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--raised); outline: none; }
.cald b { font: 500 11px var(--mono); color: var(--muted); } .cald i { font: 600 11px var(--mono); font-style: normal; text-align: right; }
.cald.l1 { background: color-mix(in srgb, var(--s1) 18%, var(--surface)); } .cald.l2 { background: color-mix(in srgb, var(--s1) 38%, var(--surface)); }
.cald.l3 { background: color-mix(in srgb, var(--s1) 62%, var(--surface)); } .cald.l4 { background: var(--s1); }
.cald.l3 b, .cald.l3 i, .cald.l4 b, .cald.l4 i { color: #fff; }
.cald.later { opacity: 0.35; } .cald.pick { cursor: pointer; } .cald:hover, .cald:focus-visible { box-shadow: 0 0 0 2px var(--violet); }
.cbar .ct.rel { position: relative; } .cbar .ct i.hot { background: var(--over); }
.cbar .ct .usual { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; }
.cbar .cv.bad { color: var(--over); } .cbar .cv.good { color: var(--mint); }
.item .d { white-space: nowrap; }
.gear { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  text-decoration: none; font-size: 18px; line-height: 1; margin-left: 4px; }
.gear:hover, .gear:focus-visible { color: var(--text); border-color: var(--muted); }
.gear.on { color: var(--text); border-color: var(--mint); background: var(--raised); }
@media (max-width: 560px) { .gear { order: 2; width: 30px; height: 30px; margin-left: 0; font-size: 16px; } }
.viewframe { display: block; width: 100%; height: 260px; border: 0; background: transparent; }
/* Plaid's bank-link window. On a phone Plaid sizes it with a style tag of its own, which our content policy
   refuses, so the window came out 300 by 150 at the foot of the page. These are Plaid's rules, served from here. */
html#plaid-link-temporary-id, html#plaid-link-temporary-id > body { overflow: hidden !important; }
iframe.plaid-link-iframe { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100% !important; height: 100% !important; border: 0 !important; overflow: auto !important; z-index: 9999999999 !important;
  background-color: rgba(17, 17, 18, 0.16) !important; }
.preview { border: 1px dashed var(--violet); border-radius: 12px; padding: 10px; display: grid; gap: 8px; }
.hint { margin-bottom: 10px; border-color: var(--violet); }
.xtable tbody tr[tabindex] { cursor: pointer; }
.plainlist { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 4px; }

/* the debt plan */
.debt .focus { border-color: var(--mint); }
.debt .big { font-size: 20px; } .debt .focus .num { font-family: var(--mono); }
.debtrow .meter { margin-top: 6px; } .debtrow .a { text-align: right; }
.hintrow { border-top: 1px solid var(--line); padding-top: 10px; }
.stat .v.accent, .stat .v.good, .stat .v.bad { font-size: 22px; }

/* light theme: mint and light purple touches */
:root[data-theme="light"] .stat { border-color: #e6dff7; box-shadow: 0 1px 0 rgba(143, 115, 242, 0.06); }
:root[data-theme="light"] .helperbtn { background: var(--violet); }
:root[data-theme="light"] .badge:not(.warn):not(.over):not(.mint):not(.violet) { background: #ece6fd; color: #4b3fa0; }
:root[data-theme="light"] .badge.mint { background: #d7f5ea; color: #0b6f56; }
:root[data-theme="light"] .badge.violet { background: #ece6fd; color: #5b47c9; }
:root[data-theme="light"] .tile:hover, :root[data-theme="light"] .tile:focus-visible { border-color: var(--mint); }

/* Getting started, on Home */
.startcard h3 { margin: 0; }
.startstep { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.startstep .grow { min-width: 12rem; }
.startstep .tick { flex: none; width: 22px; height: 22px; border-radius: 999px; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 13px; }
.startstep.done .tick { background: var(--mint); border-color: var(--mint); color: var(--bg); }
.startstep.done strong { color: var(--muted); font-weight: 500; }

/* transactions: categories and tags in colour, rows to tick, and the bar that changes the ticked ones */
.cat { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px 1px 7px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: color-mix(in srgb, var(--c) 62%, var(--text)); }
.cat .ci { font-size: 13px; line-height: 1; } .budget .top .ci { font-size: 15px; line-height: 1; flex: none; }
.tag[style] { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); } .tag[style]::before { color: var(--c); }
table.xtable td.in { color: var(--mint); }
table.xtable th.ck, table.xtable td.ck { width: 34px; padding: 0 0 0 12px; cursor: default; }
table.xtable td.ck input, table.xtable th.ck input { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--violet); cursor: pointer; }
table.xtable tr.sel { background: color-mix(in srgb, var(--violet) 12%, transparent); }
.newdot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--violet); margin-right: 7px; vertical-align: middle; }
.selbar { position: fixed; left: 8px; right: 8px; bottom: 16px; margin: 0 auto; width: fit-content; z-index: 15; display: none; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: var(--surface); border: 1px solid var(--violet); border-radius: 14px; padding: 8px 12px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35); max-width: calc(100% - 16px); }
.selbar.show { display: flex; } .selbar .count { font-weight: 600; font-size: 14px; white-space: nowrap; margin-right: 4px; }
.selbar select { width: auto; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
body.has-sel #toast { bottom: 84px; } body.has-sel main { padding-bottom: 90px; }

/* filters: each one can be taken away, and a dropdown ticks several things */
.filt { display: inline-flex; align-items: center; gap: 2px; border-radius: 10px; }
.filt .x { all: unset; cursor: pointer; color: var(--muted); font-size: 11px; padding: 4px 5px; border-radius: 6px; } .filt .x:hover, .filt .x:focus-visible { color: var(--text); background: var(--raised); }
.filt.on > select, .filt.on > details > summary, .filt.on > input { border-color: var(--violet); }
select.addfilter { color: var(--muted); border-style: dashed; }
details.drop { position: relative; display: inline-block; }
details.drop > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); border-radius: 10px; padding: 7px 28px 7px 10px; font-size: 14px; background: var(--surface);
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; position: relative; }
details.drop > summary::-webkit-details-marker { display: none; }
details.drop > summary::after { content: "▾"; position: absolute; right: 10px; color: var(--muted); }
details.drop > .droplist { position: absolute; z-index: 12; top: calc(100% + 4px); left: 0; width: max-content; min-width: 220px; max-width: min(320px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); display: grid; gap: 6px; }
details.drop.inline { display: block; margin-top: 8px; } details.drop.inline > summary { display: inline-block; font-size: 13px; padding: 4px 26px 4px 10px; }
details.drop.inline > .droplist { position: static; box-shadow: none; margin-top: 6px; width: auto; max-width: none; }
.ticks { display: grid; gap: 6px; min-width: 0; } .ticks .find { width: 100%; }
.ticklist { display: grid; max-height: 240px; overflow: auto; overscroll-behavior: contain; }
.tick { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; min-width: 0; }
.tick:hover, .tick:focus-visible { background: var(--raised); } .tick .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tick .dot { margin-right: 0; flex: none; }
.tick .box, .boxkey { flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1.5px solid var(--muted); border-radius: 5px; font-size: 11px; font-weight: 700; line-height: 1; color: var(--ink); }
.tick.on .box { background: var(--violet); border-color: var(--violet); }
.tick.some .box, .boxkey.some { border-color: var(--warn); border-style: dashed; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.tick.new .box { border-style: dashed; color: var(--muted); } .ticks .pad { padding: 6px 8px; }

/* to review */
.cardhead, .cardfoot { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.cardfoot { border-top: 1px solid var(--line); } .card.review { border-color: color-mix(in srgb, var(--violet) 45%, var(--line)); }
.btn.ok { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 50%, var(--line)); flex: none; }
input.emoji { width: 44px !important; min-width: 0 !important; flex: none; text-align: center; padding-left: 4px; padding-right: 4px; }
.row.tight { gap: 6px; flex-wrap: nowrap; }
.hero .stat:nth-child(1) { border-top: 3px solid var(--violet); } .hero .stat:nth-child(2) { border-top: 3px solid var(--mint); } .hero .stat:nth-child(3) { border-top: 3px solid var(--warn); }

/* setup: categories as a list, the picture picker, and the way into the hands-on settings */
.catlist .caticon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 18px; background: color-mix(in srgb, var(--c) 18%, transparent); }
.catlist .item .a.muted { color: var(--muted); font-family: var(--sans); font-size: 13px; }
.emojis { display: flex; flex-wrap: wrap; gap: 4px; max-height: 132px; overflow: auto; padding: 2px; }
.emo { all: unset; box-sizing: border-box; cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; font-size: 20px; border-radius: 9px; border: 1.5px solid transparent; }
.emo:hover, .emo:focus-visible { background: var(--raised); } .emo.on { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 16%, transparent); }
.emojis input.emoji { height: 36px; }
dialog label.toggle { border-top: 0; padding: 4px 0; }
.setnav a.adv { margin-top: 10px; border-top: 1px solid var(--line); border-radius: 0 0 9px 9px; padding-top: 12px; font-size: 13px; }
a.backlink { color: var(--mint); text-decoration: none; font-size: 14px; } a.backlink:hover { text-decoration: underline; }
a.advrow { text-decoration: none; color: inherit; } a.advrow .s { white-space: normal; }
