/* ---------- Shell: one nav, two layouts (bottom tab bar on phones, left sidebar on desktop) ---------- */
.app { min-height: 100dvh; }

.nav {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; align-items: stretch; justify-content: space-around;
  padding: 0 var(--s2) var(--safe-bottom); min-height: calc(var(--tabbar-h) + var(--safe-bottom));
  background: var(--bar-bg); border-top: 1px solid var(--separator);
}
@supports (backdrop-filter: blur(1px)) {
  .nav, .topbar { backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); }
}
.nav > .nav-brand, .nav > .nav-add, .nav > .nav-spacer, .nav > .nav-account, .nav > .nav-toggle, .nav > .nav-theme { display: none; } /* desktop-only parts of the one nav */
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); color: var(--label-2); font-size: 0.6875rem; font-weight: 500;
}
.nav-item[aria-current="page"] { color: var(--accent); }
.nav-item svg { width: 24px; height: 24px; }
.nav-item { min-width: 0; }
.nav-item .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between;
  min-height: calc(var(--topbar-h) + var(--safe-top)); padding: var(--safe-top) var(--s4) 0;
  background: var(--bar-bg);
}
.topbar-brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: 1.0625rem; color: var(--label); }
.topbar-actions { display: flex; gap: var(--s1); }
.mark { width: 28px; height: 28px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; flex: none; }
.mark svg { width: 18px; height: 18px; }
.mark img { width: 100%; height: 100%; display: block; border-radius: inherit; }

.screen { max-width: 720px; margin: 0 auto; padding: var(--s2) var(--s4) calc(var(--tabbar-h) + var(--safe-bottom) + 96px); }
#view:focus { outline: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) 0 var(--s4); }

@media (min-width: 1024px) {
  :root { --nav-w: var(--sidebar-w); }
  html[data-nav="collapsed"] { --nav-w: var(--rail-w); }
  .nav {
    top: 0; right: auto; width: var(--nav-w); flex-direction: column; justify-content: flex-start; gap: var(--s1);
    padding: var(--s5) var(--s3) var(--s4); border-top: 0; border-right: 1px solid var(--separator); overflow: hidden;
    transition: width var(--dur) var(--ease);
  }
  .nav > .nav-brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s3); font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
  .nav > .nav-toggle { display: grid; place-items: center; position: absolute; top: var(--s5); right: var(--s3); width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--label-3); }
  .nav > .nav-toggle:hover { background: var(--fill); color: var(--label); }
  .nav > .nav-toggle svg { width: 20px; height: 20px; }
  .nav > .nav-add { display: flex; margin: 0 0 var(--s4); white-space: nowrap; }
  .nav > .nav-spacer { display: block; flex: 1; }
  .nav > .nav-account, .nav > .nav-theme { display: flex; }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: var(--s3); min-height: 44px; padding: 0 var(--s3); border-radius: var(--radius-control); font-size: 1rem; white-space: nowrap; border: 0; background: none; width: 100%; text-align: left; }
  .nav-item[aria-current="page"] { background: var(--accent-soft); }
  .nav-item:hover:not([aria-current="page"]) { background: var(--fill); }
  .nav-theme { color: var(--label-2); }
  .topbar, .fab { display: none; }
  #view { margin-left: var(--nav-w); transition: margin-left var(--dur) var(--ease); }
  .screen { max-width: 1200px; padding: var(--s6) var(--s8) var(--s12); }
  .screen.narrow { max-width: 760px; }

  /* collapsed: icon rail. Labels stay in the DOM for screen readers, and each item gets a tooltip from app.js */
  html[data-nav="collapsed"] .nav { padding-inline: var(--s3); }
  html[data-nav="collapsed"] .nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  html[data-nav="collapsed"] .nav-item { justify-content: center; padding: 0; }
  html[data-nav="collapsed"] .nav > .nav-brand { justify-content: center; padding-inline: 0; margin-top: 40px; }
  html[data-nav="collapsed"] .nav > .nav-toggle { right: auto; left: 50%; transform: translateX(-50%); }
  html[data-nav="collapsed"] .nav > .nav-add { padding: 0; width: 44px; margin-inline: auto; }
}

/* floating action button (phones) */
.fab {
  position: fixed; z-index: 19; right: var(--s4); bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s4));
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: var(--on-accent);
  box-shadow: 0 6px 18px rgba(34, 35, 49, 0.35);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(0.96); }
