/* Cardwell Family App, Money planner. Component styles, written on styles/tokens.css.
   Colours, sizes, radii and spacing come from tokens only. No text is smaller than 13px (--fs-cap).
   Breakpoints (custom properties cannot be used in media queries):
     56.25em (900px)  the sidebar replaces the phone tab bar, tables replace stacked rows
     70em   (1120px)  the right rail appears beside the main column */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font-ui); font-size: var(--fs-body); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
:focus-visible { outline: 0.1875rem solid var(--focus); outline-offset: 0.125rem; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--sp-4); top: var(--sp-4); z-index: 30; padding: var(--sp-2) var(--sp-4); background: var(--card); border-radius: var(--r-ctl); }
.num { font-variant-numeric: var(--num); white-space: nowrap; }
.soft, .muted { color: var(--ink-soft); }
.small { font-size: var(--fs-cap); }
.pos { color: var(--left-ink); }
.neg { color: var(--over); }
.icon { width: 1.375rem; height: 1.375rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon--sm { width: 1rem; height: 1rem; }
main:focus { outline: none; }

/* ---------- Shell ---------- */
.side { display: none; }
.main {
  max-width: var(--content-max);
  padding: 0 var(--gutter) calc(var(--tabbar-h) + var(--safe-b) + var(--sp-10));
}
.strip { height: 0.25rem; margin: 0 calc(var(--gutter) * -1); background: var(--scope); }
.app[data-scope="both"] .strip { background: var(--shared-stripe); }

.header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding-top: var(--sp-4); }
.header__title { font-size: var(--fs-sub); font-weight: var(--fw-medium); color: var(--ink-soft); }
.header .seg { flex: 1 1 100%; order: 3; }
.header__phone { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-cap); color: var(--ink-soft); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--ground-deep); border-radius: var(--r-pill); padding: 0.1875rem; }
.seg-btn {
  min-height: calc(var(--tap) - 0.375rem); padding: 0 var(--sp-4);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill); font-size: var(--fs-sub); font-weight: var(--fw-medium); color: var(--ink-soft);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg-btn.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-thumb); }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--ground-deep); border-top: 1px solid var(--line);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1875rem;
  font-size: var(--fs-tab); font-weight: var(--fw-medium); color: var(--ink-soft);
}
.tabbar__item.is-active { color: var(--coral-ink); }

.brand { font-family: var(--font-display); font-size: 1.625rem; line-height: 1.08; letter-spacing: var(--tr-display); }
.brand small { display: block; margin-top: var(--sp-2); font-family: var(--font-ui); font-size: var(--fs-cap); letter-spacing: 0; color: var(--ink-soft); }
.nav { display: grid; gap: var(--sp-1); margin-top: var(--sp-10); }
.nav__item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left;
  min-height: var(--tap); padding: 0 var(--sp-3); border-radius: var(--r-ctl);
  color: var(--ink-soft); font-weight: var(--fw-medium);
}
.nav__item:hover { color: var(--ink); }
.nav__item.is-active { background: var(--card); color: var(--coral-ink); box-shadow: var(--shadow-thumb); }
.nav__gap { height: var(--sp-3); }
.nav__grow { display: block; }
.side__foot { margin-top: var(--sp-3); padding: 0 var(--sp-3); font-size: var(--fs-cap); color: var(--ink-soft); display: grid; gap: var(--sp-1); justify-items: start; }
.side__foot .link { padding: 0; min-height: 0; }

@media (min-width: 56.25em) {
  .side {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    display: flex; flex-direction: column;
    padding: var(--sp-8) var(--sp-5) var(--sp-6);
    background: var(--ground-deep); border-right: 1px solid var(--line); overflow-y: auto;
  }
  .nav { flex: 1; align-content: start; }
  .nav__grow { flex: 1; min-height: var(--sp-6); }
  .main { margin-left: var(--sidebar-w); padding-bottom: var(--sp-16); }
  .tabbar { display: none; }
  .header .seg { flex: 0 0 auto; order: 0; }
  .header__phone { display: none; }
}

.alerts:not(:empty) { padding-top: var(--sp-4); }
.alert-box { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-ctl); background: var(--over-soft); box-shadow: inset 0 0 0 1px var(--over); }

