/* Ledger: one stylesheet, tokens from the ui-system skill. Calm, readable, phone first.
   Inter for everything (owner, 08/11/2026: minimal, readable, web friendly; OFL licence in
   fonts/INTER-LICENSE.txt); served from here, no outside font service. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/inter.2bf3d951bf9d.woff2") format("woff2"); }

/* Light: deep teal on a soft sage-grey page, warm ink. */
:root {
  --ink: #20342e;
  --muted: #5c7266;
  --line: #e1e7e1;
  --field-line: #7f9188;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235c7266' stroke-width='2'/%3E%3C/svg%3E");
  --surface: #ffffff;
  --page: #f5f6f3;
  --side: #ffffff;
  --side-ink: #20342e;
  --side-muted: #5c7266;
  --accent: #145c43;
  --accent-soft: #eaf3ed;
  --red: #af443b;
  --green: #1d6b47;
  --amber: #8f5418;
  --amber-soft: #fff4e5;
  --red-soft: #fbeeec;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 4px 16px rgba(20, 30, 50, 0.05);
  --radius: 8px;
  /* PLAN v2 step 17: the one spacing scale (approved pictures, Workups - Attempt 2). Every margin,
     padding and gap is one of these steps or a sum of them (tests/web/test_spacing_scale.py). */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --gutter: var(--s4);
  --page-max: 1200px;
  --nav-h: 60px;
  --side-w: 248px;
  --head: "Inter", system-ui, sans-serif;
  color-scheme: light;
}

/* Dark: the same teal, lifted for contrast on a deep green-black. Chosen by the switch in the
   menu (a cookie the server reads, so no flash), or by the device when set to Auto. */
:root[data-theme="dark"] {
  --ink: #e4ece7;
  --muted: #a3b5ab;
  --line: #26362f;
  --field-line: #5f7469;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a3b5ab' stroke-width='2'/%3E%3C/svg%3E");
  --surface: #16231e;
  --page: #0f1a16;
  --side: #16231e;
  --side-ink: #e4ece7;
  --side-muted: #a3b5ab;
  --accent: #6fcf9f;
  --accent-soft: #1b3329;
  --red: #ff8f85;
  --green: #6fd69f;
  --amber: #e6b84a;
  --amber-soft: #2d2410;
  --red-soft: #341a18;
  --on-accent: #0c1512; /* white on light blue is under 3:1 */
  --shadow: none;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --ink: #e4ece7;
    --muted: #a3b5ab;
    --line: #26362f;
    --field-line: #5f7469;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a3b5ab' stroke-width='2'/%3E%3C/svg%3E");
    --surface: #16231e;
    --page: #0f1a16;
    --side: #16231e;
    --side-ink: #e4ece7;
    --side-muted: #a3b5ab;
    --accent: #6fcf9f;
    --accent-soft: #1b3329;
    --red: #ff8f85;
    --green: #6fd69f;
    --amber: #e6b84a;
    --amber-soft: #2d2410;
    --red-soft: #341a18;
    --on-accent: #0c1512;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1; /* even figures; a plain single-storey a */
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

a { color: var(--accent); }

/* S12 (owner 09/11): one weight, as drawn in the 390 shots; emphasis by size, colour and capitals */
b, strong, th, dt, legend, summary, optgroup, h1, h2, h3, h4 { font-weight: 400; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

/* Keyboard users jump past the menu; it shows only when tabbed to. */
.skip { position: absolute; left: 16px; top: -100px; z-index: 30; padding: var(--s2) var(--s4); background: var(--surface); color: var(--accent); border: 2px solid var(--accent); border-radius: var(--radius); }
.skip:focus { top: 8px; }

h1, h2, h3, .brand { font-family: var(--head); letter-spacing: 0.01em; }
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 var(--s4); font-weight: 400; }
h2 { font-size: 19px; margin: var(--s5) 0 var(--s2); font-weight: 400; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--s4) var(--gutter) var(--s6);
}

/* ------------------------------------------------------------ header and navigation */

/* Back on the left, the name in the middle, Home (or the desktop menu) on the right. */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s2);
  /* The bar spans the window; its ends line up with the page content (main: 1200 px wide), so
     a wide desktop has no empty run beside the menu. */
  padding: calc(var(--s2) + env(safe-area-inset-top))
    max(var(--gutter), calc((100% - var(--page-max)) / 2 + var(--gutter))) var(--s2)
    max(var(--gutter), calc((100% - var(--page-max)) / 2 + var(--gutter)));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top .brand { font-weight: 400; color: var(--ink); text-decoration: none; text-align: center; }
.top .back { justify-self: start; }
.top .home { justify-self: end; }

.top a.back,
.top a.home,
.top .out button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--s2);
  text-decoration: none;
}
.top .out { justify-self: start; margin: 0; }
.top .out button { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
/* While the keyboard is up, iOS lets a sticky bar float down over the field being typed in. */
body.typing .top { position: static; }
@supports (padding: max(0px)) {
  .top { padding-left: max(var(--gutter), env(safe-area-inset-left), calc((100% - var(--page-max)) / 2 + var(--gutter)));
         padding-right: max(var(--gutter), env(safe-area-inset-right), calc((100% - var(--page-max)) / 2 + var(--gutter))); }
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: grid;
  grid-auto-flow: column; /* one row, whatever the number of items */
  grid-auto-columns: 1fr;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
body.typing .bottom-nav { display: none; } /* the keyboard would lift it over the fields (app.js) */

.bottom-nav a {
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.bottom-nav a[aria-current="page"] { color: var(--accent); font-weight: 400; }


/* ------------------------------------------------------------ figures */

/* A figure never breaks; its currency (and Dr/Cr) may go under it when space is short, so
   the largest amount fits at 320 px (CLAUDE.md §19.2). */
.amount { text-align: right; white-space: normal; }
.cur { color: var(--muted); font-size: 0.85em; margin-left: var(--s1); display: inline-block; white-space: nowrap; }
.dr { color: var(--green); }
.cr { color: var(--red); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ forms */

form.stack { display: grid; gap: var(--s4); max-width: 560px; }

label { display: grid; gap: var(--s1); align-content: start; font-weight: 400; font-size: 14px; } /* a taller row never stretches the field */

input, select, textarea {
  font: inherit;
  font-size: 16px; /* never smaller: a smaller field makes the iPhone zoom in on tap */
  font-weight: 400;
  min-height: 44px;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--field-line); /* 3:1 against the page: a field must show where it is */
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}

input.num { text-align: right; }

/* The field being typed in: its own border turns teal; no ring outside it (owner, 31/10/2026). */
input:not([type=checkbox]):not([type=radio]):focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* The drop-down looks like every other field (white, the same border), with its own arrow. */
select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface) var(--select-arrow) no-repeat right 14px center;
  padding-right: calc(var(--s6) + var(--s2));
}

.hint { font-weight: 400; color: var(--muted); font-size: 14px; }
.field-error { font-weight: 400; color: var(--red); font-size: 14px; }

button, .button {
  font: inherit;
  font-weight: 400;
  min-height: 44px;
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.quiet, .button.quiet { background: var(--surface); color: var(--accent); }
button.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
button[disabled] { opacity: 0.6; cursor: wait; }

.alert {
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--ink);
  background: var(--red-soft);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
}

.warn {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
  border-radius: var(--radius);
  padding: var(--s2) var(--s3);
}

.note { color: var(--muted); }
.pager { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--s2); margin: var(--s2) 0; }
.pager .button { min-width: 44px; padding-left: var(--s3); padding-right: var(--s3); }
.pager .off { opacity: 0.35; pointer-events: none; }
.pager-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; margin-right: var(--s1); }
@media print { .pager { display: none; } }

.actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0 var(--s4); }

/* A phone: the ledger's four actions as an even 2 x 2 grid; a form's main button full width. */
@media screen and (max-width: 767px) {
  .actions.grid { display: grid; grid-template-columns: 1fr 1fr; }
  /* An odd one out (New entry's Invoice) takes the whole row, so the grid stays even. */
  .actions.grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  form.stack button[type="submit"]:not(.tab) { width: 100%; }
}

/* Print / Share under the period (ledger) or the lines (entry): one quiet button. */
.print-link { margin: var(--s4) 0; }

/* ------------------------------------------------------------ ledgers */

/* Unseen but read out or pressed by Enter. It must beat every button rule (M7: "submit buttons are full width" on a phone made the unseen Save scroll the page sideways). */
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.search { margin-bottom: var(--s2); max-width: 320px; } /* M123: as ledgers-desktop-a2 */

.list-group h2 { font-size: 14px; color: var(--muted); margin: var(--s4) 0 var(--s1); }

.ledger-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ledger-list li + li { border-top: 1px solid var(--line); }
.ledger-list a { display: flex; justify-content: space-between; gap: var(--s3); align-items: center; min-height: 52px; padding: var(--s2) var(--s4); color: var(--ink); text-decoration: none; }
.ledger-list .balances { display: grid; justify-items: end; }

.ledger-head h1 { margin-bottom: 0; }
.ledger-head .closing { display: grid; justify-items: start; gap: var(--s1); font-size: 19px; margin: var(--s2) 0; }

/* The period: ‹ From To › in one even row, Show under it on a phone. */
.period {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 44px;
  align-items: end;
  gap: var(--s2);
  margin: var(--s2) 0 var(--s4);
  max-width: 560px;
}
.period .button { padding: 0; }
/* The date hint shares the label's line, so the boxes and the buttons share one bottom edge. */
.period label { grid-template-columns: auto 1fr; column-gap: var(--s2); align-items: baseline; }
.period label > input, .period label > .date-box { grid-column: 1 / -1; grid-row: 2; }
.period label > .hint { grid-row: 1; grid-column: 2; justify-self: end; } /* after "From", never before it */
.period .show { grid-column: 1 / -1; }
/* Phones: From and Till share the first row, ‹ Show › the second. An iPhone's own date box
   doesn't shrink, so in one row with the arrows it ran over them (owner, 31/10/2026). */
@media screen and (max-width: 767px) {
  .period:not(.one) {
    grid-template-columns: 44px 1fr 1fr 44px;
    grid-template-areas: "from from till till" "prev show show next";
  }
  .period:not(.one) > a:first-child { grid-area: prev; }
  .period:not(.one) > label:first-of-type { grid-area: from; }
  .period:not(.one) > label:last-of-type { grid-area: till; }
  .period:not(.one) > a:last-of-type { grid-area: next; }
  .period:not(.one) > .show { grid-area: show; }
  .period input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
  .period input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}
@media print, (min-width: 768px) {
  .period { grid-template-columns: 44px 10em 10em 44px auto; }
  .period .show { grid-column: auto; }
}

/* ------------------------------------------------------------ statement and lines */

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
th { font-size: 14px; color: var(--muted); font-weight: 400; position: sticky; top: 61px; background: var(--surface); }
th.amount, td.amount { text-align: right; }
tr.brought td:not(.bal) { color: var(--muted); }

/* On a phone a table row becomes a small block: no sideways scrolling (iPhone rule). The same
   up to 999 px, where the index leaves the middle panel under 752 px (STAGES 15 item 32, BUGS
   M15: a table never leaves its panel; the page audit checks it at 900 and 1000 px). */
@media screen and (max-width: 999px) {
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: var(--s2) var(--s3); }
  table.stack td { border: 0; padding: var(--s1) 0; display: flex; justify-content: flex-end; align-items: baseline; gap: var(--s1); text-align: right; }
  table.stack td:empty { display: none; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 14px; text-align: left; margin-right: auto; }
  table.stack td.lead { display: block; text-align: left; font-weight: 400; }
  table.stack td.lead::before { content: none; }
}
/* The statement on a phone, and up to 1179 px (BUGS M43: the set columns need 1180): a heading
   with the date, then two lines per entry (BUGS M97, the owner's approved picture).
     01/11/2026
     particulars ........................ amount DR/CR
     [PV-0010] other ledger ................. balance */