@media (min-width: 1024px) { .fab { display: none; } } /* desktop has the sidebar button */

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border-radius: var(--radius-card); padding: var(--s5); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s6); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 0 var(--s1) var(--s2); }
.section-title h2.label { font-size: var(--fs-footnote); font-weight: 600; color: var(--label-2); letter-spacing: 0.04em; }
.section-title.wrap { flex-wrap: wrap; row-gap: var(--s3); }
.section-title h2 { font-size: var(--fs-title); font-weight: 600; letter-spacing: -0.01em; }

/* grouped inset list: rounded container, hairlines inset from the left, no per-row boxes */
.group { background: var(--surface); border-radius: var(--radius-card); overflow: hidden; --inset: var(--s4); }
.group.with-icons { --inset: 64px; }
.row {
  position: relative; display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px;
  padding: var(--s2) var(--s4); background: none; border: 0; text-align: left; color: inherit;
}
.row + .row::before, .row-wrap + .row-wrap::before { content: ""; position: absolute; top: 0; left: var(--inset); right: 0; height: 1px; background: var(--separator); }
.row-wrap { position: relative; }
button.row:hover, a.row:hover { background: var(--fill); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: var(--fs-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--fs-footnote); color: var(--label-2); display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.row-end { flex: none; text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.row-chevron { width: 18px; height: 18px; color: var(--label-3); flex: none; }
.row.danger .row-title { color: var(--negative-text); }

.tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--tile-bg, var(--fill)); color: var(--tile-fg, var(--label-2)); }
.tile svg { width: 20px; height: 20px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s5);
  border: 0; border-radius: var(--radius-control); background: var(--surface); color: var(--accent); font-weight: 600; text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--separator); /* white fill keeps the blue label above 4.5:1 on every background */
}
.btn svg { width: 20px; height: 20px; }
.btn:hover { filter: brightness(0.96); }
.btn-primary { background: var(--accent-fill); color: var(--on-accent); box-shadow: none; }
.btn-danger { background: var(--negative-soft); color: var(--negative-text); box-shadow: none; }
.btn-plain { background: none; padding: 0 var(--s2); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--accent); }
.icon-btn:hover { background: var(--fill); }
.icon-btn svg { width: 24px; height: 24px; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s1) 0; } /* every choice is visible: never a sideways-scrolling row that hides some */
.chips::-webkit-scrollbar { display: none; }
.chips[aria-label="Filters"] { flex-wrap: wrap; overflow: visible; margin: 0; padding-inline: 0; }
.chips[aria-label="Filters"] .chip { max-width: 100%; white-space: normal; text-align: left; } /* a long label wraps at big text sizes instead of overflowing */ /* every filter is visible: no sideways scrolling row */
.chip {
  position: relative; flex: none; min-height: 36px; padding: 0 var(--s4); border: 0; border-radius: var(--radius-pill);
  background: var(--surface); color: var(--label); font-size: 0.9375rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip::after { content: ""; position: absolute; inset: -4px 0; } /* 44px touch target, 36px look */
.chip[aria-pressed="true"] { background: var(--label); color: var(--bg); }
.chip svg { width: 16px; height: 16px; }

.segmented { display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 2px; background: var(--fill); border-radius: 10px; }
.segmented button { white-space: nowrap; min-height: 32px; padding: 0 var(--s4); border: 0; border-radius: 8px; background: none; font-size: 0.9375rem; font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); font-weight: 600; }

.month-ctl { max-width: 100%; display: inline-flex; align-items: center; background: var(--surface); border-radius: var(--radius-pill); }
.month-ctl .icon-btn { width: 44px; height: 44px; color: var(--label); }
.month-ctl .icon-btn[disabled] { color: var(--label-3); opacity: 0.5; cursor: default; }
.month-label { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 var(--s2); border: 0; background: none; font-weight: 600; min-width: min(11ch, 100%); justify-content: center; }
.month-label svg { width: 14px; height: 14px; color: var(--label-3); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-footnote); color: var(--label-2); }
.input {
  min-height: 44px; padding: 0 var(--s3); width: 100%; background: var(--surface-2); border: 1px solid var(--separator); border-radius: var(--radius-control);
}
.input:focus-visible { outline-offset: 0; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--label-3); pointer-events: none; }
.search .input { padding-left: 38px; background: var(--fill); border-color: transparent; }
.inline-form { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.inline-form .input { flex: 1; min-width: 160px; }
.form-msg { font-size: var(--fs-footnote); min-height: 1.2em; }
.form-msg.error { color: var(--negative-text); }

.progress { display: block; height: 6px; background: var(--fill); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 3px; background: var(--label-2); transform-origin: left; } /* neutral: blue means "tappable" */
.progress.over > i { background: var(--negative); }
.progress.near > i { background: var(--warning); }
.progress.indeterminate > i { width: 40%; animation: slide 1.4s var(--ease) infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

.callout { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--radius-card); background: var(--surface); }
.callout > svg { width: 24px; height: 24px; flex: none; margin-top: 1px; }
.callout.warn-box { background: var(--warning-soft); }
.callout.warn-box > svg { color: var(--warning-text); }
.callout.info > svg { color: var(--accent); }
.callout-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--s1); align-items: flex-start; overflow-wrap: anywhere; } /* long text and big text sizes wrap instead of pushing the page wider */
.callout-body .btn { margin-top: var(--s2); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-caption); font-weight: 600; color: var(--warning-text); }
.badge svg { width: 14px; height: 14px; }