/* ---------- The sentence ---------- */
.hero { display: grid; gap: var(--sp-5); padding-top: var(--section-gap); }
.hero__line {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--fs-hero); line-height: var(--lh-tight); letter-spacing: var(--tr-display);
  max-width: 21ch; text-wrap: balance;
}
.hero__amt { color: var(--left-ink); }
.hero__amt.is-plain { color: inherit; }
.hero__amt.is-over { color: var(--over); }
.hero__sub { margin-top: var(--sp-3); max-width: 62ch; font-size: var(--fs-lead); color: var(--ink-soft); }
.hero__side { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
@media (min-width: 56.25em) { .hero { grid-template-columns: minmax(0, 1fr) auto; align-items: end; } }

/* ---------- Buttons and links ---------- */
.btn {
  min-height: var(--tap); padding: 0 var(--sp-5);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border-radius: var(--r-ctl); background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: var(--fs-sub); font-weight: var(--fw-strong); text-decoration: none; text-align: center;
  transition: background var(--dur-fast) var(--ease);
}
.btn:hover, .btn:active { background: var(--press); }
.btn-primary { background: var(--coral-ink); color: var(--on-fill); box-shadow: none; }
.btn-primary:hover, .btn-primary:active { background: var(--coral-press); }
.btn-small { min-height: 2.25rem; padding: 0 var(--sp-3); font-size: var(--fs-cap); }
.btn-add { width: 100%; margin-top: var(--sp-3); background: none; color: var(--coral-ink); box-shadow: inset 0 0 0 1px var(--coral-ink); border-radius: var(--r-ctl); }
.btn-add:hover { background: var(--coral-soft); }
.btn-danger { background: none; color: var(--over); box-shadow: none; padding: 0 var(--sp-2); }
.btn-danger:hover, .btn-danger:active { background: var(--over-soft); }
.btn-danger-quiet { background: none; color: var(--over); box-shadow: none; }
.btn-danger-quiet:hover { background: var(--over-soft); }
.btn--wide-phone { width: 100%; }
@media (min-width: 56.25em) { .btn--wide-phone { width: auto; } }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-4); }
.btn-row--stack { flex-direction: column; align-items: stretch; }
.panel-actions { display: flex; justify-content: center; margin-top: var(--stack); }
label.btn { cursor: pointer; }
.link {
  color: var(--coral-ink); font-size: var(--fs-sub); font-weight: var(--fw-medium); text-decoration: none; text-align: left;
  min-height: 2.25rem; padding: 0 var(--sp-1); display: inline-flex; align-items: center;
}
.link:hover { text-decoration: underline; text-underline-offset: 0.1875rem; }

/* ---------- Chips and badges ---------- */
.badge, .chip {
  display: inline-flex; align-items: center; gap: 0.3125rem;
  padding: 0.0625rem 0.5rem; border-radius: var(--r-chip);
  font-size: var(--fs-label); font-weight: var(--fw-medium); line-height: 1.6; white-space: nowrap;
  background: var(--ground-deep); color: var(--ink);
}
.badge.biz { background: var(--business-soft); color: var(--business-ink); }
.badge.shared::before { content: ""; width: 0.75rem; height: 0.5rem; border-radius: 0.125rem; background: var(--shared-stripe); }
.badge.est, .chip--est { background: none; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line-strong); }
.badge.debt { background: var(--over-soft); color: var(--over); }
.badge.sink { background: var(--left-soft); color: var(--left-ink); }
.badge.tax { background: var(--note-bg); color: var(--note-ink); }
.badge.ok, .chip--good { background: var(--left-soft); color: var(--left-ink); }
.chip--behind { background: var(--coral-soft); color: var(--coral-ink); }
.badges { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); }
.badges:empty { display: none; }

/* ---------- Charts: ribbon, key, swatches ---------- */
.ribbon-wrap { margin-top: var(--section-gap); }
.ribbon { display: flex; gap: 0.125rem; height: 2.75rem; border-radius: var(--r-ctl); overflow: hidden; }
.ribbon--thin { height: 1.25rem; margin-top: var(--sp-3); }
.ribbon__seg { flex: 0 1 auto; width: var(--w); min-width: 0.25rem; }
.ribbon .ribbon__seg.fill-held { flex-shrink: 0; }
.fill-1 { background: var(--step-1); } .fill-2 { background: var(--step-2); } .fill-3 { background: var(--step-3); }
.fill-4 { background: var(--step-4); } .fill-5 { background: var(--step-5); } .fill-6 { background: var(--step-6); }
.fill-left { background: var(--left); }
.fill-over { background: var(--over); }
.fill-coral { background: var(--coral); }
.fill-held { background: var(--setaside-hatch); box-shadow: inset 0 0 0 1px var(--scope); }
.key { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin-top: var(--sp-3); font-size: var(--fs-cap); color: var(--ink-soft); }
.key li { display: flex; align-items: center; gap: var(--sp-2); }
.key b { color: var(--ink); font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.sw { width: 0.75rem; height: 0.75rem; border-radius: 0.1875rem; flex: none; display: inline-block; }
.sw--line { height: 0; width: 1rem; border-top: 1px dashed var(--ink-faint); border-radius: 0; }
.sw--dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; }
.sw--held { background: var(--setaside-hatch); box-shadow: inset 0 0 0 1px var(--scope); }
.dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; margin-right: var(--sp-1); vertical-align: 0.0625rem; }
.dot.due { background: var(--coral); }
.dot.inc { background: var(--left); margin-left: var(--sp-4); }

