/* Biller — one stylesheet for every page. Teal = brand, orange = the one action per screen. */

:root {
  --brand: #12677E;
  --brand-strong: #0E5467;
  --brand-tint: #E7F1F3;
  --cta: #F04A2A;
  --cta-strong: #D93D1F;
  --bg: #F5F7F8;
  --surface: #FFFFFF;
  --surface-2: #F0F3F5;
  --text: #16232A;
  --muted: #5B6B73;
  --line: #DDE4E8;
  --focus: #1B8FAE;
  --success: #117A45;
  --success-bg: #E3F4EA;
  --danger: #B42318;
  --danger-bg: #FDECEA;
  --pending: #8A5A00;
  --pending-bg: #FFF4D6;
  --neutral: #4B5A62;
  --neutral-bg: #ECEFF1;
  --shadow: 0 1px 2px rgba(16, 35, 42, .06), 0 2px 8px rgba(16, 35, 42, .05);
  --on-brand: #FFFFFF;
  --on-cta: #FFFFFF;
  /* Chart marks: validated (lightness, chroma, CVD, contrast) on the light surface. */
  --data-1: #0F7C9C;
  --data-over: #B42318;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #4FB3CC;
    --brand-strong: #7CC8DB;
    --brand-tint: #15323A;
    --cta: #FF6A4D;
    --cta-strong: #FF8469;
    --bg: #0F1619;
    --surface: #172126;
    --surface-2: #1E2A30;
    --text: #E6EEF1;
    --muted: #97A8B0;
    --line: #2A3840;
    --focus: #6FD0E8;
    --success: #5FD394;
    --success-bg: #16301F;
    --danger: #FF8A7F;
    --danger-bg: #3A1B18;
    --pending: #F2C35B;
    --pending-bg: #352A10;
    --neutral: #B5C3CA;
    --neutral-bg: #25323A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --on-brand: #0B1A1F;
    --on-cta: #1F0B06;
    --data-1: #25A3C9;
    --data-over: #E5484D;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must win over any display rule (.notice, .btn are flex). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
a:hover { color: var(--brand-strong); }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }

.icon { width: 20px; height: 20px; flex: none; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.text-center { text-align: center; }
.m-0 { margin: 0 !important; }
.pt-0 { padding-top: 0 !important; }
.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 0 16px;
  height: 60px; display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 750; font-size: 1.125rem; color: var(--text); text-decoration: none;
}
.brand-mark {
  width: 30px; height: 30px; padding: 6px; border-radius: 9px;
  background: var(--brand); color: #fff; fill: #fff; stroke: none;
}
.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.is-active { background: var(--brand-tint); color: var(--brand); }

.account { margin-left: auto; position: relative; }
.account summary { list-style: none; cursor: pointer; border-radius: 50%; }
.account summary::-webkit-details-marker { display: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); font-weight: 700;
}
.account-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12); padding: 6px; z-index: 30;
}
.account-who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.account-who strong, .account-who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-who span { color: var(--muted); font-size: .875rem; }
.account-menu a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.account-menu a:hover { background: var(--surface-2); }

