/* Bookkeeping — one stylesheet. Dark by default; light via [data-theme=light].
   Phone first: below 768px the nav moves to a bottom tab bar with a centre "+". */
:root {
  --bg: #14161b;
  --bg-elev: #1c1f26;
  --bg-elev-2: #252932;
  --fg: #e7e7e4;
  --fg-muted: #9aa0a9;
  --line: #2e333c;
  --accent: #4cbf8a;
  --accent-strong: #5fd39c;
  --accent-fg: #0d1a13;
  --pos: #5fd39c;
  --neg: #f08a7e;
  --warn: #e6b450;
  --err: #f0705f;
  --focus: #7cc4ff;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --tabbar-h: 64px;
  /* S9 chart series (D63) */
  --c1: #5fb4f0; --c2: #f0a35f; --c3: #b48cf0; --c4: #5fd39c; --c5: #f07fb4; --c6: #d6c95f; --c7: #5fd3d0; --c8: #a0a6b0;
  /* S15 payment states */
  --paid-bg: #1d3a2c; --paid-line: #3f8f68; --est-bg: #1f2b3d; --est-line: #5f8fc8; --now-col: #1f2a25;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f4f0;
  --bg-elev: #ffffff;
  --bg-elev-2: #eceae4;
  --fg: #1c1e22;
  --fg-muted: #5d626b;
  --line: #dcdad3;
  --accent: #1f7f55;
  --accent-strong: #176a46;
  --accent-fg: #ffffff;
  --pos: #1b7a4b;
  --neg: #b8382b;
  --warn: #8f6200;
  --err: #b3261e;
  --focus: #1d6fd1;
  --c1: #1f6fb2; --c2: #c2621c; --c3: #6b45b8; --c4: #1b7a4b; --c5: #b83a78; --c6: #8a7a10; --c7: #11807c; --c8: #5d626b;
  --paid-bg: #d9f0e2; --paid-line: #5aab80; --est-bg: #dfeafa; --est-line: #6f9bd0; --now-col: #eef6f1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  background: var(--bg); color: var(--fg);
  min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; }
h1 { font-size: 1.45rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--bg-elev-2); padding: 0.05em 0.35em; border-radius: 4px; }
.muted { color: var(--fg-muted); }
.small { font-size: 0.85rem; }
.pre { white-space: pre-wrap; }
.ta-r { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----------------------------------------------------------------- shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; font-weight: 650; white-space: nowrap; }
.topnav { display: flex; gap: 0.15rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav a {
  text-decoration: none; color: var(--fg-muted); padding: 0.4rem 0.65rem; border-radius: 999px; white-space: nowrap; font-size: 0.95rem;
}
.topnav a:hover { color: var(--fg); background: var(--bg-elev); }
.topnav a[aria-current="page"] { color: var(--fg); background: var(--bg-elev-2); }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.theme-toggle {
  font: inherit; font-size: 0.8rem; cursor: pointer; color: var(--fg-muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.7rem; min-height: 32px;
}
.theme-toggle:hover { color: var(--fg); }

.content { max-width: 1120px; margin: 0 auto; padding: 1rem 16px 2.5rem; }

.tabbar { display: none; }

@media (max-width: 767px) {
  .topnav, .topbar .btn-add { display: none; }
  .content { padding-bottom: calc(var(--tabbar-h) + 2rem + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-elev); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    height: 100%; min-width: 0; white-space: nowrap; text-decoration: none; color: var(--fg-muted); font-size: 0.68rem;
  }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar .ti { font-size: 1.25rem; line-height: 1; }
  .tabbar .tab-add span {
    display: grid; place-items: center; width: 48px; height: 48px; margin-top: -18px;
    border-radius: 50%; background: var(--accent); color: var(--accent-fg);
    font-size: 2rem; font-weight: 400; line-height: 1; box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
  }
}

/* --------------------------------------------------------------- blocks */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin: 0.25rem 0 1rem; }
.section-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin: 1.4rem 0 0.5rem; font-weight: 600; }
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.9rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.empty { text-align: center; padding: 2rem 1rem; }
.grid-2 { display: grid; gap: 0 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.stack > * { margin-bottom: 0.9rem; }
.notice {
  display: block; text-decoration: none; padding: 0.7rem 0.9rem; margin-bottom: 0.9rem; border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--bg-elev)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
}

.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--neg); }
.pos { color: var(--pos); }