/* ---------- Columns, cards, notes ---------- */
.cols { display: grid; gap: var(--stack); margin-top: var(--section-gap); align-items: start; }
.col { display: grid; gap: var(--stack); min-width: 0; }
@media (min-width: 70em) { .cols { grid-template-columns: minmax(0, 1fr) var(--rail-w); } }
main > .cards, main > .card, main > .panel, main > .plan-grid, main > .card-grid, main > .pcs, main > .leftover-bar, main > .callout { margin-top: var(--stack); }
main > .note + .cards, main > .note + .card, main > .note + .panel { margin-top: var(--stack); }
main > .note:first-child { margin-top: var(--section-gap); }
main > .empty, main > p.muted { margin-top: var(--stack); }

.card, .panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: var(--card-pad); min-width: 0;
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card__head--pad { padding: var(--card-pad) var(--card-pad) 0; margin-bottom: var(--sp-2); }
.card__title, .panel-title {
  font-family: var(--font-display); font-weight: 400; font-size: var(--fs-title);
  line-height: var(--lh-snug); letter-spacing: var(--tr-title);
}
.card__note { font-size: var(--fs-cap); color: var(--ink-soft); margin-top: var(--sp-3); }
.card__note--top { margin-top: calc(var(--sp-2) * -1); margin-bottom: var(--sp-4); }
.card__note--pad { margin: 0; padding: 0 var(--card-pad) var(--sp-3); }
.card--flush { padding: 0; overflow: hidden; }
.card--spaced { margin-top: var(--stack); }
.note {
  margin-top: var(--section-gap); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-ctl);
  background: var(--note-bg); color: var(--note-ink); font-size: var(--fs-cap);
}
.notice { padding: var(--sp-3) var(--sp-4); background: var(--left-soft); color: var(--left-ink); border-radius: var(--r-ctl); margin-top: var(--sp-3); }
.empty { color: var(--ink-soft); font-size: var(--fs-sub); }
.empty--pad { padding: 0 var(--card-pad) var(--card-pad); }
.callout { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-ctl); background: var(--note-bg); color: var(--ink); margin-top: var(--stack); }
.callout.ok { background: var(--left-soft); }
.callout.warn { background: var(--over-soft); }
.welcome { margin-top: var(--section-gap); border-style: dashed; border-color: var(--line-strong); }
.recover { margin-top: var(--section-gap); }
.recover ol { padding-left: var(--sp-5); display: grid; gap: var(--sp-4); margin-top: var(--sp-4); list-style: decimal; }
.recover li .btn { margin-left: var(--sp-2); }

/* Total tiles */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr)); gap: var(--stack); margin-top: var(--section-gap); }
.cards .card { padding: var(--card-pad) var(--sp-4); }
.card-label { font-size: var(--fs-label); font-weight: var(--fw-medium); color: var(--ink-soft); letter-spacing: var(--tr-label); }
.card-value { margin: var(--sp-1) 0; font-size: var(--fs-stat); font-weight: var(--fw-strong); line-height: var(--lh-snug); font-variant-numeric: var(--num); }
.card-sub { font-size: var(--fs-cap); color: var(--ink-soft); }
.card-leftover.pos { background: var(--left-soft); border-color: var(--left-soft); }
.card-leftover.pos .card-value { color: var(--left-ink); }
.card-leftover.neg { background: var(--over-soft); border-color: var(--over-soft); }
.card-leftover.neg .card-value { color: var(--over); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(21rem, 100%), 1fr)); gap: var(--stack); margin-top: var(--stack); align-items: start; }

/* ---------- Overview: where it goes ---------- */
.rank { display: grid; gap: var(--sp-3); }
.rank li { display: grid; grid-template-columns: minmax(5rem, 8rem) minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); font-size: var(--fs-sub); }
.rank li > span:first-child { overflow-wrap: anywhere; }
.meter { display: block; height: 0.625rem; border-radius: var(--r-bar); background: var(--ground-deep); overflow: hidden; }
.meter i { display: block; height: 100%; width: var(--w); border-radius: var(--r-bar); background: var(--scope); }
.meter i.fill-over { background: var(--over); }
.meter--thin { height: 0.375rem; }
.meter--room { background: var(--left-soft); }
.rank__amt { font-weight: var(--fw-strong); font-variant-numeric: var(--num); text-align: right; }