.empty { text-align: center; padding: var(--s8) var(--s4); display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.empty > svg, .empty .big-icon svg { width: 44px; height: 44px; }
.empty > svg { color: var(--label-3); }
.big-icon { display: flex; }

/* ---------- Dashboard ---------- */
.hero { padding: var(--s2) 0 0; }
.hero-number { font-size: var(--fs-hero); font-weight: 700; line-height: 1.05; letter-spacing: -0.03em; margin: var(--s1) 0 var(--s2); }
.hero-sub { color: var(--label-2); display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); }
.hero-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--s3); padding: 6px 12px; border-radius: var(--radius-pill); font-size: var(--fs-footnote); font-weight: 500; }
.hero-chip svg { width: 16px; height: 16px; }
.hero-chip.good { background: var(--positive-soft); color: var(--positive-text); }
.hero-chip.bad { background: var(--warning-soft); color: var(--warning-text); }
.fade-in { animation: fade var(--dur) var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.dash { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.d-pace > .card { height: 100%; justify-content: center; }
@media (min-width: 1024px) {
  .dash { grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s5); }
  .d-hero { grid-column: span 7; }
  .d-pace { grid-column: span 5; }
  .d-alerts { grid-column: 1 / -1; }
  .d-spend { grid-column: 1 / -1; }
  .hero { background: var(--surface); border-radius: var(--radius-card); padding: var(--s6); height: 100%; }
}

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--s4); }
@media (min-width: 1024px) { .donut-wrap { flex-direction: row; align-items: center; gap: var(--s8); } .donut-wrap .donut { width: 240px; height: 240px; } .donut-wrap .legend { flex: 1; min-width: 0; } }
.row-main .progress { margin-top: 6px; }
.legend .row-end { min-width: 6.5rem; } /* same width on every row, so the budget bars all end at the same place */
.donut { width: 200px; height: 200px; flex: none; }
.donut circle { fill: none; transition: opacity var(--dur); }
.donut .seg { cursor: pointer; animation: sweep 700ms var(--ease) both; }
.donut.dimmed .seg:not(.on) { opacity: 0.25; }
@keyframes sweep { from { stroke-dasharray: 0 100; } }
.donut text { fill: var(--label); text-anchor: middle; }
.donut .d-label { fill: var(--label-2); font-size: 11px; }
.donut .d-total { font-size: 18px; font-weight: 700; }
.legend { width: 100%; }
.legend .row { min-height: 48px; }
.legend.dimmed .row:not(.on) { opacity: 0.45; }
.pct { color: var(--label-2); font-size: var(--fs-footnote); width: 3em; text-align: right; }

.budget-row { padding: var(--s3) var(--s4); display: flex; flex-direction: column; gap: var(--s2); width: 100%; background: none; border: 0; text-align: left; color: inherit; }
button.budget-row:hover { background: var(--fill); }
.budget-top { display: flex; align-items: center; gap: var(--s3); }
.budget-status { display: flex; align-items: center; gap: 6px; font-size: var(--fs-footnote); color: var(--label-2); }
.budget-status svg { width: 16px; height: 16px; }
.budget-status.over { color: var(--negative-text); font-weight: 600; }
.pace-text { font-size: var(--fs-body); }