@media screen and (max-width: 1179px) {
  table.statement thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.statement, table.statement tbody { display: block; width: 100%; }
  table.statement td:empty { display: none; }
  table.statement tr { width: 100%; border-bottom: 1px solid var(--line); padding: var(--s2) var(--s3); }
  table.statement tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "desc amount" "id balance"; column-gap: var(--s3); row-gap: var(--s1); align-items: baseline; }
  table.statement td { display: block; padding: 0; }
  table.statement td::before { content: none; }
  table.statement td.date, table.statement td.desk, table.statement td.voucher { display: none; }
  table.statement td.lead { display: contents; }
  table.statement .description { grid-area: desc; }
  table.statement .entry-id { grid-area: id; }
  table.statement td.phone-amount { grid-area: amount; text-align: right; font-weight: 400; }
  table.statement td.bal { grid-area: balance; display: flex; justify-content: flex-end; }
  table.statement tr.day-row { display: block; padding: var(--s1) var(--s3); background: var(--page); color: var(--muted); font-size: 14px; }
  table.statement tr.day-row td { display: block; text-align: left; }
  /* the voucher number is a tag coloured by the entry's type, as on Home (its tap area is larger than it looks) */
  table.statement .entry-id a.vtag { position: relative; display: inline-block; margin: 0; padding: 1px var(--s1); border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; letter-spacing: 0.04em; line-height: 20px; text-decoration: none; }
  table.statement .entry-id a.vtag::after { content: ""; position: absolute; inset: -12px -8px; }
  table.statement .entry-id a.vtag.payment { background: #fbefe3; color: #8a4b12; }
  table.statement .entry-id a.vtag.entry, table.statement .entry-id a.vtag.conversion, table.statement .entry-id a.vtag.opening { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); } /* M122 */
  table.statement .entry-id a.vtag.invoice { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  :root[data-theme="dark"] table.statement .entry-id a.vtag.payment { background: #33271b; color: #f0b072; }
}
@media screen and (max-width: 1179px) and (prefers-color-scheme: dark) {
  :root[data-theme="auto"] table.statement .entry-id a.vtag.payment { background: #33271b; color: #f0b072; }
}
@media print, (min-width: 1180px) { table.statement tr.day-row { display: none; } }
@media print, (min-width: 1180px) {
  table.statement td.phone-amount { display: none; }
  /* M126 (ledger-desktop-a2): one line per entry; the voucher has its own column, the other
     ledger follows the particulars on the same line, cut with "..." (the whole text on hover) */
  table.statement td.lead .description, table.statement td.lead .entry-id { display: inline; font-size: inherit; }
  table.statement .entry-id a.vtag { display: none; }
  table.statement td.voucher a.tag { position: relative; margin: 0; padding: 1px var(--s1); text-decoration: none; }
  table.statement td.voucher a.tag::after { content: ""; position: absolute; inset: -12px -8px; } /* a 44 px tap area */
  table.statement td.date.again { color: var(--muted); }
}
/* BUGS M43: set widths, so every currency's table of one ledger lines up, up to
   999,999,999,999,999 (measured 16/11: Date fits the "Opening" tag; 11 digits or more at 14 px) */
@media screen and (min-width: 1180px) {
  table.statement { table-layout: fixed; }
  table.statement th:nth-child(1) { width: 7.5rem; }
  table.statement th:nth-child(2) { width: 6.5rem; }
  table.statement th:nth-child(4), table.statement th:nth-child(5) { width: 10.5rem; }
  table.statement th:nth-child(6) { width: 12.5rem; }
  table.statement .money.long { font-size: 14px; }
  /* M126: one line per entry on a screen; a print keeps the whole particulars (A4) */
  table.statement td.lead { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ------------------------------------------------------------ entry forms */

label.check { display: flex; align-items: center; gap: var(--s3); min-height: 44px; font-weight: 400; font-size: 16px; }
label.check input { width: 24px; min-height: 24px; height: 24px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
/* BUGS M72 (owner 20/11/2026, choice B; replaces M46's two-line room and M5's kept empty line):
   a balance line takes only its own room, 4 px under its box; an empty one adds no gap */
.check-line { color: var(--muted); font-size: 14px; line-height: 1.5; }
.warn-text { color: var(--amber); }

details.optional { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.optional summary { min-height: 44px; display: flex; align-items: center; padding: 0 var(--s4); cursor: pointer; color: var(--accent); font-weight: 400; }
form.stack .stack-inner { display: grid; gap: var(--s4); } /* M51: Add ledger's Address and Phone sat 0 px apart */
details.optional .stack-inner { display: grid; gap: var(--s4); padding: 0 var(--s4) var(--s4); }
/* M121 (receipt-desktop-a2): a form's "+ Add currency" is a plain link in line with the fields */
details.add-currency { border: 0; background: none; }
details.add-currency summary { width: max-content; padding: 0; }
details.add-currency .stack-inner { padding: 0 0 var(--s4); }
details.danger-zone { margin: var(--s5) 0 var(--s2); }
details.danger-zone summary { color: var(--red); }

fieldset.line { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: var(--s3) var(--s4) var(--s4); margin: 0; display: grid; gap: var(--s3); }
fieldset.line legend { font-weight: 400; padding: 0 var(--s1); }

.menu-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); max-width: 560px; }
.menu-list li + li { border-top: 1px solid var(--line); }
.menu-list a { display: grid; gap: var(--s1); min-height: 52px; padding: var(--s2) var(--s4); text-decoration: none; color: var(--ink); }
.menu-list .name { font-weight: 400; }

/* Form pages: one centred column on a desktop, so the page is balanced; the Journal is wider. */
.form-page { max-width: 560px; margin: 0 auto; }
.form-page.wide { max-width: 960px; }
/* Signed out (sign-in, setup, PIN): one narrow card in the middle of the window. */
body:not(.signed-in) main { max-width: 440px; padding-top: 10vh; }
@media (min-width: 768px) {
  body:not(.signed-in) .form-page { padding: var(--s5) var(--s6) var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
}
.form-page form.stack { max-width: none; }
/* a quick page swap that takes more than a moment: the page dims until the next one is in */
html.loading main { opacity: 0.55; transition: opacity 0.15s; }
html.loading { cursor: progress; }
/* a second, quieter choice under a form (Not now, Forgot the PIN): apart from its main button */
.form-page .after-form { margin-top: var(--s3); }
.phrase { font: 400 1.5rem/1.6 ui-monospace, monospace; letter-spacing: 0.08em; padding: var(--s4); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; overflow-wrap: anywhere; user-select: all; }

/* A journal line: ledger across the top, then currency and rate, then debit and credit. */
fieldset.line { grid-template-columns: 1fr 1fr; }
fieldset.line > label:first-of-type { grid-column: 1 / -1; }
/* On a phone, Debit beside Credit, then Currency beside Rate (fields: ledger, currency, debit,
   credit, rate). */
@media screen and (max-width: 767px) {
  fieldset.line > label:nth-of-type(3) { order: 1; }
  fieldset.line > label:nth-of-type(4) { order: 2; }
  fieldset.line > label:nth-of-type(2) { order: 3; }
  fieldset.line > label:nth-of-type(5) { order: 4; }
}
@media print, (min-width: 768px) {
  /* One row per line on a desktop: ledger, currency, debit, credit, rate. */
  fieldset.line { grid-template-columns: 2fr 0.8fr 1fr 1fr 1fr; align-items: end; }
  fieldset.line > label:first-of-type { grid-column: auto; }
}

button.wide, .button.wide { width: 100%; max-width: 560px; justify-content: center; text-align: center; }

/* Light | Dark | Auto */
.theme-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s1); max-width: 560px; }
.theme-switch button { min-height: 44px; padding: 0 var(--s2); border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 400; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------ dashboard */

.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--s3) var(--s5); margin-bottom: var(--s4); }
.dash-head h1 { margin: 0; }
.dash-head p { margin: var(--s1) 0 0; }
.quick { display: flex; flex-wrap: wrap; gap: var(--s2); }
@media screen and (max-width: 767px) { .quick { display: grid; grid-template-columns: 1fr 1fr; } } /* 2 x 2, never 3 + 1 */
/* Cards take as many columns as fit at their least width and wrap (as Frappe's number cards); a
   card's figures size to the card itself, never to the window (owner review 3). */
.kpis { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); margin-bottom: var(--s4); }
.kpi { padding: var(--s4) var(--s4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.kpi h2 { margin: 0 0 var(--s2); font-size: 16px; color: var(--muted); font-weight: 400; }
.kpi .figures { display: grid; gap: var(--s1); }
.kpi .amount { text-align: left; font-size: 19px; font-weight: 400; }
.kpi.lead { border-top: 4px solid var(--accent); }
.kpi .amount.big { font-size: 28px; }
.kpi .amount.pos { color: var(--green); }
.kpi details { margin-top: var(--s2); }
.kpi summary { min-height: 44px; display: flex; align-items: center; color: var(--accent); font-weight: 400; cursor: pointer; }
.kpi .where { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; border-top: 1px solid var(--line); }
.kpi .where .amount { font-size: 16px; }
.home { display: grid; gap: var(--s3); }
.home > * { min-width: 0; }
.kpi { border-top: 4px solid transparent; } /* every card the same height of top edge */
.panel { padding: var(--s2) 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s2) var(--s4); }
.panel-head h2 { margin: 0; font-size: 19px; }
.panel-head a { min-height: 44px; display: inline-flex; align-items: center; font-weight: 400; text-decoration: none; }
.panel > p { padding: 0 var(--s4); }
/* A transaction row: what and its amount on top, the date under it, then From -> To. desk.css
   lays the same parts out as one table row. */
.tx { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what amt" "date amt" "flow flow"; column-gap: var(--s4); padding: var(--s3) var(--s4); border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.tx-what { grid-area: what; min-width: 0; overflow-wrap: anywhere; }
.tx-date { grid-area: date; color: var(--muted); font-size: 14px; }
.tx .flow { grid-area: flow; min-width: 0; overflow-wrap: anywhere; }
.tx-amount { grid-area: amt; }
.tx:hover { background: var(--accent-soft); }
.tx .flow { color: var(--muted); font-size: 14px; }
.tx-amount { display: grid; justify-items: end; align-content: start; white-space: nowrap; font-weight: 400; }
/* A statement in a narrow desktop window: each amount's currency and Dr/Cr go under it, so
   Particulars keeps its room. */
@media screen and (min-width: 1180px) and (max-width: 1279px) {
  table.statement td.amount .cur { display: block; }
}

/* ------------------------------------------------------------ invoices (after Ledger's redesign) */

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.page-head h1 { margin: 0; }

/* Reports (§8): group headings, the total under a rule, the balance check; on phones each row
   is a card (table.stack) and an entry's lines sit under its voucher. */
table.report tr.group, table.report tr.group td { font-weight: 400; background: var(--page); }
table.report tr.subtotal td { font-weight: 400; }
table.report tr.total td { font-weight: 400; }
table.report.compact { max-width: 760px; margin-bottom: var(--s4); } /* name and figure stay close */
.ok-line { color: var(--green); font-weight: 400; }
.plain-list { padding-left: var(--s4); color: var(--muted); }
table.day-book tr.entry-head td { padding-top: var(--s2); }
table.day-book tr.entry-line td { border-bottom: 0; padding-top: var(--s1); padding-bottom: var(--s1); }
table.day-book tr.entry-line td.lead { font-weight: 400; padding-left: var(--s4); }
/* a single date (trial balance, balance sheet): the field and Show, not the ‹ From Till › grid */
.period.one { grid-template-columns: 1fr; }
/* rules go on rows, not cells: on phones the cells of one row are a card's lines */
@media print, (min-width: 768px) { .period.one { grid-template-columns: 12em auto; } }
@media print, (min-width: 1000px) {
  table.report tr.total td { border-top: 2px solid var(--ink); }
  table.day-book tbody.entry tr.entry-head td { border-top: 1px solid var(--line); }
}
@media screen and (max-width: 999px) {
  table.report tr.total { border-top: 2px solid var(--ink); }
  table.day-book tbody.entry { border-top: 1px solid var(--line); }
  table.day-book tr.entry-head, table.day-book tr.entry-line { border-bottom: 0; }
  table.day-book tr.entry-line { padding-top: 0; }
}
@media print { table.day-book tbody.entry { break-inside: avoid; } }

[hidden] { display: none !important; } /* sections the invoice type doesn't use */

/* Goods sale | Logistics, and the income switch: one row of segments. The text sits in a span
   after the radio, so the chosen one shows everywhere (no :has(), older Safari too). */
fieldset.segmented { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.segmented .track { display: flex; flex-wrap: wrap; gap: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; } /* M129: an outlined bar, the chosen part solid green */
fieldset.segmented legend { padding: 0 0 var(--s1); font-weight: 400; font-size: 14px; } /* M131: as every label */
fieldset.segmented label { flex: 1 1 auto; position: relative; cursor: pointer; }
fieldset.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
fieldset.segmented span { min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 0 var(--s3); border-radius: 6px; font-weight: 400; color: var(--muted); text-align: center; }
fieldset.segmented input:checked + span { background: var(--accent); color: var(--on-accent); }
fieldset.segmented input:focus-visible + span { outline: 3px solid var(--accent); }
fieldset.income { background: none; padding: 0; gap: var(--s2); }
fieldset.income label { flex: 0 1 auto; }
fieldset.income span { border: 1px solid var(--line); background: var(--surface); }
fieldset.income input:checked + span { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Trucking / Sea freight: two tick cards side by side, coloured only when ticked. */
.ticks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
label.tick { position: relative; cursor: pointer; }
label.tick input { position: absolute; left: var(--s3); top: 15px; width: 22px; height: 22px; min-height: 22px; accent-color: var(--accent); }
label.tick span { min-height: 52px; display: flex; align-items: center; padding: 0 var(--s3) 0 calc(var(--s6) + var(--s3)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-weight: 400; }
label.tick input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
label.tick input:focus-visible + span { outline: 3px solid var(--accent); }

/* Two fields side by side on a phone too (Date + Currency; Quantity, Unit, Rate), as in the
   Ledger redesign; a name (Bill to) and a line's description take the whole row. */
.pair, .triple { display: grid; gap: var(--s3); grid-template-columns: 1fr 1fr; align-items: start; }
/* Each label shares the row's tracks (text, field, hint), so a two-line label or a date's hint
   never lowers the field beside it (owner review 2). */
@supports (grid-template-rows: subgrid) {
  /* BUGS M51: no row gaps here (gaps around an empty hint row gave 20 px, Firefox 28, under a
     field with no hint): the field and its hint keep 4 px by a margin, and a label's bottom margin
     lands under its lowest part, field or hint, so rows are 16 px apart, as in a form.stack */
  .pair, .triple { row-gap: 0; margin-bottom: calc(-1 * var(--s4)); }
  .pair > label, .triple > label { grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; margin-bottom: var(--s4); }
  .pair > label > :not(.term), .triple > label > :not(.term) { margin-top: var(--s1); }
  /* WebKit put that margin inside an empty hint row (the field spilled 16 px past its label, measured
     19/11/2026): an empty mark keeps every hint row taken, as under a date */
  .pair > label::after, .triple > label::after { content: ""; grid-row: 3; }
  /* Firefox gives the field's row the 8 px by which the two gaps differ and stretched the field
     to 52 px (measured 15/11/2026; WebKit: 44): a field keeps its own height */
  .pair > label > *, .triple > label > * { align-self: start; }
}
.pair > *, .triple > * { min-width: 0; }
.row-card.line { grid-template-columns: 1fr 1fr; row-gap: var(--s4); } /* M51: as every form's fields */
.row-card.line .desc { grid-column: 1 / -1; }
td.lead, .row-card { overflow-wrap: anywhere; }
td.date, td[data-label="Date"], td.voucher, td.amount { white-space: nowrap; }
.entry-facts { display: grid; gap: var(--s1); margin: 0 0 var(--s4); }
.entry-facts p { margin: 0; }
.narr { font-size: 14px; } /* a narration under its entry: a quieter line, mostly one line long */
.period label, .period input { min-width: 0; }
@media (min-width: 768px) {
  .pair { grid-template-columns: 1fr 1fr; }
  .triple { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) { /* one row per line only where the middle panel has the room */
  .row-card.line { grid-template-columns: 3fr 1fr 1fr 1.4fr; }
  .row-card.line .desc { grid-column: auto; }
}
.card { display: grid; gap: var(--s3); padding: var(--s4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card h2, .card h3 { margin: 0; }
.card h3 { font-size: 16px; color: var(--muted); }
.rows { display: grid; gap: var(--s2); }
.row-card { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--page); }
button.add { justify-self: start; min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); color: var(--accent); font-weight: 400; }
details.more summary { min-height: 44px; display: flex; align-items: center; color: var(--accent); font-weight: 400; cursor: pointer; }
details.more[open] summary { margin-bottom: var(--s2); }

/* ------------------------------------------------------------ printing any page */

/* Owner (30/10/2026): every page prints on A4, whatever the screen. The page is laid out 18 cm
   wide (A4 less 1.5 cm margins), black on white, without menus, buttons or forms; tables keep
   their desktop columns, headings repeat and rows don't split. Statements and vouchers have
   their own print pages (print.css); this covers the browser's Print on any other page. */
/* UI audit (31/10/2026): long names and big figures wrap instead of pushing past the screen;
   a phone turned sideways keeps clear of the notch; voucher links are big enough to tap; a
   field scrolled to stays clear of the bars. */
html {
  scroll-padding-top: calc(var(--nav-h) + var(--s2) + env(safe-area-inset-top));
  scroll-padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + var(--s4));
}
h1 { overflow-wrap: anywhere; }
.ledger-list a > * { min-width: 0; overflow-wrap: anywhere; }
/* the number never breaks; in a card too narrow the currency goes under it, never out of the card */
.kpi .amount { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--s1); white-space: nowrap; font-size: 19px; }
.kpi .amount.big { font-size: clamp(20px, 7vw, 28px); }
main {
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.bottom-nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.sidebar :focus-visible { outline-color: var(--accent); }
td.voucher a, td.lead > a:first-child { display: inline-block; padding: var(--s3) 0; margin: calc(-1 * var(--s3)) 0; }
.actions.grid > form, .actions.grid > form > button { width: 100%; }
@media screen and (max-width: 999px) {
  table.stack td { flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
  table.stack td > div { flex-basis: 100%; text-align: right; }
}
@media screen and (max-width: 1179px) { /* M43: the statement's cards */
  table.statement td { min-width: 0; overflow-wrap: anywhere; }
  table.statement td.phone-amount .cur { display: block; }
}

@page { size: A4 portrait; margin: 15mm; }

@media print {
  /* Black on white whatever the theme: the dark theme's selectors are stronger than :root. */
  :root, :root[data-theme] {
    --accent: #145c43;
    --amber: #8f5a00;
    --side: #fff;
    --ink: #1a1a1a;
    --muted: #5f6672;
    --line: #d5d9e0;
    --surface: #fff;
    --page: #fff;
    --green: #1a1a1a;
    --red: #1a1a1a;
    color-scheme: light;
  }
  body { padding: 0; background: #fff; font-size: 9pt; }
  .sidebar, .quick, .theme-switch { display: none !important; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .amount, .kpi .amount.big { font-size: 12pt; }
  .panels { grid-template-columns: 1fr; }
  main { width: 180mm; max-width: none; margin: 0; padding: 0; }
  .top, .bottom-nav, .actions, .period, .print-link, .search, form, button, .button,
  details.optional summary { display: none !important; }
  a { color: inherit; text-decoration: none; }
  h1 { font-size: 16pt; }
  th { position: static; font-size: 8pt; }
  th, td { padding: 1.5mm 2mm; font-size: 9pt; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  table, .card, .position, .kpi, .panel { box-shadow: none; }
  .kpi summary, .panel-head a { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* (i) beside a professional term: one plain sentence, on tap. The tap area is 44 px; the mark is small. */
.term { display: inline-flex; align-items: center; gap: var(--s1); }
.i {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 44px; min-width: 44px; height: 44px; min-height: 44px; margin: calc(-1 * var(--s3)) calc(-1 * var(--s2)); padding: 0;
  color: var(--muted); cursor: pointer;
}
.i span {
  display: block; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%;
  font: 400 11px/14px var(--head); text-align: center;
}
.i:hover, .i[aria-expanded="true"] { color: var(--accent); }
.tip {
  display: block; margin-top: var(--s1); color: var(--muted); font-size: 14px; font-weight: 400;
  text-transform: none; letter-spacing: normal; white-space: normal; text-align: left;
}
@media print { .i, .tip { display: none; } }

.currency-list { list-style: none; margin: var(--s2) 0 var(--s4); padding: 0; }
.currency-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: 44px; border-bottom: 1px solid var(--line);
}

/* ---- T-account view switch (SPEC §7.1, prototype #tswitch): the server draws both layouts;
   startup.js puts data-tview on <html> before drawing, so only one ever shows. */
.sheet-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s2) 0 var(--s4); }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; cursor: pointer; margin-left: auto; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; }
.switch .track { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--field-line); flex: 0 0 auto; transition: background 0.15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .knob { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }
.t-view { display: none; }
:root[data-tview="on"] .t-view { display: block; }
:root[data-tview="on"] .sheet-view { display: none; }
.t-view { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; margin-bottom: var(--s4); }
.t-brought { margin: 0; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.t-sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.t-side { min-width: 0; }
.t-dr { border-right: 1px solid var(--line); }
.t-side h3 { margin: 0; padding: var(--s2) var(--s3); font-size: 14px; border-bottom: 1px solid var(--line); background: var(--page); }
.t-row { display: grid; gap: var(--s1); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 44px; }
.t-row:hover { background: var(--accent-soft); }
.t-when { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.t-what { overflow-wrap: anywhere; }
.t-row .amount { font-variant-numeric: tabular-nums; font-weight: 400; }
.t-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s3); background: var(--accent-soft); }
.t-foot .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media print { .switch { display: none; } }

/* A recent transaction's amount keeps its currency beside it (UI review, Stage 7). */
.tx-amount .amount { white-space: nowrap; }
/* Home's Sign out sits at the right end, like Home on the other pages (UI review). */
.top .out { justify-self: end; }

/* Home's backup reminder (SPEC §6.3): always there; amber (.warn) when a new download is due. */
.backup-reminder { margin: var(--s3) 0; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.backup-reminder a { display: inline-block; min-height: 44px; line-height: 44px; margin-left: var(--s1); }
.backup-reminder.warn { background: var(--amber-soft); border-color: var(--amber); }


/* A More menu (owner review 4): a button that opens a short list of rarely used tools */
details.menu { position: relative; }
details.menu > summary { list-style: none; width: 100%; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::after { content: "▾"; margin-left: var(--s1); font-size: 12px; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 13rem;
  display: grid; padding: var(--s1); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(20, 30, 50, 0.12);
}
.menu-pop a { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s3); border-radius: 6px; color: var(--ink); text-decoration: none; }
.menu-pop a:hover, .menu-pop a:focus-visible { background: var(--accent-soft); color: var(--accent); }

/* Settings > Guide (owner review 4): the explanations taken off the forms, one term a row */
.guide-toc { display: flex; flex-wrap: wrap; column-gap: var(--s4); margin: 0 0 var(--s2); }
.guide-toc a { display: inline-flex; align-items: center; min-height: 44px; }
.guide dl { margin: 0; border-top: 1px solid var(--line); }
.guide dl > div { display: grid; gap: var(--s1) var(--s5); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.guide dt { font-weight: 400; }
.guide dd { margin: 0; color: var(--muted); }
@media screen and (min-width: 768px) { .guide dl > div { grid-template-columns: 12rem minmax(0, 1fr); } }

/* ==== 1.1.0 ==== */
/* ---- FIXES TO EXISTING APP RULES (Stage 15 item 34a, from the mockup; each with its BUGS.md ID) ---- */

/* C3: the help "i" sits inside headings set in capitals, so it showed as "I" */
.i, .i span { text-transform: none; }

/* N7 (shots 04, 08): the DD/MM/YYYY hint sat beside "From" and broke onto two lines; it goes under the field */
.period label > .hint, label > .hint { grid-row: auto; grid-column: 1 / -1; justify-self: start; white-space: nowrap; }
/* 04, N7: with the hint under the field, the buttons of a date row stay on the field's own row (label, field, hint: three shared rows) */
@supports (grid-template-rows: subgrid) {
  @media print, (min-width: 768px) {
    .period { grid-template-rows: auto auto auto; row-gap: var(--s1); }
    .period > label { grid-row: 1 / span 3; grid-template-rows: subgrid; align-items: stretch; } /* not baseline: WebKit's first layout drew the field 10 px above its row */
    .period > .button, .period > .show { grid-row: 2; }
  }
}

/* M68, BUGS M91 (owner 19/11/2026, Attempt 2's net-cash-position picture): from 768 px the period bar is
   one short row, ‹ From [date] To [date] › Show: the label beside its box, each box as wide as a date
   (10 digits and its padding), one small step (12 px) from one box to the next label. M121
   (trial-balance-desktop-a2): a single date (.one) is the same short row, On [date] Show. Phones keep
   their rows. */
@media screen and (min-width: 768px) {
  .period { grid-template-columns: 44px auto auto 44px auto; grid-template-rows: none; column-gap: var(--s3); align-items: center; justify-content: start; }
  .period.one { grid-template-columns: auto auto; }
  .period > label { grid-row: auto; grid-template-rows: none; display: flex; align-items: center; gap: var(--s2); }
  .period > .button, .period > .show { grid-row: auto; }
  .period .date-box { flex: none; width: calc(10ch + var(--s5) + var(--s2)); }
}

/* 01, 02, C1: stacked or side-by-side buttons always 12 px apart, primary first */
.button-group { display: flex; flex-wrap: wrap; gap: var(--s3); margin-top: var(--s4); }
.button-group.stack { flex-direction: column; }
.button-group > * { margin: 0; }

/* C6: the index panel's background reaches the bottom of a long page */
.sidebar, .right { min-height: 100%; align-self: stretch; }

/* N14: the four position cards on Home sit 4 across, or 2 by 2 when the page is narrow (never 3 + 1) */
/* Home as its approved picture (owner 21/11/2026, BUGS M93): the quick buttons in the head (a phone keeps
   Receipt and Payment), Latest entries one line per row with a voucher tag, This month a panel beside
   them from 1180 px (the work area has the full width since the details panel opens only on request). */
.page-head { flex-wrap: wrap; }
.quick { display: flex; flex-wrap: wrap; gap: var(--s2); }
.quick .button { gap: var(--s2); }
.quick .dot { display: inline-block; width: 8px; height: 8px; border: 2px solid var(--accent); border-radius: 50%; box-sizing: content-box; }
.quick .dot.receipt { background: var(--accent); }
.quick .dot.payment { background: var(--amber); border-color: var(--amber); }
@media screen and (max-width: 767px) {
  .quick { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .quick .more { display: none; }
}
.home-cols { display: grid; gap: var(--s5); align-items: start; }
/* M122 (home-desktop-a2): LATEST ENTRIES / THIS MONTH are small grey capital labels, as POSITION AT */
.home-cols h2 { margin: var(--s4) 0 var(--s3); font-size: 12px; line-height: 16px; letter-spacing: 0.08em; color: var(--muted); }
.home-latest .day-book { display: flex; justify-content: flex-end; margin: 0; }
.home-latest .day-book a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
@media screen and (min-width: 1180px) {
  .home-cols:not(.solo) { grid-template-columns: minmax(0, 1fr) 300px; }
}
.home-latest, .home-month { min-width: 0; }
@media screen and (min-width: 1000px) {
  /* M108: Date, Voucher and Amount take the room their text needs (a Conversion's amount is two figures);
     the Entry takes the rest and wraps in it (width 100% and max-width 0 do that; M168: never cut). */
  .home-latest td.lead { width: 100%; max-width: 0; }
}
.home-latest td.voucher { white-space: nowrap; }
.home-latest a.tag { display: inline-block; padding: var(--s1) var(--s2); text-decoration: none; }
/* Under 1000 px a row is a card of two lines (the plan's target for a phone): the date, the voucher and
   the amount on the first, what the entry is on the second (cut after two lines) */
@media screen and (max-width: 999px) {
  /* M119: a row that wraps: date and voucher, the amount on the right when it fits beside them (else on its
     own line, still on the right), then the entry; the largest figure never runs over the voucher */
  .home-latest tbody tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s3); }
  .home-latest table.stack td { display: block; width: auto; padding: var(--s1) 0; text-align: left; }
  .home-latest table.stack td::before { content: none; }
  .home-latest table.stack td.amount { order: 1; max-width: 100%; margin-left: auto; text-align: right; }
  .home-latest table.stack td.lead { order: 2; flex: 1 0 100%; min-width: 0; }
  .home-latest .one-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow: hidden; text-overflow: ellipsis; }
}
/* M108: a conversion's two figures ("AED 6,000 › PKR 453,000") are too wide to share a line with the date and
   voucher on a phone: its card is date and voucher, the entry, then the amount on its own line */
@media screen and (max-width: 999px) {
  .home-latest tbody tr.two-figures td.amount { order: 3; flex: 1 0 100%; }
}
table.month tr.cur, table.month tr.cur th { background: var(--page); text-align: left; }
table.month th[scope="row"] { background: none; text-align: left; font-weight: 400; color: var(--muted); }

/* The Net Cash Position report's tables (owner 20/11/2026, first Home's): a row per word, Net Cash Position bold under a
   rule. Each row lists every currency on its own line, in the same order, so figures line up
   from row to row on any width and with any number of currencies. */
table.position { margin-top: var(--s4); }
table.position th { position: static; }
table.position th[scope="row"] { width: 40%; background: none; vertical-align: top; }
table.position th[scope="row"] > a { color: var(--accent); text-decoration: none; }
table.position th[scope="row"] > a:hover { text-decoration: underline; }
table.position th.name { color: var(--ink); } /* a row name that opens nothing (the report) */
table.position .with { display: block; margin-top: var(--s1); font-size: 12px; color: var(--muted); text-transform: none; letter-spacing: 0; }
table.position td.figures { padding-top: var(--s3); padding-bottom: var(--s3); text-align: right; }
table.position .line { display: block; font-size: 19px; line-height: 32px; }
table.position tr.total th, table.position tr.total td { border-top: 2px solid var(--ink); border-bottom: 0; }
table.position tr.total .line, table.position tr.total .line .amount,
table.position tr.total th > a, table.position tr.total th.name { font-weight: 700; }
/* a narrow phone: each row's name above its figures, so a 15-digit figure has the full width */
@media screen and (max-width: 480px) {
  table.position thead { display: block; } /* M122 (home-phone-a2): POSITION AT <date> stays */
  table.position thead th + th { display: none; }
  table.position, table.position tbody, table.position tr, table.position th, table.position td { display: block; width: auto; }
  table.position th[scope="row"] { width: auto; padding-bottom: 0; border-bottom: 0; }
  table.position td.figures { padding-top: var(--s1); }
  table.position tr.total td { border-top: 0; }
  table.position .line { font-size: 16px; line-height: 28px; }
}
/* Home's position (M150, owner 22/11/2026, home-desktop-a2 / home-phone-a2): a row per currency and
   a column per word (each word opens its page), Net Cash Position bold. A phone: a box per
   currency, its code on top, a line per word, Net Cash Position under a rule (as the pictures; to
   1279 px, where five columns with a 15-digit figure do not fit beside the side menu). Never
   added across currencies. */
.home-pos .eyebrow { margin: 0 0 var(--s3); }
.home-pos { margin-top: var(--s5); } /* 24 px under the notices (a phone 16), as the pictures */
@media screen and (max-width: 767px) { .home-pos { margin-top: var(--s4); } }
.home-pos table.position { margin: 0; table-layout: fixed; }
.home-pos table.position th { position: static; }
.home-pos table.position thead th:first-child { width: 112px; }
.home-pos table.position thead a { color: inherit; text-decoration: none; }
.home-pos table.position th.cur-cell { color: var(--ink); background: none; font-size: 15px; }
.home-pos table.position .ph-word { display: none; }
.home-pos table.position td.fig { text-align: right; white-space: nowrap; }
.home-pos table.position td.total strong, .home-pos table.position td.total .amount { font-weight: 700; }
.pos-note { margin: var(--s2) 0 0; font-size: 13px; color: var(--muted); }
@media screen and (max-width: 1279px) {
  .home-pos table.position, .home-pos table.position tbody { display: block; border: 0; background: none; overflow: visible; }
  .home-pos table.position thead { display: none; }
  .home-pos table.position tr { display: block; margin: 0 0 var(--s4); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
  .home-pos table.position th.cur-cell { display: flex; align-items: center; min-height: 56px; padding: 0 var(--s4); border-bottom: 1px solid var(--line); background: var(--page); letter-spacing: 0.06em; }
  .home-pos table.position td { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; column-gap: var(--s3); min-height: 40px; padding: 0 var(--s4); border-bottom: 1px solid var(--line); font-size: 14px; text-align: right; }
  .home-pos table.position td.total { border-bottom: 0; border-top: 2px solid var(--ink); }
  .home-pos table.position .amount { margin-left: auto; }
  .home-pos table.position .ph-word { display: inline-flex; align-items: center; min-height: 40px; flex: 0 0 auto; color: var(--muted); text-align: left; text-decoration: none; }
  .home-pos table.position td.total .ph-word { color: var(--ink); }
  .home-pos table.position th, .home-pos table.position td { width: auto; }
}
@media screen and (min-width: 1280px) and (max-width: 1399px) { .home-pos table.position .money.long { font-size: 12px; } } /* five columns, no room for 15 digits (a2 snug) */
@media print { /* A4 keeps the table (its headings repeat); a 15-digit figure fits its column */
  .home-pos table.position thead th:first-child { width: 48px; }
  .home-pos table.position th, .home-pos table.position td { padding-left: var(--s1); padding-right: var(--s1); }
  .home-pos table.position .money.long { font-size: 10px; }
}
.home-pos table.position th[scope="row"] { width: auto; vertical-align: middle; }

/* S1 (owner 09/11): fields and lists use the page font with the same settings as the text */
input, select, textarea, button { font-family: inherit; font-feature-settings: inherit; }

/* N11: the balance line overlapped the field above it. M72: 4 px under its box (inside .side-box, whose
   gap is 4 px; step 19a). Empty, it leaves the grid (a grid item keeps its gap even at 0 px) but stays
   in the page, so its news is still read out. A negative margin here (step 18) put it over a picker
   button wherever no grid gap lay under it: removed (the hooks test of the mockup found it) */
.check-line:empty { position: absolute; margin: 0; }

/* M87 (step 19a, owner 20/11/2026): Receipt, Payment, Entry and Conversion as their approved pictures
   (Workups - Attempt 2): 4 columns on a phone, 8 on a computer. A ledger and its balance line are one
   item (.side-box), the line 4 px under its box. One currency (.one): Date, Amount, Currency in a row
   (phone: Date beside Currency, Amount under), then the two ledgers side by side. Conversion (.conv):
   Date alone, From and To, then Amount, Currency, Other amount, Other currency, then Enter and Rate,
   with no box around them. The date's format line is for screen readers only, as in the pictures. */
.form-page.laid-page { max-width: 720px; } /* the pictures' form is 664 px: room for a date (M68) */
/* Owner 21/11/2026: DD/MM/YYYY dimmed inside the date box; the typed part covers its letters (the
   same text, transparent, so each digit sits where its letter was) */
.date-box { position: relative; display: block; min-width: 0; }
.date-mask { position: absolute; inset: 0; display: flex; align-items: center; padding: var(--s2) var(--s3);
  border: 1px solid transparent; font-size: 16px; color: var(--muted); opacity: 0.7; white-space: pre; overflow: hidden; pointer-events: none; }
.date-mask[hidden] { display: none; }
.date-mask i { font-style: normal; color: transparent; }
.side-box { display: grid; gap: var(--s1); align-content: start; min-width: 0; }
.side-box > .check-line { margin: 0; }
form.entry-form.laid { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: var(--s4); }
form.entry-form.laid.one { grid-auto-flow: row dense; }
form.entry-form.laid .convert { display: contents; }
form.entry-form.laid .field-date { grid-column: 1 / span 2; }
form.entry-form.laid.one .field-currency { grid-column: 3 / span 2; }
form.entry-form.laid.one .field-amount { grid-column: 1 / -1; }
form.entry-form.laid.conv .field-amount, form.entry-form.laid.conv .field-currency,
form.entry-form.laid .field-other_amount, form.entry-form.laid .field-other_currency,
form.entry-form.laid .field-by, form.entry-form.laid .field-rate { grid-column: auto / span 2; }
@media (min-width: 1024px) { /* under 1024 px the eight columns leave a date 104 px (found by the audit at 768 px) */
  form.entry-form.laid { grid-template-columns: repeat(8, minmax(0, 1fr)); column-gap: var(--s5); }
  form.entry-form.laid.one .field-amount { grid-column: 3 / span 4; }
  form.entry-form.laid.one .field-currency { grid-column: 7 / span 2; }
  form.entry-form.laid .fields > .side-box { grid-column: auto / span 4; }
  form.entry-form.laid .field-date + .side-box { grid-column: 1 / span 4; }
  /* M129: an opening's Balance side beside its Ledger; a change's reason on the left half */
  form.entry-form.laid .field-side { grid-column: auto / span 4; }
  form.entry-form.laid .field-reason { grid-column: 1 / span 4; }
}

/* N12: tabs never look like links (two were underlined, one not) */
.tabs a.tab { text-decoration: none; }

/* N13: on a phone a button group is full width (Save was full width, Cancel small). M74/M86 (owner
   19/11/2026): a form's Cancel and Save (.pair) share one row, equal halves, Cancel first. Where half
   the row is under 156 px (the widest short label, "Confirm and save", measured 153 px) or the label is
   longer (.wide: "Save opening balance"), Save takes its own full row under Cancel, as M74's picture.
   Other groups stack, the main button first */
@media screen and (max-width: 767px) {
  .button-group { flex-direction: column; } .button-group.cancel-first { flex-direction: column-reverse; }
  .button-group > * { width: 100%; }
  .button-group.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 156px), 1fr)); }
  .button-group.pair.wide { grid-template-columns: 1fr; }
  .button-group.pair > * { padding-left: var(--s2); padding-right: var(--s2); }
}
.dialog-actions.button-group, .actions.button-group { justify-content: flex-end; gap: var(--s3); }

/* S1: the help "i" and the passphrase on the scale (both were set through a "font:" shorthand) */
.i span { font: 400 12px/14px var(--head); }
.phrase { font-size: 19px; }

/* S1: currency code and Dr/Cr are the size of their amount ("AED 1,234 Dr" is one size) */
.amount .cur, .amount .side, .money .cur, .money .side, .cur, .side { font-size: inherit; }

/* S1: the help "i" on the scale */
.i { font-size: 12px; }

/* ---- NEW COMPONENTS (Stage 15 item 34a) ---- */

/* Back link above a page title (05, 12, B7) */
.back-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 400; text-decoration: none; }
/* N10: one back control per screen size: the phone header's back on phones, the page's on desktop
   (this rule must follow the one above, or the one above wins) */
@media screen and (max-width: 767px) { .back-link { display: none; } }

/* Title above a group of choices (same look as a field label) */
.field-title { display: block; margin: 0 0 var(--s1); font-weight: 400; font-size: 14px; }

/* Picker button: looks like a text field, opens the app's list (15) */
.picker-btn { display: block; width: 100%; min-height: 44px; padding: 0 calc(var(--s6) + var(--s1)) 0 var(--s3); border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--surface) var(--select-arrow) no-repeat right 14px center; color: var(--ink); font-size: 16px; font-weight: 400; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-list [role="option"] { flex-wrap: wrap; }

/* Segmented choice: equal parts, one line each (S3) */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--field-line); border-radius: var(--radius); overflow: hidden; }
.seg > * { display: grid; place-items: center; min-height: 44px; padding: 0 var(--s2); font-weight: 400; font-size: 14px; white-space: nowrap; color: var(--ink); background: var(--surface); text-decoration: none; }
.seg > [aria-checked="true"], .seg > [aria-current] { background: var(--accent); color: var(--on-accent); }

/* N16: a choice with 4 or more parts wraps into equal parts on a narrow screen (Day book, History) */
@media screen and (max-width: 480px) {
  .seg.many { display: grid; grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
}

/* Tick box with its term (Custodial account, Conversion) */
.tick-row { display: flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 400; }
.tick-row input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--accent); }

/* Ledger picker drawn by the app, in the app's font (15, B5, 13): no "Choose", headings not choosable */
.picker { position: relative; }
.picker-list { list-style: none; margin: var(--s1) 0 0; padding: var(--s1) 0; border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.picker-list .group { padding: var(--s2) var(--s3) var(--s1); font-size: 12px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.picker-list [role="option"] { display: flex; justify-content: space-between; gap: var(--s3); min-height: 44px; align-items: center; padding: 0 var(--s3); }
@media (hover: hover) { .picker-list [role="option"]:hover { background: var(--line); } }
.picker-list [aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 400; }
.picker-list .bal { color: var(--muted); font-size: 14px; white-space: nowrap; }
.picker-list .add { color: var(--accent); font-weight: 400; }
/* The live list (picker.js) lies over what follows and never moves the form (M5); it scrolls when long */
label.picker > .picker-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; max-height: 272px; overflow-y: auto; font-size: 16px; cursor: pointer; }
.has-error .picker-btn { border-color: var(--red); }

/* Balance of a ledger at today, with its word (B3, 14) */
/* BUGS M48: Receivable and Payable (or Cash held and Payable) always side by side; a figure
   steps down in size as it grows (shell.css .mid, .long) so it fits its card */
.balance-now { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); margin: var(--s3) 0; }
.balance-now > div:only-child { grid-column: 1 / -1; }
/* a phone: one card above the other, as before M48 (side by side, a 6-digit balance no longer
   fits at 320 px); up to 767 px also when a figure has 11 digits or more (measured 16/11) */
@media screen and (max-width: 479px) { .balance-now { grid-template-columns: minmax(0, 1fr); } }
@media screen and (max-width: 767px) { .balance-now.has-big { grid-template-columns: minmax(0, 1fr); } }
.balance-now .none { display: block; }
.balance-now > div { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s2) var(--s3); background: var(--surface); }
.balance-now .word { display: block; font-size: 14px; color: var(--muted); }
.balance-now .amount { display: block; font-size: 19px; font-weight: 400; white-space: nowrap; } /* M44: each currency on its own line */

