/* benseddiq.com: black theme.
   1. Settings (colours, sizes)   2. Page and top bar   3. Totals
   4. Bills table                 5. Buttons and boxes  6. Add a bill
   7. Phone layout */

/* ---------------------------------------------------------------- 1 */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("vendor/fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #050505;            /* the page */
  --surface: #0d0d0f;       /* cards */
  --surface-2: #131316;     /* table header, total row */
  --surface-3: #1b1b1f;     /* hover */
  --edge: rgba(255, 255, 255, 0.07);         /* card edges, table lines */
  --edge-strong: rgba(255, 255, 255, 0.14);  /* boxes you type in */
  --text: #d6d3d1;          /* all main text: "warm stone" (bright white #f4f4f5 until 2026-11-16) */
  --muted: #8b8b95;
  --faint: #4b4b53;         /* fees of 0 */
  --accent: #72b3a8;        /* muted teal: totals, buttons (bright mint #6ee7b7 until 2026-11-16) */
  --accent-rgb: 114, 179, 168;  /* the same colour as numbers, for see-through tints: rgba(var(--accent-rgb), 0.1) */
  --accent-soft: rgba(var(--accent-rgb), 0.14);
  --accent-ink: #071b18;    /* text on a teal button */
  --danger: #f87171;
  --row-h: 46px;            /* height of every table row, header included */
  --radius: 16px;
  --radius-sm: 10px;
  --width: 1240px;
  --gutter: 24px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

/* scrollbar-gutter: the scrollbar's strip is always kept free, so the page
   doesn't shift sideways when opening a card makes it long enough to
   scroll (or closing one makes it short again). */
html { color-scheme: dark; -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* a faint mint glow behind the top of the page */
  background-image: radial-gradient(1100px 480px at 50% -220px, rgba(var(--accent-rgb), 0.08), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(5, 5, 5, 0.72);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--edge);
}

.topbar-inner {
  max-width: var(--width);
  margin: 0 auto;
  padding: 12px max(var(--gutter), env(safe-area-inset-right)) 12px max(var(--gutter), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #a6d4cc, #5a9f93);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 18px rgba(90, 159, 147, 0.25);
}

.nav { display: flex; gap: 4px; }

.nav a {
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: color 0.15s, background-color 0.15s;
}

.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-3); }

/* phones: the logo without its name, and a tighter menu, so the three
   pages and the gear fit on one line */
@media (max-width: 480px) {
  .topbar-inner { gap: 12px; }
  .brand-name { display: none; }
  .nav { gap: 2px; }
  .nav a { padding: 6px 10px; }
}