/* ---------- Transactions ---------- */
.day-head {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: 5; padding: var(--s2) var(--s1); margin: 0;
  font-size: var(--fs-footnote); font-weight: 600; color: var(--label-2); background: var(--bg);
}
@media (min-width: 1024px) { .day-head { top: 0; } }
.tx-amount { font-weight: 600; }
.tx-cat { display: none; }
@media (min-width: 1024px) {
  .row.tx { display: grid; grid-template-columns: 36px minmax(0, 1fr) 230px 150px; column-gap: var(--s4); }
  .row.tx .row-sub { display: none; }
  .row.tx .tx-cat { display: flex; align-items: center; gap: var(--s2); color: var(--label-2); font-size: 0.9375rem; }
  .row.tx .tx-cat { flex-wrap: nowrap; min-width: 0; } /* one line per payment: long text is cut with an ellipsis, badges stay whole */
  .row.tx .tx-cat-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row.tx .tx-cat .badge { flex: none; }
  .row.tx .tx-amount { text-align: right; }
  .tx-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) 230px 150px; column-gap: var(--s4); padding: 0 var(--s4) var(--s2); font-size: var(--fs-caption); font-weight: 600; color: var(--label-3); text-transform: uppercase; letter-spacing: 0.04em; }
  .tx-head span:last-child { text-align: right; }
}
.tx-head { display: none; }
@media (min-width: 1024px) { .tx-head { display: grid; } }
.tx-amount.in { color: var(--positive-text); }
.tx-list { display: flex; flex-direction: column; gap: var(--s2); }