/* ---------- Overview: cash due by month ---------- */
.months { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(0.25rem, 0.9vw, 0.625rem); height: 9.5rem; padding-top: 1.5rem; }
.months__col { position: relative; display: flex; align-items: flex-end; height: 100%; border-radius: var(--r-bar); }
.months__col:hover { background: var(--press); }
.months__bar { display: block; width: 100%; height: var(--h); border-radius: var(--r-bar) var(--r-bar) 0 0; background: var(--step-3); }
.months__col.is-heavy .months__bar { background: var(--coral); }
.months__val {
  position: absolute; left: 50%; bottom: calc(var(--h) + var(--sp-1)); translate: -50% 0;
  font-size: var(--fs-label); font-weight: var(--fw-strong); font-variant-numeric: var(--num); white-space: nowrap;
  color: var(--ink); pointer-events: none;
}
.months__col.is-heavy .months__val { color: var(--coral-ink); }
.months__labels .m-one { display: none; }
.months__avg { position: absolute; left: 0; right: 0; bottom: var(--h); border-top: 1px dashed var(--ink-faint); pointer-events: none; }
.months__labels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(0.25rem, 0.9vw, 0.625rem); margin-top: var(--sp-2); font-size: var(--fs-label); color: var(--ink-soft); text-align: center; }
.months__labels .is-on { color: var(--ink); font-weight: var(--fw-strong); }
.months__labels .has-three::after { content: ""; display: block; width: 0.375rem; height: 0.375rem; margin: 0.1875rem auto 0; border-radius: 50%; background: var(--left); }
/* A 13px value over each of 12 phone-width bars would collide; on a phone only the heavy months say their amount. */
@media (max-width: 56.24em) {
  .months__col:not(.is-heavy) .months__val { display: none; }
  .months__col:first-of-type .months__val { left: 0; translate: 0 0; }
  .months__col:last-of-type .months__val { left: auto; right: 0; translate: 0 0; }
  .months__labels .m-full { display: none; }
  .months__labels .m-one { display: inline; }
}

/* ---------- Lists: coming up, held back ---------- */
.due li { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); padding: var(--row-pad-y) 0; border-top: 1px solid var(--line); }
.due li:first-child { border-top: 0; padding-top: 0; }
.due li:last-child { padding-bottom: 0; }
.due__date { display: block; padding: 0.25rem 0; border-radius: var(--r-chip); background: var(--ground); text-align: center; line-height: 1.15; }
.due__date b { display: block; font-size: 1.125rem; font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.due__date span { font-size: var(--fs-label); color: var(--ink-soft); }
.due__name { display: block; font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.due__meta { display: block; font-size: var(--fs-cap); color: var(--ink-soft); }
.due__amt { font-weight: var(--fw-strong); font-variant-numeric: var(--num); text-align: right; }
.plain li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--line); font-size: var(--fs-sub); }
.plain li:first-child { border-top: 0; padding-top: 0; }
.plain li > span:first-child { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.plain .is-total { font-weight: var(--fw-strong); font-size: var(--fs-body); padding-bottom: 0; }

/* ---------- Budget: groups and rows ---------- */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-4); margin-bottom: var(--sp-3); }
.panel-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); min-width: 0; }
.panel-title .meter { width: clamp(3rem, 9vw, 7rem); }
.panel-total { margin-left: auto; font-weight: var(--fw-strong); font-variant-numeric: var(--num); text-align: right; }
.panel-total .muted { font-weight: var(--fw-regular); font-size: var(--fs-cap); }
.group-tools { flex-basis: 100%; display: flex; gap: var(--sp-1); margin-left: calc(var(--sp-1) * -1); }
main > .panel.group { margin-top: var(--stack); }

.rows { border-top: 1px solid var(--line); margin: 0 calc(var(--card-pad) * -1); }
.card--flush .rows { margin: 0; }
.panel > .empty { padding: var(--sp-2) 0; }
.row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-3); align-items: start;
  padding: var(--row-pad-y) var(--card-pad); border-top: 1px solid var(--line);
}
.rows > .row:first-child { border-top: 0; }
.row[role="button"] { cursor: pointer; }
.row[role="button"]:hover { background: var(--press); }
.cell { font-variant-numeric: var(--num); min-width: 0; }
.cell-name { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.125rem; }
.name { font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.meta { display: block; font-size: var(--fs-cap); color: var(--ink-soft); }
.cell[data-label]::before { content: attr(data-label); display: block; font-size: var(--fs-cap); font-weight: var(--fw-regular); color: var(--ink-soft); }
.cell-mo { font-weight: var(--fw-strong); }
.cell-yr { color: var(--ink-soft); }
.cell-amt:empty { display: none; }
.row-head { display: none; }
.row-static { cursor: default; }
.tax-note .cell-name .name { color: var(--note-ink); }
@media (min-width: 56.25em) {
  .row { grid-template-columns: minmax(0, 1fr) 7rem 6rem 6.75rem; gap: var(--sp-4); align-items: center; }
  .cell-name { grid-column: auto; }
  .cell-amt:empty { display: block; }
  .cell[data-label]::before { content: none; }
  .cell-amt, .cell-mo, .cell-yr { text-align: right; }
  .cell-amt { color: var(--ink-soft); }
  .cell-yr { font-size: var(--fs-sub); color: var(--ink); }
  .row-head { display: grid; align-items: center; padding-block: var(--sp-2); font-size: var(--fs-label); font-weight: var(--fw-medium); letter-spacing: var(--tr-label); color: var(--ink-soft); background: var(--ground); border-top: 0; }
  .row-head .cell { color: inherit; font-size: inherit; font-weight: inherit; }
}

.leftover-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4) var(--sp-8);
  padding: var(--card-pad); border-radius: var(--r-card); background: var(--left-soft);
}
.leftover-bar.neg { background: var(--over-soft); }
.leftover-bar .big { font-size: var(--fs-stat); font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.leftover-bar.pos .big { color: var(--left-ink); }
.leftover-bar.neg .big { color: var(--over); }
.leftover-bar .btn { margin-left: auto; }
@media (max-width: 56.24em) { .leftover-bar .btn { margin-left: 0; width: 100%; } }

/* ---------- Calendar ---------- */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(0.125rem, 0.9vw, 0.5rem); align-items: end; margin-top: var(--sp-3); }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); padding: var(--sp-1) 0; border-radius: var(--r-ctl); min-height: var(--tap); }
.bar-col:hover, .bar-col.on { background: var(--press); }
.bar-col.on { outline: 0.125rem solid var(--ink); outline-offset: 0.125rem; }
.bar-label { white-space: nowrap; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 0.125rem; height: 6.5rem; width: 100%; }
.bar { display: block; width: 40%; min-height: 0.125rem; border-radius: var(--r-bar) var(--r-bar) 0 0; }
.bar-in { background: var(--left); opacity: 0.55; }
.bar-due { background: var(--coral); }
.bar-amt { font-size: var(--fs-label); color: var(--ink-soft); font-variant-numeric: var(--num); }
.bar-label { font-size: var(--fs-label); font-weight: var(--fw-medium); }
@media (max-width: 56.24em) { .bar-amt { display: none; } .bar-pair { height: 5rem; } }
main > .panel .muted.small { margin-top: var(--sp-3); }

