:root {
  --ink: #1b1f24; --muted: #5c6670; --line: #d9dee3; --bg: #f5f6f8; --card: #ffffff;
  --brand: #1f3a5f; --brand-ink: #ffffff; --ok: #1e7d3c; --warn: #9a6700; --bad: #b3261e;
}
* { 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(--bg); padding: 8px 10px; border-radius: 6px; overflow-x: auto; }

.devbanner { background: #fff3cd; color: #664d03; 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); color: var(--brand-ink); }
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; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card.attention { border-color: #e0b400; background: #fffdf3; }
.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: #e8f0fe; }
.flash.success { background: #e3f6e8; color: var(--ok); }
.flash.error { background: #fde8e6; color: var(--bad); }
.flash.warn { background: #fff3cd; 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: #fff; color: var(--ink); }
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: #fff; color: var(--brand); text-decoration: none; cursor: pointer; text-align: center; }
button.primary, .button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
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: #fff5f4; }
table.preview tr.warn td { background: #fffaea; }
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: #eceff2; color: var(--muted); }
.badge.ok { background: #e3f6e8; color: var(--ok); }
.badge.warn { background: #fff3cd; color: var(--warn); }
.badge.bad { background: #fde8e6; 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; }
  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: var(--card); 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 var(--line); 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: #eef3fb; }
.badge.cleared { background: #e6eef8; 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; }

/* 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 */