/* ---------- Trends ---------- */
.trends-grid { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) { .trends-grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); } .trends-grid .month-row { display: flex; } .trends-grid .month-row .m-meta { display: flex; flex-basis: 100%; } .trends-grid .month-row .m-meta span { text-align: left; } }
.stat-trio { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: var(--s4); }
.stat { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat.pos { color: var(--positive-text); } .stat.neg { color: var(--negative-text); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.step { display: flex; align-items: flex-start; gap: var(--s3); }
.step .tile { flex: none; }
.cmp { align-items: flex-start; }
.cmp .row-main { gap: 6px; }
.cmp-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 var(--s3); } /* the change drops to its own line before a name is ever cut */
.cmp-line { display: grid; grid-template-columns: 2.4rem minmax(0, 1fr) auto; gap: var(--s2); align-items: center; font-size: var(--fs-footnote); color: var(--label-2); }
.cmp-line.on { color: var(--label); font-weight: 600; }
.cmp-track { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.cmp-track > i { display: block; height: 100%; border-radius: 4px; opacity: 0.55; }
.cmp-line.on .cmp-track > i { opacity: 1; }
.cmp-amount { min-width: 5.5rem; text-align: right; }
.window-bar { display: grid; gap: var(--s2); }
.row.trend-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; grid-template-areas: "tile name amount" "tile sub change" "tile spark spark" "tile note note"; column-gap: var(--s3); row-gap: 3px; align-items: center; text-align: left; }
.trend-row > .tile { grid-area: tile; align-self: start; }
.tr-name { grid-area: name; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-amount { grid-area: amount; justify-self: end; font-weight: 600; }
.tr-sub { grid-area: sub; min-width: 0; }
.tr-change { grid-area: change; justify-self: end; white-space: nowrap; }
.trend-spark { grid-area: spark; width: 100%; height: 24px; display: block; overflow: visible; }
.trend-spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.trend-spark .spark-mark { stroke: var(--separator); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.tr-note { grid-area: note; }
@media (min-width: 768px) { /* room to spare: the trend line sits in the middle of the row instead of taking a line of its own */
  .row.trend-row { grid-template-columns: 36px minmax(0, 1fr) minmax(140px, 220px) auto; grid-template-areas: "tile name spark amount" "tile sub spark change" "tile note note note"; }
}
.sheet-columns { height: 150px; gap: 2px; }
.month-line.on { background: var(--fill); }
.heat { display: grid; grid-template-columns: minmax(6.5rem, 10rem) repeat(var(--cols), minmax(0, 1fr)); gap: 3px; align-items: center; }
.heat [role="row"] { display: contents; }
.heat-month { border: 0; background: none; padding: 0; min-height: 28px; font-size: var(--fs-caption); color: var(--label-2); text-align: center; }
.heat-month.on { color: var(--label); font-weight: 700; }
.heat-name { border: 0; background: none; padding: 0; min-height: 28px; text-align: left; font-size: var(--fs-footnote); color: var(--label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat-cell { display: block; height: 26px; border-radius: 5px; cursor: pointer; background: color-mix(in srgb, var(--heat) calc(var(--level) * 1%), var(--fill)); }
.heat-cell.on { outline: 2px solid var(--label-3); outline-offset: 1px; }
.pointable { touch-action: pan-y; cursor: crosshair; -webkit-tap-highlight-color: transparent; } /* a horizontal drag reads the chart; a vertical one still scrolls the page */
.pointable:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--fill); }
.split > i { display: block; height: 100%; }
.split-regular { background: var(--label-2); } .split-oneoff { background: var(--c-group); }
.sticky-chart { position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: 4; background: var(--surface); margin: 0 calc(var(--s5) * -1); padding: var(--s2) var(--s5) var(--s3); border-bottom: 1px solid var(--separator); } /* the chart stays in view while you scroll the list that drives it */
@media (min-width: 1024px) { .sticky-chart { top: 0; } }
@media (max-width: 640px) { .sticky-chart .columns { height: 150px; } .sticky-chart .bars { height: 140px; } }
.columns { display: flex; align-items: flex-end; gap: 3px; height: 210px; }
.columns .col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.columns .col-fill { display: block; width: 100%; min-height: 2px; border-radius: 5px 5px 2px 2px; background: var(--label-3); transform-origin: bottom; animation: grow 600ms var(--ease) both; transition: opacity var(--dur); }
.columns .col-icon svg { width: 14px; height: 14px; color: var(--label-2); display: block; }
.columns .col.dim .col-fill { opacity: 0.25; }
.columns.days { height: 150px; gap: 2px; }
.columns.days .col { justify-content: flex-end; }
.columns.days .col-fill { background: var(--label-3); border-radius: 3px 3px 1px 1px; }
.columns.days .col.peak .col-fill { background: var(--accent); }
.columns.weekdays { height: 170px; gap: 6px; }
.columns.weekdays .col-fill { background: var(--label-3); border-radius: 6px 6px 3px 3px; }
.columns.weekdays .col.peak .col-fill { background: var(--accent); }
.col-label { font-size: var(--fs-caption); color: var(--label-2); }
.columns .col.peak .col-label { color: var(--label); font-weight: 600; }
.sheet-columns .col { position: relative; }
.col-budget { position: absolute; left: -1px; right: -1px; height: 0; border-top: 2px solid var(--label); opacity: 0.8; pointer-events: none; }
.sheet-columns .col.over .col-fill { outline: 2px solid var(--negative); outline-offset: -2px; }
.range-bar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; }
.range-bar .field { flex: 1 1 140px; min-width: 0; }
.columns.range-columns { gap: 1px; }
.columns.range-columns .col-fill { border-radius: 2px 2px 0 0; animation: none; }
.columns.range-columns .col.month-start { box-shadow: -1px 0 0 var(--separator); }
.range-axis { position: relative; height: 1.4em; font-size: var(--fs-caption); color: var(--label-2); }
.range-axis span { position: absolute; top: 0; white-space: nowrap; }
.day-axis { display: flex; justify-content: space-between; font-size: var(--fs-caption); color: var(--label-2); }
.pace { width: 100%; height: auto; display: block; overflow: visible; }
.pace path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pace-spent { stroke: var(--label); stroke-width: 2.5; }
.pace-even { stroke: var(--label-3); stroke-width: 2; stroke-dasharray: 6 5; }
.pace-limit { stroke: var(--separator); stroke-width: 1; }
.pace-projection { stroke: var(--label-2); stroke-width: 2; stroke-dasharray: 2 5; }
.pace-dot { fill: var(--label); }
.pace-readout { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
.pace-read { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pace-read svg.key-sample { width: 24px; height: 6px; flex: none; }
.pace-other { stroke-width: 1.75; opacity: 0.95; }
.pace-chip svg.key-sample { width: 24px; height: 6px; flex: none; }
.pace-chip[aria-pressed="true"] { background: var(--surface); color: var(--label); box-shadow: inset 0 0 0 1.5px var(--label); } /* the line's own colour sits on the plain surface, not the filled chip */
.pace-chip[aria-pressed="false"] { text-decoration: line-through; }
.key-line.even { border-top: 3px dashed var(--label-3); }
.flow { width: 100%; height: auto; display: block; overflow: visible; }
.flow-gap { fill: var(--fill); }
.flow path { stroke-linejoin: round; stroke-linecap: round; }
.flow-in { fill: none; stroke: var(--positive); stroke-width: 2.5; stroke-dasharray: 6 4; }
.flow-out { fill: none; stroke: var(--label); stroke-width: 2.5; }
.flow-zero { stroke: var(--separator); stroke-width: 1; }
.flow-bar { opacity: 0.55; } .flow-bar.on { opacity: 1; }
.flow-bar.kept { fill: var(--positive); } .flow-bar.short { fill: var(--negative); }
.flow-mark { stroke: var(--separator); stroke-width: 1; }
.flow-dot.in { fill: var(--positive); } .flow-dot.out { fill: var(--label); }
.flow-key { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-footnote); color: var(--label-2); align-items: center; }
.key-line { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--label); margin-right: 6px; vertical-align: middle; }
.key-line.in { border-top: 3px dashed var(--positive); }
.flow-months { display: flex; gap: var(--s1); flex-wrap: wrap; }
.flow-month { min-height: 36px; padding: 0 var(--s3); border: 0; border-radius: var(--radius-pill); background: var(--fill); color: var(--label-2); font-size: var(--fs-footnote); font-weight: 500; position: relative; }
.flow-month::after { content: ""; position: absolute; inset: -4px 0; }
.flow-month[aria-pressed="true"] { background: var(--label); color: var(--bg); }
.bar-stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 3px 3px; overflow: hidden; min-height: 4px; animation: grow 600ms var(--ease) both; transform-origin: bottom; }
.bar-stack > i { display: block; flex: 0 0 auto; min-height: 1px; border-top: 1px solid var(--surface); transition: opacity var(--dur); }
.bar-stack > i.dim { opacity: 0.2; }
.bar-col:not([aria-pressed="true"]) .bar-stack { opacity: 0.85; }
.movers { display: grid; gap: var(--s4); }
.mover-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.mover { display: flex; align-items: center; gap: var(--s3); }
.mover-icon { width: 20px; height: 20px; flex: none; color: var(--label-2); }
.mover { flex-wrap: wrap; }
.mover .row-main { min-width: 0; flex: 1 1 8rem; }
.mover-delta { text-align: right; font-weight: 600; margin-left: auto; } /* wraps below the name on a narrow screen instead of pushing the page wider */
.spark { width: 64px; height: 22px; flex: none; overflow: visible; }
@media (max-width: 480px) { .spark { width: 44px; } }
@media (max-width: 360px) { .spark { display: none; } } /* at the narrowest width the names matter more than the decorative mini-trend */
.spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bars { display: flex; align-items: flex-end; gap: var(--s2); height: 180px; margin-top: var(--s4); overflow-x: auto; padding-top: 4px; }
.bar-col { flex: 1 0 44px; max-width: 120px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; background: none; border: 0; padding: 0; }
.bar-fill { width: 100%; background: var(--fill); border-radius: 8px 8px 4px 4px; transform-origin: bottom; animation: grow 600ms var(--ease) both; min-height: 4px; }
.bar-col[aria-pressed="true"] .bar-fill { background: var(--accent); }
.bar-col span { font-size: var(--fs-caption); color: var(--label-2); }
.bar-col[aria-pressed="true"] span { color: var(--label); font-weight: 600; }
@keyframes grow { from { transform: scaleY(0); } }
.readout { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.readout .big { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.month-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px var(--s4); padding: var(--s3) var(--s4); }
.month-row .m-name { font-weight: 600; }
.month-row .m-meta { flex-basis: 100%; display: flex; gap: var(--s4); font-size: var(--fs-footnote); color: var(--label-2); flex-wrap: wrap; }
@media (min-width: 768px) {
  .month-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; align-items: center; }
  .month-row .m-meta { display: contents; }
  .month-row .m-meta span { text-align: right; }
}

/* ---------- Budgets ---------- */
.btn-link { border: 0; background: none; padding: 0; min-height: 44px; text-align: left; color: var(--accent-text, var(--accent)); font-size: var(--fs-footnote); text-decoration: underline; }
.budget-choice { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding-top: var(--s2); }
.budget-choice .btn { min-height: 44px; }
.budget-input { display: flex; align-items: center; gap: 4px; flex: none; }
.budget-input .cur { color: var(--label-2); }
.budget-input .input { width: 8.5em; text-align: right; }
.saved { font-size: var(--fs-caption); color: var(--positive-text); min-height: 1em; }

/* ---------- Upload ---------- */
.drop { border: 2px dashed var(--separator); border-radius: var(--radius-card); background: var(--surface); padding: var(--s8) var(--s5); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.drop.over-drop { border-color: var(--accent); background: var(--accent-soft); }
.drop > svg { width: 44px; height: 44px; color: var(--accent); }
.big-number { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.02em; }

/* ---------- Sheet (bottom sheet on phones, side panel on desktop) ---------- */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 560px; margin-inline: auto; max-height: 90dvh;
  padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--bg); color: var(--label);
  will-change: transform; overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgb(var(--scrim-rgb) / calc(var(--sheet-p, 1) * var(--scrim-max))); }