.cal-head { justify-content: space-between; flex-wrap: nowrap; }
.cal-head .panel-title { flex: 1; justify-content: center; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.125rem; margin-top: var(--sp-3); }
.dow { padding-bottom: var(--sp-2); font-size: var(--fs-label); color: var(--ink-soft); text-align: center; }
.day {
  position: relative; min-height: var(--tap); padding: 0.25rem 0 0.375rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.1875rem;
  border-radius: var(--r-chip); font-size: var(--fs-sub);
}
.day:hover { background: var(--press); }
.day.blank { visibility: hidden; }
.day .num { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; }
.day.has-in .num { box-shadow: inset 0 0 0 0.125rem var(--left); }
.day.today .num { background: var(--ink); color: var(--on-fill); font-weight: var(--fw-strong); }
.day.sel { background: var(--coral-soft); }
.due-amt { font-size: 0; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--coral); }
.in-dot { display: none; }
@media (min-width: 56.25em) {
  .cal { gap: 0.25rem; }
  .day { min-height: 4.75rem; align-items: flex-start; padding: 0.375rem 0.5rem; background: var(--ground); }
  .day.blank { background: none; }
  .day:hover { background: var(--press); }
  .day.sel { background: var(--coral-soft); }
  .due-amt { font-size: var(--fs-label); width: auto; height: auto; border-radius: 0; background: none; color: var(--coral-ink); font-weight: var(--fw-strong); font-variant-numeric: var(--num); margin-top: auto; }
}
.day-detail { margin-top: var(--sp-5); padding: var(--sp-4); background: var(--ground); border-radius: var(--r-ctl); }
.day-detail h3 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-title); letter-spacing: var(--tr-title); margin-bottom: var(--sp-2); }
.line { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-2) 0; border-top: 1px solid var(--line); font-size: var(--fs-sub); }
.line:first-of-type { border-top: 0; }
.line strong { font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.line.in strong { color: var(--left-ink); }
.line.total { font-weight: var(--fw-strong); }
.cal-head + p.muted { margin-bottom: var(--sp-2); font-size: var(--fs-sub); }
main > .panel > p.muted { margin-top: var(--sp-3); }

/* ---------- Paychecks ---------- */
.stepper { display: inline-flex; align-items: center; gap: var(--sp-1); }
.stepper__label { min-width: 9.5rem; text-align: center; font-weight: var(--fw-medium); }
.cal__step { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 50%; color: var(--ink-soft); }
.cal__step:hover { background: var(--press); }
.pcs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(21rem, 100%), 1fr)); gap: var(--stack); margin-top: var(--stack); align-items: start; }
.pc { display: grid; gap: var(--sp-4); }
.pc.short { border-color: var(--over); }
.pc__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.pc__from { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.375rem; margin-top: 0.125rem; font-size: var(--fs-cap); color: var(--ink-soft); }
.pc__amt { font-size: var(--fs-stat); font-weight: var(--fw-strong); line-height: var(--lh-snug); font-variant-numeric: var(--num); color: var(--left-ink); white-space: nowrap; }
.bill-list { display: grid; gap: var(--sp-2); font-size: var(--fs-sub); }
.bill-list li { display: grid; grid-template-columns: 3.75rem minmax(0, 1fr) auto; gap: var(--sp-3); align-items: baseline; }
.pc__foot { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); font-size: var(--fs-sub); color: var(--ink-soft); }
.pc__foot b { font-weight: var(--fw-strong); font-variant-numeric: var(--num); color: var(--left-ink); white-space: nowrap; }
.pc__foot b.is-over { color: var(--over); }