.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  padding: 0.12rem 0.45rem; border-radius: 999px; background: var(--bg-elev-2); color: var(--fg-muted); vertical-align: middle;
}
.badge-draft { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.badge-confirmed { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge-void { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.badge-tip { text-transform: none; }
.badge-run-success { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge-run-failed { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.badge-run-skipped { background: var(--bg-elev-2); color: var(--fg-muted); }
.badge-run-running { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.chip { display: inline-block; text-decoration: none; padding: 0.15rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.85rem; }

/* segmented control: links, buttons or radio labels */
.seg { display: inline-flex; background: var(--bg-elev-2); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg-wide { display: flex; width: 100%; margin-bottom: 1rem; }
.seg > a, .seg > button, .seg-radio span {
  font: inherit; font-size: 0.88rem; border: 0; background: transparent; color: var(--fg-muted); cursor: pointer;
  text-decoration: none; padding: 0.45rem 0.8rem; border-radius: 999px; white-space: nowrap; flex: 1; text-align: center; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
}
.seg-radio { flex: 1; display: flex; position: relative; margin: 0; }
.seg-radio input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg > a[aria-current], .seg > button[aria-checked="true"], .seg-radio input:checked + span {
  background: var(--bg-elev); color: var(--fg); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
}
.seg-radio input:focus-visible + span { outline: 2px solid var(--focus); }
/* entry-type switcher: five options wrap into a tidy grid on narrow phones */
.seg.tmpl { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.6rem, 1fr)); border-radius: 16px; overflow: visible; }
.seg.tmpl > button { border-radius: 12px; }

/* buttons */
.btn {
  font: inherit; font-size: 0.95rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 40px; padding: 0.45rem 0.95rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev-2); color: var(--fg); white-space: nowrap;
}
.btn:hover { border-color: var(--fg-muted); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.btn-lg { min-height: 48px; font-size: 1.05rem; padding: 0.6rem 1.4rem; }
.icon-btn {
  font: inherit; cursor: pointer; background: transparent; border: 0; color: var(--fg-muted); text-decoration: none;
  min-width: 36px; min-height: 36px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--bg-elev-2); color: var(--fg); }
.link-btn { font: inherit; font-size: 0.92rem; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0.4rem 0; min-height: 36px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.75rem 0; }
.actions form { margin: 0; }

/* forms */
input, select, textarea {
  font: inherit; font-size: 16px; /* no iOS zoom */ color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem; min-height: 44px; width: 100%; min-width: 0;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input[readonly] { opacity: 0.7; }
label { display: block; font-size: 0.85rem; color: var(--fg-muted); margin-bottom: 0.3rem; }
label.check { display: flex; gap: 0.5rem; align-items: center; color: var(--fg); font-size: 0.95rem; }
label.check input { width: auto; min-height: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-size: 0.85rem; color: var(--fg-muted); padding: 0; margin-bottom: 0.35rem; }
.field { margin-bottom: 0.9rem; min-width: 0; }
.field-row { display: grid; gap: 0 0.75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.hint { font-size: 0.82rem; color: var(--fg-muted); margin: 0.35rem 0 0.75rem; }
.error { color: var(--err); font-weight: 500; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; margin-top: 0.75rem; }
.inline-form label { width: 100%; margin: 0; }
.inline-form input { flex: 1 1 180px; width: auto; }

/* --------------------------------------------------------------- home */
.networth { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.75rem 1.5rem; }
.nw-main .label { color: var(--fg-muted); font-size: 0.9rem; }
.nw-value { font-size: clamp(1.9rem, 7vw, 2.6rem); font-weight: 650; letter-spacing: -0.01em; }
.nw-split { display: flex; gap: 1.5rem; margin: 0; }
.nw-split dt { font-size: 0.8rem; color: var(--fg-muted); }
.nw-split dd { margin: 0; font-weight: 600; }

.list { list-style: none; padding: 0; }
.list.card { padding: 0.25rem 0; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1rem; text-decoration: none; min-height: 52px; }
a.row:hover, .row a.row-main:hover .row-title { color: var(--accent); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.8rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; }
/* Accounts: on a desktop the actions sit in the row; on a phone the name, its details and the balance
   take the first line and the actions a small line of their own (owner, 2026-10-26) */
.acct-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; min-width: 14.5rem; }
@media (max-width: 767px) {
  .acct-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.75rem; row-gap: 0.3rem; align-items: start; }
  .acct-row .row-main { grid-column: 1; grid-row: 1; }
  .acct-row .row-end { grid-column: 2; grid-row: 1; }
  .acct-row .row-main .row-sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
  .acct-row .acct-actions { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: flex-end; gap: 0.25rem; min-width: 0; }
  .acct-row .acct-actions .btn-sm { min-height: 30px; padding: 0.15rem 0.7rem; font-size: 0.8rem; }
}
.is-archived { opacity: 0.6; }

.bars { list-style: none; margin: 0; padding: 0; }
.bars a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.75rem; padding: 0.45rem 0; text-decoration: none; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { grid-column: 1 / -1; height: 6px; background: var(--bg-elev-2); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.75rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }

/* ------------------------------------------------------- transactions */
.search { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.search input { flex: 1; }
.filters summary { cursor: pointer; font-weight: 500; min-height: 28px; }
.filter-grid { display: grid; gap: 0.25rem 0.75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-top: 0.75rem; }
.filter-grid label { margin: 0 0 0.5rem; }
.filter-actions { display: flex; gap: 0.5rem; align-items: end; padding-bottom: 0.5rem; }

.tx-list.card { padding: 0; overflow: hidden; }
.tx-head, .tx-row {
  display: grid; grid-template-columns: 6.5rem minmax(0, 1.4fr) minmax(0, 1.3fr) minmax(0, 1fr) 8.5rem;
  gap: 0.75rem; align-items: center; padding: 0.65rem 1rem;
}
.tx-head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); border-bottom: 1px solid var(--line); }
.tx-row { text-decoration: none; border-top: 1px solid var(--line); min-height: 52px; }
.tx-head + .tx-row { border-top: 0; }
.tx-row:hover { background: var(--bg-elev-2); }
.tx-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tx-date, .tx-acct { color: var(--fg-muted); font-size: 0.9rem; }
.tx-amt { text-align: right; font-weight: 550; }
.tx-row.is-void .tx-payee, .tx-row.is-void .tx-amt { text-decoration: line-through; opacity: 0.6; }
.load-more { padding: 0.75rem; text-align: center; border-top: 1px solid var(--line); }

@media (max-width: 767px) {
  .tx-head { display: none; }
  .tx-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "payee amt" "meta date";
    gap: 0.1rem 0.75rem; padding: 0.65rem 0.9rem;
  }
  .tx-payee { grid-area: payee; font-weight: 500; }
  .tx-amt { grid-area: amt; }
  .tx-cat { grid-area: meta; font-size: 0.82rem; color: var(--fg-muted); }
  .tx-acct { display: none; }
  .tx-date { grid-area: date; font-size: 0.8rem; text-align: right; }
}

/* detail */
.detail-amount { font-size: clamp(1.8rem, 7vw, 2.3rem); font-weight: 650; margin-bottom: 0.75rem; }
.kv { display: grid; gap: 0.45rem; margin: 0; }
.kv > div { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 0.75rem; }
.kv dt { color: var(--fg-muted); font-size: 0.88rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-wide > div { grid-template-columns: 11rem minmax(0, 1fr); }
@media (max-width: 480px) { .kv > div, .kv-wide > div { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.table-wrap { overflow-x: auto; padding: 0.25rem 0; }
.table-wrap > p { padding: 0 1rem; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.55rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td a { text-decoration: none; }
td a:hover { color: var(--accent); }
.runs td { font-size: 0.88rem; }
.void-box summary { list-style: none; }
.void-box summary::-webkit-details-marker { display: none; }
.void-box[open] { flex-basis: 100%; }
.history { list-style: none; padding: 0.5rem 1rem; }
.history li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.h-action { font-weight: 600; text-transform: capitalize; margin-right: 0.4rem; }
.diff { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; }

/* ----------------------------------------------------------- tx form */
.txform { max-width: 640px; }
.amount-field {
  display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.75rem; padding: 0.25rem 0.9rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--fg);
}
.amount-field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.amount-field .cur { font-size: 1.5rem; color: var(--fg-muted); font-weight: 500; }
.amount-field input {
  border: 0; background: transparent; box-shadow: none !important; padding: 0.35rem 0; min-height: 56px;
  font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.lines .line { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 0.5rem; align-items: start; margin-bottom: 0.5rem; }
.lines .line-amount, .lines [data-remove-line] { display: none; }
.lines.is-split .line { grid-template-columns: minmax(0, 1fr) 7.5rem 36px; }
.lines.is-split .line-amount { display: block; }
.lines.is-split [data-remove-line] { display: inline-grid; }
.lines:not(.is-split) .line { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 420px) { .lines.is-split .line { grid-template-columns: minmax(0, 1fr) 6.2rem 32px; } }

.catpick { position: relative; min-width: 0; }
.catpick-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 18rem; overflow-y: auto;
  list-style: none; margin: 0; padding: 0.25rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.35);
}
.catpick-list li { padding: 0.6rem 0.65rem; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 0.5rem; min-height: 44px; align-items: center; }
.catpick-list li small { color: var(--fg-muted); font-style: italic; }
.catpick-list li.active, .catpick-list li:hover { background: var(--bg-elev-2); }
.catpick-list li.none { color: var(--fg-muted); cursor: default; font-size: 0.88rem; }

@media (max-width: 767px) {
  .page-form .sticky-actions {
    position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5;
    background: var(--bg-elev); padding: 0.5rem 0; margin-bottom: -0.25rem;
  }
  .page-form .sticky-actions .btn-primary { flex: 1; }
}

/* ---------------------------------------------------------- categories */
.add-cat summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.cat-group { padding: 0.25rem 0; }
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem 0.35rem 1rem; min-height: 44px; }
.cat-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem; min-width: 0; }
.cat-top { font-weight: 600; }
.cat-name { text-decoration: none; }
.cat-name:hover { color: var(--accent); }
.cat-children { list-style: none; margin: 0; padding: 0 0 0.25rem; border-top: 1px solid var(--line); }
.cat-children .cat-row { padding-left: 2rem; font-weight: 400; }
.aliases { color: var(--fg-muted); font-size: 0.8rem; font-style: italic; min-width: 0; overflow-wrap: anywhere; }
.maps { color: var(--fg-muted); font-size: 0.8rem; }
.cat-count { font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: right; min-width: 1.5rem; }
.cat-move { display: inline-flex; }
.cat-move form { margin: 0; }
.cat-move .icon-btn { min-width: 32px; min-height: 32px; font-size: 0.9rem; }
.merge-counts { padding-left: 1.2rem; }

/* -------------------------------------------------------------- health */
.status-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-ok { background: var(--accent); }
.dot-warn { background: var(--warn); }
.dot-error { background: var(--err); }
.status-ok { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.status-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.status-error { border-color: color-mix(in srgb, var(--err) 50%, var(--line)); }
.issues { margin: 0.6rem 0 0; padding-left: 1.2rem; }
.issues li { margin: 0.2rem 0; overflow-wrap: anywhere; }
.issue-error { color: var(--err); }
.issue-warn { color: var(--warn); }
.repo .kv > div { grid-template-columns: 7.5rem minmax(0, 1fr); }

/* --------------------------------------------------------------- toast */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(1.25rem + env(safe-area-inset-bottom)); width: min(92vw, 460px); pointer-events: none;
}
@media (max-width: 767px) { .toast-wrap { bottom: calc(var(--tabbar-h) + 0.75rem + env(safe-area-inset-bottom)); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.9rem 0.7rem 1.1rem;
  border-radius: var(--radius); background: var(--fg); color: var(--bg); box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  transition: opacity 0.3s, transform 0.3s;
}
.toast span { flex: 1; }
.toast a { color: inherit; font-weight: 600; }
.toast form { margin: 0; }
.toast-undo { font: inherit; font-weight: 700; color: #1a7349; background: transparent; border: 0; cursor: pointer; padding: 0.35rem 0.6rem; min-height: 36px; }
:root[data-theme="light"] .toast-undo { color: #7be0ad; }
.toast-error { background: var(--err); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(8px); }

/* ------------------------------------------------- Session 2: capture UI */
.nav-badge {
  display: inline-block; min-width: 1.2rem; padding: 0 0.3rem; text-align: center;
  border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 0.7rem; font-weight: 700; line-height: 1.35rem; vertical-align: 1px;
}
.tabbar .ti { position: relative; }
.tab-badge { position: absolute; top: -6px; right: -14px; line-height: 1.1rem; min-width: 1.1rem; }

.review-list.card { padding: 0; }
.review-row {
  grid-template-columns: 1.6rem 6.2rem minmax(0, 1.3fr) minmax(0, 1.3fr) minmax(0, 1fr) 7.5rem 7rem;
}
.review-row input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; }
.review-actions { display: inline-flex; gap: 0.15rem; justify-content: flex-end; }
.review-actions .icon-btn { min-width: 34px; min-height: 34px; }
div.tx-row { text-decoration: none; }
div.tx-row a { text-decoration: none; }
@media (max-width: 767px) {
  .review-row {
    grid-template-columns: 1.6rem minmax(0, 1fr) auto;
    grid-template-areas: "check payee amt" "check meta actions";
    gap: 0.1rem 0.6rem;
  }
  .review-row > span:first-child { grid-area: check; align-self: center; }
  .review-row .tx-date { display: none; }
  .review-row .tx-payee { grid-area: payee; }
  .review-row .tx-cat { grid-area: meta; font-size: 0.82rem; color: var(--fg-muted); }
  .review-row .tx-acct { display: none; }
  .review-row .tx-amt { grid-area: amt; }
  .review-row .review-actions { grid-area: actions; }
  .review-list .tx-head { display: none; }
}

.inbox-grid { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.inbox-item { margin-bottom: 0; }
.inbox-album-label { margin: 0 0 0.4rem; font-weight: 600; }
.inbox-album-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.inbox-album-photo { margin: 0; display: grid; gap: 0.25rem; min-width: 0; }
.inbox-album-photo .inbox-thumb { width: 100%; height: 130px; max-width: none; }
.inbox-thumb, .evidence-thumb {
  display: block; width: 100%; max-width: 280px; max-height: 220px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg);
}
.evidence-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start; }
.evidence-row .evidence-thumb { width: 160px; height: 120px; }
.evidence-photo { display: grid; gap: 0.3rem; justify-items: start; }
.evidence-photo form { margin: 0; }
.evidence-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.evidence-actions form { margin: 0; }
/* the receipt viewer over the transaction page (owner, 2026-10-23) */
.rv-dialog { width: min(960px, calc(100vw - 2rem)); height: min(92vh, 1100px); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); color: var(--fg); }
.rv-dialog[open] { display: flex; flex-direction: column; }
.rv-dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.rv-dialog .rv { position: static; flex: 1; height: auto; min-height: 0; border: 0; margin: 0; }
.rv-dialog .rv-bar { padding-right: 2.6rem; }
.rv-close { position: absolute; top: 0.55rem; right: 0.55rem; z-index: 2; }
@media (max-width: 767px) {
  .rv-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
}
.evidence-chip {
  display: flex; flex-direction: column; gap: 0.15rem; padding: 0.6rem 0.8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); max-width: 100%;
}
.rule-edit select { min-width: 12rem; max-width: 100%; }
.merchant-table input:not([type=checkbox]) { min-width: 8rem; }
.merchant-table select { min-width: 12rem; }
.merchant-table input[type=checkbox] { width: auto; min-height: 0; }
.merchant-table .row-actions { display: flex; gap: 0.35rem; align-items: center; }


/* ------------------------------------------------- dev instance marker */
.dev-banner {
  position: sticky; top: 0; z-index: 40;
  background: repeating-linear-gradient(-45deg, #b58015, #b58015 14px, #9a6c0e 14px, #9a6c0e 28px);
  color: #fff8e6; text-align: center; font-weight: 700; font-size: 0.8rem;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 0.25rem 1rem;
}
.env-dev .topbar { top: 1.55rem; border-bottom: 2px solid var(--warn); }


/* ------------------------------------------------- Session 3: statements */
.upload-zone { text-align: center; border: 2px dashed var(--line); }
.upload-zone.dragging { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-elev)); }
.upload-zone input[type=file] { max-width: 22rem; margin: 0.5rem auto; }
.checks-list { list-style: none; padding: 0.75rem 1rem; }
.issue-ok { color: var(--pos); }
.stmt-lines td { font-size: 0.9rem; }