/* One-row ledger toolbar (04, 08, C2): the Period list, Statement and ⋯; their boxes open under the row, inside its width */
.toolbar-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s2); align-items: end; margin: var(--s3) 0; }
.toolbar-row > form { display: flex; gap: var(--s2); margin: 0; }
.toolbar-row > form > label { flex: 1 1 auto; min-width: 0; }
.toolbar-row details.menu { position: static; }

/* Net Change arrows (owner 09/11: green up, red down) */
.up { color: var(--green); } .down { color: var(--red); }

/* The Conversion form's box (A3, owner 09/11: the box not selected is filled by the server; Q26) */
.convert { border: 1px solid var(--accent); border-radius: var(--radius); padding: var(--s3); display: grid; gap: var(--s4) var(--s3); } /* M51: fields 16 px apart, as in every form */
.field-error:empty { display: none; }

/* Latest entries on Home (Q1) and History rows: date and number on one line */
.nowrap { white-space: nowrap; }


/* Net Cash Position: six columns of amounts fit the middle panel only from 1280 px (the largest
   amount, §19.2); below that its rows are stacked, as table.stack does up to 999 px */
@media screen and (min-width: 1000px) and (max-width: 1279px) {
  table.net-cash thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.net-cash, table.net-cash tbody, table.net-cash tr, table.net-cash td { display: block; width: 100%; }
  table.net-cash tr { border-bottom: 1px solid var(--line); padding: var(--s2) var(--s3); }
  table.net-cash td { border: 0; padding: var(--s1) 0; display: flex; justify-content: flex-end; align-items: baseline; gap: var(--s1); text-align: right; }
  table.net-cash td::before { content: attr(data-label); color: var(--muted); font-size: 14px; text-align: left; margin-right: auto; }
}