/* ---------- Debt ---------- */
.debt-card header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.debt-card .name { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-title); letter-spacing: var(--tr-title); padding: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--sp-3) var(--sp-4); margin: var(--sp-4) 0; }
.facts dt { font-size: var(--fs-label); color: var(--ink-soft); }
.facts dd { font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.facts dd .muted { font-weight: var(--fw-regular); }

/* ---------- Savings: fund gauges ---------- */
.fund {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name mo" "sched of" "saved saved" "bar bar" "state state";
  gap: 0.125rem var(--sp-4); align-items: baseline;
  padding: var(--row-pad-y) var(--card-pad); border-top: 1px solid var(--line);
}
.rows > .fund:first-child, .rows > .fund--head + .fund { border-top: 0; }
.fund__name { grid-area: name; font-weight: var(--fw-medium); min-width: 0; }
.fund__name .link { padding: 0; font-weight: var(--fw-medium); color: var(--ink); text-align: left; }
.fund__name .link:hover { color: var(--coral-ink); }
.fund__sched { grid-area: sched; font-size: var(--fs-cap); color: var(--ink-soft); }
.fund__mo { grid-area: mo; font-weight: var(--fw-strong); font-variant-numeric: var(--num); text-align: right; white-space: nowrap; }
.fund__mo::after { content: " a month"; font-size: var(--fs-cap); font-weight: var(--fw-regular); color: var(--ink-soft); }
.fund__of { grid-area: of; font-size: var(--fs-cap); color: var(--ink-soft); font-variant-numeric: var(--num); text-align: right; white-space: nowrap; }
.fund__amt { display: none; }
.fund__saved { grid-area: saved; display: grid; grid-template-columns: minmax(0, 1fr) 8rem; align-items: center; gap: var(--sp-1) var(--sp-3); margin-top: var(--sp-3); }
.fund__saved::before { content: "Saved so far"; font-size: var(--fs-cap); font-weight: var(--fw-medium); color: var(--ink-soft); }
.fund__saved .form-error { grid-column: 1 / -1; }
.fund__bar { grid-area: bar; margin-top: var(--sp-2); }
.fund__state { grid-area: state; margin-top: var(--sp-1); font-size: var(--fs-cap); color: var(--ink-soft); }
.fund__state.is-behind { color: var(--coral-ink); font-weight: var(--fw-medium); }
.fund--head { display: none; }
.gauge { position: relative; height: 0.625rem; border-radius: var(--r-bar); background: var(--ground-deep); }
.gauge i { display: block; height: 100%; width: var(--w); border-radius: var(--r-bar); }
.gauge b { position: absolute; top: -0.1875rem; bottom: -0.1875rem; left: var(--at); width: 0.125rem; margin-left: -0.0625rem; border-radius: 0.0625rem; background: var(--ink); }
@media (min-width: 56.25em) {
  .fund { grid-template-columns: minmax(0, 1fr) 6rem 5.75rem 7rem; grid-template-areas: "name amt mo saved" "sched amt mo saved" "bar bar state state"; align-items: center; }
  .fund__of { display: none; }
  .fund__amt { display: block; grid-area: amt; align-self: start; text-align: right; color: var(--ink-soft); font-variant-numeric: var(--num); }
  .fund__mo { align-self: start; }
  .fund__mo::after { content: none; }
  .fund__saved { display: block; grid-area: saved; margin-top: 0; }
  .fund__saved::before { content: none; }
  .fund__state { text-align: right; margin-top: var(--sp-2); }
  .fund--head { display: grid; grid-template-areas: none; padding-block: var(--sp-2); font-size: var(--fs-label); font-weight: var(--fw-medium); letter-spacing: var(--tr-label); color: var(--ink-soft); background: var(--ground); border-top: 0; align-items: center; }
  .fund--head .r { text-align: right; }
}

/* ---------- Plans ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(21rem, 100%), 1fr)); gap: var(--stack); align-items: start; }
.plan-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--card-pad); min-width: 0; display: grid; gap: var(--sp-3); }
.plan-card.committed { border-color: var(--left); box-shadow: inset 0 0 0 1px var(--left); }
.plan-card header { display: flex; align-items: center; gap: var(--sp-3); }
.plan-name { flex: 1; min-width: 0; padding: 0 var(--sp-2); border: 1px solid transparent; border-radius: var(--r-ctl); background: none; min-height: var(--tap); font-family: var(--font-display); font-size: var(--fs-title); letter-spacing: var(--tr-title); }
.plan-name:hover { border-color: var(--line-strong); }
.bucket { display: grid; grid-template-columns: minmax(0, 1fr) 4.5rem 6rem; gap: var(--sp-2); align-items: center; padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.bucket:first-child { border-top: 0; }
.bucket .b-name { grid-column: 1 / -1; }
.bucket .b-out { grid-column: 1 / 3; font-variant-numeric: var(--num); }
.bucket .link { grid-column: 3; justify-self: end; }
.bucket input, .bucket select { height: 2.5rem; min-height: 2.5rem; }
.bucket select { padding-right: 1.75rem; background-position: calc(100% - 0.9375rem) 50%, calc(100% - 0.625rem) 50%; }
.bucket .b-val { text-align: right; }
.plan-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.plan-card .facts { margin: var(--sp-2) 0; padding: var(--sp-3) 0; border-block: 1px solid var(--line); }

/* ---------- Settings ---------- */
.set { display: grid; gap: var(--sp-2); }
.set__sum { display: flex; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); font-size: var(--fs-sub); }
.set__sum b { font-weight: var(--fw-strong); font-variant-numeric: var(--num); }
.tax-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.tax-row input:first-child { flex: 1; min-width: 10rem; }
.tax-row input[inputmode="decimal"] { width: 5rem; text-align: right; }
.cols--settings { margin-top: var(--section-gap); }