/* ------------------------------------------------- Session 5B: Parser Studio */
.studio-page .content { max-width: 1800px; }
.studio-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.studio-head-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.studio-version-bar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0.4rem 0 0.6rem;
  overflow-wrap: anywhere; }
.reparse-note { margin: 0.25rem 0 0.5rem; max-width: 40rem; }
.chip-active { outline: 2px solid var(--accent); }
.studio-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 1rem; align-items: start; }
.studio-canvas-panel { position: sticky; top: 4.5rem; }
.studio-canvas-bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.studio-canvas-bar select { max-width: 18rem; }
.studio-pager { display: inline-flex; align-items: center; gap: 0.25rem; }
.studio-overlay-toggle { font-size: 0.85rem; color: var(--fg-muted); }
.studio-canvas { position: relative; overflow: auto; max-height: calc(100vh - 12rem); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; touch-action: none; user-select: none; }
.studio-canvas img { display: block; width: 100%; height: auto; }
#st-boxes { position: absolute; inset: 0; pointer-events: none; }
.studio-word { position: absolute; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
#st-rubber { position: absolute; border: 1.5px dashed var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); pointer-events: none; }
/* S11B tags: one colour per role, on the canvas and in the list */
#st-tags { position: absolute; inset: 0; pointer-events: none; }
.studio-tag { position: absolute; border: 2px solid var(--tag-color, var(--accent));
  background: color-mix(in srgb, var(--tag-color, var(--accent)) 10%, transparent); }
.studio-tag-label { position: absolute; top: -1.3em; left: -2px; font-size: 0.72rem; white-space: nowrap; padding: 0 0.3em;
  background: var(--tag-color, var(--accent)); color: #fff; border-radius: 3px 3px 0 0; }
.role-details { --tag-color: #b5651d; }
.role-summary { --tag-color: #2f7d5b; }
.role-rates { --tag-color: #a0346e; }
.role-movements { --tag-color: #2f5f9e; }
.role-plan_table { --tag-color: #8a4fbf; }
.role-ignore { --tag-color: #8a8a8a; }
.chip.role-details, .chip.role-summary, .chip.role-rates, .chip.role-movements, .chip.role-plan_table, .chip.role-ignore { background: var(--tag-color); color: #fff; }
.studio-mode { display: inline-flex; gap: 0.6rem; margin-left: auto; }
/* S11I: suggested boxes, resize handles, the read panel */
.studio-tag.is-suggested { border-style: dashed; background: color-mix(in srgb, var(--tag-color, var(--accent)) 5%, transparent); }
.studio-tag.is-suggested .studio-tag-label { opacity: 0.85; }
.studio-tag-handle { position: absolute; pointer-events: auto; background: var(--tag-color, var(--accent)); opacity: 0.55; border-radius: 2px; }
.studio-tag-handle:hover { opacity: 1; }
.handle-n { top: -4px; left: 50%; width: 28px; height: 7px; margin-left: -14px; cursor: ns-resize; }
.handle-s { bottom: -4px; left: 50%; width: 28px; height: 7px; margin-left: -14px; cursor: ns-resize; }
.handle-w { left: -4px; top: 50%; width: 7px; height: 28px; margin-top: -14px; cursor: ew-resize; }
.handle-e { right: -4px; top: 50%; width: 7px; height: 28px; margin-top: -14px; cursor: ew-resize; }
.studio-tag-actions { display: inline-flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }
.studio-tag-item.is-suggested { opacity: 0.9; }
.studio-tag-item-actions { display: inline-flex; gap: 0.2rem; flex-wrap: wrap; margin-left: auto; }
.chip-suggested { border-style: dashed; }
.studio-read-out { margin-top: 0.6rem; display: grid; gap: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.studio-read-headline { font-weight: 600; margin: 0; }
.studio-read-headline.ok { color: var(--accent); }
.studio-read-lines { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.studio-read-lines td, .studio-read-lines th { padding: 0.15rem 0.35rem; border-top: 1px solid var(--line); }
.card.status.status-ok { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.read-headline { margin: 0 0 0.4rem; }
.still-open-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.still-open-item { padding-top: 0.6rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.still-open-item:first-child { border-top: 0; padding-top: 0; }
.still-open-item p { margin: 0 0 0.4rem; }
.still-open-form { flex-wrap: wrap; gap: 0.4rem; }
.still-open-form select { max-width: 100%; min-width: 0; }
.parser-filter { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: end; margin: 0 0 0.6rem; }
.parser-filter label { display: grid; gap: 0.15rem; font-size: 0.85rem; min-width: 0; flex: 1 1 10rem; max-width: 18rem; }
.parser-filter input, .parser-filter select { width: 100%; min-width: 0; }
.parser-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
#parser-table tr[data-status="retired"] td { opacity: 0.7; }
.studio-tag-form { margin: 0.5rem 0; }
.studio-tag-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.35rem; }
.studio-tag-item { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.studio-new-parser { margin-top: 0.4rem; }
.studio-propose-out { margin-top: 0.6rem; display: grid; gap: 0.5rem; }
.studio-equation { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.studio-equation.accepted p { font-weight: 600; }
.studio-columns { display: grid; gap: 0.25rem; }
.studio-column { display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; }
.studio-column select { width: auto; min-width: 8rem; }
.studio-proposal-wrap { margin-bottom: 0.6rem; border: 1px solid var(--accent); border-radius: var(--radius); padding: 0.4rem 0.6rem; }
.studio-proposal-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.85rem; }
.studio-coord { font-family: var(--mono); margin-left: 0.4rem; }
.studio-canvas img { -webkit-user-drag: none; }
.studio-proposal { margin-top: 0.5rem; padding: 0.6rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); font-size: 0.8rem; overflow: auto; max-height: 14rem; white-space: pre-wrap; }
.studio-inspector { display: flex; flex-direction: column; min-width: 0; }
.studio-editor-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; gap: 0.5rem; }
.studio-yaml { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 0.82rem; line-height: 1.35; tab-size: 2; resize: vertical; }
.studio-members { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.studio-members li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.35rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.studio-exclude-form { display: inline-flex; gap: 0.3rem; }
.studio-exclude-form input { max-width: 11rem; font-size: 0.82rem; }
.studio-result-table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.studio-result-table th, .studio-result-table td { text-align: left; padding: 0.3rem 0.4rem; border-top: 1px solid var(--line); vertical-align: top; }
.studio-diff { font-size: 0.8rem; overflow: auto; }
.studio-diff .diff-add { color: var(--pos); display: block; }
.studio-diff .diff-del { color: var(--neg); display: block; }
.studio-diff .diff-hunk { color: var(--fg-muted); display: block; }
.studio-phone-note { display: none; }
@media (max-width: 1023px) {
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
  .studio-canvas-panel, .studio-yaml, .studio-page .form-actions, .studio-editor-bar, .studio-member-actions { display: none; }
  .studio-phone-note { display: block; }
}
.studio-guide-list { margin: 0.5rem 0 0 1.1rem; padding: 0; display: grid; gap: 0.4rem; }
.studio-guide-list .btn { margin-left: 0.35rem; }


/* ------------------------------------------------- Session 6A: monthly close */
.close-period { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.close-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.close-fields { display: grid; gap: 0 0.9rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.close-field input { width: 100%; font-variant-numeric: tabular-nums; }
.close-field.has-error input { border-color: var(--err); }
.close-hint { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin-top: 0.2rem; }
.chip-src { font-size: 0.72rem; padding: 0.05rem 0.45rem; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.close-checks { display: grid; gap: 0.4rem; margin: 0.4rem 0 0.2rem; }
.close-check { display: flex; gap: 0.5rem; align-items: baseline; }
.close-actions { border-top: 1px solid var(--line); padding-top: 0.75rem; }
.close-verdict { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.4rem; }
.close-verdict.ok { color: var(--accent); }
.close-verdict.off { color: var(--err); }
.close-verdict.pending { color: var(--warn); }
.due-list { list-style: none; padding: 0; margin: 0; }
.due-list li { display: flex; justify-content: space-between; gap: 0.6rem; align-items: center; padding: 0.45rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.due-list li:first-child { border-top: 0; }
@media (max-width: 480px) { .close-fields { grid-template-columns: minmax(0, 1fr); } }
.close-pick { position: relative; }
.close-pick[open] .due-list { position: absolute; right: 0; z-index: 20; min-width: 16rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.3rem 0.8rem; box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
@media (max-width: 480px) { .close-pick[open] .due-list { position: static; } }
.line-sources { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end; }
.line-sources .inline-form { margin-top: 0; }
.lines-controls { display: grid; gap: 0.5rem; }
.lines-preview th select { min-width: 8.5rem; font-size: 0.82rem; }
.lines-preview td { font-size: 0.82rem; white-space: nowrap; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.lines-table td { vertical-align: middle; }
.lines-table .ln-date { width: 7.5rem; font-size: 0.85rem; }
.lines-table .ln-amount { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.lines-table .ln-desc { font-size: 0.88rem; min-width: 12rem; }
.lines-unverified { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.paste-box { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }


/* ------------------------------------------------- Session 7A: budgets */
.budget-strong dt, .budget-strong dd, li.budget-strong { font-weight: 700; }
.occ-list { list-style: none; padding: 0; margin: 0; }
.occ-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.3rem 0.75rem; align-items: center; padding: 0.45rem 0; border-top: 1px solid var(--line); }
.occ-list li:first-child { border-top: 0; }
.occ-proposals { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.85rem; }
.occ-proposals .inline-form, .occ-list .inline-form { margin-top: 0; }
.budget-lines td { vertical-align: top; }
.budget-lines .line-name { font-weight: 600; }
.budget-lines .bar { margin-top: 0.35rem; max-width: 16rem; }
.bar span.warn { background: var(--warn); }
.bar span.over { background: var(--err); }
.line-edit summary { cursor: pointer; color: var(--fg-muted); }
.line-edit .inline-form input[name=assigned] { max-width: 8rem; }
.add-line { border-top: 1px solid var(--line); padding-top: 0.75rem; }
.add-line select { max-width: 18rem; }
.add-line input { max-width: 8rem; }
.coverage { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.cov-lines { border-color: var(--accent); color: var(--accent); }
.cov-close_only { border-color: var(--warn); color: var(--warn); }
.cov-open { color: var(--fg-muted); }
.cov-none { color: var(--fg-muted); border-style: dashed; }
.schedule-picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; min-width: 0; }
.schedule-kinds { flex-wrap: wrap; border-radius: 12px; margin-bottom: 0.75rem; }
.seg-opt { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.88rem; cursor: pointer; }
.seg-opt input { width: auto; min-height: 0; margin: 0; }
@media (max-width: 480px) {
  .budget-lines th:nth-child(2), .budget-lines td:nth-child(2),
  .budget-lines th:nth-child(3), .budget-lines td:nth-child(3) { display: none; }
  .budget-lines { font-size: 0.85rem; }
  .budget-lines th, .budget-lines td { padding-left: 0.35rem; padding-right: 0.35rem; }
  .budget-lines .chip { font-size: 0.7rem; }
}
.trip-chip { display: inline-flex; gap: 0.4rem; align-items: center; padding: 0.35rem 0.8rem; margin-bottom: 0.8rem; border-color: var(--accent); }
.trip-chip input { width: auto; min-height: 0; margin: 0; }
.budget-card { display: block; text-decoration: none; color: inherit; }
.budget-card .section-title { display: block; margin: 0 0 0.5rem; }
.budget-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.6rem 1rem; }
.budget-card-grid > span { display: grid; gap: 0.1rem; }
.trip-banner { display: block; }


/* ------------------------------------------------- Session 8A: golden receipts */
.golden-work { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.golden-photo img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; border-radius: var(--radius); background: var(--bg-elev-2); }
.golden-exclude { grid-column: 1 / -1; }
.golden-progress .chip { margin-right: 0.3rem; }
@media (max-width: 767px) { .golden-work { grid-template-columns: minmax(0, 1fr); } }

/* Session 8B: receipts read from photos */
.chip-photo { font-size: 0.75rem; padding: 0 0.4rem; margin-left: 0.25rem; }
.inbox-read, .inbox-account { margin: 0.4rem 0; flex-wrap: wrap; }
.inbox-account select { max-width: 100%; min-width: 0; flex: 1 1 10rem; }
.inbox-queued { display: inline-block; margin: 0.4rem 0; }
.inbox-note { overflow-wrap: anywhere; }
.receipt-warn-line { display: block; font-size: 0.78rem; color: var(--warn); overflow-wrap: anywhere; }
.receipt-warn-line span { display: block; }
.receipt-reading h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.receipt-warnings { margin: 0 0 0.6rem; padding: 0.4rem 0.6rem; list-style: none; color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: 8px; overflow-wrap: anywhere; }
.receipt-items td:first-child { overflow-wrap: anywhere; }

/* Session 8C: receipt items */
.item-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.item-row { padding: 0.45rem 0; border-top: 1px solid var(--line); }
.item-main { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.item-name { flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }
.item-total { margin-left: auto; white-space: nowrap; }
.item-cat { margin-top: 0.25rem; flex-wrap: wrap; gap: 0.35rem; }
.item-cat select { flex: 1 1 12rem; min-width: 0; max-width: 100%; }
.receipt-lines .chip { margin: 0.1rem 0.15rem 0.1rem 0; }
.item-fix { margin-top: 0.3rem; }
.item-fix > summary { cursor: pointer; width: fit-content; }
.item-fix[open] { display: grid; gap: 0.5rem; }
.item-fix input { min-width: 0; width: 100%; box-sizing: border-box; }
.item-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
.item-add { margin-top: 0.75rem; }
.pick-list { display: grid; gap: 0.4rem; margin: 0; }
.pick-list label.check { align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.pick-account .inline-form { margin-top: 0.75rem; }
.card-numbers { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; gap: 0.35rem; }
.card-numbers li { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }

/* ================= Session 9: reports ================= */
.report-tabs { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0.2rem 0 0.5rem; scrollbar-width: thin; }
.report-tabs a { flex: 0 0 auto; text-decoration: none; padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--line); font-size: 0.85rem; }
.report-tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.report-filters { display: grid; gap: 0.5rem; margin-bottom: 0.6rem; }
.rf-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.rf-field { display: grid; gap: 0.15rem; font-size: 0.8rem; color: var(--fg-muted); min-width: 0; flex: 1 1 8.5rem; max-width: 14rem; }
.rf-field select, .rf-field input { width: 100%; min-width: 0; }
.rf-chips { gap: 0.35rem; }
.rf-chip { cursor: pointer; font-size: 0.8rem; display: inline-flex; gap: 0.3rem; align-items: center; }
.rf-chip input[type=checkbox] { margin: 0; width: auto; height: auto; min-height: 0; padding: 0; }
.rf-more summary { cursor: pointer; font-size: 0.85rem; color: var(--fg-muted); }
.completeness { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0 0 0.75rem; }
.cov { font-size: 0.78rem; text-decoration: none; }
.cov-lines { border-color: var(--pos); }
.cov-close_only, .cov-untracked { border-color: var(--warn); color: var(--warn); }
.cov-open, .cov-none { border-color: var(--neg); color: var(--neg); }
.chart-card { overflow: hidden; }
.report-total { margin: 0 0 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.report-total .amount { font-size: 1.35rem; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--fg-muted); font-size: 13px; font-family: var(--font); }
svg.chart .lbl { fill: var(--fg); }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { stroke: var(--fg-muted); stroke-width: 1; }
svg.chart .cbar.s1 { fill: var(--c1); } svg.chart .cbar.s2 { fill: var(--c2); } svg.chart .cbar.s3 { fill: var(--c3); }
svg.chart .cbar.s4 { fill: var(--c4); } svg.chart .cbar.s5 { fill: var(--c5); } svg.chart .cbar.s6 { fill: var(--c6); }
svg.chart .cbar.s7 { fill: var(--c7); } svg.chart .cbar.s8 { fill: var(--c8); }
svg.chart .cbar.untracked { fill: var(--warn); }
svg.chart .cbar.neg { opacity: 0.75; }
svg.chart a:hover .cbar, svg.chart a:focus .cbar { opacity: 0.8; }
svg.chart .ln { stroke-width: 2.2; }
svg.chart polyline.l1, .key.l1 { stroke: var(--c1); } svg.chart polyline.l2, .key.l2 { stroke: var(--c2); }
svg.chart polyline.l3, .key.l3 { stroke: var(--c3); } svg.chart polyline.l4, .key.l4 { stroke: var(--c4); }
svg.chart polyline.l5 { stroke: var(--c5); } svg.chart polyline.l6 { stroke: var(--c6); }
svg.chart polyline.l7 { stroke: var(--c7); } svg.chart polyline.l8 { stroke: var(--c8); }
svg.chart circle.pt { fill: var(--bg-elev); stroke-width: 2; }
svg.chart circle.l1 { stroke: var(--c1); } svg.chart circle.l2 { stroke: var(--c2); } svg.chart circle.l3 { stroke: var(--c3); }
svg.chart circle.l4 { stroke: var(--c4); } svg.chart circle.l5 { stroke: var(--c5); }
svg.spark { width: 120px; height: 28px; display: inline-block; vertical-align: middle; }
svg.spark polyline { stroke: var(--accent); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: center; }
.key { display: inline-block; width: 14px; height: 0; border-top: 3px solid var(--c1); vertical-align: middle; }
.key.s1 { border-color: var(--c1); height: 10px; border-top-width: 10px; } .key.s2 { border-color: var(--c2); height: 10px; border-top-width: 10px; }
.key.l1 { border-color: var(--c1); } .key.l2 { border-color: var(--c2); } .key.l3 { border-color: var(--c3); } .key.l4 { border-color: var(--c4); }
.key.l5 { border-color: var(--c5); }
.key.dashed { border-top-style: dashed; }
.chart-data { margin-top: 0.4rem; }
.chart-data summary { cursor: pointer; font-size: 0.85rem; color: var(--fg-muted); }
.report-table td, .report-table th { white-space: nowrap; }
.report-table td:first-child { white-space: normal; overflow-wrap: anywhere; }
.row-untracked td { color: var(--warn); }
.row-total td { font-weight: 600; border-top: 2px solid var(--line); }
.trend-cats { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.4rem; }
.trend-cat { flex: 1 1 12rem; min-width: 0; max-width: 100%; }
.report-foot { margin-top: 0.8rem; }
/* calendar */
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-head span { font-size: 0.72rem; color: var(--fg-muted); text-align: center; }
.cal-week { margin-top: 3px; }
.cal-day { display: flex; flex-direction: column; min-height: 3.6rem; padding: 3px 4px; border-radius: 6px; text-decoration: none;
  background: var(--bg-elev-2); border: 1px solid transparent; min-width: 0; overflow: hidden; }
.cal-day.out { opacity: 0.35; }
.cal-day.is-today { border-color: var(--focus); }
.cal-day.is-selected { border-color: var(--accent); }
.cal-day.heat-1 { background: color-mix(in srgb, var(--neg) 14%, var(--bg-elev-2)); }
.cal-day.heat-2 { background: color-mix(in srgb, var(--neg) 28%, var(--bg-elev-2)); }
.cal-day.heat-3 { background: color-mix(in srgb, var(--neg) 44%, var(--bg-elev-2)); }
.cal-day.heat-4 { background: color-mix(in srgb, var(--neg) 62%, var(--bg-elev-2)); }
.cal-n { font-size: 0.78rem; font-weight: 600; }
.cal-amt { font-size: 0.7rem; color: var(--fg); overflow: hidden; text-overflow: ellipsis; }
.cal-marks { display: flex; flex-wrap: wrap; gap: 2px; margin-top: auto; }
.mk { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c8); }
.mk-income { background: var(--pos); } .mk-fixed { background: var(--c2); } .mk-expense { background: var(--c3); }
.mk-msi { background: var(--c5); } .mk-card { background: var(--neg); } .mk-close { background: var(--warn); }
@media (max-width: 480px) {
  .hide-phone { display: none; }
  .cal-day { min-height: 2.9rem; padding: 2px; }
  .cal-amt { font-size: 0.62rem; }
}
.chart-box .chart-narrow { display: none; }
.chart-box .chart-wide svg.chart { max-width: 900px; }
@media (max-width: 600px) {
  .chart-box .chart-narrow { display: block; }
  .chart-box .chart-wide { display: none; }
}
/* Session 9B: Home dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.6rem; margin-bottom: 0.8rem; }
.dash-card { display: flex; flex-direction: column; gap: 0.25rem; text-decoration: none; min-width: 0; }
.dash-card .amount { font-size: 1.3rem; }
.dash-top { display: flex; flex-wrap: wrap; gap: 0.2rem 0.7rem; }
.dash-warn { border-color: var(--warn); }
.dash-upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.dash-upcoming li { display: flex; gap: 0.35rem; align-items: center; min-width: 0; overflow-wrap: anywhere; }
.dash-upcoming .amount { margin-left: auto; white-space: nowrap; }
.nw-spark { display: inline-block; margin-top: 0.2rem; }
.wallet-fx { white-space: normal; }
/* Session 10: people */
.person-actions form { margin-bottom: 0.5rem; flex-wrap: wrap; }
.person-actions input, .person-actions select { min-width: 0; max-width: 100%; }
.person-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.summary-box { width: 100%; margin-top: 0.5rem; font-family: var(--mono); font-size: 0.85rem; }
.stack-form { display: grid; gap: 0.5rem; }
.stack-form label { display: grid; gap: 0.15rem; font-size: 0.85rem; }
.plan-share { display: inline-block; vertical-align: top; }
.plan-share summary { list-style: none; cursor: pointer; }
.plan-share summary::-webkit-details-marker { display: none; }
.plan-share[open] .stack-form { width: min(16rem, 70vw); margin-top: 0.5rem; text-align: left; }
/* D112: the schedule fields show only for "a total, on their own schedule" (all fields stay without :has) */
.plan-share .share-sched { display: grid; gap: 0.35rem; }
.plan-share .share-sched label { display: grid; gap: 0.1rem; }
.plan-share form:has(select[name=share_kind] option[value=schedule]:checked) .share-per { display: none; }
.plan-share form:not(:has(select[name=share_kind] option[value=schedule]:checked)) .share-sched { display: none; }
.shared-plan-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem; align-items: baseline; margin-bottom: 0.5rem; }
.people-list .plan-line { display: block; }
.shared-plan-rows .nowrap { white-space: nowrap; }
.settle-choice { flex-wrap: wrap; gap: 0.3rem; }
.settle-choice select { max-width: 11rem; }
.paid-by summary { cursor: pointer; }
.paid-by form { flex-wrap: wrap; margin-top: 0.3rem; }
.mk-loan { background: var(--c7); }


/* ------------------------------------------------- Session 11P: the Paste Studio */
.paste-head-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.paste-new .field { margin-bottom: 0.8rem; }
.paste-top-row { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end; margin-bottom: 0.6rem; }
.paste-top-row label { display: inline-flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; }
.paste-top-row select, .paste-top-row input { min-width: 11rem; }
.paste-top .actions { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; margin-top: 0.6rem; }
.paste-part { margin-top: 0.9rem; }
.paste-part.is-verified { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.paste-part-head { display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem; align-items: center; margin-bottom: 0.6rem; }
.paste-part-head .paste-part-name { min-width: 12rem; font-weight: 600; }
.paste-part-actions { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.paste-fields { display: grid; gap: 0.2rem 0.9rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.paste-fields input { width: 100%; font-variant-numeric: tabular-nums; }
.paste-more summary, .paste-columns summary, .paste-override summary { cursor: pointer; }
.paste-more[open], .paste-columns[open] { margin-bottom: 0.6rem; }
.paste-unread .chip { margin: 0.1rem 0.2rem 0.1rem 0; }
.paste-rows td { padding: 0.15rem 0.3rem; }
.paste-rows .paste-desc { min-width: 18rem; width: 100%; }
.paste-rows .paste-inst { width: 4.2rem; text-align: center; }
.paste-rows .paste-card, .paste-part-head .paste-card { width: 4.8rem; text-align: center; }
.paste-rows .paste-kind { font-size: 0.8rem; max-width: 8rem; }
.paste-rows .ln-amount.is-credit { color: var(--pos); }
.paste-rows tr.row-added td { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.paste-row-actions { white-space: nowrap; }
.paste-row-actions .btn { padding: 0.1rem 0.45rem; }
.paste-table-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.4rem; }
.paste-checks { margin-top: 0.9rem; }
.paste-import { border-top: 1px solid var(--line); padding-top: 0.75rem; margin-top: 0.5rem; }
.paste-override { margin-top: 0.4rem; }
.paste-override textarea { margin: 0.3rem 0; }
.paste-phone-note { display: none; }
@media (max-width: 1023px) {
  /* D100: read-only on the phone — the values stay visible, nothing can be changed */
  .paste-page #paste-top, .paste-page #paste-body .paste-row-actions, .paste-page #paste-body .paste-part-actions,
  .paste-page #paste-body .paste-table-foot .btn, .paste-page .paste-import, .paste-page #paste-save { display: none; }
  .paste-page #paste-body form { pointer-events: none; }
  .paste-phone-note { display: block; }
}
.paste-rows .paste-fx { display: inline-flex; align-items: center; gap: 0.25rem; margin-top: 0.2rem; font-size: 0.75rem; color: var(--fg-muted); }
.paste-fx-clear { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 0.15rem; font-size: 0.9rem; line-height: 1; }
.paste-fx-clear:hover, .paste-fx-clear:focus-visible { color: var(--err); }


/* ------------------------------------------------- Session 11Q: the receipt beside the edit form */
.page-viewer .content { max-width: 1760px; }
.tx-split.has-viewer { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); gap: 1rem; align-items: start; }
.tx-split.has-viewer .txform { max-width: none; }
.rv { position: sticky; top: 4.6rem; display: flex; flex-direction: column; gap: 0.5rem; height: calc(100vh - 6rem); min-width: 0; padding: 0.6rem; }
.env-dev .rv { top: 6.2rem; height: calc(100vh - 7.6rem); }
.rv-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.rv-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.rv-tab { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 0.15rem 0.7rem; cursor: pointer; font: inherit; font-size: 0.85rem; }
.rv-tab[aria-selected="true"] { background: var(--bg-elev-2); border-color: var(--accent); }
.rv-tools { display: flex; gap: 0.2rem; align-items: center; margin-left: auto; }
.rv-panel { flex: 1; min-height: 0; display: flex; }
.rv-panel[hidden] { display: none; }
.rv-stage { flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); cursor: grab; }
.rv-stage.is-dragging { cursor: grabbing; user-select: none; }
.rv-canvas { position: relative; margin: 0 auto; }
.rv-img { position: absolute; max-width: none; user-select: none; }
.rv-frame { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
@media (max-width: 1023px) {
  /* a phone has no room for two columns: the receipt sits above the form, half a screen tall */
  .tx-split.has-viewer { grid-template-columns: minmax(0, 1fr); }
  .rv { position: static; order: -1; height: 55vh; }
}

/* ------------------------------------- review: the ticket and a quick category beside the list */
.review-split.has-viewer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 540px); gap: 1rem; align-items: start; }
.review-main { min-width: 0; }
.review-side { position: sticky; top: 4.6rem; display: flex; flex-direction: column; gap: 0.6rem; max-height: calc(100vh - 5.4rem); overflow: auto; min-width: 0; }
.env-dev .review-side { top: 6.2rem; max-height: calc(100vh - 7rem); }
.review-side[hidden] { display: none; }
.review-side .rv { position: static; height: 62vh; flex: none; }
.review-side-head { display: flex; align-items: center; gap: 0.5rem; }
.review-side-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-side-head .icon-btn { margin-left: auto; }
.review-cat-form { padding: 0.7rem; }
.newcat-box { margin: 0.3rem 0; }
.newcat-box summary { cursor: pointer; display: inline-block; }
.newcat { display: grid; gap: 0.5rem; margin: 0.4rem 0; }
@media (max-width: 1023px) {
  .review-split.has-viewer { grid-template-columns: minmax(0, 1fr); }
  .review-side { position: static; max-height: none; order: -1; overflow: visible; }
  .review-side .rv { height: 55vh; }
}

/* ------------------------------------------- S15: MSI table + payment calendar */
.msi-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; margin: 0 0 0.75rem; }
.msi-lbl { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); margin-right: 0.2rem; }
.msi-bar .chip { color: var(--fg); }
.msi-col { font: inherit; font-size: 0.85rem; cursor: pointer; background: var(--bg-elev-2); }
.msi-col[aria-pressed="false"] { background: transparent; color: var(--fg-muted); text-decoration: line-through; }
.msi-link { font: inherit; font-size: 0.85rem; cursor: pointer; background: none; border: 0; padding: 0.15rem 0.25rem; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msi-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.9rem; }
.msi-stat { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; min-width: 0; }
.msi-stat .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); }
.msi-stat .v { font-size: 1.1rem; font-weight: 650; margin-top: 0.1rem; overflow-wrap: anywhere; }
.msi-stat .s { font-size: 0.8rem; color: var(--fg-muted); }
@media (max-width: 767px) { .msi-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.msi-wrap { overflow: auto; max-height: 75vh; padding: 0; }
.msi-table { border-collapse: separate; border-spacing: 0; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.msi-table th, .msi-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-elev); text-align: left; }
.msi-table .num, .msi-table .m { text-align: right; }
.msi-table thead { position: sticky; top: 0; z-index: 3; }
.msi-table thead th { background: var(--bg-elev-2); font-size: 0.78rem; font-weight: 600; color: var(--fg-muted); vertical-align: bottom; }
.msi-table .msi-tot th { color: var(--fg); font-size: 0.85rem; border-bottom: 2px solid var(--line); text-transform: none; letter-spacing: normal; }
.msi-table tr[data-label] [data-col] { overflow: visible; text-overflow: clip; }
.msi-table tr[data-label] .c-card { z-index: 2; }
.msi-table .c-card { width: 8.5rem; min-width: 8.5rem; max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; }
.msi-table .c-buy { width: 13rem; min-width: 13rem; max-width: 13rem; overflow: hidden; text-overflow: ellipsis; }
.msi-table .c-buy a { text-decoration: none; }
.msi-table .c-buy a:hover { text-decoration: underline; }
.msi-table .c-end { border-right: 2px solid var(--line); }
.msi-table th.m { min-width: 6.4rem; }
.msi-table .now { background: var(--now-col); }
.msi-table thead th.now { background: color-mix(in srgb, var(--accent) 22%, var(--bg-elev-2)); color: var(--fg); }
.msi-table td.last { position: relative; }
.msi-table td.last::after { content: ""; position: absolute; top: 0.35rem; right: 0.2rem; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msi-table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--bg-elev)); }
.msi-table .msi-sub td { background: var(--bg-elev-2); font-weight: 600; }
.msi-yr { color: var(--accent); }
.msi-barcol { display: flex; align-items: flex-end; justify-content: flex-end; height: 30px; margin: 0.15rem 0 0.25rem; }
.msi-barcol i { display: block; width: 70%; background: var(--accent); border-radius: 3px 3px 0 0; opacity: 0.85; }
.msi-tag { display: inline-block; font-size: 0.72rem; padding: 0 0.4rem; border-radius: 999px; border: 1px solid var(--line); color: var(--fg-muted); }
.msi-fin { color: var(--accent); border-color: var(--accent); }
.msi-legend .msi-swatch { display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 3px; vertical-align: -2px; background: var(--now-col); border: 1px solid var(--line); }
.msi-legend .msi-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.msi-table.hide-card [data-col="card"], .msi-table.hide-buy [data-col="buy"], .msi-table.hide-orig [data-col="orig"],
.msi-table.hide-n [data-col="n"], .msi-table.hide-nth [data-col="nth"], .msi-table.hide-left [data-col="left"],
.msi-table.hide-left_amount [data-col="left_amount"] { display: none; }
@media (max-width: 767px) {
  /* a phone: narrow name columns; the purchase stays pinned while the months scroll under it */
  .msi-table .c-card { width: 5.5rem; min-width: 5.5rem; max-width: 5.5rem; }
  .msi-table .c-buy { width: 8.5rem; min-width: 8.5rem; max-width: 8.5rem; position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); }
  .msi-table thead .c-buy { z-index: 4; }
  .msi-table th.m { min-width: 5.6rem; }
  .msi-table th, .msi-table td { padding: 0.4rem 0.45rem; }
  .msi-table tr[data-label] [data-col] { white-space: normal; overflow: hidden; }
}
@media (min-width: 768px) {
  .msi-table .c-card { position: sticky; left: 0; z-index: 1; }
  .msi-table .c-buy { position: sticky; left: 8.5rem; z-index: 1; }
  .msi-table.no-card .c-buy { left: 0; }
  .msi-table thead .c-card, .msi-table thead .c-buy { z-index: 4; }
}

.pay-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; margin-bottom: 0.6rem; }
.pay-head h2 { margin: 0; }
.pay-progress { height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; margin-bottom: 0.9rem; }
.pay-progress i { display: block; height: 100%; background: var(--paid-line); }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.55rem; }
.pay {
  display: grid; grid-template-areas: "date" "name" "amt" "src" "act"; gap: 0.2rem; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.6rem 0.7rem; background: var(--bg-elev);
}
.pay-date { grid-area: date; display: flex; align-items: baseline; gap: 0.35rem; }
.pay-date b { font-size: 1.45rem; line-height: 1; font-variant-numeric: tabular-nums; }
.pay-date span { font-size: 0.75rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pay-name { grid-area: name; font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pay-amt { grid-area: amt; font-size: 1.05rem; font-variant-numeric: tabular-nums; min-width: 0; }
.pay-est-form { display: flex; align-items: center; gap: 0.25rem; margin: 0; }
.pay-est-form input { font: inherit; font-variant-numeric: tabular-nums; width: 100%; min-width: 0; padding: 0.1rem 0.25rem; background: transparent; color: var(--fg); border: 0; border-bottom: 1px dashed var(--fg-muted); border-radius: 0; }
.pay-est-form .pay-save { padding: 0.1rem 0.5rem; min-height: 28px; font-size: 0.75rem; }
.pay-src { grid-area: src; font-size: 0.75rem; color: var(--fg-muted); }
.pay-note { display: block; }
.pay-act { grid-area: act; display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; margin-top: 0.15rem; }
.pay-act form { margin: 0; }
.pay-act .btn { font-size: 0.75rem; min-height: 28px; padding: 0.1rem 0.6rem; }
.pay-state { font-size: 0.75rem; font-weight: 600; }
.pay.pay-est { background: var(--est-bg); border-color: var(--est-line); }
.pay.pay-soon { border-color: var(--warn); }
.pay-soon .pay-state { color: var(--warn); }
.pay.pay-late { border-color: var(--err); border-width: 2px; }
.pay-late .pay-state { color: var(--err); }
.pay.pay-paid { background: var(--paid-bg); border-color: var(--paid-line); }
.pay-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.6rem; }
.pay-sw { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 3px; border: 1px solid var(--line); background: var(--bg-elev); vertical-align: -2px; }
.pay-sw-est { background: var(--est-bg); border-color: var(--est-line); }
.pay-sw-paid { background: var(--paid-bg); border-color: var(--paid-line); }
.pay-sw-soon { border: 2px solid var(--warn); }
.pay-sw-late { border: 2px solid var(--err); }
.pay-settings summary { cursor: pointer; }
.pay-settings input[type=number] { max-width: 6rem; }
@media (max-width: 560px) {
  .pay-grid { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .pay { grid-template-columns: 3.2rem minmax(0, 1fr); grid-template-areas: "date name" "date amt" "date src" "date act"; align-items: center; column-gap: 0.6rem; }
  .pay-date { flex-direction: column; align-items: flex-start; gap: 0; align-self: start; }
  .pay-est-form input { width: 8rem; flex: 0 0 auto; }
  .pay-note { display: inline; }
  .pay-note::before { content: " · "; }
}

/* S15g: MSI plan selection (tick plans; every total counts the ticked ones) */
.msi-table .c-sel { width: 2.4rem; min-width: 2.4rem; max-width: 2.4rem; text-align: center; padding-left: 0.35rem; padding-right: 0.35rem; }
.msi-table:not(.js-sel) .c-sel { display: none; }
.msi-table .c-sel input, .msi-check input { width: 1.05rem; height: 1.05rem; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; flex: 0 0 auto; }
.msi-table tbody tr.unsel td:not(.c-sel) { opacity: 0.4; }
.msi-table tbody tr.unsel td.m { text-decoration: line-through; }
.msi-table.js-sel .c-sel { position: sticky; left: 0; z-index: 2; }
.msi-table.js-sel thead .c-sel { z-index: 5; }
@media (min-width: 768px) {
  .msi-table.js-sel .c-card { left: 2.4rem; }
  .msi-table.js-sel .c-buy { left: 10.9rem; }
  .msi-table.js-sel.no-card .c-buy { left: 2.4rem; }
}
@media (max-width: 767px) {
  .msi-table.js-sel .c-buy { left: 2.4rem; }
}
.msi-count b { font-variant-numeric: tabular-nums; }
.msi-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; cursor: pointer; }
.msi-sep { width: 1px; align-self: stretch; background: var(--line); }
.msi-sets { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.msi-set { display: inline-flex; align-items: center; gap: 0.2rem; }
.msi-set button { font: inherit; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; }
.msi-set .x { color: var(--fg-muted); padding-left: 0.15rem; }
.msi-set-form input { font: inherit; font-size: 0.85rem; padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); width: 9rem; }

/* ------------------------------------------------ swipe review (one draft at a time, built for the phone) */
.sw { max-width: 440px; margin: 0 auto; display: grid; gap: 0.7rem; min-width: 0; }
.sw [hidden] { display: none !important; }
.sw-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.sw-bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.sw-stack { position: relative; height: 430px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.sw-stack.single { height: 412px; }
.sw-card {
  position: absolute; inset: 0 0 auto 0; height: 410px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); padding: 1rem; display: grid;
  grid-template-rows: auto auto 1fr; gap: 0.6rem; transform-origin: 50% 90%; will-change: transform; overflow: hidden;
}
.sw-card.top { touch-action: none; cursor: grab; }
.sw-card.top.drag { cursor: grabbing; transition: none; }
.sw-card.l1 { transform: translateY(14px) scale(0.95); }
.sw-card.l2 { transform: translateY(26px) scale(0.9); opacity: 0.9; }
.sw-card:not(.top) > * { visibility: hidden; }
.sw-card.l1 .sw-peek { visibility: visible; display: flex; }
.sw-card.fly { transition: transform 0.25s ease-in, opacity 0.25s; }
.sw-card.back { transition: transform 0.2s ease-out; }
.sw-peek { display: none; position: absolute; left: 1rem; right: 1rem; bottom: 0.7rem; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; color: var(--fg-muted); }
.sw-peek b { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sw-peek .tag { font: 700 0.65rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); flex: none; }
.sw-row1 { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; }
.sw-date { font: 600 0.75rem var(--mono); color: var(--fg-muted); letter-spacing: 0.04em; }
.sw-payee { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; overflow-wrap: anywhere; }
.sw-amount { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.sw-amount.neg { color: var(--neg); }
.sw-amount.pos { color: var(--pos); }
.sw-body { display: grid; align-content: start; gap: 0.6rem; min-height: 0; overflow: hidden; }
.sw-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sw-chip { font-size: 0.82rem; padding: 0.2rem 0.65rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev-2); overflow-wrap: anywhere; max-width: 100%; }
.sw-chip.cat { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: transparent; }
.sw-chip.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); border-color: transparent; color: var(--warn); }
.sw-ticket { display: grid; grid-template-columns: 78px 1fr; gap: 0.7rem; align-items: center; background: var(--bg-elev-2); border: 1px dashed var(--line); border-radius: 12px; padding: 0.45rem; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none; }
.sw-ticket img { width: 78px; height: 96px; object-fit: cover; object-position: top; border-radius: 4px; background: #fff; }
.sw-ticket small { display: block; color: var(--fg-muted); font-size: 0.78rem; }
.sw-pdf { font-size: 2rem; text-align: center; }
.sw-noticket { margin: 0; }
.sw-stamp { position: absolute; top: 1rem; font: 800 1.2rem var(--font); letter-spacing: 0.08em; border: 3px solid; border-radius: 10px; padding: 0.1rem 0.6rem; opacity: 0; pointer-events: none; transform: rotate(-12deg); }
.sw-stamp.yes { left: 1rem; color: var(--accent); }
.sw-stamp.no { right: 1rem; color: var(--warn); transform: rotate(12deg); }
.sw-stamp.up { left: 50%; top: 0.7rem; color: var(--focus); transform: translateX(-50%); }
.sw-actions { display: grid; grid-template-columns: 48px 1fr 1fr 1fr; gap: 0.6rem; align-items: center; }
.sw-act { border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg); border-radius: 16px; min-height: 58px; font: 700 0.9rem var(--font); cursor: pointer; display: grid; place-items: center; padding: 0.3rem; }
.sw-act span { font-size: 1.25rem; line-height: 1; }
.sw-act small { font-size: 0.7rem; font-weight: 600; color: var(--fg-muted); }
.sw-act.sw-yes { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.sw-act.sw-yes small { color: var(--accent-fg); opacity: 0.85; }
.sw-act.sw-later { color: var(--warn); }
.sw-act.sw-edit { color: var(--focus); }
.sw-act.sw-undo { min-height: 48px; border-radius: 50%; padding: 0; }
.sw-act:disabled { opacity: 0.35; cursor: default; }
.sw-hint { text-align: center; margin: 0; }
.sw-next { display: grid; gap: 0.4rem; }
.sw-next h2 { font: 700 0.7rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--fg-muted); margin: 0.2rem 0 0; }
.sw-nrow { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.6rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.75rem; min-width: 0; }
.sw-nrow b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-nrow .a { font-variant-numeric: tabular-nums; font-weight: 600; }
.sw-nrow small { color: var(--fg-muted); grid-column: 1 / -1; }
.sw-nrow.first { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev)); }
.sw-toast { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; background: var(--fg); color: var(--bg); border-radius: 14px; padding: 0.7rem 0.9rem; font-size: 0.9rem; z-index: 6; }
.sw-toast button { background: none; border: 0; color: inherit; font: 700 0.9rem var(--font); text-decoration: underline; cursor: pointer; }
.sw-sheet { display: grid; gap: 0.6rem; padding: 0.9rem; }
.sw-sheet h3 { margin: 0; font-size: 1.05rem; }
.sw-sheet label { display: grid; gap: 0.2rem; font-size: 0.85rem; color: var(--fg-muted); }
.sw-sheet select, .sw-sheet input { font: inherit; padding: 0.5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev-2); color: var(--fg); min-width: 0; }
.sw-sheet-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.sw-lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.88); display: grid; grid-template-rows: auto 1fr; gap: 0.5rem; padding: 0.7rem; overflow: auto; }
.sw-lightbox img { max-width: 100%; margin: 0 auto; align-self: start; }
.sw-lightbox .btn { justify-self: end; }
#swipe-link { margin-left: auto; }
@media (prefers-reduced-motion: reduce) { .sw-card.fly, .sw-card.back, .sw-bar > i { transition: none; } }

/* product-03: the login page and the sign-out foot of More */
.login-page #login-form { max-width: 24rem; margin: 1.5rem auto 0; }
.login-page .page-head { max-width: 24rem; margin-left: auto; margin-right: auto; }
.form-error { margin: 0 0 0.5rem; padding: 0.5rem 0.75rem; border-radius: 0.5rem; color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); font-size: 0.9rem; }
.menu-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.75rem; padding: 0.75rem 1rem; }
