/* Large text, high contrast, plain layout, for people of 50 to 70. Slice 11 step 1 (docs/design-system.md, docs/ux/prototypes/proto.css): tokens, six
   components, the focus ring; the old class names (.button, .secondary-action, .small, .danger, .small-link) are aliases. rem is on the 16 px root:
   1.125rem = 18 px (the smallest text on a data screen), 3rem = 48 px, 2.75rem = 44 px. */
:root {
  color-scheme: light;
  --ink: #1a1a1a; --ink-2: #4a4a4a; --surface: #ffffff; --bg: #f6f7f9; --tint: #f1f4f8; --line: #dfe3e8; --line-strong: #6b6b6b;
  --accent: #0a4f8f; --accent-dark: #083f73; --accent-tint: #eaf2fa; --ok: #1e6b3a; --ok-tint: #e9f5ee; --warn: #6b4200; --warn-tint: #fdf3df;
  --danger: #9b1c1c; --danger-tint: #fbeceb; --halo: #ffbf00;
  --t-title: 1.75rem; --t-section: 1.375rem; --t-body: 1.125rem; --t-dense: 1.125rem;
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem;
  --control: 3rem; --control-min: 2.75rem; --radius: 8px; --radius-lg: 12px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Gujarati", "Noto Sans Devanagari", "Liberation Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 var(--t-body)/1.5 var(--font); color: var(--ink); background: var(--surface); }
main { max-width: 42rem; margin: var(--s-6) auto; padding: 0 var(--s-5) 4rem; }
main.wide { max-width: 96rem; }
h1 { font-size: var(--t-title); line-height: 1.25; font-weight: 700; margin: 0 0 var(--s-4); }
section h2, h2 { font-size: var(--t-section); line-height: 1.35; }
section h2 { margin-top: var(--s-6); }
a { color: var(--accent); text-underline-offset: 3px; }
a:not(.button):not(.btn) { display: inline-flex; align-items: center; min-height: var(--control-min); }

/* focus: a dark ring with a yellow halo, visible on white and on a tint; never removed */
:focus-visible { outline: 3px solid var(--ink); outline-offset: 0; box-shadow: 0 0 0 6px var(--halo); }
tr:focus-visible { box-shadow: none; }

/* top bar: light, with links; Sign out is a link */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 4rem; padding: 0 var(--s-5);
       background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-size: var(--t-section); font-weight: 700; color: var(--ink); text-decoration: none; }
.who { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); color: var(--ink-2); }
.who form { margin: 0; }
.quiet { font-size: var(--t-body); }

/* 1, primary: the one action of a screen (.btn; old names .button and a bare button) */
button, .button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); margin-top: var(--s-5); min-height: var(--control);
       padding: 0 var(--s-5); font: 700 var(--t-body)/1.2 var(--font); color: #fff; background: var(--accent); border: 2px solid var(--accent);
       border-radius: var(--radius); cursor: pointer; text-decoration: none; }
button:hover, .button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
/* 2, secondary */
.btn-secondary, .secondary-action, .secondary, .quiet-button { background: var(--surface); color: var(--accent); }
.btn-secondary:hover, .secondary-action:hover, .secondary:hover, .quiet-button:hover { background: var(--accent-tint); color: var(--accent-dark); border-color: var(--accent); }
.quiet-button { margin-left: var(--s-4); }
/* 3, danger: always with the word */
.btn-danger, button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover, button.danger:hover { background: var(--danger-tint); color: var(--danger); border-color: var(--danger); }
/* 4, small: in rows and tables */
.btn-small, button.small, .button.small { margin-top: 0; min-height: var(--control-min); padding: 0 var(--s-4); font-size: var(--t-body); }
/* 5, link: navigation, and a button that must read as one (Sign out) */
a.link, .small-link, button.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: var(--t-body); font-weight: 400; }
button.link { margin: 0; padding: 0 var(--s-3); min-height: var(--control-min); background: none; border: 0; font-family: inherit; }
button.link:hover { background: none; color: var(--accent-dark); }
/* 6, disabled: looks it, and a sentence beside it says why */
button:disabled, button[disabled], .btn[disabled], .btn[aria-disabled=true] { background: #eceef1; color: var(--ink-2); border: 2px dashed var(--line-strong); cursor: not-allowed; }

/* forms: label above the box, boxes 48 px tall, help below in grey */
label { display: block; font-weight: 700; margin: var(--s-5) 0 var(--s-2); }
input[type=email], input[type=password], input[type=text], textarea, select { font: inherit; min-height: var(--control); padding: 0 var(--s-4); color: var(--ink);
       background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--radius); }