/* ---------- More (phone) ---------- */
.more { padding: 0; overflow: hidden; margin-top: var(--section-gap); }
.more button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3); width: 100%; min-height: 4rem; padding: var(--sp-3) var(--card-pad); border-top: 1px solid var(--line); text-align: left; }
.more li:first-child button { border-top: 0; }
.more button:hover { background: var(--press); }
.more .icon { color: var(--ink-soft); }
.more b { display: block; font-weight: var(--fw-medium); }
.more small { display: block; font-size: var(--fs-cap); color: var(--ink-soft); }

/* ---------- Forms and dialog ---------- */
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--field);
  font-size: var(--fs-body);
}
textarea { padding: var(--sp-2) var(--sp-3); }
input[type="checkbox"] { width: 1.25rem; min-height: 0; height: 1.25rem; accent-color: var(--coral-ink); flex: none; margin: 0.125rem 0 0; }
input[type="range"] { padding: 0; border: 0; background: none; }
input.num, .input.num { text-align: right; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 1.125rem) 50%, calc(100% - 0.8125rem) 50%; background-size: 0.3125rem 0.3125rem; background-repeat: no-repeat; padding-right: var(--sp-8); }
.field { display: grid; gap: 0.375rem; min-width: 0; font-size: var(--fs-sub); }
.field > span { font-size: var(--fs-cap); font-weight: var(--fw-medium); color: var(--ink-soft); }
.field.inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.field.inline > span { font-size: var(--fs-sub); }
.field.inline input { width: 8rem; }
.check { display: flex; gap: var(--sp-3); align-items: flex-start; margin: var(--sp-2) 0; font-size: var(--fs-sub); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(13.75rem, 100%), 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }
.edit-form { display: grid; gap: var(--sp-1); }
.edit-form > .grid-2:first-child { margin-top: 0; }
.field-group { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: var(--sp-3) var(--sp-4) var(--sp-4); margin: var(--sp-4) 0 0; min-width: 0; }
.field-group legend { font-weight: var(--fw-strong); padding: 0 var(--sp-2); font-size: var(--fs-sub); }
.hint { font-size: var(--fs-cap); color: var(--ink-soft); margin-top: var(--sp-2); }
.form-error { color: var(--over); font-size: var(--fs-sub); font-weight: var(--fw-medium); margin-top: var(--sp-2); }
.form-error:empty { display: none; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
.spacer { flex: 1; }
dialog {
  border: 0; border-radius: var(--r-card); padding: var(--card-pad);
  width: min(42.5rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem); overflow: auto;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-float);
}
dialog::backdrop { background: var(--scrim); }
@media (max-width: 56.24em) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: calc(100dvh - var(--sp-8)); border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding-bottom: calc(var(--card-pad) + var(--safe-b)); }
}
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }

/* ---------- Design check pass (Iris, 2026-11-15) ---------- */

/* Scope switch: the dot that explains the stripe along the top. */
.seg-btn::before { content: ""; width: 0.5rem; height: 0.5rem; margin-right: var(--sp-2); border-radius: 50%; flex: none; }
.seg-btn[data-view="personal"]::before { background: var(--personal); }
.seg-btn[data-view="business"]::before { background: var(--business); }
.seg-btn[data-view="both"]::before { background: var(--shared-stripe); }

/* Both view keeps the two sides in their own colours. */
.fill-personal { background: var(--personal); }
.fill-business { background: var(--business); }
.meter i.is-personal { background: var(--personal); }
.meter i.is-business { background: var(--business); }
.meter i.is-shared { background: var(--shared-stripe); }