.page {
  max-width: var(--width);
  margin: 0 auto;
  padding: 44px max(var(--gutter), env(safe-area-inset-right)) 80px max(var(--gutter), env(safe-area-inset-left));
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.lede { margin: 8px 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- 3 */
.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 30px 0 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
}

.stat-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

.stat-accent {
  background: linear-gradient(160deg, rgba(var(--accent-rgb), 0.15), rgba(var(--accent-rgb), 0.03) 70%);
  border-color: rgba(var(--accent-rgb), 0.25);
}

.stat-accent .stat-value { color: var(--accent); }

/* ---------------------------------------------------------------- 4 */
.card {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.bills {
  width: 100%;
  table-layout: fixed;   /* columns take exactly the widths below, in every table */
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

/* Tablets and small windows (wider than a phone, narrower than the table):
   the table keeps its columns and scrolls sideways inside its card, so Name
   never gets squeezed. Every table has the same smallest width, so their
   columns still line up. Phones use cards instead (section 7). */
/* (relative: hidden helpers such as the tick boxes stay inside the scroll
   area instead of widening the whole page) */
/* hidden for a moment while the page goes back to where you were (site.js) */
html.restoring body { visibility: hidden; }

.table-scroll { position: relative; overflow-x: auto; overscroll-behavior-x: contain; container-type: inline-size; }
@media (min-width: 641px) {
  .bills { min-width: 1190px; }   /* the card's width on a computer */
  /* the edit panel stays in view, as wide as the card, while the row scrolls */
  .table-scroll .edit-panel {
    position: sticky;
    left: 0;
    box-sizing: border-box;
    width: 100cqw;   /* the visible width of .table-scroll (a size container) */
  }
}

/* Every row, header and Total included, is --row-h tall (a row only grows
   if a long name wraps onto two lines). */
.bills th,
.bills td {
  height: var(--row-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--edge);
  text-align: left;
  vertical-align: middle;
}

.bills thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bills tbody tr { transition: background-color 0.12s; }
.bills tbody tr:not(.editing):not(.empty):not(.error-row):hover { background: rgba(255, 255, 255, 0.025); }

/* Money columns take only the room their numbers (or their two-line header)
   need; the Name column gets the rest. */
/* Fixed column widths (since 2026-11-16), the same in the Bills and the
   Subscriptions tables so their columns line up; Name takes the rest. */
.bills .num { width: 88px; text-align: right; white-space: nowrap; }
.bills thead th { line-height: 1.3; }
.bills .name { min-width: 230px; font-weight: 600; overflow-wrap: break-word; }
.bills th:first-child,
.bills td:first-child { padding-left: 20px; }
.bills .strong { font-weight: 700; }
.bills .zero { color: var(--faint); }
.bills .accent { color: var(--accent); }

.bills .actions { width: 112px; white-space: nowrap; text-align: right; padding-left: 8px; }

.row-buttons { display: inline-flex; align-items: center; gap: 4px; }

.bills tfoot th,
.bills tfoot td {
  border-bottom: 0;
  background: var(--surface-2);
  font-weight: 700;
}

.bills tfoot th { font-size: 15px; }

.bills .empty td {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

/* The row being edited is highlighted; its edit panel opens underneath. */
.bills tr.open td { background: rgba(var(--accent-rgb), 0.05); }

.bills tr.editing td {
  height: auto;
  padding: 0;
  background: rgba(var(--accent-rgb), 0.035);
}

.edit-panel { padding: 18px 20px 20px; }
.edit-title { margin: 0 0 14px; font-size: 15px; font-weight: 700; }

/* Paused and canceled bills: faded, since they are not in the totals. */
.bills tr.left-out .name-text,
.bills tr.left-out .num,
.bills tr.left-out .renew-flag { opacity: 0.45; }

.foot-note { color: var(--muted); font-size: 12px; font-weight: 500; text-align: right; white-space: nowrap; }

/* Service rows: everything in regular weight (names, amounts, payment,
   tags, status pills). The Total row stays bold; the edit panel keeps its
   own look. Since 2026-11-16. */
.bills tbody tr:not(.editing) td,
.bills tbody tr:not(.editing) td * { font-weight: 400; }
/* ------------------------------------------------- 4e. Sections */
/* Bills, Subscriptions and Supplements: one card each that folds away
   (<details>). The title bar (<summary>): a coloured "+" (section 6), the
   title, the monthly cost and a chevron on the right. */
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 20px;
  cursor: pointer;
  list-style: none;             /* no browser triangle */
  user-select: none;
  transition: background-color 0.15s;
}
.section-head::-webkit-details-marker { display: none; }
.section-head:hover { background: rgba(255, 255, 255, 0.02); }
.section-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.section-card[open] > .section-head { border-bottom: 1px solid var(--edge); }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .section-sum { margin-left: auto; }
.section-head .add-chevron { margin-left: 4px; }
.section-sum { white-space: nowrap; font-variant-numeric: tabular-nums; }
.section-sum-value { font-size: 18px; font-weight: 700; color: var(--text); }
.section-sum-unit { color: var(--muted); font-size: 13px; }

.stat-value small { color: var(--muted); font-size: 13px; font-weight: 500; }

/* A card showing a "What if I cancel" figure: dashed teal edge, the figure
   in teal, and the real figure struck through underneath. */
.stat.whatif-on { border-style: dashed; border-color: rgba(var(--accent-rgb), 0.45); }
.stat.whatif-on .stat-num { color: var(--accent); }
.stat-was { color: var(--muted); font-size: 12px; text-decoration: line-through; font-variant-numeric: tabular-nums; }
/* the Subscriptions header and Total row while boxes are ticked */
.whatif-num { color: var(--accent); }
.bills tfoot .whatif-num { text-decoration: underline dashed rgba(var(--accent-rgb), 0.5); text-underline-offset: 4px; cursor: help; }
.section-sum .stat-was { margin-left: 8px; }

/* "What if I cancel": the last column, headed by a scissors icon, with a
   tick box on each Active or Trial subscription (both shown only with
   JavaScript); the struck-through row, and the line with the savings. */
.bills .cut-cell { width: 40px; padding-left: 4px; padding-right: 14px; text-align: center; }
.cut-head { display: none; justify-content: center; color: var(--muted); }
.js .cut-head { display: inline-flex; }
.cut-head svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cut { display: none; flex: none; position: relative; cursor: pointer; vertical-align: middle; }
.js .cut { display: inline-flex; }
.cut input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.cut-mark {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--faint);
  border-radius: 5px;
  transition: border-color 0.15s, background-color 0.15s;
}
.cut:hover .cut-mark { border-color: var(--muted); }
.cut input:checked + .cut-mark {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23071b18' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / 11px;
}
.cut input:focus-visible + .cut-mark { outline: 2px solid var(--accent); outline-offset: 2px; }
.bills tr.cutting .name-text,
.bills tr.cutting .num { text-decoration: line-through; text-decoration-color: rgba(var(--accent-rgb), 0.6); opacity: 0.6; }

.whatif {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--edge);
  background: rgba(var(--accent-rgb), 0.03);
  transition: background-color 0.15s;
}
.whatif[hidden],
.whatif-clear[hidden] { display: none; }  /* Clear shows only once something is ticked */
.whatif.active { background: rgba(var(--accent-rgb), 0.08); }
.whatif-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.whatif-text { flex: 1; margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.whatif-text strong { color: var(--accent); font-weight: 700; }

/* Type in the form: Bill | Subscription, a two-way switch */
.bill-form .f-kind { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: block;
  padding: 6px 16px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.seg span:hover { color: var(--text); }
.seg input:checked + span { background: rgba(var(--accent-rgb), 0.16); color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-hint { color: var(--faint); font-size: 12px; }

/* ------------------------------------------------- 4f. Supplements */

/* Supplements columns: Pharmacy and Doctor (names, grey; 150px until
   2026-11-18, narrowed to give Name more room; a long name ends in "…" and
   shows in full on hover), Duration */
.supps .where {
  width: 112px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.supps .where .none { color: var(--faint); }
.supps .duration { width: 84px; }

/* the supplement form: Name · Prescription · Pharmacy, then the two costs,
   months and the three live costs, then Payment · Notes · button */
.bill-form .f-rx,
.bill-form .f-ph,
.supp-form .f-snotes { grid-column: span 2; }
.bill-form .f-rx,
.bill-form .f-ph { position: relative; }

/* the Add card's Bill | Subscription | Supplement switch (JavaScript only;
   without it both forms show, each with its own title) */
.add-switch { display: none; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 16px; }
.js .add-switch { display: flex; }
.js .add-pane .f-kind { display: none; }  /* the switch above sets the type */
.add-pane[hidden] { display: none; }
.pane-title { margin: 22px 0 12px; font-size: 15px; font-weight: 700; }
.js .pane-title { display: none; }

/* ------------------------------------------------- 4d. Info (notes) */
.bills .info { width: 44px; padding-left: 6px; padding-right: 6px; text-align: center; white-space: nowrap; }
.info-btn { color: var(--faint); }
.info-btn.has-notes { color: var(--accent); }
.info-btn[aria-expanded="true"] { color: var(--text); background: var(--surface-3); }

/* the small window with a bill's notes (placed by site.js) */
.note-pop {
  position: fixed;
  z-index: 50;
  width: min(320px, calc(100vw - 24px));
  padding: 10px 12px 14px 14px;
  background: var(--surface-2);
  border: 1px solid var(--edge-strong);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  text-align: left;
  white-space: normal;
}
.note-pop[hidden] { display: none; }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.note-pop .note-title { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.note-close { width: 28px; height: 28px; min-width: 28px; }
.note-body {
  max-height: 240px;
  margin-bottom: 12px;
  overflow-y: auto;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;        /* keep the line breaks as typed */
  overflow-wrap: anywhere;
}
.note-body.empty { color: var(--faint); }
.note-pop .btn { font-weight: 600; }
/* a week's window on Tracking: its notes in a box, and Save */
.note-form { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; margin: 0; }
.note-form .notes-input { width: 100%; min-height: 96px; }

/* the Notes box in the form */
.notes-input {
  height: auto;
  min-height: 42px;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}

/* ------------------------------------------------- 4c. Status, auto-renew */
.bills .status-cell { width: 108px; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.bills .renew { width: 56px; padding-left: 8px; padding-right: 8px; white-space: nowrap; text-align: center; }

/* Payment method: quiet grey text; "—" when not set. "Payment · " is only
   shown on a phone, where there's no header. */
.bills .payment { width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; font-weight: 500; }
.bills .payment .none { color: var(--faint); }
.pay-word { display: none; }
.bills tr.left-out .payment { opacity: 0.45; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 2px 10px 2px 9px;
  border: 1px solid var(--st-edge);
  border-radius: 999px;
  background: var(--st-bg);
  color: var(--st);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.status::before {           /* the coloured dot */
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-active   { --st: var(--accent); --st-bg: rgba(var(--accent-rgb), 0.10); --st-edge: rgba(var(--accent-rgb), 0.28); }
/* Trial: fuchsia (blue until 2026-11-16; blue now marks temporary payments) */
.status-trial    { --st: #f0abfc; --st-bg: rgba(240, 171, 252, 0.10); --st-edge: rgba(240, 171, 252, 0.28); }
/* Finished: a temporary payment after its last month (worked out from Ends) */
.status-finished { --st: var(--muted); --st-bg: rgba(255, 255, 255, 0.04); --st-edge: rgba(255, 255, 255, 0.12); }
.status-paused   { --st: #fcd34d; --st-bg: rgba(252, 211, 77, 0.10);  --st-edge: rgba(252, 211, 77, 0.28); }
.status-canceled { --st: #fca5a5; --st-bg: rgba(248, 113, 113, 0.10); --st-edge: rgba(248, 113, 113, 0.30); }

/* Auto-renew in the table: an icon on a computer (the words stay for
   screen readers), the words "Auto-renew On" on a phone. */
.renew-flag { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; vertical-align: middle; }
.renew-flag.on { color: var(--accent); }
.renew-flag.off { color: var(--faint); }
.renew-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.renew-text {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

form.inline { display: inline; margin: 0; }

/* "Paid through": a small tag with the service's name; "Direct" faded. */
.tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.08);
  color: #a6d4cc;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* In the bills table the tag sits in the name cell, pushed to the right
   (margin-left: auto); the name, and in Subscriptions the "what if" tick
   box before it, stay on the left. */
.name-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-width: 0;
}
.name-line .name-text { min-width: 0; }
.name-line .tag { flex: none; max-width: 50%; margin-left: auto; }
.name-line .tag + .tag { margin-left: 0; }  /* two tags: together on the right */
.via-word { font-weight: 500; opacity: 0.75; } /* "via" a little lighter than the name */

/* Temporary payment (Ends set): a light blue tag, an hourglass and "until
   Mar 2027"; "ended Mar 2027" in grey once finished. */
.tag-ends {
  gap: 5px;
  border-color: rgba(147, 197, 253, 0.26);
  background: rgba(147, 197, 253, 0.09);
  color: #93c5fd;
}
.bills tr.left-out .tag-ends { border-color: var(--edge); background: none; color: var(--faint); }
/* a paused supplement: an amber "Paused" tag (the Paused pill's colours) */
.tag-paused {
  border-color: rgba(252, 211, 77, 0.28);
  background: rgba(252, 211, 77, 0.10);
  color: #fcd34d;
}
.bills tr.left-out .where { opacity: 0.45; }
.tag-icon {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* in a section's title bar: "$45.00 / mo ends by Mar 2027" */
.section-ending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: #93c5fd;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.section-ending + .section-sum { margin-left: 14px; }
.label-soft { color: var(--faint); font-weight: 400; }

.hint { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- 5 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, background-color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--edge-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn:hover { color: var(--text); background: var(--surface-3); }
.icon-btn.danger:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

.icon-btn .confirm-text { display: none; }
.icon-btn.armed { padding: 0 12px; color: var(--danger); background: rgba(248, 113, 113, 0.14); }
.icon-btn.armed svg { display: none; }
.icon-btn.armed .confirm-text { display: inline; }

.btn:focus-visible,
.icon-btn:focus-visible,
.nav a:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field::placeholder { color: var(--faint); }
.field:hover { border-color: rgba(255, 255, 255, 0.22); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
.num-input { text-align: right; font-variant-numeric: tabular-nums; }

/* Dropdown (Status): the browser's own arrow replaced by a thin chevron. */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px;
  cursor: pointer;
}
.select option { background: var(--surface-2); color: var(--text); }

/* "Paid through" suggestions (site.js): a chevron in the box, and the
   list of names already in use dropping down underneath. */
.bill-form .f-via,
.bill-form .f-pay { position: relative; }
.field.has-suggest {
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px;
}
.suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  margin-top: 6px;
  padding: 4px;
  max-height: 232px;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.suggest[hidden] { display: none; }
/* a list opened inside a table's edit panel floats above the page (site.js) */
.suggest.floating { position: fixed; right: auto; margin-top: 0; z-index: 60; }
.suggest-item {
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.suggest-item:hover,
.suggest-item.active { background: var(--surface-3); color: var(--accent); }

/* Status dropdown (site.js): the box shows the chosen status as its pill;
   the list shows all four, with a tick beside the chosen one. */
.bill-form .f-status { position: relative; }
.pick-button { display: flex; align-items: center; text-align: left; cursor: pointer; }
.pick-button:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }
.pick-item { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; }
/* Paid through / Payment lists: the box's current name also gets the tick */
.suggest-item.chosen { display: flex; align-items: center; justify-content: space-between; }
.suggest-item.chosen::after,
.pick-item[aria-selected="true"]::after {
  content: "";
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2372b3a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / contain;
}
.pick-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0; pointer-events: none;
}

/* Switch (Auto-renew): a real checkbox, drawn as a sliding switch with
   "On" / "Off" beside it. Sits in a box the same height as the others. */
.bill-form label.switch,
.switch {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.switch-track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--edge-strong);
  transition: background-color 0.15s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background-color 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); box-shadow: none; }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: var(--accent-ink); }
.switch-state::before { content: "Off"; color: var(--muted); font-size: 14px; font-weight: 600; }
.switch input:checked ~ .switch-state::before { content: "On"; color: var(--text); }
.switch:has(input:focus-visible) { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18); }

.errors {
  list-style: none;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-sm);
  color: #fecaca;
  font-size: 14px;
}

/* ---------------------------------------------------------------- 6 */
/* Add a bill folds away (<details>): the title bar opens and closes it. */
.add-card { overflow: visible; }

.add-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;            /* no browser triangle */
  user-select: none;
  transition: background-color 0.15s;
}
.add-summary::-webkit-details-marker { display: none; }
.add-summary:hover { background: rgba(255, 255, 255, 0.02); }
.add-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.add-card[open] .add-summary { border-radius: var(--radius) var(--radius) 0 0; }

.add-summary h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* the "+" on the left of a foldable card turns into a "×" when open. Its
   colour: teal for Add, amber for Bills, blue for Subscriptions, violet for
   Supplements (--plus, and --plus-bg behind it). */
.add-plus {
  --plus: var(--accent);
  --plus-bg: var(--accent-soft);
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--plus-bg);
  transition: transform 0.2s;
}
.add-plus.plus-bill         { --plus: #fcd34d; --plus-bg: rgba(252, 211, 77, 0.14); }
.add-plus.plus-subscription { --plus: #93c5fd; --plus-bg: rgba(147, 197, 253, 0.14); }
.add-plus.plus-supplement   { --plus: #c4b5fd; --plus-bg: rgba(196, 181, 253, 0.14); }
.add-plus::before,
.add-plus::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  border-radius: 1px;
  background: var(--plus);
}
.add-plus::after { transform: rotate(90deg); }
details[open] > summary .add-plus { transform: rotate(45deg); }

/* the chevron on the right points up when open */
.add-chevron {
  width: 18px;
  height: 18px;
  margin-left: auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}
details[open] > summary .add-chevron { transform: rotate(180deg); }

.add-body { padding: 4px 24px 24px; }

/* The bill form (Add a bill, and the edit panel under a row), in rows:
     Name (2) · Paid through (2) · Payment (2)
     Status · Auto-renew · Monthly fee · Annual fee · Monthly cost · Weekly cost
     buttons (2, on the right)                                           */
.bill-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.bill-form label,
.bill-form .f-renew,
.bill-form .preview { display: flex; flex-direction: column; min-width: 0; }
.bill-form .f-name,
.bill-form .f-via,
.bill-form .f-pay { grid-column: span 2; }
.bill-form .f-card-bill { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.f-card-bill .label { margin-bottom: 0; }
.card-bill-flag { display: inline-flex; flex: none; color: var(--accent); }
.card-bill-flag svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.available-tile small { color: var(--muted); font-size: 11px; line-height: 1.5; }
.available-pop .available-breakdown { display: flex; flex-direction: column; gap: 10px; }
.available-pop small, .available-pop p { font-size: 12px; line-height: 1.6; color: var(--muted); }
.available-pop p { margin: 0; }
.fsa-setting .fsa-covered { display: none; flex: 0 1 180px; }
.fsa-setting:has(input[name="fsa_funded"]:checked) .fsa-covered { display: flex; }
.fsa-setting .seg-hint { flex: 1 1 260px; }
.fsa-covered .label { margin-bottom: 6px; }
.f-buttons { grid-column: 5 / 7; display: flex; gap: 10px; }
.bill-form .f-notes { grid-column: 1 / 5; }
/* third row of the bill form: Ends · Notes (3) · buttons (2) */
.bill-form .f-ends + .f-notes { grid-column: 2 / 5; }
/* supplement form, third row: Status · Payment · Notes (2) · buttons (2) */
.supp-form .f-pay { grid-column: span 1; }
.bill-form input[type="month"] { color-scheme: dark; }
.f-buttons .btn { flex: 1; }

.label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.preview-value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------- 6b. Login, log out */
.logout {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 0 auto;
}

.who { color: var(--muted); font-size: 13px; font-weight: 600; }
/* the gear at the top right (Settings); highlighted while you're there */
.settings-link[aria-current="page"] { color: var(--text); background: var(--surface-3); }

/* ------------------------------------------------- 6c. Settings page */
/* Four name lists (Paid through, Payment, Doctor, Pharmacy) and Account,
   two cards a row on a computer, one on a phone. */
.settings-grid,
.flash:first-of-type { margin-top: 26px; }
.flash + .settings-grid { margin-top: 0; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.settings-grid .card { margin-bottom: 0; }
/* each column is its own stack, 20px between cards, so cards never leave
   holes beside each other and folding one only moves the ones below it */
.settings-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.list-count { color: var(--muted); font-size: 13px; font-weight: 500; }
.list-hint-body { margin: 0; padding: 12px 20px 4px; }
.list-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--edge); }
.list-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.list-hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.list-hint strong { color: var(--text); font-weight: 600; }
.choice-list { list-style: none; margin: 0; padding: 6px 0; }
.choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 14px;
}
.choice-rename { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; margin: 0; }
/* the name looks like plain text until you point at it or click into it */
.choice-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  font-size: 14px;
}
.choice-input:hover { border-color: var(--edge); }
.choice-input:focus { border-color: var(--accent); background: var(--surface-2); }
/* the tick (save) shows only while the name is being changed */
/* (opacity, not hidden, so a click on it still counts as focus moves away) */
.choice-save { opacity: 0; color: var(--accent); transition: opacity 0.15s; }
.choice-rename:focus-within .choice-save,
.choice-save:focus-visible { opacity: 1; }
.choice-uses { flex: none; min-width: 64px; color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.choice-uses.unused { color: var(--faint); }
.choice-empty { padding: 10px 22px; color: var(--faint); font-size: 14px; }
.choice-add { display: flex; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--edge); margin: 0; }
.choice-add .field { flex: 1; min-width: 0; height: 36px; font-size: 14px; }
.choice-add .btn { flex: none; height: 36px; }
.account-actions { padding: 16px 20px 20px; margin: 0; }


/* the message after adding, renaming or deleting */
.flash {
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.flash-ok { color: #a6d4cc; background: rgba(var(--accent-rgb), 0.08); border: 1px solid rgba(var(--accent-rgb), 0.25); }
.flash-error { color: #fecaca; background: rgba(248, 113, 113, 0.08); border: 1px solid rgba(248, 113, 113, 0.25); }

@media (max-width: 760px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------- 6d. Tracking page */
/* The weeks table: Friday, Income, Weekly Cost, Available (teal), Cash,
   Minimums, Extra paid and the buttons. Fixed column widths (the <colgroup> in
   tracking.html) spread them evenly across the card; month names are
   divider rows. On narrow screens it scrolls sideways inside its card. */
.track-card { margin-top: 26px; overflow: hidden; }
/* Safe to Spend (purchases since 2026-11-22): what's left (big) and the
   Week box on top; under them the spent bar, "+ Purchase" or its form, and
   the week's purchases (folds). On phones everything stacks. */
.safe-spend-card { margin-top: 26px; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 18px; }
.safe-spend-card > :not(.safe-spend-main):not(.safe-spend-week) { grid-column: 1 / -1; }
.safe-spend-card + .track-card { margin-top: 0; }
.safe-spend-card h2 { margin: 0 0 8px; font-size: 16px; }
.safe-spend-value { display: block; color: var(--accent); font-size: 32px; font-variant-numeric: tabular-nums; }
.safe-spend-value.short { color: var(--danger); }
.safe-spend-of { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.safe-spend-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.safe-spend-week { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; max-width: 100%; }
.spend-bar { height: 6px; margin-top: 14px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.spend-bar[hidden] { display: none; }
.spend-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.spend-bar.over span { background: var(--danger); }
.spend-actions { margin-top: 14px; }
.spend-actions[hidden], .purchase-form[hidden] { display: none; }
.spend-add { height: 42px; gap: 6px; padding: 0 18px; }
.spend-add svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.purchase-form {
  margin-top: 14px; padding: 14px; border: 1px solid var(--edge-strong); border-radius: var(--radius-sm);
  display: grid; grid-template-columns: 140px minmax(0, 1fr) 170px auto; gap: 10px 12px; align-items: end;
}
.purchase-form h3 { grid-column: 1 / -1; margin: 0; font-size: 14px; }
.purchase-form label { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; }
.purchase-form .field { min-width: 0; }
.purchase-form .pf-amount .field { text-align: right; font-variant-numeric: tabular-nums; }
.pf-buttons { display: flex; gap: 8px; }
.pf-buttons .btn { height: 42px; }
.purchase-error { grid-column: 1 / -1; margin: 0 !important; color: var(--danger) !important; font-size: 13px !important; }
.spend-list { margin-top: 14px; border-top: 1px solid var(--edge); }
.spend-list[hidden] { display: none; }
.spend-list summary { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; font-size: 14px; }
.spend-list summary::-webkit-details-marker { display: none; }
.spend-list summary small { color: var(--muted); font-size: 12px; }
.spend-list summary b { margin-left: auto; font-variant-numeric: tabular-nums; }
.spend-chevron { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; transition: transform .2s ease; }
.spend-list[open] .spend-chevron { transform: rotate(180deg); }
.spend-list ul { list-style: none; margin: 0; padding: 0; }
.spend-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; min-height: 46px; border-top: 1px solid var(--edge); font-size: 14px; }
.spend-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.spend-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spend-what.blank { color: var(--faint); }
.spend-amount { font-variant-numeric: tabular-nums; text-align: right; }
.spend-row .row-buttons { display: inline-flex; gap: 2px; }
.spend-empty { padding: 12px 0 4px; border-top: 1px solid var(--edge); color: var(--muted); font-size: 13px; }
@media (max-width: 640px) {
  .safe-spend-card { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
  .safe-spend-week .field { width: 100%; }
  .spend-add { width: 100%; height: 48px; font-size: 15px; }
  .purchase-form { grid-template-columns: minmax(0, 4fr) minmax(0, 6fr); }
  .purchase-form .pf-date .field { padding: 0 8px; }
  .purchase-form .pf-what { grid-column: 1 / -1; order: 3; }
  .purchase-form .pf-buttons { grid-column: 1 / -1; order: 4; }
  .purchase-form .purchase-error { order: 5; }
  .pf-buttons .btn { flex: 1; height: 46px; }
  /* 16px stops iPhones from zooming in on the box */
  .purchase-form .field { font-size: 16px; height: 46px; }
  .spend-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "what amount buttons" "date amount buttons"; row-gap: 0; padding: 6px 0; }
  .spend-row .spend-what { grid-area: what; }
  .spend-row .spend-date { grid-area: date; }
  .spend-row .spend-amount { grid-area: amount; }
  .spend-row .row-buttons { grid-area: buttons; }
}
.safe-spend-inline { display: flex; justify-content: space-between; gap: 8px; }
.safe-spend-inline b { color: var(--accent); font-variant-numeric: tabular-nums; }
.safe-spend-inline b.short { color: var(--danger); }
.flash + .track-card { margin-top: 0; }
.track {
  width: 100%;
  min-width: 900px;
  table-layout: fixed;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.track col.c-day { width: 13%; }
.track col.c-money { width: 11.66%; }
.track col.c-info { width: 6%; }
.track col.c-actions { width: 11%; }
.track .t-info { padding-left: 4px; padding-right: 4px; text-align: center; }
.track th,
.track td {
  height: var(--row-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--edge);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.track th:first-child,
.track td:first-child { padding-left: 20px; }
.track th:last-child,
.track td:last-child { padding-right: 16px; }
.track thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.track .num { text-align: right; }
.track .zero { color: var(--faint); }
.track .none { color: var(--faint); }
.track .t-year { color: var(--faint); font-weight: 500; }
/* the month's name: a slim divider row above its weeks ("Next paycheck"
   above the row that adds one) */
.track tr.month-row th {
  height: 30px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 1px solid var(--edge-strong);
}
.track tr.month-row .t-year { letter-spacing: 0; }
.track tr.next-label th { color: var(--muted); }
.track tbody tr.month-row:hover th { background: rgba(255, 255, 255, 0.025); }
.track .t-day { color: var(--muted); }
.track .t-day .cell-input { width: 100%; max-width: 150px; }
/* the amount boxes sit at the right of their column, as wide as a number */
.track .num .cell-input { display: block; width: 100%; max-width: 130px; margin-left: auto; }
.track .t-available { color: var(--accent); font-weight: 700; }
.track .t-available.short { color: var(--danger); }
.track .t-actions { text-align: right; }
.track .t-actions .row-buttons { justify-content: flex-end; }
.track tbody tr:not(.empty):hover td { background: rgba(255, 255, 255, 0.02); }
.track tr.empty td { padding: 36px 16px; color: var(--muted); text-align: center; white-space: normal; }
.track tfoot tr { background: var(--surface-2); }
.track .plan { color: var(--muted); }
.track .t-cost { font-weight: 600; }
.track [data-week-paid] { color: var(--accent); }
.track .t-income .cell-input[readonly] { pointer-events: none; }
.track tr.week-edit-open .t-income .cell-input:not([aria-invalid="true"]) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.08); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.16); }
.track .t-actions:has(.armed) [data-week-edit] { display: none; }
/* The row owns its inputs, while Save and Cancel stay in the open panel. */
.track .row-save { display: none; }
/* "Delete?" (after the first click on the bin) is wider than the bin: the
   Update button steps aside meanwhile, so it fits the column without a
   scrollbar */
.track .t-actions { padding-left: 6px; }
.track .t-actions:has(.armed) .row-tools:not(:has(.armed)) { display: none; }
.track tr.dirty td { background: rgba(var(--accent-rgb), 0.05); }
.track tr[hidden] { display: none; }
/* the "Add week" button, alone on its row until clicked */
.track .add-open td { height: 52px; padding-left: 16px; }
.add-week-btn { display: inline-flex; align-items: center; gap: 6px; }
.add-week-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.track tfoot .t-available.plan { color: var(--accent); }

/* The card payments editor sits inside the week being added or edited. */
.track .week-panel td { height: auto; padding: 0 20px 18px; white-space: normal; background: rgba(var(--accent-rgb), 0.035); }
/* The motion wrapper includes this gap when the existing week's editor slides. */
.track .week-panel:not(.week-panel-new) td { padding-top: 18px; }
.track .week-panel:hover td { background: rgba(var(--accent-rgb), 0.035); }
.week-panel-body { border: 1px solid var(--edge); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.week-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px 0; }
.week-panel-head h3 { margin: 0; font-size: 16px; }
.week-panel-body > .list-hint { padding: 4px 18px 0; margin: 0; }
.week-panel-body a { color: var(--accent); }
.payment-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--edge); }
.payment-flow > div { display: flex; flex-direction: column; gap: 5px; padding: 13px 15px; border: 1px solid var(--edge); border-radius: var(--radius-sm); background: var(--surface-2); }
.payment-flow span { color: var(--muted); font-size: 12px; }
.payment-flow strong { color: var(--text); font-size: 20px; font-variant-numeric: tabular-nums; }
.payment-flow .payment-saved { border-color: rgba(var(--accent-rgb), 0.35); background: rgba(var(--accent-rgb), 0.07); }
.payment-flow .payment-saved strong { color: var(--accent); }
.payment-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; padding: 16px 18px; }
.payment-entry { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--text); font-size: 13px; }
.payment-entry span { overflow-wrap: anywhere; }
.payment-entry small { color: var(--muted); font-size: 11px; }
.payment-entry .field { width: 100%; text-align: right; }
.payment-empty { margin: 0; color: var(--muted); font-size: 13px; }
.week-panel-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--edge); }
@media (max-width: 860px) {
  .payment-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payment-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .payment-flow { grid-template-columns: 1fr; }
  .payment-fields { grid-template-columns: 1fr; }
}

/* a value you can change in place: looks like text until pointed at */
.cell-form { margin: 0; }
.cell-input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}
.cell-input.num-input { text-align: right; }
.cell-input:hover { border-color: var(--edge); }
.cell-input:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.track tfoot .cell-input { border-color: var(--edge); background: var(--bg); }
/* Weekly Checks uses the shared collapsible section header. */
.track-card > .section-head .paid-off { margin-left: auto; }
.paid-off { color: var(--muted); font-size: 13.5px; }
.paid-off strong { margin-left: 6px; color: var(--accent); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.track-hint { margin: 0; padding: 12px 20px 14px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--edge); }

/* ------------------------------------------------- 6e. Tools page */
/* Each tool is a folding card (called the Rent page until 2026-11-21).
   Rent: Rent, Xfinity, PG&E, then three tiles (Total, Roommate's half in
   teal, Check to landlord), then the Check and Envelope blocks. */
.tool-card { margin-top: 26px; }
.tool-card .list-count { font-weight: 500; }
.tool-block {
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.tool-block h3 { margin: 0; padding: 14px 20px 0; font-size: 15px; font-weight: 700; }
.rent-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
  padding: 20px 20px 4px;
}
.rent-form label { display: flex; flex-direction: column; min-width: 0; }
.rent-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px 20px;
}
.split-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.split-tile.accent { border-color: rgba(var(--accent-rgb), 0.35); background: rgba(var(--accent-rgb), 0.07); }
.split-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.split-tile.accent .split-value { color: var(--accent); }

/* under it: what to write on the check and the envelope */
.rent-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 20px 20px;
  align-items: start;
}
.rent-notes .card { margin-bottom: 0; }
.write-down { margin: 0; padding: 14px 20px 18px; }
.write-down > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--edge); }
.write-down > div:last-child { border-bottom: 0; }
.write-down dt { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.write-down dd { margin: 0; color: var(--text); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.envelope { display: flex; flex-direction: column; gap: 4px; font-style: normal; color: var(--text); font-size: 17px; font-weight: 600; line-height: 1.45; }

@media (max-width: 640px) {
  .rent-form, .rent-split, .rent-notes { grid-template-columns: minmax(0, 1fr); }
}
/* House Payments and Notes stack independently of the taller Buffers card. */
.track-side {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto 1fr;
  gap: 20px;
  align-items: start;
}
.track-side .card { margin-bottom: 0; }
.track-side > [aria-labelledby="buffers-title"] { grid-column: 2; grid-row: 1 / span 2; }
.track-side > [aria-labelledby="notes-title"] { grid-column: 1; grid-row: 2; }
.buffer-list { list-style: none; margin: 0; padding: 8px 0; }
.buffer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  padding: 6px 12px 6px 14px;
}
.buffer-form { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; }
.buffer-name { flex: 1; font-weight: 600; }
.buffer-field { display: flex; align-items: center; gap: 4px; flex: none; }
.buffer-field span { color: var(--faint); font-size: 12px; }
.buffer-field .cell-input { width: 96px; }
.buffer-form:focus-within .choice-save { opacity: 1; }
.buffer-goal { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 2px 8px 4px; }
.goal-bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.goal-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.goal-text { flex: none; color: var(--muted); font-size: 12.5px; }
.buffer-add .buffer-amount { flex: 0 0 110px; text-align: right; }
.notes-form { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; padding: 14px 20px 18px; margin: 0; }
.notes-form .notes-input { width: 100%; min-height: 120px; }

@media (max-width: 860px) {
  .track-side { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .track-side > [aria-labelledby="buffers-title"],
  .track-side > [aria-labelledby="notes-title"] { grid-column: auto; grid-row: auto; }
}
@media (max-width: 640px) {
  .buffer-form { flex-wrap: wrap; }
  .buffer-name { flex-basis: 100%; }
}

.auth {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 190px);
}

.auth-card {
  width: min(400px, 100%);
  padding: 34px 30px 30px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.auth-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  border-radius: 12px;
  font-size: 22px;
}

.auth-card h1 { font-size: 26px; }
.auth-card .lede { margin-bottom: 22px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; }
.auth-form .btn { width: 100%; margin-top: 6px; }

/* ---------------------------------------------------------------- 7 */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }  /* six cards: three rows of two */
  .bill-form { grid-template-columns: 1fr 1fr; }
  .f-buttons { grid-column: 1 / -1; }
  .bill-form .f-notes,
  .bill-form .f-ends + .f-notes { grid-column: 1 / -1; }
}