.sheet-inner { display: flex; flex-direction: column; max-height: 90dvh; }
.sheet-head { position: relative; display: flex; align-items: center; justify-content: space-between; padding: var(--s5) var(--s2) var(--s2) var(--s5); touch-action: none; cursor: grab; user-select: none; }
.sheet-head:active { cursor: grabbing; }
.sheet-head::before { content: ""; position: absolute; top: 0.5rem; left: 50%; width: 2.25rem; height: 0.3125rem; margin-left: -1.125rem; border-radius: 3px; background: var(--label-3); opacity: 0.45; }
.sheet-body > * { flex-shrink: 0; } /* let the sheet scroll instead of squashing its lists */
.sheet-body { overflow-y: auto; padding: 0 var(--s4) calc(var(--s6) + var(--safe-bottom)); display: flex; flex-direction: column; gap: var(--s4); }
@media (min-width: 1024px) {
  .sheet-head { cursor: default; touch-action: auto; padding-top: var(--s4); }
  .sheet-head::before { display: none; }
  dialog.sheet { inset: 0 0 0 auto; margin: 0; width: 420px; max-width: 100vw; height: 100dvh; max-height: none; border-radius: 20px 0 0 20px; }
  .sheet-inner { max-height: none; height: 100dvh; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--s4)); transform: translate(-50%, 20px);
  max-width: min(92vw, 420px); padding: var(--s3) var(--s4); border-radius: var(--radius-control); background: var(--label); color: var(--bg);
  font-size: 0.9375rem; opacity: 0; pointer-events: none; transition: opacity var(--dur), transform var(--dur) var(--ease);
  display: flex; align-items: center; gap: var(--s4);
}
.toast.has-action { pointer-events: auto; }
.toast-action { min-height: 44px; margin: -0.5rem -0.5rem -0.5rem 0; padding: 0 var(--s3); border: 0; background: none; color: var(--toast-action); font-weight: 600; border-radius: var(--radius-control); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1024px) { .toast { bottom: var(--s6); } }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--s5); }
.auth-card .mark { width: 48px; height: 48px; border-radius: 13px; }
.auth-card .mark svg { width: 30px; height: 30px; }
.auth-brand { display: flex; flex-direction: column; gap: var(--s3); align-items: flex-start; }
.auth form { display: flex; flex-direction: column; gap: var(--s3); }