/* Coral means "press this to move forward"; red means "actually over". */
.group-tools .link, .bucket .link, .group-row__tools .link, .tax-row .link { color: var(--ink-soft); }
.group-tools .link:hover, .group-tools .link:focus-visible, .bucket .link:hover, .bucket .link:focus-visible,
.group-row__tools .link:hover, .group-row__tools .link:focus-visible, .tax-row .link:hover, .tax-row .link:focus-visible { color: var(--ink); }
.group-row__tools .link[data-action="group-del"] { color: var(--over); }
.btn-add { width: auto; justify-self: start; background: var(--coral-soft); color: var(--coral-ink); box-shadow: none; }
.btn-add:hover, .btn-add:active { background: var(--coral-soft); box-shadow: inset 0 0 0 1px var(--coral-ink); }
.line .link, .debt-card header .link.name { color: var(--ink); }
.badge.debt { background: var(--note-bg); color: var(--note-ink); }
.chip--neutral { background: var(--ground-deep); color: var(--ink); }
.fund__state.is-behind, .fund__state.is-notstarted { color: var(--ink-soft); font-weight: var(--fw-regular); }

/* Calendar: bills in the quiet step, heavy months in coral, and a key for the marks. */
.bar-due { background: var(--step-3); }
.bar-due.is-heavy { background: var(--coral); }
.due-amt { background: var(--ink-faint); }
.sw--ring { width: 0.875rem; height: 0.875rem; border-radius: 50%; box-shadow: inset 0 0 0 0.125rem var(--left); background: none; }
.sw--today { width: 0.875rem; height: 0.875rem; border-radius: 50%; background: var(--ink); }
.fill-ink { background: var(--ink-faint); }
.sw--shared { background: var(--shared-stripe); }
.key--cal { margin-top: var(--sp-4); }
@media (min-width: 56.25em) {
  .due-amt { background: none; color: var(--ink); }
  .key__phone { display: none; }
}

/* Overview month chart on a phone: first and last value stay inside the plot. */
.cards--debt .card-label { min-height: 2lh; }
.facts__wide { grid-column: 1 / -1; }
.nowrap { white-space: nowrap; }
.per { font-size: var(--fs-cap); font-weight: var(--fw-regular); color: var(--ink-soft); }

/* Settings groups: name on line one, count left and tools right on line two. */
.group-row { justify-content: space-between; }
.tax-row.group-row input:first-child { flex: 1 1 100%; }
.line .link { padding-left: 0; }
.group-row__count { flex: 1; }
.group-row__tools { display: flex; align-items: center; gap: var(--sp-1); }

/* Paychecks extra months. */
.plain--months { margin-top: var(--sp-4); }
.plain--months .link { white-space: nowrap; }
@media (max-width: 56.24em) {
  .plain--months li { flex-direction: column; align-items: flex-start; gap: 0; }
}

/* Phone Overview: Coming up sits right under the stat cards. */
@media (max-width: 56.24em) {
  main:has(> .cols:not(.cols--settings)) { display: flex; flex-direction: column; }
  main:has(> .cols:not(.cols--settings)) .cols, main:has(> .cols:not(.cols--settings)) .col { display: contents; }
  main:has(> .cols:not(.cols--settings)) .cols .card { margin-top: var(--stack); order: 2; }
  main:has(> .cols:not(.cols--settings)) .ribbon-wrap { order: 2; }
  main:has(> .cols:not(.cols--settings)) .cols .card[aria-label="Coming up"] { order: 1; }
}

@media (min-width: 56.25em) {
  /* Savings: four columns on the first line only, gauge and status run the full width beneath. */
  .fund { grid-template-areas: "name amt mo saved" "sched amt mo saved" "bar bar bar bar" "state state state state"; }
  .fund__state { text-align: left; margin-top: var(--sp-2); }
  /* Budget rows: the chips ride the cadence line instead of making a third line. */
  .row .cell-name { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--sp-3); row-gap: 0.125rem; }
  .row .cell-name .name { flex: 1 0 100%; }
  .row .cell-name .meta { display: inline; }
  /* Budget: What's left stays in view while a line in the middle is edited. */
  .leftover-bar { position: sticky; bottom: var(--sp-4); z-index: 4; box-shadow: var(--shadow-float); }
}

/* ---------- Gate: sign-in, not invited, cannot reach the budget ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4); }
.gate__card { width: 100%; max-width: 28rem; display: grid; gap: var(--sp-4); padding: var(--sp-8) var(--sp-6); background: var(--card); border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line); }
.gate__title { font-family: var(--font-display); font-size: var(--fs-title); letter-spacing: var(--tr-title); line-height: var(--lh-snug); }
.gate__note { padding: var(--sp-3) var(--sp-4); border-radius: var(--r-ctl); background: var(--note-bg); color: var(--note-ink); }
.gate__note--stop { background: var(--over-soft); color: var(--over); box-shadow: inset 0 0 0 1px var(--over); }
.gate .btn-row { margin-top: var(--sp-2); }
.account { display: grid; gap: var(--sp-2); }
