/* Two themes: dark (the default) and light, which a person picks with the header's switch (app.js keeps it in a
   "theme" cookie and the server draws the page in it: base.html). Colors live here; the rest of the file uses the
   tokens. Signature pads and previews stay white in both: they show the signature as it prints on paper. */
:root {
  color-scheme: dark;
  --ink: #e6e9ed; --muted: #9aa4b0; --line: #2d343d; --bg: #0f1216; --card: #171b21; --field: #11151a; --code-bg: #11151a;
  --brand: #8ab4f0; --brand-bg: #1b2e4b; --brand-ink: #ffffff; --primary-ink: #0f1216;
  --ok: #6fd48a; --warn: #e8bf4a; --bad: #f58f86;
  --ok-bg: rgba(111,212,138,0.14); --warn-bg: rgba(232,191,74,0.14); --bad-bg: rgba(245,143,134,0.14);
  --info-bg: rgba(138,180,240,0.14); --info-ink: var(--brand); --select-bg: rgba(138,180,240,0.12);
  --chip-bg: #252b33; --hover-bg: #252b33; --cleared-bg: rgba(138,180,240,0.14);
  --row-bad-bg: rgba(245,143,134,0.14); --row-warn-bg: rgba(232,191,74,0.14);
  --attention-line: #e8bf4a; --attention-bg: rgba(232,191,74,0.14);
  --banner-bg: rgba(232,191,74,0.14); --banner-ink: #e8bf4a;
  --scrim: rgba(0,0,0,0.6); --shadow: rgba(0,0,0,0.5);
}
:root[data-theme="light"] {
  color-scheme: light;
  --ink: #1b1f24; --muted: #5c6670; --line: #d9dee3; --bg: #f5f6f8; --card: #ffffff; --field: #ffffff; --code-bg: #f5f6f8;
  --brand: #1f3a5f; --brand-bg: #1f3a5f; --brand-ink: #ffffff; --primary-ink: #ffffff;
  --ok: #1e7d3c; --warn: #9a6700; --bad: #b3261e;
  --ok-bg: #e3f6e8; --warn-bg: #fff3cd; --bad-bg: #fde8e6;
  --info-bg: #e8f0fe; --info-ink: var(--ink); --select-bg: #eef3fb;
  --chip-bg: #eceff2; --hover-bg: #eef1f4; --cleared-bg: #e6eef8;
  --row-bad-bg: #fff5f4; --row-warn-bg: #fffaea;
  --attention-line: #e0b400; --attention-bg: #fffdf3;
  --banner-bg: #fff3cd; --banner-ink: #664d03;
  --scrim: rgba(15,18,22,0.45); --shadow: rgba(0,0,0,0.2);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 1000px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; margin: 0 0 12px; overflow-wrap: anywhere; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92rem; }