/* Phones: the two destinations move to a thumb-reach tab bar. */
@media (max-width: 639px) {
  .mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  }
  .mainnav a { flex-direction: column; gap: 2px; padding: 6px; font-size: .75rem; justify-content: center; }
  .mainnav a .icon { width: 22px; height: 22px; }
  body.app { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  html:has(body.app) { scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------- Layout ---------- */

.page { max-width: 880px; margin: 0 auto; padding: 20px 16px 48px; }
.page-narrow { max-width: 560px; margin: 0 auto; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-header p { color: var(--muted); margin-top: 4px; }

.backlink {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem;
  margin: 0 0 12px -4px; padding: 6px 8px 6px 4px; border-radius: 8px;
}
.backlink:hover { color: var(--text); background: var(--surface-2); }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-head a { font-weight: 600; font-size: .95rem; text-decoration: none; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
@media (min-width: 640px) { .card-pad { padding: 28px; } }

/* ---------- Summary strip ---------- */

.summary {
  margin-bottom: 20px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.summary .card { padding: 16px; }
.summary-label { color: var(--muted); font-size: .875rem; }
.summary-value { font-size: clamp(1rem, 4.6vw, 1.5rem); font-weight: 750; margin-top: 2px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.summary-sub { color: var(--muted); font-size: .8125rem; margin-top: 2px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Lists (bills, payments) ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }

.row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
  color: inherit; text-decoration: none;
}
a.row:hover { background: var(--surface-2); }
.list > li:first-child .row { border-radius: var(--radius) var(--radius) 0 0; }
.list > li:last-child .row { border-radius: 0 0 var(--radius) var(--radius); }
.list > li:only-child .row { border-radius: var(--radius); }

.row-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; background: var(--brand-tint); color: var(--brand);
}
.row-main { flex: 1; min-width: 0; }
.row-title, .row-sub { display: block; }
.row-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-chevron { color: var(--muted); }

.bill-row { display: flex; align-items: center; }
.bill-row .row { flex: 1; min-width: 0; padding-right: 8px; }
.bill-row .btn { margin-right: 16px; }
.bill-row .row-sub { white-space: normal; }
.bill-chevron { display: none; margin-right: 16px; }
/* On phones the whole row already opens the pay screen; give the text the room. */
@media (max-width: 479px) {
  .bill-row .btn { display: none; }
  .bill-chevron { display: block; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid transparent; font: inherit; font-weight: 650; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-cta { background: var(--cta); color: var(--on-cta); }
.btn-cta:hover { background: var(--cta-strong); color: var(--on-cta); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); color: var(--on-brand); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-tint); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .9rem; border-radius: 10px; }
.btn-lg { min-height: 54px; font-size: 1.0625rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .7; cursor: progress; }

.btn .spinner { display: none; }
.btn.is-busy .spinner { display: inline-block; }
.btn.is-busy .icon { display: none; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-stack { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.actions-stack .btn { white-space: normal; text-align: center; }

/* ---------- Forms ---------- */

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-weight: 650; margin-bottom: 6px; }
.label .opt { font-weight: 400; color: var(--muted); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.label-row a { font-weight: 600; text-decoration: none; }
.hint { color: var(--muted); font-size: .875rem; margin-top: 6px; }
.field-error { color: var(--danger); font-size: .875rem; margin-top: 6px; }

.input {
  display: block; width: 100%; min-height: 50px; padding: 12px 14px;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--muted); opacity: .75; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea.input { min-height: 88px; resize: vertical; }

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-affix {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 10px;
}
.input-affix:hover { color: var(--text); }

.amount-wrap { position: relative; }
.amount-wrap .prefix {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 650;
}
.input-amount {
  padding-left: 58px; min-height: 60px; font-size: 1.5rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Segmented control built from radios */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 10px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; color: var(--muted);
}
.segmented input:checked + label { border-color: var(--brand); background: var(--brand-tint); color: var(--brand); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Choice list (saved phones) */
.choices { display: grid; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface);
}
.choice label::before {
  content: ""; width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
}
.choice input:checked + label { border-color: var(--brand); background: var(--brand-tint); }
.choice input:checked + label::before { border-color: var(--brand); box-shadow: inset 0 0 0 4px var(--surface); background: var(--brand); }
.choice input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice .tag { margin-left: auto; font-size: .8125rem; color: var(--muted); }
.choice-extra { margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  min-height: 38px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: .9375rem; font-variant-numeric: tabular-nums;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.is-on { border-color: var(--brand); background: var(--brand-tint); color: var(--brand); }

/* ---------- Pills & notices ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 650; white-space: nowrap;
}
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-pending { background: var(--pending-bg); color: var(--pending); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: .95rem;
}
.notice .icon { margin-top: 1px; }
.notice-success { background: var(--success-bg); color: var(--success); }
.notice-error { background: var(--danger-bg); color: var(--danger); }
.notice-info { background: var(--brand-tint); color: var(--text); }
.notice-info .icon { color: var(--brand); }
.tips ul { margin: 6px 0 0; padding-left: 18px; }
.tips li + li { margin-top: 4px; }
.nudge span { flex: 1; }
.nudge-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px; }
.nudge-close:hover { color: var(--text); }

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 36px 20px; }
.empty .row-icon { margin: 0 auto 12px; width: 52px; height: 52px; }
.empty h2 { margin-bottom: 4px; }
.empty p { color: var(--muted); margin-bottom: 16px; }

/* ---------- Pay screen ---------- */

.payee {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.payee-name { font-weight: 700; font-size: 1.125rem; }
.payee-meta { color: var(--muted); font-size: .9rem; }
.payee-meta strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- Status screen ---------- */

.status-hero { text-align: center; padding: 32px 20px 24px; }
.status-badge {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center;
}
.status-badge .icon { width: 36px; height: 36px; }
.status-hero[data-tone="success"] .status-badge { background: var(--success-bg); color: var(--success); }
.status-hero[data-tone="danger"] .status-badge { background: var(--danger-bg); color: var(--danger); }
.status-hero[data-tone="neutral"] .status-badge { background: var(--neutral-bg); color: var(--neutral); }
.status-hero[data-tone="pending"] .status-badge { background: var(--pending-bg); color: var(--pending); }
.status-hero .amount { font-size: 2.25rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 6px 0 4px; }
.status-hero p { color: var(--muted); max-width: 40ch; margin: 0 auto; }

.pulse-ring { position: relative; }
.status-hero[data-tone="pending"] .status-badge::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--pending); opacity: .5; animation: ring 1.6s ease-out infinite;
}
.status-badge { position: relative; }
@keyframes ring { from { transform: scale(.9); opacity: .6; } to { transform: scale(1.25); opacity: 0; } }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps li::before {
  counter-increment: s; content: counter(s);
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: .8125rem; font-weight: 700;
  background: var(--brand-tint); color: var(--brand);
}

/* Key/value details */
.details { margin: 0; }
.details > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.details > div:first-child { border-top: 0; }
.details dt { color: var(--muted); white-space: nowrap; }
.details dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700; letter-spacing: .04em;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-left: 6px;
  background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  color: var(--brand); cursor: pointer; font: inherit; font-size: .8125rem; font-weight: 600;
  vertical-align: middle;
}
.copy-btn:hover { background: var(--brand-tint); }
.copy-btn .icon { width: 16px; height: 16px; }

/* ---------- Filters & pager ---------- */

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a {
  padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.tabs a.is-active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tabs .count { opacity: .75; font-weight: 500; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }

/* ---------- Progress ---------- */

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; min-width: 6px; border-radius: inherit; background: var(--brand); }
.pot-row .progress { max-width: 260px; }
.pot-row .row-title, .pot-row .row-sub, .entry-row .row-title, .entry-row .row-sub { white-space: normal; }

/* ---------- Goal / investment / loan card ---------- */

.pot-card {
  border-radius: 20px; padding: 22px 20px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #1B8FAE 0%, #12677E 45%, #0B3E4C 100%);
  box-shadow: 0 10px 30px rgba(11, 62, 76, .25);
}
.pot-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.pot-card h1 { font-size: 1.15rem; letter-spacing: .02em; text-transform: uppercase; }
.pot-card p { color: rgba(255, 255, 255, .75); font-size: .875rem; margin-top: 4px; overflow-wrap: anywhere; }
.pot-edit { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .14); }
.pot-edit:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.pot-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 18px; }
.pot-label { font-size: .8125rem; color: rgba(255, 255, 255, .75); }
.pot-big { font-size: clamp(1.15rem, 5.4vw, 1.6rem); font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.pot-progress-row { display: flex; justify-content: space-between; margin-top: 16px; font-size: .9rem; color: rgba(255, 255, 255, .85); }
.pot-card .progress { background: rgba(255, 255, 255, .2); }
.pot-card .progress > span { background: #fff; }
.pot-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed rgba(255, 255, 255, .3); }
.pot-tile { background: rgba(0, 0, 0, .18); border-radius: 14px; padding: 12px; font-weight: 700; }
.pot-tile-wide { grid-column: 1 / -1; }
.pot-tile-link { color: #fff; text-decoration: none; }
.pot-tile-link:hover { color: #fff; background: rgba(0, 0, 0, .28); }
.suffix-pct { left: auto !important; right: 16px; }
.pot-hint { font-weight: 400; font-size: .8125rem; color: rgba(255, 255, 255, .75); }
.entry-form > summary, .list-settings > summary { list-style: none; cursor: pointer; }
.entry-form > summary::-webkit-details-marker, .list-settings > summary::-webkit-details-marker { display: none; }
.entry-form > summary { width: 100%; }
.entry-form[open] > summary { display: none; }
.segmented-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented-3 label { font-size: .875rem; padding: 8px 4px; text-align: center; gap: 6px; overflow-wrap: anywhere; }
@media (max-width: 359px) { .segmented-3 label .icon { display: none; } }
.entry-row { display: flex; align-items: center; }
.entry-row > .row { flex: 1; min-width: 0; }
.entry-del { margin-right: 8px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer; }
.icon-btn:hover { color: var(--danger); background: var(--danger-bg); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.mb-12 { margin-bottom: 12px; }

/* ---------- Charts ---------- */

.chart { position: relative; margin: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-zero { stroke: var(--muted); stroke-opacity: .5; }
/* --u = viewBox units per CSS pixel, set by app.js, so text and marks keep their real size on a phone. */
.chart svg { --u: 1; }
.chart-axis { fill: var(--muted); font-size: calc(12px * var(--u)); font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke: var(--data-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-area { fill: var(--data-1); fill-opacity: .1; }
.chart-dot { fill: var(--data-1); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: .8125rem; box-shadow: var(--shadow);
}
.chart-tip strong { display: block; font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 8px; font-size: .875rem; }
.chart-table summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.chart-table th, .chart-table td { text-align: left; padding: 6px 0; border-bottom: 1px solid var(--line); }
.chart-table .num { text-align: right; }
.hero-figure { font-size: clamp(1.6rem, 7vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.networth-split { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: .875rem; margin: 4px 0 12px; }

/* ---------- Net worth, spending, projects ---------- */

.networth { margin-bottom: 8px; }
.networth .summary-label { font-size: .875rem; font-weight: 600; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.month-nav-pad { width: 44px; }
.cat-bars { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 16px; }
.cat-bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: .9375rem; margin-bottom: 6px; }
.cat-name { font-weight: 600; }
.cat-track { position: relative; height: 12px; border-radius: 6px; background: var(--surface-2); display: flex; gap: 2px; }
.cat-fill { height: 100%; background: var(--data-1); border-radius: 4px; min-width: 4px; }
.cat-over { background: var(--data-over); }
.cat-limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); border-radius: 1px; }
.cat-note { margin: 6px 0 0; font-size: .875rem; display: flex; gap: 4px; align-items: center; }
.cat-note.over, .over { color: var(--danger); font-weight: 600; }
.cat-note.near { color: var(--pending); font-weight: 600; }
.columns { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; align-items: end; height: 160px; }
.column { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; text-decoration: none; color: inherit; }
.column-bar { width: 100%; max-width: 40px; background: var(--data-1); opacity: .55; border-radius: 4px 4px 0 0; }
.column.is-current .column-bar, .column:hover .column-bar { opacity: 1; }
.column-val { font-size: .75rem; font-weight: 700; min-height: 1em; }
.column-label { font-size: .8125rem; color: var(--muted); }
.limit-grid { display: grid; gap: 10px; }
.limit-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; align-items: center; font-size: .9375rem; }
.limit-row .input { padding-left: 58px; min-height: 44px; }
.limit-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); font-size: .9rem; }
.limit-banner .icon { color: var(--brand); margin-top: 1px; }
.limit-banner.is-over { background: var(--danger-bg); color: var(--danger); }
.limit-banner.is-over .icon { color: var(--danger); }
.progress.is-over > span { background: var(--data-over); }
.stage-row { display: flex; align-items: flex-start; flex-wrap: wrap; }
.stage-row > .row { flex: 1; min-width: 0; }
.stage-row .row-sub { white-space: normal; }
.stage-edit { margin: 10px 8px 0 0; }
.stage-edit > summary { list-style: none; cursor: pointer; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.stage-edit > summary::-webkit-details-marker { display: none; }
.stage-edit > summary:hover { background: var(--surface-2); color: var(--text); }
.stage-edit[open] { flex-basis: 100%; margin: 0; padding: 0 16px 14px; display: grid; gap: 8px; }
.stage-edit[open] > summary { justify-self: end; }
.stage-form { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 8px; }
.add-stage { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 8px; padding: 12px 16px; }
.add-stage .input, .stage-form .input { min-height: 40px; padding: 8px 10px; }
.input-file { padding: 10px; }
.empty-inline { display: flex; gap: 12px; align-items: center; padding: 16px; color: inherit; text-decoration: none; }
.empty-inline .icon { color: var(--brand); flex: none; }
.empty-inline:hover { border-color: var(--brand); color: inherit; }
.topup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.topup { display: flex; gap: 12px; align-items: center; padding: 14px 16px; color: inherit; text-decoration: none; }
.topup:hover { border-color: var(--brand); color: inherit; }
.topup strong, .topup .small { display: block; }
.statement-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.statement-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-bottom: 8px; }
.statement-brand .brand-mark { width: 26px; height: 26px; padding: 5px; }
.statement-totals { margin: 0; display: grid; gap: 4px; min-width: 200px; }
.statement-totals > div { display: flex; justify-content: space-between; gap: 16px; }
.statement-totals dt { color: var(--muted); }
.statement-totals dd { margin: 0; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.statement-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.statement-table th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: 8px 10px 8px 0; white-space: nowrap; }
.statement-table td { border-bottom: 1px solid var(--line); padding: 8px 10px 8px 0; vertical-align: top; }
.statement-table .num { text-align: right; white-space: nowrap; }
/* Narrow screens: each statement row becomes a small labelled card. */
@media screen and (max-width: 599px) {
  .statement-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .statement-table tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .statement-table td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 2px 0; }
  .statement-table td::before { content: attr(data-label); color: var(--muted); }
  .statement-table td.num { text-align: right; }
  .statement-table td:empty { display: none; }
}
@media (max-width: 479px) {
  .stage-form, .add-stage { grid-template-columns: minmax(0, 1fr) 96px; }
  .stage-form .btn, .add-stage .btn { grid-column: 1 / -1; }
  .limit-row { grid-template-columns: minmax(0, 1fr) 130px; }
}
@media print {
  .statement { border: 0; padding: 0; }
  .statement-table { font-size: 10pt; }
  .table-wrap { overflow: visible; }
}

/* ---------- Plans, split, settings ---------- */

.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: 12px; }
.field-row > .field { min-width: 0; }
.plan-row { padding-bottom: 6px; }
.plan-row.is-paused .row-title, .plan-row.is-paused .row-icon { opacity: .55; }
.plan-row .row-sub { white-space: normal; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 12px 8px 68px; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.split-row:first-child { border-top: 0; }
.split-row .row-sub { white-space: normal; }
.split-row .input { min-height: 44px; padding-left: 58px; }
.split-total { display: flex; justify-content: space-between; font-weight: 700; padding: 12px 0 0; border-top: 2px solid var(--line); margin-top: 6px; }
.split-total.is-over { color: var(--danger); }
.batch-steps { list-style: none; margin: 0; padding: 0; }
.batch-step { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.batch-step:first-child { border-top: 0; }
.batch-step .row-main { min-width: 0; }
.batch-step.is-current { background: var(--pending-bg); }

/* ---------- Milestones ---------- */

.milestone-next h2 { font-size: 1rem; }
.auto-add > summary { list-style: none; display: inline-flex; }
.auto-add > summary::-webkit-details-marker { display: none; }
.auto-add[open] > summary { display: none; }
.milestone-next .progress { margin-top: 10px; }
.row-icon.is-done { background: var(--success-bg); color: var(--success); }

/* ---------- Due soon ---------- */

.section-tight { margin-bottom: 20px; }
.summary-link { color: inherit; text-decoration: none; display: block; }
.summary-link:hover { border-color: var(--brand); color: inherit; }
.icon-sm { width: 14px; height: 14px; vertical-align: -2px; }
.row-sub.feeds { color: var(--brand); font-weight: 600; }
.feeds-banner { display: flex; gap: 10px; align-items: center; margin: 0; padding: 12px 20px; background: var(--brand-tint); color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.feeds-banner .icon { color: var(--brand); }
.feeds-banner .muted { display: block; font-size: .875rem; }
.feeds-done { border: 0; border-radius: 12px; margin-bottom: 12px; padding: 12px 14px; }
.feeds-done .icon { color: var(--success); }

.due-row .row-sub strong { color: var(--pending); }
.due-row.is-overdue .row-sub strong { color: var(--danger); }

/* ---------- Shopping list ---------- */

.add-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.add-grid .add-name { grid-column: 1 / -1; }
.add-grid .label { font-size: .875rem; }
.items { list-style: none; margin: 0; padding: 0; }
.items > li + li { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; min-height: 60px; }
.item-main { flex: 1; min-width: 0; }
.item-name { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-sub { display: block; color: var(--muted); font-size: .875rem; }
.item-total { font-weight: 700; white-space: nowrap; }
.tick { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; }
.tick .icon { width: 18px; height: 18px; }
.item.is-bought .tick { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.item.is-bought .item-name { text-decoration: line-through; color: var(--muted); }
.items-empty { padding: 18px; color: var(--muted); text-align: center; }
.list-settings > summary { display: flex; align-items: center; gap: 8px; font-weight: 650; }

/* ---------- Sign-in options ---------- */

.icon-google { width: 20px; height: 20px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); font-size: .875rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-head h2 { display: flex; align-items: center; gap: 8px; }
.keylist { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.keyrow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.keyrow .row-icon { width: 36px; height: 36px; border-radius: 10px; }
.keyrow .row-main { min-width: 0; flex: 1; }
.keyrow .row-title, .keyrow .row-sub { white-space: normal; }
.keyrow form { flex: none; }
.pw-details > summary { list-style: none; display: inline-flex; }
.pw-details > summary::-webkit-details-marker { display: none; }
.pw-details[open] > summary { display: none; }

/* ---------- Auth pages ---------- */

body.auth { min-height: 100vh; min-height: 100dvh; display: flex; }
.auth-page { width: 100%; max-width: 420px; margin: auto; padding: 32px 16px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 20px; }
.auth-brand .brand-mark { width: 40px; height: 40px; padding: 8px; border-radius: 12px; }
.auth-brand span { font-size: 1.5rem; font-weight: 800; }
.auth-title { text-align: center; margin-bottom: 20px; }
.auth-title p { color: var(--muted); margin-top: 4px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-foot a { font-weight: 650; }

/* ---------- Receipt / print ---------- */

.receipt-head { text-align: center; padding: 24px 20px 8px; }
.receipt-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

@media print {
  .topbar, .mainnav, .backlink, .no-print, .skip { display: none !important; }
  body { background: #fff; color: #000; padding: 0 !important; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; }
  .pill { border: 1px solid currentColor; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Income ---------- */
.income-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.income-figures dt { color: var(--muted); font-size: .8125rem; }
.income-figures dd { margin: 2px 0 0; font-weight: 700; font-size: 1.0625rem; }
.income-card h3 { font-size: 1rem; margin: 0; }
.line-edit > summary { list-style: none; cursor: pointer; }
.line-edit > summary::-webkit-details-marker { display: none; }
.line-edit[open] > summary { background: var(--surface-2); }
.line-form, .line-del { padding: 12px 16px 0; }
.line-del { padding-bottom: 12px; }
.income-line { display: block; }
.income-total { padding: 12px 16px; margin: 0; list-style: none; }

/* Pay cycle on Home: in, out, left */
.cycle { padding: 16px; margin-bottom: 20px; }
.cycle-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.cycle-head .summary-label { font-weight: 600; color: var(--text); }
.cycle-left { font-size: clamp(1.5rem, 7vw, 2rem); font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; }
.cycle-left.is-over { color: var(--pending); }
.income-card .row-title, .income-card .row-sub { white-space: normal; overflow: visible; overflow-wrap: break-word; }
.income-card .row { flex-wrap: wrap; row-gap: 4px; }
.income-card .row-main { flex: 1 1 150px; }
.income-card .row-end { margin-left: auto; }
@media (max-width: 419px) { .income-card.card-pad { padding: 16px 14px; } }
.income-card .row-end { flex-shrink: 0; }
.income-total { gap: 12px; flex-wrap: wrap; }
.auto-add > summary { max-width: 100%; white-space: normal; text-align: left; }
.income-total > span:last-child { margin-left: auto; }

/* ---------- M-Pesa ---------- */
.mp-month { display: inline-flex; gap: 4px; }
.mp-month a { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; color: var(--brand); }
.mp-month a:hover { background: var(--brand-tint); }
.mp-month .flip .icon { transform: rotate(180deg); }
.mpesa-balance .list .row { padding-left: 0; padding-right: 0; }
.row-amount.is-in { color: var(--success); }
.mpesa-list .row { flex-wrap: wrap; row-gap: 4px; }
.mpesa-list .row-main { flex: 1 1 170px; }
.mpesa-list .row-title, .mpesa-list .row-sub { white-space: normal; overflow-wrap: break-word; }
.mpesa-list .row-end { margin-left: auto; }
.mpesa-balance .row-sub, .mpesa-balance .row-title { white-space: normal; }
.sort-row { display: grid; gap: 10px; padding: 14px 16px; }
.sort-what .row-title, .sort-what .row-sub { white-space: normal; overflow-wrap: break-word; }
.sort-pick { display: flex; gap: 8px; align-items: center; }
.sort-pick .input { flex: 1; min-width: 0; min-height: 44px; }
.tag-line { margin-top: 4px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); }
.tag.is-guess { background: var(--surface-2); color: var(--muted); }
.tag.is-open { background: var(--pending-bg); color: var(--pending); }

/* Pay cycle figures: each one opens its page */
.cycle-figures { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cycle-figures a { display: grid; gap: 2px; color: inherit; text-decoration: none; border-radius: 10px; padding: 6px 8px; margin: -6px -8px; }
.cycle-figures a:hover { background: var(--surface-2); color: inherit; }
.cycle-figures .icon { display: none; }
.cf-label { color: var(--muted); font-size: .75rem; }
.cf-value { font-weight: 700; font-size: .9375rem; white-space: nowrap; }
@media (max-width: 419px) {
  .cycle-figures { grid-template-columns: 1fr; gap: 2px; }
  .cycle-figures a { display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 44px; }
  .cf-label { flex: 1; font-size: .8125rem; }
  .cycle-figures .icon { display: inline-block; color: var(--muted); }
}
.home-top { display: grid; gap: 16px; margin-bottom: 20px; }
.home-top > .card { margin-bottom: 0; }
@media (min-width: 900px) { .home-top { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; } }

/* Number boxes: no spinner arrows (amounts are typed, never nudged by 1) */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Narrow phones: give names in goal/bill rows more room */
@media (max-width: 420px) {
  .pot-row .row-icon { width: 36px; height: 36px; }
  .pot-row .row-amount { font-size: .9375rem; }
}
.sort-accept { display: flex; justify-content: flex-end; margin-top: 10px; }
.pair-code { font-size: 2rem; font-weight: 800; letter-spacing: .12em; margin: 4px 0; }
.screens { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.screens pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-size: .8125rem; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; }

/* ---------- Inside the Biller phone app (WebView) ---------- */
/* The app shows its own native top bar, so the web's header and bottom nav are hidden to avoid a
   double header. Section-to-section navigation is the app's Home tiles and the in-page card links. */
body.in-app .topbar { display: none !important; }
body.in-app.app { padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important; }