.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 1.5rem; font-weight: 600; flex: none; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--fill); padding: var(--s3); border-radius: var(--radius-control); word-break: break-all; user-select: all; }
.qr { background: #fff; padding: var(--s2); border-radius: var(--radius-control); align-self: flex-start; }

/* budget rows: on phones the input gets its own full-width line so category names never truncate */
@media (max-width: 520px) {
  .budget-line { flex-wrap: wrap; row-gap: var(--s2); }
  .budget-line .row-main { flex: 1 1 calc(100% - 52px); }
  .budget-line.has-edit .row-main { flex-basis: calc(100% - 52px - 2.75rem); }
  .budget-line .budget-input { flex: 1 1 100%; margin-left: 48px; }
  .budget-line .budget-input .input { flex: 1; width: auto; }
}

/* ---------- Instant feedback on press (starts on touch-down, not release) ---------- */
.btn, .chip, .icon-btn, .month-label, .bar-col, .nav-item, .fab { transition: transform 90ms ease-out, background-color 90ms ease-out, filter 90ms ease-out; }
.btn:active, .chip:active, .nav-item:active, .month-label:active { transform: scale(0.97); }
.icon-btn:active { transform: scale(0.92); background: var(--fill); }
.bar-col:active .bar-fill { filter: brightness(0.9); }
button.row:active, a.row:active, button.budget-row:active { background: var(--fill); transition: none; }
.btn-primary:active { filter: brightness(0.88); }
.fab:active { transform: scale(0.94); }

/* ---------- Glass (dashboard first) ----------
   Only floating, interactive pieces are glass: the month control, the account picker, the sidebar/top bar, and the sheet while it is open over
   this screen. Cards that carry money stay solid so figures are always legible. The soft colour behind is fixed and static (no movement). */
.screen.glass::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(60rem 36rem at 12% -8%, var(--glow-lavender), transparent 70%), radial-gradient(50rem 32rem at 100% 12%, var(--glow-champagne), transparent 65%);
}
@supports (backdrop-filter: blur(1px)) {
  .screen.glass .month-ctl, .screen.glass .chip:not([aria-pressed="true"]), .screen.glass .segmented, .screen.glass .cat-pill {
    background: linear-gradient(180deg, var(--glass-sheen), transparent 55%), var(--glass-bg);
    backdrop-filter: blur(18px) saturate(180%); -webkit-backdrop-filter: blur(18px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--glass-edge), inset 0 0 0 1px var(--glass-rim), var(--glass-shadow);
  }
  body:has(.screen.glass) dialog.sheet {
    background: linear-gradient(180deg, var(--glass-sheen), transparent 30%), var(--glass-sheet-bg);
    backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
    box-shadow: inset 0 1px 0 var(--glass-edge), 0 -10px 40px rgba(10, 10, 18, 0.25);
  }
}