/* Phones: each bill becomes a small card: name and buttons on top, the
   three amounts in a row underneath, each with its own label. */
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .page { padding-top: 28px; }
  .topbar-inner { gap: 18px; }
  .who { display: none; }
  .auth { min-height: 0; padding-top: 12px; }
  .auth-card { padding: 28px 20px 22px; }
  .stats { gap: 10px; margin-top: 22px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 20px; }
  .field { font-size: 16px; } /* 16px stops iPhones zooming into the box */
  .add-summary { padding: 14px 16px; }
  .add-body { padding: 4px 16px 18px; }
  .bill-form .f-name,
  .bill-form .f-via,
  .bill-form .f-pay,
  .bill-form .f-rx,
  .bill-form .f-ph,
  .supp-form .f-snotes { grid-column: 1 / -1; }
  .edit-panel { padding: 16px; }

  .bills thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }

  .bills tbody tr,
  .bills tfoot tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 12px;
    row-gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--edge);
  }

  .bills tfoot tr { background: var(--surface-2); border-bottom: 0; }

  .bills th,
  .bills td,
  .bills tfoot th,
  .bills tfoot td,
  .bills tr.editing td {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
    background: none;
  }

  .bills th:first-child,
  .bills td:first-child { padding-left: 0; }

  .bills .name,
  .bills tfoot th { grid-column: 1 / 4; grid-row: 1; align-self: center; font-size: 16px; }

  .bills .actions { grid-column: 4; grid-row: 1; width: auto; padding: 0; }

  /* the notes icon sits on the top line, just left of edit and delete */
  .bills tbody .name { grid-column: 1 / 3; min-width: 0; } /* (230px is for computers) */
  /* the "via" tag goes on its own line under the name, so the name keeps
     the whole width */
  .bills .name-line { flex-wrap: wrap; row-gap: 5px; }
  .bills .name-line .name-text { flex: 1 1 0; min-width: 0; }
  .bills .name-line .tag { flex-basis: auto; max-width: 100%; margin-left: 0; order: 3; }
  /* a section's "… ends by …" goes on its own line under the title */
  .section-head { flex-wrap: wrap; row-gap: 6px; }
  .section-ending { order: 5; flex-basis: 100%; margin-left: 38px; }
  .section-ending + .section-sum { margin-left: auto; }
  .bills .name-line::after { content: ""; order: 2; flex-basis: 100%; height: 0; }

  /* "What if I cancel" on a phone: bottom-right of the card, with words */
  .bills .cut-cell { grid-row: 4; grid-column: 3 / 5; width: auto; padding: 0; text-align: right; }
  .bills tbody .cut-cell:empty { display: none; }
  .bills .status-cell,
  .bills .renew { padding: 0; } /* (the 8px is for computers) */

  /* Supplements on a phone: Pharmacy and Prescription on the third line,
     each with a small label; the empty Total cells are left out. */
  .supps .where { grid-row: 3; width: auto; white-space: normal; overflow-wrap: anywhere; }
  .supps td.where:nth-child(2) { grid-column: 1 / 3; }
  .supps td.where:nth-child(3) { grid-column: 3 / 5; text-align: right; }
  .supps td.where::before { content: attr(data-short) " · "; color: var(--faint); }
  .supps tfoot .where,
  .supps tfoot .duration { display: none; }

  /* Bills (no fee columns): Cost / mo and Cost / wk share the line */
  .no-fees .true-cost { grid-column: 1 / 3; }
  .no-fees .weekly { grid-column: 3 / 5; }
  .bills.no-fees .payment { grid-column: 1 / -1; }  /* no "what if" box beside it */
  .bills.supps .cut::before { content: "What if I stop"; }
  .bills .cut { align-items: center; gap: 8px; }
  .bills .cut::before { content: "What if I cancel"; order: -1; color: var(--faint); font-size: 12px; }
  .bills .info { grid-column: 3; grid-row: 1; width: auto; padding: 0; text-align: right; align-self: start; }

  /* Four amounts in a row: Monthly, Annual, True / mo, Weekly. */
  .bills .num { grid-row: 2; width: auto; text-align: left; white-space: nowrap; font-size: 14px; }
  .bills .weekly { text-align: right; }

  .bills .num::before {
    content: attr(data-short);
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  /* the tiny labels on a service card: medium, not bold */
  .bills tbody tr:not(.editing) .num::before { font-weight: 500; }

  .bills tfoot .foot-note { grid-row: 3; grid-column: 1 / -1; text-align: left; white-space: normal; }
  .bills tfoot .foot-note:empty { display: none; }

  /* Third line of each card: status on the left, auto-renew on the right. */
  .bills .status-cell { grid-row: 3; grid-column: 1 / 3; width: auto; }
  .bills .renew { grid-row: 3; grid-column: 3 / 5; width: auto; text-align: right; align-self: center; }
  /* Fourth line: "Payment · Chase Credit" (left out when not set). */
  .bills .payment { grid-row: 4; grid-column: 1 / 3; width: auto; white-space: normal; }
  .bills tbody .payment:has(.none) { display: none; }
  .pay-word { display: inline; color: var(--faint); }

  .renew-icon { display: none; }
  .renew-text { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; }
  .renew-flag.on .renew-text { color: var(--text); }
  .renew-word { margin-right: 5px; color: var(--muted); font-weight: 500; }

  .bills tr.open { background: rgba(var(--accent-rgb), 0.05); }
  .bills tr.editing { display: block; padding: 0; background: rgba(var(--accent-rgb), 0.035); }

  .bills tr.empty,
  .bills tr.error-row { display: block; }
  .bills tr.empty td { padding: 44px 16px; }
  .bills tr.error-row { padding: 14px 16px 0; background: rgba(var(--accent-rgb), 0.035); }
}