/* M8 (cause measured 14/11: the form's one grid column grew to its fields' own width, 327 px at
   320 px): the column may shrink */
form.stack { grid-template-columns: minmax(0, 1fr); }
/* M8: a field never grows past its column */
form.stack input, form.stack select, form.stack textarea { max-width: 100%; min-width: 0; box-sizing: border-box; }
/* M8, cause: a field's hint was set not to wrap (white-space: nowrap, 327 px) and stretched the label past a 320 px screen */
form.stack label > .hint { white-space: normal; }

/* BUGS M105 (step 33): the invoice's Sea freight and Trucking sections: the On/Off switch sits in the
   heading, off folds the body; "Bill to someone else" is a link under Bill to, not a box. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.fold { display: grid; gap: var(--s3); }
.switch input:checked ~ .off, .switch input:not(:checked) ~ .on { display: none; }
details.bill-else { border: 0; background: none; }
details.bill-else summary { padding: 0; }
details.bill-else .stack-inner { padding: var(--s2) 0 0; }

/* BUGS M89 (step 24a, the approved pictures): from 1280 px Will post, Save and Cancel are a column beside the
   form. The form's grid keeps its 8 columns; a 9th, outside them (so every 1 / -1 still ends at the 8th),
   holds .form-side. Narrower, and on a phone, .form-side melts away and its children sit in the form as before. */
.form-side { display: contents; }
@media (min-width: 1280px) {
  .form-page.laid-page { max-width: 1040px; }
  form.entry-form.laid { grid-auto-columns: 320px; } /* M129: the pictures' column, 320 px */
  form.entry-form.laid .form-side { display: grid; gap: var(--s3); grid-column: 9; grid-row: 1 / span 4; align-self: start; }
  form.entry-form.laid .form-side .button-group.pair { display: flex; flex-direction: column-reverse; margin: 0; }
  form.entry-form.laid .form-side .button-group.pair > * { width: 100%; }
}