/* ---------- Accessibility preferences ---------- */
@media (prefers-reduced-transparency: reduce) {
  .nav, .topbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .screen.glass::before { display: none; }
  .screen.glass .month-ctl, .screen.glass .chip:not([aria-pressed="true"]), .screen.glass .segmented, .screen.glass .cat-pill { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  body:has(.screen.glass) dialog.sheet { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: var(--label-3); }
  .card, .group, .callout, .month-ctl, .drop, .screen.glass .chip { outline: 1px solid var(--label-3); outline-offset: -1px; }
  .screen.glass::before { display: none; }
  .screen.glass .month-ctl, .screen.glass .chip:not([aria-pressed="true"]), .screen.glass .segmented, .screen.glass .cat-pill { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  body:has(.screen.glass) dialog.sheet { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  .btn { box-shadow: inset 0 0 0 1.5px var(--label-2); }
  .btn-primary { box-shadow: none; }
}

/* ---------- Demo banner ---------- */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s3); background: var(--accent-soft); border-radius: var(--radius-card); }
.demo-banner > svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.demo-banner .demo-text { flex: 1 1 14rem; }
.demo-banner .btn { min-height: 40px; padding: 0 var(--s4); }

/* a row whose control is wide (the Appearance selector) stacks on phones: label first, control full-width underneath */
@media (max-width: 520px) {
  .wrap-row { flex-wrap: wrap; row-gap: var(--s2); }
  .wrap-row .row-main { flex: 1 1 calc(100% - 3rem); }
  .wrap-row .segmented { flex: 1 1 100%; margin-left: 3rem; }
  .wrap-row .segmented button { flex: 1; }
}

/* ---------- Trends category picker ---------- */
.cat-pill { display: inline-flex; align-items: center; gap: var(--s2); max-width: 100%; min-height: 44px; padding: 0 var(--s3) 0 var(--s2); border: 0; border-radius: var(--radius-pill); background: var(--fill); font-weight: 600; }
.cat-pill-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--cat-color); background: color-mix(in srgb, var(--cat-color) 16%, transparent); flex: none; }
.cat-pill-icon svg { width: 18px; height: 18px; }
.cat-pill-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-pill-chev { width: 16px; height: 16px; color: var(--label-3); flex: none; }

/* ---------- Switch + transfer review ---------- */
.switch { flex: none; position: relative; width: 3.25rem; height: 2rem; border: 0; border-radius: 1rem; background: var(--fill); padding: 0; }
.switch i { position: absolute; top: 0.1875rem; left: 0.1875rem; width: 1.625rem; height: 1.625rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 180ms var(--ease); }
.switch[aria-checked="true"] { background: var(--positive); }
.switch[aria-checked="true"] i { transform: translateX(1.25rem); }
.row.pair { cursor: pointer; align-items: flex-start; }
.row.pair input { width: 1.375rem; height: 1.375rem; margin-top: 0.125rem; accent-color: var(--accent-fill); flex: none; }
.tx-amount.transfer { color: var(--label-3); font-weight: 500; }
.badge.quiet { color: var(--label-2); }

/* ---------- Category form: icon and colour pickers ---------- */
.pick-grid { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pick { width: 44px; height: 44px; display: grid; place-items: center; border: 2px solid transparent; border-radius: 12px; background: var(--fill); color: var(--label); padding: 0; }
.pick svg { width: 22px; height: 22px; }
.pick[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pick.swatch { background: var(--swatch); border-radius: 50%; color: transparent; }
.pick.swatch[aria-checked="true"] { border-color: var(--label); color: #fff; }
.pick.swatch svg { width: 20px; height: 20px; filter: drop-shadow(0 0 2px rgba(0,0,0,.45)); }