input[type=email], input[type=password], input[type=text], textarea { width: 100%; }
input[type=email], input[type=password], input[type=text], select { height: var(--control); }
textarea { padding: var(--s-3) var(--s-4); }
input.short { width: 6rem; }
fieldset { border: 2px solid var(--line-strong); border-radius: var(--radius); margin: var(--s-5) 0; padding: var(--s-2) var(--s-4) var(--s-4); }
legend { font-weight: 700; padding: 0 var(--s-2); }
.choice-row { display: flex; align-items: center; gap: var(--s-3); min-height: var(--control-min); font-weight: 400; margin: var(--s-2) 0; cursor: pointer; }
.choice-row input { width: 1.75rem; height: 1.75rem; margin: 0; flex: none; }
.help { color: var(--ink-2); }
.hidden-label { position: absolute; left: -9999px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.inline, form.inline { display: inline; margin: 0; }
p.link { word-break: break-all; font-family: monospace; }

/* notices: the words say it, the colour repeats it */
.problem, .notice, .support { padding: var(--s-3) var(--s-4); margin: var(--s-4) 0; color: var(--ink); border-left: 8px solid var(--danger); background: var(--danger-tint); }
.notice { border-color: var(--ok); background: var(--ok-tint); }
.support { border-color: var(--warn); background: var(--warn-tint); }
.problem p { margin: var(--s-1) 0; }
.row-problem { color: var(--danger); font-weight: 700; }

/* lists and tables: tinted header, light rules */
.choices { list-style: none; padding: 0; }
.choices li { margin: var(--s-4) 0; }
.choice { font-size: var(--t-section); font-weight: 700; }
.people, .heads, .opening { width: 100%; border-collapse: collapse; margin: var(--s-2) 0 var(--s-5); }
.people th, .people td, .heads th, .heads td, .opening td { text-align: left; padding: var(--s-3) var(--s-2); border-bottom: 1px solid var(--line); vertical-align: top; }
.people th, .heads th { background: var(--tint); color: var(--ink); border-bottom: 2px solid var(--line-strong); }
.opening td { vertical-align: middle; }
.opening td.amount { width: 12rem; }
.opening input[type=text] { text-align: right; }
.heads .place, .history .when { color: var(--ink-2); }
.heads .not-placed { color: var(--warn); font-weight: 700; }
.group-title { margin-top: var(--s-6); }
.steps, .totals, .quick { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: var(--s-2) var(--s-4) var(--s-3); margin: 0 0 var(--s-5); background: var(--tint); }
.steps .step-count { font-size: var(--t-section); font-weight: 700; margin: var(--s-1) 0; }
.steps ol { margin: var(--s-1) 0 0; padding-left: var(--s-5); }
.steps li { margin: var(--s-1) 0; }
.steps li.current { font-weight: 700; }
.steps .done { color: var(--ok); font-weight: 700; }
.totals { margin: var(--s-5) 0; padding-bottom: var(--s-4); }
.totals dl { margin: var(--s-2) 0; }
.totals dt { font-weight: 700; margin-top: var(--s-2); }
.totals dd { margin: 0; font-size: var(--t-section); }
.totals .verdict { font-weight: 700; margin: var(--s-3) 0 0; }
.totals .verdict.ok { color: var(--ok); }
.facts { margin: var(--s-2) 0 var(--s-5); }
.facts dt { font-weight: 700; margin-top: var(--s-3); }
.facts dd { margin: 0; }
.facts dd.lines, .lines { white-space: pre-line; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; }
.history { list-style: none; padding: 0; }
.history > li { border-bottom: 1px solid var(--line); padding: var(--s-3) 0; }
.history .when { margin: 0; }
.history .what { margin: var(--s-1) 0; font-weight: 700; }
.history .changes { margin: var(--s-1) 0 0; padding-left: var(--s-5); }
.history li.by-support { background: var(--warn-tint); padding-left: var(--s-3); }

/* Slice 2b: the cash book. A wide page, boxes and buttons at least 44 px tall, focus that shows. */
.num { text-align: right; }
.month-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin: var(--s-4) 0; }
.month-bar form { display: flex; gap: var(--s-2); align-items: center; margin: 0; }
.year-choices, .month-strip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.year-chip, .month-chip { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control-min); min-width: 3.25rem; padding: 0 var(--s-3); border: 2px solid var(--line-strong); border-radius: var(--radius); color: var(--ink); background: var(--surface); text-decoration: none; font-weight: 600; }
.year-chip.current, .month-chip.current { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; text-decoration: underline; }
.month-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.month-chip.this-month:not(.current) { border-style: dashed; }
.quick { margin: var(--s-4) 0; padding-top: var(--s-1); }
.quick summary { font-weight: 700; cursor: pointer; min-height: var(--control-min); display: flex; align-items: center; }
.more-heads summary { font-weight: 700; cursor: pointer; padding: var(--s-3) 0; min-height: var(--control-min); }
.quick-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-3); }
.month-title { margin: var(--s-4) 0 var(--s-1); }
table.grid { width: 100%; border-collapse: collapse; margin: var(--s-2) 0 var(--s-4); font-size: var(--t-dense); table-layout: fixed; }
table.grid th, table.grid td { padding: var(--s-2); border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
table.grid th.c-date { width: 8.5rem; } table.grid th.c-reference { width: 7rem; } table.grid th.c-in, table.grid th.c-out { width: 8.5rem; }
table.grid th.c-balance { width: 9rem; } table.grid th.c-actions { width: 16.5rem; }
table.grid.editor { table-layout: auto; }
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid thead th { background: var(--tint); color: var(--ink); border-bottom: 2px solid var(--line-strong); }
table.grid tr.carry th, table.grid tr.closing th, table.grid tr.totals th { text-align: left; font-weight: 700; }
table.grid tr.carry, table.grid tr.closing { background: var(--accent-tint); font-weight: 700; }
table.grid tbody.entry:nth-of-type(even) tr.entry-row { background: var(--bg); }
table.grid tr.entry-row:focus { outline: 3px solid var(--ink); outline-offset: -3px; background: #fffbe6; }
table.grid tr.edit-row, table.grid tr.blank-row { background: #fffdf2; }
table.grid input[type=text] { width: 100%; min-width: 4rem; font-size: var(--t-dense); padding: 0 var(--s-2); height: var(--control-min); min-height: var(--control-min); }
table.grid td.c-date input { min-width: 7.5rem; }
table.grid td.c-in input, table.grid td.c-out input { text-align: right; min-width: 7rem; }
table.grid td.c-actions { white-space: nowrap; }
table.grid td.c-actions form { display: inline; margin: 0; }
table.grid tr.row-problems td, table.grid tr.row-hint td { padding: var(--s-3); }
table.grid tr.row-problems td { border-left: 8px solid var(--danger); background: var(--danger-tint); }
table.grid tr.row-problems ul { margin: var(--s-1) 0 0; padding-left: var(--s-5); }
table.grid tr.row-hint td { border-left: 8px solid var(--warn); background: var(--warn-tint); }
.undo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); }
.undo-bar p, .undo-bar form { margin: 0; }
.suggest-wrap, td.c-account, td.c-particulars { position: relative; }
ul.suggest { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 0; padding: 0; list-style: none; background: var(--surface); border: 2px solid var(--ink);
       border-radius: var(--radius); max-height: 18rem; overflow-y: auto; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
ul.suggest[hidden] { display: none; }
ul.suggest li { padding: var(--s-2) var(--s-3); min-height: var(--control-min); cursor: pointer; border-bottom: 1px solid var(--line); font-size: var(--t-dense); }
ul.suggest li.active, ul.suggest li[aria-selected=true] { background: var(--accent); color: #fff; outline: 3px solid var(--halo); outline-offset: -3px; }
ul.suggest li .opt-label { color: var(--ink-2); }
ul.suggest li.active .opt-label, ul.suggest li[aria-selected=true] .opt-label { color: #dbe4f5; }
ul.suggest li.opt-new { font-weight: 700; border-top: 2px solid var(--ink); }
dialog { max-width: 42rem; width: calc(100% - 2rem); border: 2px solid var(--ink); border-radius: var(--radius-lg); padding: var(--s-4) var(--s-5) var(--s-5); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog input[type=text], dialog select { width: 100%; }
.keys-help { margin-top: var(--s-6); }
dl.keys { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); }
dl.keys dt { font-weight: 700; }
dl.keys dd { margin: 0; }
.editor-head { display: grid; grid-template-columns: 10rem 1fr 14rem; gap: var(--s-4); }
.editor-head label { margin-top: var(--s-2); }
table.editor td input[type=text] { width: 100%; }
/* filters: a label above each box, two to a row, one below 640 px */
.filter-bar { display: grid; grid-template-columns: repeat(2, minmax(12rem, 1fr)); gap: 0 var(--s-5); align-items: end; margin: var(--s-4) 0; }
.filter-bar label { margin: var(--s-4) 0 var(--s-2); }
.filter-bar .actions { grid-column: 1 / -1; }
@media (max-width: 640px) { .filter-bar { grid-template-columns: 1fr; } }

/* Slice 2b, ruling 11 (900 px, a laptop at 150 percent zoom): below 1200 px a row is two lines (date, particulars, the two amounts; then reference,
   account, balance, buttons); each box says what it is in text above it, so no meaning is left to position or colour. */
@media (max-width: 1200px) {
  table.grid:not(.editor), table.grid:not(.editor) thead, table.grid:not(.editor) tbody, table.grid:not(.editor) tfoot { display: block; }
  table.grid:not(.editor) thead { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.grid:not(.editor) td, table.grid:not(.editor) th { display: block; border: 0; padding: 0.2rem 0.25rem; min-width: 0; overflow-wrap: anywhere; }
  table.grid:not(.editor) tr.entry-row, table.grid:not(.editor) tr.edit-row, table.grid:not(.editor) tr.blank-row {
    display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 0.5rem; row-gap: 0.15rem; align-items: start;
    padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line-strong); }
  table.grid:not(.editor) td.c-date { grid-column: 1 / span 2; grid-row: 1; }
  table.grid:not(.editor) td.c-particulars { grid-column: 3 / span 4; grid-row: 1; }
  table.grid:not(.editor) td.c-in { grid-column: 7 / span 3; grid-row: 1; }
  table.grid:not(.editor) td.c-out { grid-column: 10 / span 3; grid-row: 1; }
  table.grid:not(.editor) td.c-reference { grid-column: 1 / span 2; grid-row: 2; }
  table.grid:not(.editor) td.c-account { grid-column: 3 / span 3; grid-row: 2; }
  table.grid:not(.editor) td.c-balance { grid-column: 6 / span 3; grid-row: 2; }
  table.grid:not(.editor) td.c-actions { grid-column: 9 / span 4; grid-row: 2; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; white-space: normal; }
  table.grid:not(.editor) td.c-actions form { display: inline-flex; }
  table.grid:not(.editor) td.c-actions .button.small, table.grid:not(.editor) td.c-actions button.small { padding: 0 0.6rem; }
  table.grid:not(.editor) td.c-date::before { content: "Date"; content: "Date" / ""; }
  table.grid:not(.editor) td.c-particulars::before { content: "Particulars"; content: "Particulars" / ""; }
  table.grid:not(.editor) td.c-reference::before { content: "Reference"; content: "Reference" / ""; }
  table.grid:not(.editor) td.c-in::before { content: var(--cb-in); content: var(--cb-in) / ""; }
  table.grid:not(.editor) td.c-out::before { content: var(--cb-out); content: var(--cb-out) / ""; }
  table.grid:not(.editor) td.c-account::before { content: "Account"; content: "Account" / ""; }
  table.grid:not(.editor) td.c-balance::before { content: "Balance"; content: "Balance" / ""; }
  table.grid:not(.editor) td.c-date::before, table.grid:not(.editor) td.c-particulars::before, table.grid:not(.editor) td.c-reference::before,
  table.grid:not(.editor) td.c-in::before, table.grid:not(.editor) td.c-out::before, table.grid:not(.editor) td.c-account::before,
  table.grid:not(.editor) td.c-balance::before { display: block; font-size: var(--t-dense); font-weight: 700; color: var(--ink-2); }
  table.grid:not(.editor) td.c-actions:empty::before, table.grid:not(.editor) td.c-balance:empty { display: none; }
  table.grid:not(.editor) td.c-in input, table.grid:not(.editor) td.c-out input, table.grid:not(.editor) td.c-date input, table.grid:not(.editor) input[type=text] { min-width: 0; }
  table.grid:not(.editor) tr.carry, table.grid:not(.editor) tr.closing, table.grid:not(.editor) tr.totals {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 1.5rem; padding: 0.4rem 0.5rem; }
  table.grid:not(.editor) tr.carry td:empty, table.grid:not(.editor) tr.closing td:empty, table.grid:not(.editor) tr.totals td:empty { display: none; }
  table.grid:not(.editor) tr.totals td.c-in::before, table.grid:not(.editor) tr.totals td.c-out::before { display: inline; margin-right: 0.5rem; }
  table.grid:not(.editor) tr.carry td.c-balance::before, table.grid:not(.editor) tr.closing td.c-balance::before { display: none; }
  table.grid:not(.editor) tr.row-problems, table.grid:not(.editor) tr.row-hint { display: block; }
}