/* Review is independent of the amount: a checked bank can have a zero payment. */
.payment-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--payment-rows), auto); grid-auto-flow: column; }
.payment-entry { flex-direction: row; align-items: center; padding: 8px; border: 1px solid var(--edge); border-radius: var(--radius-sm); }
.payment-entry .field { width: 130px; flex-shrink: 0; }
.payment-check { flex: 1; display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; color: var(--text); font: inherit; cursor: pointer; padding: 4px; }
.payment-check small { display: block; }
.review-mark { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border: 1px solid var(--edge); border-radius: 50%; color: transparent; }
.payment-check[aria-pressed="true"] .review-mark { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.payment-check:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.track .t-saved { color: var(--accent); font-weight: 700; }
.track .t-saved.short, .payment-flow strong.short { color: var(--danger); }
@media (max-width: 800px) { .payment-fields { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; } }

/* A new week is entered as a complete form, with Income in the summary. */
.new-week-head { padding-bottom: 8px; }
.week-date { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.week-date .field { width: auto; color-scheme: dark; }
.new-week-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.new-week-summary > div { min-height: 100px; justify-content: center; }
.new-week-summary label { color: var(--muted); font-size: 12px; }
.new-week-summary strong { font-size: 26px; }
.income-tile:focus-within { border-color: var(--accent); }
.income-tile input { width: 100%; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.income-tile input::placeholder { color: var(--faint); }
.track .week-panel-new td { padding-top: 18px; }
@media (max-width: 640px) {
  .new-week-head { align-items: flex-start; flex-direction: column; }
  .new-week-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Invalid week amounts stay visible until corrected. */
.track input[aria-invalid="true"] { border: 1px solid var(--danger); box-shadow: 0 0 0 2px rgba(239, 68, 68, .16); color: var(--danger); }
.week-panel-new .income-tile:has([aria-invalid="true"]) { border-color: var(--danger); }
.week-field-error { color: var(--danger); padding: 12px 18px 0; margin: 0; font-size: 13px; }

.weekly-cost-label, .available-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weekly-cost-label .icon-btn, .available-label .available-info-icon { width: 28px; height: 28px; color: var(--accent); }
.weekly-cost-tile [data-refresh-error] { color: var(--danger); font-size: 12px; }
.edit-week-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .edit-week-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Independent house payments: half-width beside Buffers. */
.house-table-wrap { overflow-x: auto; }
.house-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.house-table th, .house-table td { height: var(--row-h); padding: 0 8px; border-bottom: 1px solid var(--edge); text-align: left; vertical-align: middle; }
.house-table th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.house-table th:first-child, .house-table td:first-child { padding-left: 18px; }
.house-table .house-number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.house-year { color: var(--muted); font-weight: 600; }
.house-table .house-actions { white-space: nowrap; width: 80px; padding-right: 12px; }
.house-actions .icon-btn { width: 32px; height: 32px; }
.house-table .house-info { width: 36px; padding-left: 4px; padding-right: 4px; text-align: center; }
.house-empty { padding: 18px; color: var(--muted); font-size: 13px; }
.house-editor { border-top: 1px solid var(--edge); }
.house-editor > summary { padding: 15px 18px; cursor: pointer; color: var(--accent); font-size: 13px; }
.house-form { padding: 0 18px 18px; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.house-form label { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
.house-form .field { width: 100%; }
.house-form .house-wide { grid-column: 1 / -1; }
.house-form .house-form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.house-form [aria-invalid="true"] { border-color: var(--danger); color: var(--danger); }
.house-error { color: var(--danger); font-size: 12px; margin: 0; }

/* House Payments positions chosen in the temporary layout editor.
   Anchors are percentages of the row width, including the cell contents. */
.house-table { display: block; width: 100%; min-width: 520px; }
.house-table thead, .house-table tbody { display: block; width: 100%; }
.house-table tr { display: block; position: relative; height: var(--row-h); border-bottom: 1px solid var(--edge); }
.house-table thead tr { background: var(--surface-2); }
.house-table th, .house-table td { display: flex; align-items: center; position: absolute; top: 0; height: 100%; width: max-content; padding: 0; border: 0; white-space: nowrap; }
.house-table th:first-child, .house-table td:first-child { padding: 0; }
.house-table th:nth-child(1), .house-table td:nth-child(1) { left: 4.8%; }
.house-table th:nth-child(2), .house-table td:nth-child(2) { left: 14.9%; }
.house-table th:nth-child(3), .house-table td:nth-child(3) { left: 45%; transform: translateX(-100%); }
.house-table th:nth-child(4), .house-table td:nth-child(4) { left: 65.7%; transform: translateX(-100%); }
.house-table .house-info { left: 77%; width: max-content; padding: 0; transform: translateX(-50%); }
.house-table th:last-child, .house-table .house-actions { left: 95.7%; width: max-content; padding: 0; transform: translateX(-100%); }
.house-table .house-actions { gap: 4px; }
.house-table .house-actions:has(.armed) > a { display: none; }
.house-count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tracking-request-error { margin: 12px 18px; color: var(--danger); font-size: 13px; }
/* Alternate month groups; undated continuation rows inherit their month. */
.house-table tbody .house-band-0 { background: var(--surface); }
.house-table tbody .house-band-1 { background: var(--surface-2); }

@media (max-width: 640px) {
  .track-card > .section-head { flex-wrap: wrap; }
  .track-card > .section-head .paid-off { order: 4; width: 100%; margin-left: 42px; font-size: 12px; }
  .track-card > .section-head .add-chevron { margin-left: auto; }
}

/* ------------------------------------------------- 6f. Cards page */
/* (since 2026-11-21) Credit cards sorted by APR, debit cards, Add a card.
   The tables reuse the bills table's look (rows, header, Total, edit panel,
   phone cards); only the columns differ. */
.add-plus.plus-credit { --plus: #fca5a5; --plus-bg: rgba(248, 113, 113, 0.14); }
.add-plus.plus-debit  { --plus: #93c5fd; --plus-bg: rgba(147, 197, 253, 0.14); }

/* Columns: 6px on each side of every cell. Lock, Info and the buttons in
   both tables keep these widths; the Credit cards widths are set below. */
.cards-table th,
.cards-table td { padding-left: 6px; padding-right: 6px; }
.cards-table .num { width: auto; }
.cards-table .c-lock { width: 48px; text-align: center; white-space: nowrap; }
.cards-table .info { width: 44px; }
.cards-table .actions { width: 80px; padding-right: 14px; }

/* Credit cards column widths, chosen with the column tuner on 2026-11-22
   (they add up to 1190px, the card's width on a computer). The tags
   ([12% to Jan 30], [Line]) sit 16px from the right edge of Name. To add a
   column, add a width here and take it from the others. */
@media (min-width: 641px) {
  .cards-table:not(.debit-table) thead th:nth-child(1)  { width: 382px; }  /* Name */
  .cards-table:not(.debit-table) thead th:nth-child(2)  { width: 90px; }   /* Balance */
  .cards-table:not(.debit-table) thead th:nth-child(3)  { width: 84px; }   /* Limit */
  .cards-table:not(.debit-table) thead th:nth-child(4)  { width: 74px; }   /* Used */
  .cards-table:not(.debit-table) thead th:nth-child(5)  { width: 74px; }   /* APR */
  .cards-table:not(.debit-table) thead th:nth-child(6)  { width: 79px; }   /* Monthly Interest */
  .cards-table:not(.debit-table) thead th:nth-child(7)  { width: 67px; }   /* Due */
  .cards-table:not(.debit-table) thead th:nth-child(8)  { width: 65px; }   /* Auto Pay */
  .cards-table:not(.debit-table) thead th:nth-child(9)  { width: 85px; }   /* Updated */
  .cards-table:not(.debit-table) thead th:nth-child(10) { width: 50px; }   /* Lock */
  .cards-table:not(.debit-table) thead th:nth-child(11) { width: 47px; }   /* Info */
  .cards-table:not(.debit-table) thead th:nth-child(12) { width: 93px; }   /* buttons */
  .cards-table:not(.debit-table) tbody td.name { padding-right: 16px; }
}

/* the highest APR you owe on (the card to pay off first), light red */
.apr-top { color: #fca5a5; }
/* Auto pay: a check mark, green when on, red when off */
.autopay { display: inline-grid; place-items: center; vertical-align: middle; }
.autopay svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.autopay.on { color: #86efac; }
.autopay.off { color: #fca5a5; }
/* the name never wraps; if a window is too narrow, the tags shrink first
   (ending in "…"), then the name (full name on mouse-over) */
@media (min-width: 641px) {
  /* every column but Name centred, titles and figures alike (2026-11-22) */
  .cards-table th:not(:first-child),
  .cards-table td:not(:first-child) { text-align: center; }
  .cards-table .name-line { flex-wrap: nowrap; }
  .cards-table .name-line .name-text { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cards-table .name-line .tag { flex: 0 10 auto; min-width: 0; max-width: none; }
}
.cards-table .none,
.stat .none { color: var(--faint); }
@media (min-width: 641px) {
  .bills.debit-table { min-width: 0; }   /* four columns: no need to scroll */
}
/* the last 4 digits: right after the name (pulled 6px into the 12px gap);
   on a phone they go to the second line, with the tags (section 7 below) */
.last4 { flex: none; margin-left: -6px; color: var(--muted); font-size: 12.5px; letter-spacing: 0.04em; white-space: nowrap; }
.cards-table tr.left-out .last4 { opacity: 0.45; }

/* the top card you owe on: a teal edge on its left */
.tag-line { border-color: rgba(196, 181, 253, 0.26); background: rgba(196, 181, 253, 0.09); color: #c4b5fd; }
.tag-promo { border-color: rgba(147, 197, 253, 0.26); background: rgba(147, 197, 253, 0.09); color: #93c5fd; }
.tag-promo-soon { border-color: rgba(252, 211, 77, 0.28); background: rgba(252, 211, 77, 0.10); color: #fcd34d; }

/* Used: teal up to 30%, amber to 50%, red above */
.used-ok { color: var(--accent); }
.used-mid { color: #fcd34d; }
.used-high { color: #fca5a5; }
.cards-table .interest { color: #fca5a5; }
.due-soon { color: #fcd34d; }
.stale { color: #fcd34d; }
/* (td only: the Updated header keeps the same size as the others) */
.cards-table td.c-upd { font-size: 13px; color: var(--muted); }
.cards-table .c-upd .stale { color: #fcd34d; }

/* Lock: just an icon (since 2026-11-22). Unlocked: a blue open padlock;
   Locked: a yellow closed one. A click switches it. */
.lock-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #93c5fd;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 0.15s, color 0.15s;
}
.lock-btn:hover { background: rgba(147, 197, 253, 0.12); color: #bfdbfe; }
.lock-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lock-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lock-btn.is-locked { color: #fcd34d; }
.lock-btn.is-locked:hover { background: rgba(252, 211, 77, 0.12); color: #fde68a; }

/* five tiles in a row on a computer (Minimums removed 2026-11-22); two
   per row on smaller screens, the last one the full width */
@media (min-width: 861px) {
  .stats.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .stats.stats-5 > .stat:last-child { grid-column: 1 / -1; }
}

/* the tiles: Pay first shows a name, with the rate and balance under it
   (a long name ends in "…" instead of widening the tile and the page) */
.stats > .stat { min-width: 0; }
.stat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; }
.stat-sub { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-first { border-color: rgba(var(--accent-rgb), 0.25); }
.stat-first .stat-name { color: var(--accent); }

/* the card form: Type, then Name (3) · Last 4 · Locked · Due day, then
   Balance · Limit · APR · Promo APR · Promo ends · Interest, then Notes and
   the buttons. A debit card hides the money boxes. */
.bill-form .f-lock { display: flex; flex-direction: column; min-width: 0; }
.card-form .f-name { grid-column: span 2; }   /* Name · Last 4 · Locked · Auto pay · Due day */
@media (max-width: 860px) {
  .card-form .f-name { grid-column: 1 / -1; }   /* the form has two columns here */
}
.card-form[data-kind="debit"] .credit-only { display: none; }
.card-form input[type="date"] { color-scheme: dark; }

@media (max-width: 640px) {
  /* Phone cards: name, lock, notes and buttons on top (the lock and the
     notes icon share the third column); Balance, Used, APR and Interest on
     the second line; Limit, Due and Updated on the third. */
  .cards-table th,
  .cards-table td,
  .cards-table .actions { padding: 0; }
  .cards-table .c-limit,
  .cards-table .c-due,
  .cards-table .c-auto,
  .cards-table .c-upd { grid-row: 3; }
  .cards-table .num,
  .cards-table .c-upd { width: auto; text-align: left; }
  .cards-table tbody .c-lock { grid-row: 1; grid-column: 3; justify-self: start; align-self: start; width: auto; }
  .cards-table tbody .info { justify-self: end; }
  .cards-table .lock-btn { width: 28px; height: 28px; margin: -2px 0 0 -4px; }
  /* Credit cards: the name takes the top line up to edit/delete (one line
     for names like "American Express Credit"); the third line is Limit,
     Due, Auto pay and Updated; lock and notes sit at the right of a fourth. */
  .cards-table:not(.debit-table) tbody .name { grid-column: 1 / 4; }
  .cards-table:not(.debit-table) tbody .c-lock { grid-row: 4; grid-column: 4; align-self: center; }
  .cards-table:not(.debit-table) tbody .info { grid-row: 4; grid-column: 4; align-self: center; }
  .cards-table:not(.debit-table) .lock-btn { margin: 0 0 0 -4px; }
  /* a long label ("Monthly interest") wraps onto two lines; the figures
     sit at the bottom of their cells, so they stay level with each other */
  .cards-table .num::before { white-space: normal; }
  .cards-table .num { align-self: end; }
  /* the last 4 digits start the second line, before the tags */
  .cards-table .name-line .last4 { order: 3; margin-left: 0; line-height: 1.6; }
  .cards-table tfoot .c-blank { display: none; }
  .cards-table tfoot .foot-note { grid-row: 4; }
  .cards-table td.c-upd { font-size: 14px; }
}

/* Small phones (since 2026-11-21, when Cards made four pages): a tighter
   menu so the logo, the four pages and the gear fit on one line at 360px;
   the Credit cards bar shows the amount without "owed". */
@media (max-width: 480px) {
  .topbar-inner { gap: 10px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 6px; font-size: 13.5px; }
  .owed-unit { display: none; }
  .card-form .seg span { padding: 6px 10px; white-space: nowrap; }
}