pre { background: var(--code-bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; }

.viewing-as { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; padding: 8px 16px; background: var(--banner-bg); color: var(--banner-ink); border-bottom: 2px solid var(--line); }
.view-as { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; }
.devbanner { background: var(--banner-bg); color: var(--banner-ink); border-bottom: 1px solid var(--line); text-align: center; padding: 6px 12px; font-size: 0.9rem; }
header.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px; background: var(--brand-bg); color: var(--brand-ink); border-bottom: 1px solid var(--line); }
header.top .brand { color: var(--brand-ink); font-weight: 700; text-decoration: none; font-size: 1.15rem; }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px; }
header.top nav a { color: var(--brand-ink); text-decoration: none; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
header.top nav a:hover { background: rgba(255,255,255,0.15); }
header.top .signout { margin-left: auto; display: flex; align-items: center; gap: 8px; }
header.top .who { opacity: 0.85; font-size: 0.9rem; }
header.top a.who { color: var(--brand-ink); }
button.link { background: none; border: 1px solid rgba(255,255,255,0.5); color: var(--brand-ink); padding: 6px 10px; border-radius: 6px; font: inherit; }
button.link:hover { background: rgba(255,255,255,0.15); }
/* The light/dark switch (shown by app.js): on the right of the header, before the name and Sign out when they show */
/* The header's right-hand side: the light/dark switch, then the name and Sign out. It moves below the menu as one
   piece when it doesn't fit beside it; on a phone it stays beside "Checks" (flex-basis 180px, below), its own items
   wrapping, still on the right. Its height is kept while app.js has not shown the switch, so the page doesn't jump. */
header.top .header-end { margin-left: auto; flex: 0 1 auto; min-width: 0; min-height: 44px; display: flex;
  flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; }
header.top .header-end .signout { margin-left: 0; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
header.top .theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; white-space: nowrap; }
header.top .theme-toggle svg { flex-shrink: 0; }
:root[data-theme="light"] .theme-toggle .icon-sun, :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card.attention { border-color: var(--attention-line); background: var(--attention-bg); }
.subform { border-left: 3px solid var(--line); padding-left: 12px; margin: 0 0 12px; }
.narrow { max-width: 560px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.flash { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; background: var(--info-bg); color: var(--info-ink); }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

label { display: block; margin: 0 0 12px; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: 22px; height: 22px; flex-shrink: 0; }  /* a long label wraps; the box keeps its size */
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type="file"] { padding: 8px; }
textarea { resize: vertical; }
fieldset.plain { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
fieldset.plain legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
fieldset.plain label.check { font-weight: 400; }
/* Who may sign: each signer's tick, then Default on the same line, in two columns (a long name wraps in the first) */
.signer-rows { display: grid; grid-template-columns: minmax(0, max-content) auto; align-items: center; gap: 0 20px; }
.signer-row { display: contents; }
.signer-row label.check { margin-bottom: 8px; }
.signer-row label.check:first-child { min-width: 0; }
.signer-row label.check + label.check { white-space: nowrap; }
.pre-line { white-space: pre-line; }
button, .button { display: inline-block; min-height: 44px; padding: 10px 16px; font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--brand); text-decoration: none; cursor: pointer; text-align: center; }
button.primary, .button.primary { background: var(--brand); color: var(--primary-ink); border-color: var(--brand); }
/* Not a disabled-looking .button (a deleted PDF), a busy button, or the chosen tab */
button:not(.primary):not(.link):not(:disabled):not([aria-selected="true"]):hover,
.button:not(.primary):not(.disabled):hover { background: var(--hover-bg); }
button.danger, .button.danger { color: var(--bad); border-color: var(--bad); }
.big { font-size: 1.05rem; padding: 12px 18px; }
.button.disabled { color: var(--muted); cursor: default; }
details { margin: 0 0 12px; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
/* Two-step confirmations: the summary is the first click, the form's button the second.
   Native confirm() dialogs are not used because some browsers, including Claude's built-in one, suppress them. */
details.confirm > summary { list-style: none; margin-bottom: 0; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { margin-bottom: 10px; }
details.confirm > :not(summary) { border-left: 3px solid var(--line); padding-left: 12px; margin: 0; }
details.confirm > p { padding-bottom: 10px; }
details.confirm form p { margin: 0 0 10px; overflow-wrap: anywhere; }
button:disabled { opacity: 0.6; cursor: wait; }
.small { min-height: 36px; padding: 6px 10px; }
form.inline { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 14px; }
form.inline label { flex: 1 1 220px; margin: 0; }
form.inline > p, form.inline > .muted { flex: 1 1 100%; margin: 0; }
form.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; margin-bottom: 12px; }
form.filters label { margin: 0; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
td:nth-child(3) { white-space: normal; }
table.preview tr.bad td { background: var(--row-bad-bg); }
table.preview tr.warn td { background: var(--row-warn-bg); }
table.preview td:last-child { white-space: normal; min-width: 200px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--chip-bg); color: var(--muted); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

ul.files { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
ul.files .button { width: 100%; }
ul.files form.showfile { margin-top: 6px; }
ul.accounts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
ul.accounts li { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: grid; gap: 4px; }
ul.accounts .name { font-weight: 600; }
ul.accounts .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }  /* a long URL in notes must not widen a phone page */

@media (max-width: 640px) {
  header.top nav { width: 100%; order: 3; }
  header.top .signout { margin-left: auto; }
  header.top .header-end { flex: 1 1 180px; }
  header.top .theme-label { display: none; }  /* the icon alone; its name is the button's aria-label */
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dt { margin-top: 8px; font-size: 0.8rem; text-transform: uppercase; }
  .actions .button, .actions button { flex: 1 1 100%; }
}

/* New batch page: tabs, and the rows of "Write several checks" */
[hidden] { display: none !important; }  /* rules like label { display: block } would otherwise show hidden boxes */
#paste-note:empty { display: none; }
#paste-note { overflow-wrap: anywhere; }  /* a long copied cell named in the note must not widen a phone page */
#paste-note .paste-choice { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs button { background: none; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
  padding: 10px 14px; margin-bottom: -1px; font: inherit; color: var(--muted); cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { background: var(--card); border-color: var(--line); color: var(--ink); font-weight: 600; }
body.has-tabs .no-tabs { display: none; }
.entry-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; }
.entries { display: grid; gap: 6px; margin: 0 0 10px; }
.entry-row { display: grid; grid-template-columns: 2fr 1fr 1.5fr; gap: 6px; }
.entry-row input { width: 100%; min-width: 0; }
.entry-head { font-weight: 600; font-size: 0.9rem; }
@media (max-width: 600px) {
  .entry-head { display: none; }
  .entry-row { grid-template-columns: 1fr 1fr; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .entry-row input[name="payee"] { grid-column: 1 / -1; }
}

/* Account page: the Signature card, the signature pad, and previews of the signature box as it prints */
h3 { font-size: 1rem; margin: 18px 0 8px; }
td.wrap { white-space: normal; min-width: 220px; }
.sigpad { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 4px 0 8px; }
.sigpad canvas { display: block; width: 100%; aspect-ratio: 3 / 1; touch-action: none; overscroll-behavior: contain;
  cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sigpad .baseline { position: absolute; left: 6%; right: 6%; bottom: 28%; border-bottom: 1px dashed #c9ced4; pointer-events: none; }
.sigpad-tools { display: flex; gap: 8px; margin: 0 0 12px; }
.sigpreview { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin: 0 0 8px; }
.sigpreview.small { max-width: 240px; }
.sigcompare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 0 0 12px; }
.sigcompare figure { margin: 0; min-width: 0; }
.sigcompare figcaption { font-weight: 600; margin-bottom: 4px; overflow-wrap: anywhere; }
ul.siglist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
ul.siglist li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
ul.siglist li > div { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
ul.siglist form { margin-top: 6px; }
[data-pad-note]:empty { display: none; }
@media (max-width: 640px) { .sigpad canvas { aspect-ratio: 2.2 / 1; } }

/* Register: tick checks, then act on them */
.actionbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 10px; margin: 0 0 10px; }
.actionbar label { flex: 1 1 220px; margin: 0; }
.actionbar #action-note { flex: 1 1 100%; margin: 0; }
#register-apply:disabled { cursor: not-allowed; }
table.selectable td:nth-child(3) { white-space: nowrap; }  /* the global rule meant the payee column */
table.selectable td.payee { white-space: normal; min-width: 140px; }
th.pick, td.pick { width: 1%; padding: 0; }
.pick label { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 40px; margin: 0; cursor: pointer; }
.pick input { display: inline-block; width: 20px; height: 20px; margin: 0; padding: 0; }
table.selectable tr:has(.pick input:checked) td { background: var(--select-bg); }
.badge.cleared { background: var(--cleared-bg); color: var(--brand); }

/* Account groups: headings in account lists, the account page's Group choice, the Account groups page */
.group-heading { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 16px 0 8px; overflow-wrap: anywhere; }
fieldset .group-heading { font-size: 0.8rem; margin: 10px 0 4px; }
form.group-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px; }
form.group-form select { display: inline-block; width: auto; max-width: 100%; flex: 0 1 240px; min-width: 0; margin: 0; }
ul.group-accounts { margin: 0 0 12px; padding-left: 20px; overflow-wrap: anywhere; }
.assign-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 16px; }
.assign-list label { font-weight: 400; overflow-wrap: anywhere; }
/* A long unbroken group or payee name in a message, a note, a tick box's label or a Changes list must not widen a
   phone page; nor in a two-step confirmation's buttons ("Yes, delete …"), which wrap like text. */
.flash, .muted, label.check, ul.changes { overflow-wrap: anywhere; }
details.confirm button, details.confirm summary.button { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
p.long-words { overflow-wrap: anywhere; }  /* a sentence naming an email (the Users pages' link page) */

/* The Accounts page and the home page's Accounts card */
.card > .actions:last-child { margin-bottom: 0; }
ul.accounts .fact { font-size: 0.85rem; }  /* not .small, which pads it like a small button */
ul.accounts li > div { min-width: 0; overflow-wrap: anywhere; }  /* a long name or bank must not widen a phone page */

/* The Archive: account, payee and memo wrap (only the table scrolls on a phone), the account and memo wide enough
   that a row stays a few lines tall; its pages and its imports */
table.archive td.account, table.archive td.payee { white-space: normal; min-width: 140px; overflow-wrap: anywhere; }
table.archive td.account { min-width: 220px; }
table.archive td.memo { white-space: normal; min-width: 240px; overflow-wrap: anywhere; }
form.archive-filters label { min-width: 0; }  /* a long account name in the menu must not widen a phone page */
@media (min-width: 700px) { form.archive-filters label.search { grid-column: span 2; } }  /* room for its hint */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 16px; }
ul.imports { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
ul.imports li { border-bottom: 1px solid var(--line); padding-bottom: 10px; overflow-wrap: anywhere; }
ul.imports details { margin: 6px 0 0; }
table.archive .sub, ul.imports .sub { font-size: 0.85rem; }  /* not .small, which pads it like a small button */

/* Signing out after the idle limit: the warning a minute before (_idle.html, app.js), over the page. Its own
   fallback (.fallback) where the browser has no modal dialogs. */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
dialog.idle-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow: auto; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--ink); box-shadow: 0 10px 40px var(--shadow); }
dialog.idle-dialog::backdrop { background: var(--scrim, rgba(0,0,0,0.6)); }  /* older browsers: no tokens in ::backdrop */
dialog.idle-dialog:not([open]) { display: none; }  /* a browser that doesn't know <dialog> would show it */
dialog.idle-dialog.fallback { position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 100; }
dialog.idle-dialog p { margin: 0 0 14px; overflow-wrap: anywhere; }
dialog.idle-dialog .actions { margin: 0; }
.idle-clock { font-variant-numeric: tabular-nums; }

/* Payees by bank account (payees.html) */
details.payee-account { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 8px; background: var(--card); }
details.payee-account > summary { cursor: pointer; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
details.payee-account > summary .name { font-weight: 600; }
details.payee-account[open] > summary { border-bottom: 1px solid var(--line); }
details.payee-account > .tablewrap, details.payee-account > p, details.payee-account > ul { margin: 8px 12px 12px; }
ul.plain-list { list-style: none; padding: 0; columns: 2 220px; }
/* The Signatures page (signatures.html): the signature now beside what it signs; earlier ones in a strip that scrolls
   sideways inside the card, never the page */
.sig-now { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-start; margin-bottom: 12px; }
.sig-now .sigpreview { max-width: 100%; }
ul.sig-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
ul.sig-strip > li { flex: 0 0 min(240px, 80%); scroll-snap-align: start; }
