/* The prototype's layout (Stage 12): index | work | entry details, after app.css, whose tokens it
   uses. Phones (< 768 px): one column, a bottom bar (Menu | + New), the details panel over the
   whole screen. 768-1279 px: index and work; the panel slides in over the right edge. From
   1280 px: three columns. Our rules stay: 44 px targets, 12 px labels, 16 px inputs. */

/* ---- one amount format: the code small, the number, Dr/Cr; red only for a problem */
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money .cur { display: inline; margin: 0 var(--s1) 0 0; font-size: inherit; color: var(--muted); } /* S1: the size of its amount */
.side { font-size: 0.85em; color: var(--muted); }
.problem, .problem .money, .problem .cur, .problem .side, .money.problem .cur, .money.problem .side { color: var(--red) !important; }
.mini { margin-left: var(--s1); padding: 0 var(--s1); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; }
:root[data-tview] [data-nojs] { display: none; }

/* ---- the shell */
body.signed-in { padding-bottom: 0; }
.shell { min-height: 100vh; }
.work { position: relative; min-width: 0; }
.sidebar { display: none; }
.right { display: none; }
.phone-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s2); padding: calc(var(--s1) + env(safe-area-inset-top)) var(--gutter) var(--s1); background: var(--surface); border-bottom: 1px solid var(--line); }
.phone-top .brand { font-size: 19px; font-weight: 400; letter-spacing: 0.06em; color: var(--ink); text-decoration: none; }
.phone-top .back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.bottom-nav { grid-template-columns: 1fr 2fr; grid-auto-flow: row; gap: var(--s2); padding: var(--s2) var(--s2) calc(var(--s2) + env(safe-area-inset-bottom)); }
.bottom-nav a { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-weight: 400; }
.bottom-nav a.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media screen and (max-width: 767px) {
  body.signed-in { padding-bottom: calc(var(--nav-h) + var(--s2) + env(safe-area-inset-bottom)); }
  .right.open { display: block; position: fixed; inset: 0; z-index: 40; overflow-y: auto; padding: calc(var(--s3) + env(safe-area-inset-top)) var(--gutter) var(--s6); background: var(--surface); }
  body.detail-open { overflow: hidden; }
}
@media print, (min-width: 768px) {
  .bottom-nav, .phone-top { display: none; }
  .shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; padding: var(--s5) var(--s2) var(--s3); background: var(--side); border-right: 1px solid var(--line); }
  .shell main { max-width: none; margin: 0; padding: var(--s5) var(--s5) var(--s7); }
  .right.open { display: block; position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(360px, 90vw); overflow-y: auto; padding: var(--s4) var(--s4) var(--s5); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(23, 52, 46, 0.2); }
}
/* Owner 21/11/2026 (Q19, BUGS M94): the details panel is closed on every page until an entry is
   opened; it then slides over the right edge (768 px and up; a phone's is the whole screen). The
   work area keeps the full width. This replaces "three panels from 1280 px" (BUGS M16, M43). */
@media (min-width: 1280px) { .shell { grid-template-columns: 224px minmax(0, 1fr); } }

/* ---- the index */
.sidebar .brand { padding: 0 var(--s2); font-size: 19px; font-weight: 400; letter-spacing: 0.08em; color: var(--accent); text-decoration: none; }
.top-nav { display: flex; flex-direction: column; margin: var(--s3) 0 var(--s2); }
.top-nav a, .sidebar .side-out { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s2); border-radius: 7px; color: var(--side-ink); font-size: 14px; text-decoration: none; }
.top-nav a:hover, .sidebar .side-out:hover { background: var(--accent-soft); }
.top-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 400; }
.find { display: grid; gap: var(--s1); margin: var(--s1) var(--s2) var(--s1); font-size: 12px; color: var(--muted); }
.find input { min-height: 44px; font-size: 16px; }
.ledger-index { flex: 1 1 auto; }
.ledger-index h2 { margin: var(--s4) var(--s2) var(--s1); font-family: inherit; font-size: 12px; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ledger-index ul { margin: 0; padding: 0; list-style: none; }
.ledger-index a { display: flex; flex-direction: column; gap: var(--s1); min-height: 44px; padding: var(--s2) var(--s2); border-radius: 7px; color: var(--side-ink); font-size: 14px; text-decoration: none; }
.ledger-index a:hover { background: var(--accent-soft); }
.ledger-index a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 400; }
.ix-name { overflow-wrap: anywhere; }
.ix-bal { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; }
.ix-add { display: flex; align-items: center; min-height: 44px; margin-top: var(--s2); padding: 0 var(--s2); font-size: 14px; font-weight: 400; text-decoration: none; }
.rail-foot { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
.rail-foot form { margin: 0; }
.sidebar .side-out { width: 100%; border: 0; background: none; font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1) var(--s2); margin-bottom: var(--s2); font-size: 14px; color: var(--muted); }
.keys p { margin: 0; }
kbd { display: inline-block; min-width: 22px; padding: 0 var(--s1); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink); font: 400 12px/18px "Inter", system-ui, sans-serif; text-align: center; }

/* ---- the details panel */
.detail-top { margin-bottom: var(--s2); }
.close-detail { min-height: 44px; padding: 0 var(--s2); }
.eyebrow { margin: 0 0 var(--s2); font-size: 12px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.saved { margin: var(--s1) 0 var(--s3); padding: var(--s2) var(--s3); border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 400; }
.tag { display: inline-block; padding: 1px var(--s1); border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; }
.tag.payment { background: #fbefe3; color: #8a4b12; }
/* M122 (a2.css .vp): entry, conversion and opening tags outlined in the hairline grey, an invoice's in green; none filled */
.tag.entry, .tag.conversion, .tag.opening { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.tag.invoice { background: none; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
:root[data-theme="dark"] .tag.payment { background: #33271b; color: #f0b072; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .tag.payment { background: #33271b; color: #f0b072; }
}
.detail-amount { margin: var(--s2) 0 var(--s1); font-size: 28px; font-weight: 400; }
.right .flow { margin: 0; font-size: 14px; }
.right .narr { margin: var(--s1) 0 var(--s3); font-size: 14px; }
.callout-rate { margin: var(--s3) 0; padding: var(--s3); border: 1px solid var(--line); border-radius: 7px; background: var(--accent-soft); font-size: 12px; }
.callout-rate strong { display: block; margin-top: var(--s1); color: var(--accent); font-size: 16px; }
.info-row { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row span { color: var(--muted); }
.lines-h { margin: var(--s4) 0 var(--s1); font-size: 16px; }
.leg { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.leg-head { display: flex; gap: var(--s2); min-width: 0; overflow-wrap: anywhere; }
.leg-head span { color: var(--muted); }
.detail-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }
.detail-actions .button { flex: 1 1 auto; justify-content: center; }
.quiet-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--s1); font-size: 14px; color: var(--muted); }

/* ---- Home */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s3); }
.page-head h1 { margin: 0; }
.page-head p { margin: var(--s1) 0 0; }
.notices { display: grid; margin-top: var(--s4); border: 1px solid #efdfc7; border-radius: 8px; background: var(--amber-soft); font-size: 14px; }
.notices > * { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s1) var(--s3); margin: 0; padding: var(--s1) var(--s3); border: 0; border-radius: 0; background: none; color: var(--ink); }
.notices > * + * { border-top: 1px solid #efdfc7; }
/* M122 (home-desktop-a2): a dot starts each notice (red for a problem), the words dark, the link at the right */
.notices > *::before { content: ""; flex: 0 0 auto; align-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.notices > .problem-line::before { background: var(--red); }
.notices > * > span { flex: 1 1 0; min-width: 0; }
.notices > * > a { margin-left: auto; white-space: nowrap; }
.notices ul { flex-basis: 100%; margin: 0; padding-left: var(--s4); }
.notices a { display: inline-flex; align-items: center; min-height: 32px; font-weight: 400; }
/* BUGS M41: up to 999,999,999,999,999 fits Home's table, the ledger's balance and the detail at 320 px.
   BUGS M90 (M75): Home's table shrinks a long figure only up to 767 px; a computer has the room */
@media screen and (max-width: 767px) { table.position .money.long { font-size: 14px; } .home-pos table.position .money.long { font-size: 13px; } } /* M150: a Home box's figures are 14 px */
/* M136 (cash-held-phone-a2, payable-phone-a2): the lists Home's cards open keep a long figure on
   its name's row the same way, its total too */
@media screen and (max-width: 767px) { .balances-table .money.long, .ledger-box.list .closing .money.long { font-size: 14px; } }
.balance-now .amount.long, .detail-amount .money.long { font-size: 14px; }
.balance-now .amount.mid { font-size: 16px; } /* M48: 8 to 10 digits, two cards side by side */
.none { font-size: 14px; color: var(--muted); }
.page-card { margin-top: var(--s4); padding: var(--s4); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.page-card h2 { margin-top: 0; }
.last-ledger .ledger-head h2 { margin: var(--s5) 0 var(--s2); }

/* ---- statements */
.ledger-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); }
.ledger-title p { margin: var(--s1) 0 0; }
.opening-line { font-size: 14px; }
/* M95: a phone shows each opening balance as a line under the cards; a computer has them in the ⋯ menu */
.menu-pop a.opening-item { display: none; }
@media screen and (min-width: 768px) {
  .opening-fold, .switch.in-menu { display: none; }
  .menu-pop a.opening-item { display: flex; flex-wrap: wrap; gap: 0 var(--s1); padding-top: var(--s2); padding-bottom: var(--s2); }
}
.opening-line a { display: inline-flex; align-items: center; min-height: 32px; color: var(--muted); }
.ledger-head .switch { margin-left: 0; white-space: nowrap; flex-shrink: 0; }
.statement-box .box { width: min(340px, 90vw); padding: var(--s3); }
.presets { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); margin-bottom: var(--s2); }
.presets a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 400; }
.ledger-box { margin-top: var(--s3); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.ledger-box table { margin: 0; }
.cur-head { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); background: var(--page); font-size: 14px; font-weight: 400; }
.balance-strip { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); background: var(--page); font-size: 14px; color: var(--muted); }
.balance-strip strong { color: var(--ink); }
/* M38: on a narrow phone the balance goes under its words instead of squeezing them. */
.balance-strip { flex-wrap: wrap; }
.balance-strip strong { margin-left: auto; white-space: nowrap; }
/* M126 (ledger-desktop-a2 / ledger-phone-a2): one head row per currency: the currency, brought
   forward, the balance at the period's end and the pager; a phone: the figure under its words,
   the pager only at the foot */
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s4); row-gap: var(--s1); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); background: var(--page); font-size: 14px; color: var(--muted); }
.sheet-head .cur-head, .sheet-head .balance-strip { padding: 0; border: 0; background: none; }
.sheet-head .cur-head { color: var(--ink); }
.sheet-head .balance-strip { display: block; }
.sheet-head .balance-strip strong, .balance-at strong { margin-left: var(--s1); white-space: nowrap; }
.sheet-head > .pager { margin: 0 0 0 auto; padding: 0; border: 0; }
@media screen and (max-width: 767px) {
  .sheet-head { flex-direction: column; align-items: flex-start; }
  .sheet-head > .pager, .balance-at { display: none; }
  .sheet-head .balance-strip strong { display: block; margin-left: 0; }
}
table.statement .description { display: block; font-weight: 400; overflow-wrap: anywhere; }
.entry-id { display: block; font-size: 12px; color: var(--muted); }
.entry-id a { display: inline-flex; align-items: center; min-height: 32px; }
tr[data-panel] { cursor: pointer; }
tr[data-panel]:hover td, tr.picked td { background: var(--accent-soft); }
.closing { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2) var(--s4); padding: var(--s3) var(--s3); border-top: 1px solid var(--line); background: var(--accent-soft); }
.closing small { display: block; font-size: 12px; color: var(--muted); }
.closing strong { font-size: 16px; }
.closing.three { display: grid; grid-template-columns: 1fr 1fr 1.3fr; }
.closing.three > div:last-child { text-align: right; }
.linkish { display: inline-flex; align-items: center; min-height: 44px; font-weight: 400; text-decoration: none; }
.ledger-box.list .closing { display: flex; }
.taccount { display: none; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
:root[data-tview="on"] .taccount { display: grid; }
.tside { min-width: 0; }
.tside:first-child { border-right: 4px solid var(--line); }
.tlabel { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.trow { display: grid; gap: var(--s1); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); color: var(--ink); font-size: 14px; text-decoration: none; overflow-wrap: anywhere; }
.trow:hover { background: var(--accent-soft); }
.trow .line { display: flex; justify-content: space-between; gap: var(--s2); }
.trow .line span { color: var(--muted); font-size: 12px; }
@media screen and (max-width: 767px) {
  .closing.three { grid-template-columns: 1fr 1fr; }
  .closing.three > div:last-child { grid-column: 1 / -1; }
  .taccount { grid-template-columns: 1fr; }
  .tside:first-child { border-right: 0; border-bottom: 4px solid var(--line); }
}

/* ---- forms in the dialog look */
.dialog-page { max-width: 560px; margin: 0 auto; } /* M121: the form sits on the page, no card */
/* M121 (a2.css a2-tabs): the form tabs are plain words on one row over a hairline; the open one
   darker (one weight, owner 22/11) with a 3 px green underline. Computer: from the left; phone: spread across. */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--line); }
.tabs .tab { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; margin: 0 0 -1px; padding: 0 var(--s1); border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); font: inherit; font-size: 15px; line-height: 20px; font-weight: 400; cursor: pointer; }
.tabs .tab.selected { color: var(--ink); border-bottom-color: var(--accent); }
@media screen and (max-width: 1023px) { .tabs { justify-content: space-between; gap: 0; } .tabs .tab { padding: 0; } }
.preview { padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 8px; background: var(--page); font-size: 14px; }
.preview .ph { margin: 0 0 var(--s1); font-size: 12px; color: var(--muted); }
.preview .post-amount { font-style: normal; margin-left: auto; white-space: nowrap; }
.preview .pl { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; overflow-wrap: anywhere; }
/* Will post: "CR (Received from)" keeps its words together; the ledger's name gives way (audit, 320 px) */
/* M129 (receipt-desktop-a2): one line per ledger; the name gives way, cut with "...", the figure
   and "DR (Into)" keep theirs (with the largest figure they drop under a 3-letter name) */
.will-post .pl { flex-wrap: wrap; align-items: baseline; }
.will-post .pl > span, .will-post .post-amount { flex: none; white-space: nowrap; }
.will-post .pl > b { flex: 1 1 0; min-width: 3em; font-weight: 400; overflow-wrap: anywhere; } /* M167: a name wraps, never cut */
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--s2); }
.dialog-actions .button, .dialog-actions button { min-width: 7rem; justify-content: center; }
/* M128 (new-desktop-a2 / new-phone-a2): a white card per form, its dot coloured as its voucher
   tag, its name, what it is for and its key; three a row on a computer, one a row on a phone */
.chooser { display: grid; grid-template-columns: repeat(auto-fill, minmax(0, 320px)); gap: var(--s4) var(--s5); margin-top: var(--s3); }
.form-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; align-content: start; gap: var(--s1) var(--s3); padding: var(--s4) var(--s5); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); text-decoration: none; }
.form-card:hover { border-color: var(--accent); }
.form-name { display: flex; align-items: center; gap: var(--s2); font-size: 16px; }
.form-note { grid-column: 1 / -1; color: var(--muted); font-size: 14px; }
.form-card .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.form-card.entry .dot, .form-card.conversion .dot { background: none; box-shadow: inset 0 0 0 2px var(--accent); }
.form-card.payment .dot { background: #8a4b12; }
:root[data-theme="dark"] .form-card.payment .dot { background: #f0b072; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .form-card.payment .dot { background: #f0b072; } }
@media screen and (max-width: 767px) { .chooser { grid-template-columns: minmax(0, 1fr); gap: var(--s3); } }
.fields { display: contents; }

/* ---- the phone's menu (M125, menu-desktop-a2 / menu-phone-a2): at the page's left edge, the
   items in one white box with "›", Sign out centred under it */
.sheet-menu { max-width: 720px; }
.sheet-menu input[name="q"] { width: 100%; }
@media screen and (min-width: 768px) { .sheet-menu input[name="q"] { max-width: 320px; } }
.mnav { display: flex; flex-direction: column; margin-top: var(--s4); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.mnav a { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 var(--s3); color: var(--accent); font-size: 16px; text-decoration: none; }
.mnav a + a { border-top: 1px solid var(--line); }
.mnav a::after { content: "›" / ""; color: var(--muted); }
.mnav-out { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: var(--s4); } /* M175: a quiet button as the others, not a bare word over a rule */
.with-after { display: flex; align-items: center; gap: var(--s2); } /* M171: "1 USD = [box] AED" */
.with-after > input { flex: 1 1 auto; min-width: 0; }
.with-after > .after { flex: none; color: var(--muted); }

@media print {
  .sidebar, .right, .bottom-nav, .phone-top, .head-new, .toolbar-row, .tabs, nav.seg { display: none !important; }
  .shell { display: block; }
}

/* Review of the first screenshots (Stage 12): sticky headings inside a box overlapped the first
   row; the side word never splits; the opening line keeps its spaces; the phone's head wraps. */
.ledger-box th { position: static; }
.leg-head span, .leg .money { white-space: nowrap; }
.opening-line a { display: inline-block; line-height: 32px; }
@media screen and (max-width: 767px) { .ledger-head { flex-wrap: wrap; } }

/* Page audit (Stage 12): "+ New" has its own row above the page, so it never sits beside a
   page's own buttons; up to 999 px a table is stacked rows (app.css), never a box that scrolls
   sideways; phones: long names and big balances wrap; the form buttons share the row. */
.ledger-list a { flex-wrap: wrap; }
.ledger-list .balances { margin-left: auto; }
/* M103 (approved pictures cash-held, receivable, payable): a phone keeps name and balance on one
   row; the balance drops under the name only when both can't fit; the total's figure stays right. */
@media screen and (max-width: 480px) {
  .balances-table tbody { display: block; }
  .balances-table tr { display: flex; flex-wrap: wrap; align-items: baseline; border-bottom: 1px solid var(--line); }
  .balances-table td { border: 0; }
  .balances-table td.lead { flex: 1 0 auto; max-width: 100%; } /* never squeezed to a word a line */
  .balances-table td.amount { flex: 0 0 auto; margin-left: auto; }
}
.ledger-box.list .closing strong { margin-left: auto; }
.ledger-box.list .lt-head { padding-inline: var(--s3); }
.dialog-actions { flex-wrap: wrap; }
@media screen and (max-width: 480px) {
  .dialog-actions > * { flex: 1 1 auto; }
}
.phone-top .brand { display: inline-flex; align-items: center; min-height: 44px; }
tr.picked, tr[data-panel]:hover { background: var(--accent-soft); }

/* Owner (08/11/2026, after Stage 12): every heading and every Total in capital letters. Done
   here only (the words in the pages stay as written); a little tracking keeps capitals readable. */
h1, h2, h3, table.position th[scope="row"] > a, table.position th.name, .cur-head, .tlabel, .lines-h, .preview .ph,
.closing small, tr.total td.lead, tr.total th { text-transform: uppercase; letter-spacing: 0.04em; }

/* UI audit (08/11/2026, after Stage 12): alignment, symmetry and readability. */
:root { --amber-line: #efdfc7; }
:root[data-theme="dark"] { --amber-line: #4a3a22; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --amber-line: #4a3a22; } }
/* tags start under the date on phones; money right-aligned in the T-account */
table.statement td.date { text-align: left; }
.trow .line { flex-direction: row-reverse; }
.trow .line strong { font-variant-numeric: tabular-nums; }
/* an amount heading's (i) goes before the word, so the word ends over the figures */
th.amount .term { flex-direction: row-reverse; }
/* every trial balance table lines up with the next */
table.report.compact { table-layout: fixed; }
table.report.compact td:first-child, table.report.compact th:first-child { width: 36%; } /* M41: each figure column fits 999,999,999,999,999 */
/* postings: name | side | amount, each in its own column */
.leg { display: grid; grid-template-columns: minmax(0, 1fr) 2.5em auto; align-items: baseline; }
.leg-head { display: contents; }
.leg-head span { text-align: center; }
/* no text under 12 px */
.ix-bal, .ix-bal .side { font-size: 12px; }
/* the ⋯ button: a 44 px square on the period's row */
.toolbar-row details.more-box > summary { min-width: 44px; padding: 0 var(--s3); justify-content: center; } /* "... ▾" (M124) */
/* forms start at the page's left edge on wide screens, like every other page */
@media (min-width: 768px) { .shell .form-page, .shell .dialog-page { margin: 0; } }
/* notices: on the 4 px grid, links 44 px tall and centred on their line, borders follow the theme */
.notices { border-color: var(--amber-line); }
.notices > * { align-items: center; min-height: 44px; padding: var(--s1) var(--s4); } /* M122: a2-notices rows */
.notices > * + * { border-top-color: var(--amber-line); }
.notices a { min-height: 44px; }
/* small links get a 44 px tap area without growing the line */
.entry-id a, .opening-line a { min-height: 0; padding: var(--s3) 0; margin: calc(-1 * var(--s3)) 0; line-height: 20px; display: inline-block; }
/* the index's and the menu's last items line up with the rest, on the left */
.ledger-index .ix-add { flex-direction: row; }
.sidebar .side-out { justify-content: flex-start; }
.bottom-nav { padding-left: var(--gutter); padding-right: var(--gutter); }
/* one look for every switch of choices: form tabs, invoice type, Light / Dark / Auto */
.theme-switch { padding: var(--s1); border-radius: 8px; background: var(--page); }
.theme-switch button { border: 0; border-radius: 6px; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); border: 0; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
/* save buttons: on the right on wide screens, the whole width on a phone */
@media (min-width: 768px) {
  form.invoice-form > button[type="submit"] { justify-self: end; width: auto; min-width: 12rem; }
}
/* the same capital-letter spacing everywhere; the scale's sizes and weights */
.ledger-index h2, .eyebrow, .tag, .tlabel, h1, h2, h3, table.position th[scope="row"] > a, table.position th.name, .cur-head, .lines-h, .preview .ph,
.closing small, tr.total td.lead, tr.total th { letter-spacing: 0.06em; }
.detail-amount { font-size: 28px; }
.cur-head, table.position th[scope="row"] > a, table.position th.name { font-size: 12px; }
.top-nav a[aria-current="page"], .ledger-index a[aria-current="page"], table.statement .description, .detail-amount, .cur-head { font-weight: 400; }
.ledger-box, .page-card { border-radius: 8px; }
/* the page buttons sit in the currency bar, not in a bar of their own */
.ledger-box > .pager { margin: 0; padding: var(--s1) var(--s3); border-bottom: 1px solid var(--line); }
@media screen and (max-width: 767px) { .chooser kbd { display: none; } }
/* the fixed trial balance columns only where the page is wide; long cells keep one line in a box that scrolls */
table.report.compact { table-layout: auto; }
@media (min-width: 1101px) { table.report.compact { table-layout: fixed; } }
@media screen and (max-width: 1100px) { table.report.compact td:first-child, table.report.compact th:first-child { width: auto; } }

/* Critique after Stage 12. (1) Every table in one card look, like the statements. (2) A page's
   own buttons share the "+ New" row; on a phone the row holds them alone (no height when empty).
   (3) Amount beside its currency, so the form is shorter on a phone. */
table.report, table.invoices, table.lines {
  border: 1px solid var(--line); border-radius: 8px; border-collapse: separate; border-spacing: 0;
  overflow: hidden; background: var(--surface);
}
table.report th, table.invoices th, table.lines th { background: var(--page); }
form.entry-form, form.entry-form .stack-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4) var(--s3); }
form.entry-form > *, form.entry-form .fields > *, form.entry-form .stack-inner > *, form.entry-form .form-side > * { grid-column: 1 / -1; }
form.entry-form .field-amount, form.entry-form .field-currency,
form.entry-form .field-other_amount, form.entry-form .field-other_currency { grid-column: auto; }
/* a card table clips its corners, so its headings cannot stick to the window: keep them in place */
table.report th, table.invoices th, table.lines th { position: static; }

/* M96 (owner's approved picture ledger-phone-a2): the ledger page on a phone, under 768 px */
.phone-top.titled { grid-template-columns: auto minmax(0, 1fr); gap: var(--s4); }
.phone-top.titled > span:not(.bar-title) { display: none; }
.phone-top .bar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.01em; }
.opening-fold { margin: 0 0 var(--s3); }
.opening-fold > summary { display: flex; align-items: center; min-height: 44px; color: var(--accent); cursor: pointer; }
.in-menu { margin: 0; padding: 0 var(--s3); }
@media screen and (max-width: 767px) {
  .ledger-title h1, .in-bar > h1 { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* the bar says it; screen readers still read it */
  .ledger-head > .switch { display: none; }
  .balance-now, .balance-now.has-big { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .balance-now > div { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s3); align-items: start; border: 0; border-radius: 0; padding: 0; background: none; }
  .balance-now .word { grid-column: 1; grid-row: 1 / span 6; padding-top: var(--s1); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
  .balance-now .amount, .balance-now .none { grid-column: 2; justify-self: end; }
  .balance-now .amount { font-size: 16px; } /* M98: beside a 12 px name, 19 px was out of proportion (a long figure stays 14 px) */
  .toolbar-row { grid-template-columns: minmax(0, 1fr) auto; }
  .toolbar-row > form { grid-column: 1 / -1; }
}
@media screen and (max-width: 379px) { /* a long figure needs the whole row: the word goes above it */
  .balance-now .word { grid-column: 1 / -1; grid-row: auto; padding-top: 0; }
  .balance-now .amount, .balance-now .none { grid-column: 1 / -1; }
}

/* M100 (owner's approved pictures ledgers-desktop-a2, ledgers-phone-a2): the Ledgers page is one table */
.add-head { align-items: center; margin-bottom: var(--s3); }
@media screen and (max-width: 767px) { .add-head { flex-direction: column; align-items: flex-start; } }
.ledger-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.lt-head { display: none; }
@media screen and (min-width: 768px) {
  .lt-head { display: flex; justify-content: space-between; padding: var(--s2) var(--s4); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
}
.ledger-table .list-group h2 { margin: 0; padding: var(--s2) var(--s4); background: var(--page); border-top: 1px solid var(--line); font-size: 12px; letter-spacing: 0.08em; }
.ledger-table .list-group:first-of-type h2 { border-top: 0; }
.ledger-table .lt-head + .list-group h2 { border-top: 0; }
.ledger-table .ledger-list { margin: 0; border: 0; border-radius: 0; background: none; }
.ledger-table .ledger-list li:first-child { border-top: 0; }
.ledger-table .ledger-list a { color: var(--accent); }
.ledger-list .name { flex: 1 1 8rem; }
.ledger-list .balances { flex: 0 0 auto; }
/* M116 (as M103): on a phone the name keeps its width; the balance drops under it if both can't fit */
@media screen and (max-width: 480px) { .ledger-list .name { flex: 1 0 auto; max-width: 100%; } }
/* M123 (ledgers-desktop-a2, ledgers-phone-a2): 44 px rows, a ledger's currency lines 20 px apart, the archived
   link small; on a phone the group names as written (15 px) and a long figure 14 px, as elsewhere */
.ledger-table .ledger-list a { min-height: 44px; padding: var(--s1) var(--s4); }
.ledger-list .balances { line-height: 20px; }
.ledger-table ~ p.note { font-size: 14px; }
@media screen and (max-width: 767px) {
  .ledger-table .list-group h2 { font-size: 15px; line-height: 20px; text-transform: none; letter-spacing: 0.04em; }
  .ledger-list .money.long { font-size: 14px; }
}

/* M101 (owner's M77, approved Attempt 2 pictures): period buttons, one row; a phone's is as wide as the page */
nav.seg { display: inline-flex; margin: 0 0 var(--s3); border: 1px solid var(--field-line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
nav.seg a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s4); color: var(--muted); font-size: 14px; text-decoration: none; white-space: nowrap; }
nav.seg a:hover { background: var(--accent-soft); }
nav.seg a[aria-current] { background: var(--accent); color: var(--on-accent); }
nav.seg a:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media screen and (max-width: 767px) {
  nav.seg { display: flex; }
  nav.seg a { flex: 1 1 0; padding: 0 var(--s2); }
  nav.seg a[href="?period=week"] { display: none; }
}


/* BUGS M107 (step 36, the approved pictures): on a phone a form page has no Menu / + New bar; its Cancel
   and Save are the bottom row, edge to edge with a line above. The row is sticky, not fixed: it stays at
   the foot of the screen while the form is longer than the screen, yet is never lifted over a field by
   the keyboard and never hidden while a field is typed in (Save stays one tap away). */
@media screen and (max-width: 767px) {
  body.has-action-bar { --bleed: var(--gutter); } /* how far the row reaches left and right: the page's edge */
  body.has-action-bar .bottom-nav { display: none; }
  body.has-action-bar.signed-in { padding-bottom: 0; }
  body.has-action-bar .button-group.pair { position: sticky; bottom: 0; z-index: 10; box-sizing: border-box; margin: var(--s4) calc(-1 * var(--bleed)) 0; gap: var(--s4); padding: var(--s3) var(--gutter) calc(var(--s4) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
}

/* Stage Pictures P0 (BUGS M120; DESIGN.md): the approved pictures' shared parts, measures from
   their stylesheet (Workups - Attempt 2/compare-tool/a2.css) */
.sidebar .side-new { display: flex; align-items: center; justify-content: center; min-height: 44px; margin: var(--s4) 0 var(--s3); }
.shell main h1 { font-size: 22px; line-height: 28px; letter-spacing: 0.04em; }
@media screen and (max-width: 767px) { .shell main h1 { font-size: 20px; line-height: 26px; } }
.shell thead th { font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.shell td a:not(.tag):not(.vtag) { text-decoration: none; }

/* M124 (ledger-desktop-a2, ledger-phone-a2): a computer has + New beside the title, the four period buttons and
   the T-account switch in the toolbar; a phone keeps the period list, the switch in the ... menu (M96) and its
   bottom bar's + New. The cards' names are small capitals; an empty card says No balance at figure size. */
.ledger-head .head-new { flex-shrink: 0; }
.toolbar-row > .switch, .toolbar-row > nav.seg { display: none; margin: 0; }
.balance-now .word { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
@media screen and (min-width: 768px) {
  .toolbar-row { display: flex; flex-wrap: wrap; align-items: center; }
  /* 44 px as the buttons beside it: the bar keeps its 1 px border, its 44 px buttons overlap it */
  .toolbar-row > nav.seg { display: inline-flex; box-sizing: border-box; height: 44px; }
  .toolbar-row > nav.seg a { margin: -1px 0; }
  .toolbar-row > .period-list { display: none; }
  .toolbar-row > .switch { display: inline-flex; margin-left: auto; }
  .balance-now .none { text-align: right; font-size: 19px; }
}
@media screen and (max-width: 767px) {
  .ledger-head .head-new { display: none; }
  .balance-now .none { font-size: 16px; }
}

/* ---- one entry's page (M127, entry-desktop-a2 / entry-phone-a2): the voucher as the title, its
   buttons beside it; LINES and DETAILS in white boxes, side by side on a computer */
.entry-top h1 { margin-bottom: 0; }
.entry-top .actions { margin: 0; flex-shrink: 0; }
.entry-sub { margin: var(--s1) 0 0; }
.entry-grid { display: grid; gap: var(--s4); margin-top: var(--s4); }
@media screen and (min-width: 1000px) { .entry-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; } }
.entry-lines, .entry-details, .entry-side details.danger-zone { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.entry-lines table.lines { margin: 0; border: 0; border-radius: 0; }
.entry-lines td.lead a { text-decoration: none; }
.side-word { display: none; }
.entry-narr { padding: var(--s2) var(--s3); border-top: 1px solid var(--line); }
.entry-narr small { display: block; font-size: 12px; color: var(--muted); }
.entry-narr p { margin: 0; }
.entry-details .info-row { padding: var(--s2) var(--s3); }
.entry-details .info-row:last-child { border-bottom: 0; }
.entry-details .info-row b { font-weight: 400; text-align: right; }
.entry-side details.danger-zone { margin: var(--s3) 0 0; padding: 0 var(--s3); }
@media screen and (max-width: 767px) {
  .entry-top { flex-direction: column; gap: var(--s3); }
  .entry-lines thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .entry-lines table, .entry-lines tbody { display: block; width: 100%; }
  .entry-lines tr { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: var(--s3); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); }
  .entry-lines td.lead { flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }
  .entry-lines td.amount { margin-left: auto; } /* a long name keeps its words: the amount goes under it */
  .entry-lines td { display: block; padding: 0; border: 0; }
  .entry-lines td.amount:empty { display: none; }
  .entry-lines td.amount { white-space: nowrap; }
  .entry-lines .side-word { display: inline; margin-left: var(--s1); color: var(--muted); } /* M157: "AED 68,709 DR" */
}

/* ---- the invoices list (M130, invoices-desktop-a2 / invoices-phone-a2): the number an outlined
   tag; on a phone a card per invoice, name and total, then the tag, date and type; "New invoice"
   under the heading */
table.invoices td.lead a.tag { position: relative; margin: 0; padding: 1px var(--s1); text-decoration: none; white-space: nowrap; }
table.invoices td.lead a.tag::after { content: ""; position: absolute; inset: -12px -8px; } /* a 44 px tap area */
@media screen and (max-width: 767px) {
  .invoices-head { flex-direction: column; align-items: flex-start; }
  /* two lines, each giving way on a narrow phone: the total under a long name, the type under
     the tag and date (the ::after is the line break between them) */
  table.invoices tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); }
  table.invoices tr::after { content: ""; flex-basis: 100%; height: 0; order: 3; }
  table.invoices td { display: block; width: auto; padding: 0; }
  table.invoices td::before { content: none; }
  table.invoices td.who { order: 1; flex: 1 1 10rem; min-width: 0; text-align: left; overflow-wrap: anywhere; }
  table.invoices td.amount { order: 2; margin-left: auto; text-align: right; }
  table.invoices td.lead { order: 4; }
  table.invoices td[data-label="Date"] { order: 5; color: var(--muted); font-size: 14px; }
  table.invoices td[data-label="Type"] { order: 6; margin-left: auto; color: var(--muted); font-size: 14px; text-align: right; }
}

/* ---- the invoice form (M131, invoice-new-desktop-a2 / invoice-new-phone-a2): sections under a
   rule, not in boxes; a computer's rows as the picture's columns, their names once above the
   first row in small capitals; INVOICE TOTAL, WILL POST, Save and Cancel in a 320 px column */
.invoice-form { display: grid; gap: var(--s4); }
.inv-main, .inv-sec { display: grid; gap: var(--s4); min-width: 0; }
.inv-side { display: contents; } /* under 1280 px its parts sit in the form, so Save and Cancel keep the phone's bar at the foot */
.inv-sec { padding-top: var(--s4); border-top: 1px solid var(--line); }
.inv-sec h2 { margin: 0; }
.inv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: end; } /* a label on two lines never lowers its field */
.inv-grid > * { min-width: 0; }
.inv-top { align-items: start; }
.inv-top .field-kind, .inv-top .field-party { grid-column: 1 / -1; }
.inv-sec .row-card { padding: 0; border: 0; border-radius: 0; background: none; }
.inv-sec .rows, .inv-sec .fold { gap: var(--s4); } /* rows 16 px apart, as every field (M51) */
.col-head { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.inv-total .inv-sum { margin-top: var(--s1); padding-top: var(--s2); border-top: 1px solid var(--ink); font-size: 16px; }
.inv-total .note { margin: var(--s1) 0 0; font-size: 12px; }
.inv-side [data-invoice-total] { display: grid; gap: var(--s3); }
@media screen and (min-width: 768px) {
  .sea-grid, .cont-grid, .sea-more { grid-template-columns: 3fr 3fr 2fr; }
  .truck-grid, .truck-more { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .row-card.line-grid { grid-template-columns: 4fr 1fr 1fr 2fr; }
  .row-card.line-grid .desc { grid-column: auto; }
  .rows > .row-card + .row-card .col-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media screen and (min-width: 1024px) { /* under 1024 px four columns leave a date too narrow (audit, 768 px) */
  .inv-top { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .inv-top .field-kind, .inv-top .field-party { grid-column: span 2; }
}
@media screen and (min-width: 1280px) {
  .form-page.inv-page { max-width: 1040px; }
  form.invoice-form { grid-template-columns: minmax(0, 1fr) 320px; column-gap: var(--s5); align-items: start; }
  .inv-side { display: grid; gap: var(--s3); align-content: start; min-width: 0; }
  .inv-side .button-group.pair { display: flex; flex-direction: column-reverse; margin: 0; }
  .inv-side .button-group.pair > * { width: 100%; }
}

/* ---- Trial balance (M133, trial-balance-desktop-a2 / -phone-a2): a box per currency, the check
   beside its code; a phone row: name and amount on one line, DR/CR after the figure (M157) */
.tb-box table.report { width: 100%; max-width: none; margin: 0; border: 0; border-radius: 0; }
.tb-check { margin: 0 0 0 auto; font-size: 14px; }
@media screen and (max-width: 999px) {
  .tb-box tbody tr:not(.total) { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: var(--s3); }
  .tb-box tbody tr:not(.total) td { display: block; width: auto; padding: 0; }
  .tb-box tbody tr:not(.total) td::before { content: none; }
  .tb-box tbody tr:not(.total) td.lead { flex: 1 1 10rem; min-width: 0; }
  .tb-box tbody tr:not(.total) td.amount { margin-left: auto; }
  .tb-box tbody tr:not(.total) td.amount { white-space: nowrap; }
  .tb-box tbody tr:not(.total) td.amount:empty { display: none; } /* M157: an empty DR or CR cell took a gap, so DR figures ended 12 px short */
  .tb-box .side-word { display: inline; margin-left: var(--s1); color: var(--muted); } /* M157 */
}
@media screen and (max-width: 767px) { .tb-check { margin: 0; } }

/* ---- Day book (M134, day-book-desktop-a2 / -phone-a2): a shaded head row per entry, the voucher
   a coloured tag and its words on one line; a row per ledger; the period bar the page's width;
   a phone's date row From / To, then ‹ › Show */
.wide-seg { display: flex; width: 100%; }
.wide-seg a { flex: 1 1 0; } /* M166: the choices share the bar, no empty run at its end */
table.day-book tr.entry-head td { background: var(--page); }
table.day-book td.voucher a.tag { position: relative; margin: 0; padding: 1px var(--s1); text-decoration: none; white-space: nowrap; }
table.day-book td.voucher a.tag::after { content: ""; position: absolute; inset: -12px -8px; } /* a 44 px tap area */
table.day-book .db-date { display: none; }
table.day-book tr.entry-line td.lead { padding-left: var(--s4); }
table.day-book tr.entry-line td { padding-top: var(--s2); padding-bottom: var(--s2); border-bottom: 1px solid var(--line); } /* a rule under every row, as the picture */
@media screen and (max-width: 999px) {
  table.day-book tr.entry-head { display: flex; align-items: baseline; gap: var(--s2); padding: var(--s2) var(--s3); background: var(--page); }
  table.day-book tr.entry-head td { display: block; width: auto; padding: 0; }
  table.day-book tr.entry-head td::before, table.day-book tr.entry-line td::before { content: none; }
  table.day-book tr.entry-head td.date { display: none; }
  table.day-book tr.entry-head td.lead { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
  table.day-book .db-date { display: inline; }
  table.day-book .db-type { display: none; }
  table.day-book tr.entry-line { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: var(--s3); padding: var(--s2) var(--s3); }
  table.day-book tr.entry-line { border-bottom: 1px solid var(--line); }
  table.day-book tr.entry-line td { display: block; width: auto; padding: 0; border: 0; }
  table.day-book tr.entry-line td:empty { display: none; }
  table.day-book tr.entry-line td.lead { flex: 1 1 10rem; min-width: 0; padding: 0; }
  table.day-book tr.entry-line td.amount { margin-left: auto; }
  table.day-book tr.entry-line td.amount { white-space: nowrap; }
  table.day-book .side-word { display: inline; margin-left: var(--s1); color: var(--muted); } /* M157 */
}
@media screen and (max-width: 767px) {
  form.period:not(.one) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  form.period:not(.one) > label:nth-of-type(1) { grid-column: 1 / span 2; grid-row: 1; }
  form.period:not(.one) > label:nth-of-type(2) { grid-column: 3 / span 2; grid-row: 1; }
  form.period:not(.one) > a.button:nth-of-type(1) { grid-column: 1; grid-row: 2; }
  form.period:not(.one) > a.button:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  form.period:not(.one) > .show { grid-column: 3 / span 2; grid-row: 2; }
}

/* ---- History (M135, history-desktop-a2 / -phone-a2): a small filter; the saves in a box headed
   "Saves" with the pager on that row; one line per save, the voucher a coloured tag; a phone row:
   the words and the time, then the tag and the date */
.hist-pick > label { flex: 0 0 auto; width: max-content; justify-self: start; align-self: start; }
.hist-pick select { width: auto; min-width: 9rem; }
.hist-box table.report { width: 100%; max-width: none; margin: 0; border: 0; border-radius: 0; }
.hist-box td.voucher a.tag, .hist-box td.voucher span.tag { position: relative; margin: 0; padding: 1px var(--s1); text-decoration: none; white-space: nowrap; }
.hist-box td.voucher a.tag::after { content: ""; position: absolute; inset: -12px -8px; } /* a 44 px tap area */
.hist-what { display: block; } /* M159: wraps, never cut */
.hist-more { display: block; font-size: 14px; }
.hist-box td.reason.none { color: var(--muted); }
.hist-date, .hist-time { display: none; }
.hist-title { color: var(--ink); font-size: 16px; }
@media screen and (min-width: 1000px) {
  .hist-box table.report { table-layout: fixed; }
  .hist-box .sheet-head { padding: var(--s2) var(--s4); } /* M163: "Saves" on its columns' 16 px edge */
  .hist-box th:nth-child(1) { width: 11rem; } .hist-box th:nth-child(2) { width: 8rem; } .hist-box th:nth-child(4) { width: 14rem; }
}
@media screen and (max-width: 999px) {
  .hist-box tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what what" "tag tag" "reason reason"; row-gap: var(--s1); padding: var(--s2) var(--s3); }
  .hist-box tbody td { display: block; width: auto; padding: 0; border: 0; }
  .hist-box tbody td::before { content: none; }
  .hist-box td.date, .hist-box td.reason.none { display: none; }
  .hist-box table td.lead { grid-area: what; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); }
  .hist-box td.lead .hist-more { grid-column: 1 / -1; }
  .hist-box .hist-time { display: block; }
  .hist-box table td.voucher { grid-area: tag; display: flex; justify-content: flex-start; align-items: baseline; gap: var(--s2); }
  .hist-box .sheet-head > .pager { display: flex; margin: 0; } /* the picture keeps it on a phone (M126 hides a statement's) */
  .hist-box .hist-date { display: inline; color: var(--muted); font-size: 14px; }
  .hist-box td.reason { grid-area: reason; font-size: 14px; text-align: left; }
  .hist-box td.reason::before { content: attr(data-label) ": "; color: var(--muted); } /* M162: under the save, labelled */
}

/* ---- Settings (M137, settings-desktop-a2 / -phone-a2): each section's name and note on the left,
   its fields on the right from 1000 px; a box and its button on one row; names in sentence case
   (owner 21/11: the pictures win over S16); the chosen Appearance solid green */
.form-page.set-page { max-width: 1040px; }
.set-sec { display: grid; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--line); }
.set-sec:first-of-type { border-top: 0; }
.set-name h2 { margin: 0; font-size: 16px; text-transform: none; letter-spacing: 0; }
.set-name .note { margin: var(--s1) 0 0; font-size: 14px; }
.set-body { display: grid; gap: var(--s3); align-content: start; min-width: 0; }
.set-body > .actions, .set-body .currency-list { margin: 0; }
.set-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: end; }
.set-row > .wide { grid-column: 1 / -1; }
.set-row > button { white-space: nowrap; padding-inline: var(--s2); }
.set-pair { display: grid; gap: var(--s4); }
.set-pair > * { min-width: 0; }
.set-pair .set-end { justify-self: end; }
.set-sec .menu-list { width: 100%; max-width: none; }
.set-sec .menu-list a { display: flex; align-items: center; justify-content: space-between; color: var(--accent); }
.set-sec .menu-list a::after { content: "›" / ""; color: var(--muted); }
.set-sec .theme-switch { display: inline-flex; width: max-content; gap: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.set-sec .theme-switch button { min-width: 64px; border-radius: 0; }
.set-sec .theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.set-btn { width: 100%; max-width: 320px; } /* M138: Security's two buttons, 320 px as the picture */
.set-body table.report { width: 100%; margin: 0; }
@media screen and (min-width: 768px) {
  /* a date box as wide as a date, a code box twice that; the button as wide as its words, at least as the box */
  .set-row { grid-template-columns: minmax(0, 10rem) minmax(10rem, max-content); justify-content: start; }
  .set-row.long { grid-template-columns: minmax(0, 20rem) minmax(10rem, max-content); }
  .set-row > .wide { grid-column: auto; }
  .set-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set-pair .set-new-row { grid-column: 1; }
  .set-pair .set-end, .set-pair .set-all { grid-column: 1 / -1; }
}
@media screen and (min-width: 1000px) {
  .set-sec { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: var(--s5); }
}

/* ---- Add and Edit ledger (M139, add-ledger-desktop-a2 / edit-ledger-desktop-a2): two fields a row
   on a computer, a plain tick box, Phone (half width) before Address, Add ledger's buttons on the
   right; a phone: one field a row */
.form-page.lf-page { max-width: 664px; } /* M151: the picture's form is 664 px (8 of 12 columns), as the entry forms (M68) */
.ledger-form .lf-details { display: grid; gap: var(--s4); }
@media screen and (min-width: 768px) {
  form.ledger-form { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s5); }
  form.ledger-form > .lf-all { grid-column: 1 / -1; }
  .ledger-form .lf-details { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--s5); }
  .ledger-form .lf-details > .lf-all { grid-column: 1 / -1; }
  .ledger-form .lf-actions { grid-column: 1 / -1; margin: 0; }
}
@media screen and (min-width: 1000px) { /* narrower, half a row is too small for "Add ledger" (audit, 768 px) */
  .ledger-form .lf-actions { grid-column: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); } /* M151: 148 + 24 + 148 */
}

/* ---- M141 (owner 22/11/2026: "the long names do not wrap on phone, the "..." is fine"): on a
   phone a list's ledger name or particulars is one line cut with "...", the whole text in its
   title; the figure keeps its place on the row (replaces 21/11's wrap) */
@media screen and (max-width: 767px) {
  .cut-name { display: block; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; overflow-wrap: normal; vertical-align: top; } /* M157: a cut name drawn as a tap box (app.css) sits on its line by its top, not its bottom edge, so "(conversion)" and "custodian" beside it stay on its line */
  .ledger-list .name { min-width: 6em; flex: 1 1 0; } /* no room beside a long figure: the figure goes under */
  table.statement .entry-id { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } /* "· the other ledger" */
  .entry-lines td.lead, .tb-box tbody tr:not(.total) td.lead, table.day-book tr.entry-line td.lead,
  .balances-table td.lead, table.invoices td.who { flex: 1 1 0; min-width: 4em; max-width: none; overflow-wrap: normal; }
  .balances-table td.lead { min-width: 9em; } /* room for "· negative balance"; else the figure goes under */
  .balances-table td.lead > .problem { display: block; } /* "negative balance" under the name, never squeezed */
  .balances-table td.lead > .problem > .sep { display: none; } /* M160: a line never starts with the dot */
  .search { max-width: none; } /* M161: Find a ledger as wide as the list (320 px is the desktop picture's) */  .balances-table td.lead > .mini { display: table; margin-left: 0; } /* M157: "custodian" under the name, on its edge (its 4 px margin put it 4 px in) */
}

/* ---- M142 (owner 22/11/2026, opening-phone): a phone bar's long ledger name is one line cut with
   "..." (its whole name in its title); the page's title shows whole */
/* M148 (owner 22/11/2026, opening-phone-a2 / invoice-new-phone-a2): the title in the middle of the
   bar on every page; the back link cut to its side's room */
.phone-top.titled { grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr); gap: var(--s2); }
.phone-top.titled > span:not(.bar-title) { display: block; }
.phone-top.titled .back { display: block; min-width: 0; line-height: 44px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* M169: a long back link ("‹ Gulf Foods Trading Company") is one line cut with "..." (navigation, owner
   22/11), as on a titled bar; on two lines it made the bar 6 px taller and dropped the page's title */
.phone-top:not(.titled) { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.phone-top:not(.titled) .back { display: block; min-width: 0; line-height: 44px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* ---- M143 (owner 22/11/2026, entry-reversal-phone): a reason is a quiet note under one rule */
.entry-lines .entry-narr { border-top: 0; padding: var(--s3); }
@media screen and (min-width: 768px) { .entry-lines .entry-narr { padding: var(--s3) var(--s4); } } /* M163: on the columns' 16 px edge */
.entry-narr .note { margin: 0; font-size: 12px; color: var(--muted); }
@media screen and (max-width: 767px) { .entry-narr .note { font-size: 14px; } }
/* ---- M144 (owner 22/11/2026, home-phone): every notice row the same room above and below its
   words, however many lines; Go to Backup keeps its 44 px touch area inside that room */
.notices > * { min-height: 0; padding-top: var(--s3); padding-bottom: var(--s3); }
.notices a { margin-top: calc(-1 * var(--s3)); margin-bottom: calc(-1 * var(--s3)); }
/* ---- M145 (owner 22/11/2026, invoice-new-desktop): a date's label names its format */
.date-format { margin-left: var(--s1); font-size: 12px; color: var(--muted); }
/* the last truck row has two fields: Dispatch date takes two columns so its label stays one line,
   its box one column wide (rows keep their 16 px gaps, M51) */
.truck-more .wide-date { grid-column: span 2; }
.truck-more .wide-date .date-box { display: block; max-width: calc(50% - var(--s2)); }
.entry-narr p + .note { margin-top: var(--s1); }

/* ==== M151 (owner 22/11/2026: "PRIORITIZE spacing and proper positioning"): the pictures' own
   layout rules (Workups Attempt 2 a2.css), checked landmark by landmark against them ==== */
/* The head: a 48 px title row on a computer (the title at its foot), the back link 14 px just above
   it (its 44 px touch area kept inside the page's top room), the page's buttons at the row's right
   end, level with its foot (a phone: 12 px under the title, sharing the row, M102); the content 24 px
   below (a phone 16). The ledger page and Ledgers keep their heads (owner 22/11: correct as they are) */
:where(.shell main) h1 { margin: 0 0 var(--s5); }
.page-head, .entry-top { margin: 0 0 var(--s5); align-items: flex-end; }
.page-head h1, .entry-top h1 { margin: 0; }
.page-head p, .entry-top .entry-sub { margin: var(--s1) 0 0; font-size: 14px; line-height: 20px; }
.page-head .acts { display: flex; flex-wrap: wrap; gap: var(--s2); margin-left: auto; }
.page-head .acts > * { margin: 0; }
@media screen and (min-width: 768px) {
  .shell main:not(:has(> .back-link)) :where(h1:not(.page-head h1, .ledger-head h1)) { display: flex; align-items: flex-end; min-height: 48px; }
  .page-head { min-height: 48px; }
  /* M169: every title at the foot of its 48 px row (M151), one with a line under it too (it sat 20 px
     higher) and Ledgers' beside its button (it sat 4 px higher) */
  .page-head > h1 { align-self: flex-end; }
  .page-head > div > h1:not(:only-child), .entry-top h1 { padding-top: calc(var(--s5) - var(--s1)); } /* 20 px: the 48 px row less the title's 28 px line */
  .back-link { font-size: 14px; line-height: 20px; margin: calc(-1 * var(--s3)) 0 calc(var(--s1) - var(--s3)); }
}
@media screen and (max-width: 767px) {
  :where(.shell main) h1, .page-head, .entry-top { margin-bottom: var(--s4); }
  .page-head { display: block; }
  .page-head > * + * { margin-top: var(--s3); }
  .page-head .acts > * { flex: 1 1 auto; white-space: nowrap; }
}
@media screen and (max-width: 767px) { .entry-top { align-items: stretch; } }
/* Settings: each section 24 px under the line above it, the first with no line (a2-set) */
.set-sec { padding: var(--s5) 0 0; margin-top: var(--s5); }
.set-sec:first-of-type { padding-top: 0; margin-top: 0; }
@media screen and (max-width: 767px) { .set-sec { margin-top: var(--s4); } }
/* Tables on a computer (a2-t): column names 40 px high in 12 px capitals, rows 44 px, text 15 px
   (a ledger's statement and the Net Cash Position report keep their own) */
@media screen and (min-width: 768px) {
  main table:not(.statement):not(.position) > thead th { height: 40px; padding-top: 0; padding-bottom: 0; vertical-align: middle; font-size: 12px; line-height: 16px; }
  main table:not(.statement):not(.position) > tbody > tr > td, main table:not(.statement):not(.position) > tbody > tr > th, main table:not(.statement):not(.position) > tfoot td, .home-pos table.position > * > tr > * { height: 44px; padding-top: 0; padding-bottom: 0; vertical-align: middle; font-size: 15px; line-height: 20px; }
  main table:not(.statement):not(.position) > * > tr > :first-child, .home-pos table.position > * > tr > :first-child { padding-left: var(--s4); }
  main table:not(.statement):not(.position) > * > tr > :last-child, .home-pos table.position > * > tr > :last-child { padding-right: var(--s4); }
  .ledger-box.list .closing, .ledger-box.list .lt-head { padding-left: var(--s4); padding-right: var(--s4); } /* in line with the rows */
  .ledger-box.list .closing { min-height: 44px; padding-top: 0; padding-bottom: 0; }
}
/* Forms (a2-fields): labels 14 px on a 20 px line, 4 px above the box; 24 px under the form tabs on a
   computer; a note box 88 px high; "+ Add currency" 14 px */
label { line-height: 20px; }
textarea { min-height: 88px; height: 88px; }
.add-currency > summary, .add-currency button { font-size: 14px; }
@media screen and (min-width: 768px) {
  .tabs { margin-bottom: var(--s2); }
}
/* The side column: Will post a box with a 40 px head band and 44 px rows; Save and Cancel 8 px apart */
.preview { padding: 0; background: var(--surface); overflow: hidden; }
.preview .ph { display: flex; align-items: center; min-height: 40px; margin: 0; padding: 0 var(--s4); border-bottom: 1px solid var(--line); background: var(--page); letter-spacing: 0.08em; text-transform: uppercase; }
.preview .pl { align-items: center; min-height: 44px; padding: 0 var(--s4); border-top: 1px solid var(--line); }
.preview .ph + .pl { border-top: 0; }
.preview > .note { margin: 0; padding: var(--s3) var(--s4); }
@media screen and (min-width: 768px) {
  form.entry-form.laid .form-side { gap: var(--s4); }
  form.entry-form.laid .form-side .button-group.pair { gap: var(--s2); }
}
/* Settings and Security on a computer: the name in 4 of 12 columns, the fields in 8; a date or a
   button 2 columns (148 px at 1280), a field 4 (from 1280 px: narrower, the words need the room) */
@media screen and (min-width: 768px) {
  .set-sec { grid-template-columns: calc(100% / 3 - 16px) minmax(0, 1fr); column-gap: var(--s5); }
}
@media screen and (min-width: 1280px) {
  .set-row { grid-template-columns: repeat(2, calc(25% - 18px)); column-gap: var(--s5); }
  .set-row.long, .set-row:has(> .wide) { grid-template-columns: calc(50% - 12px) calc(25% - 18px); }
  .set-pair { column-gap: var(--s5); }
  .set-pair .set-end { width: calc(25% - 18px); }
  .set-body > .actions button, .set-body > form.actions .button { width: calc(25% - 18px); }
}
/* One entry: the lines in 8 of 12 columns, Details in 4 (320 px at 1280); DR and CR 200 px */
@media screen and (min-width: 1000px) {
  .entry-grid { grid-template-columns: minmax(0, 1fr) calc(100% / 3 - 16px); column-gap: var(--s5); }
}
@media screen and (min-width: 1280px) { .entry-lines table th.amount { width: 200px; } }
/* Trial balance DR / CR 240 px; Invoices: Invoice 128, Date 124, Type 240, Total 184 (from 1280 px:
   narrower, the names need the room) */
@media screen and (min-width: 1280px) {
  .tb-box table th.amount { width: 240px; }
  table.invoices th:nth-child(1) { width: 128px; }
  table.invoices th:nth-child(2) { width: 124px; }
  table.invoices th:nth-last-child(2) { width: 240px; }
  table.invoices th:last-child { width: 184px; }
}
/* The phone bar: LEDGER 17 px (a2 phone top bar) */
@media screen and (max-width: 767px) { .phone-top .brand { font-size: 17px; letter-spacing: 0.02em; } }
/* Day book on a large screen (a2): Date 124, Voucher 108, DR and CR 184 px */
@media screen and (min-width: 1280px) {
  table.day-book th:nth-child(1) { width: 124px; }
  table.day-book th:nth-child(2) { width: 108px; }
  table.day-book th:nth-child(4), table.day-book th:nth-child(5) { width: 184px; }
}
/* Phone lists (a2 rows): names and figures 15 px (a ledger's statement keeps its own) */
@media screen and (max-width: 767px) { main table:not(.statement) td { font-size: 15px; } }
/* Trial balance (trial-balance-desktop-a2, a2-ch): each currency's head a 56 px band, its code 15 px
   in ink; the total row says "Total" as typed (only this box: the ledger statement keeps its head) */
.tb-box .sheet-head { min-height: 56px; padding: 0 var(--s4); align-items: center; background: var(--page); border-bottom: 1px solid var(--line); }
.tb-box .sheet-head .cur-head { font-size: 15px; color: var(--ink); letter-spacing: 0.06em; }
.tb-box tr.total td.lead { text-transform: none; letter-spacing: 0; }
/* Cash held / Receivable / Payable (cash-held-desktop-a2, a2-ch): each box opens with a 56 px band,
   its code 15 px in ink */
.ledger-box.list > .cur-head { display: flex; align-items: center; min-height: 56px; padding: 0 var(--s4); background: var(--page); border-bottom: 1px solid var(--line); font-size: 15px; color: var(--ink); letter-spacing: 0.06em; }
@media screen and (max-width: 767px) { .ledger-box.list > .cur-head { padding: 0 var(--s3); } } /* M163: "AED" on its rows' 12 px edge, not 4 px in */
/* The invoice form (invoice-new-phone-a2): a section's name 15 px; up to 1023 px Bill to someone
   else comes before Date and Currency, and B/L No., Shipping line and the ports take the row */
.inv-sec .section-head h2 { font-size: 15px; line-height: 20px; }
.inv-top > .bill-else { order: 3; grid-column: 1 / -1; } /* a computer: after Date and Currency */
@media screen and (max-width: 1023px) {
  .inv-top > .bill-else { order: 1; }
  .inv-top > .field-date, .inv-top > .field-currency { order: 2; }
  .sea-grid > label:not(.col-num) { grid-column: 1 / -1; }
}
/* BUGS M154 (owner 22/11/2026: "text out of grid and not snapping, non alignment of fields"):
   edges that nearly line up now line up exactly. A phone form's Cancel / Save split by the
   fields' 16 px gap; Add ledger's Phone / Address use the form's own 24 px columns; the sea
   freight rows on the eight columns the trucking and goods rows use (3 + 3 + 2); Home's This
   month currency band a full table row (it shared the currency tag's name, .cur, inline 4 px in) */
@media screen and (min-width: 768px) {
  form.ledger-form .lf-details { column-gap: var(--s5); }
  .sea-grid, .cont-grid, .sea-more { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .sea-grid > *, .cont-grid > *, .sea-more > * { grid-column: span 3; }
  .sea-grid > :nth-child(3n), .cont-grid > :nth-child(3n), .sea-more > :nth-child(3n) { grid-column: span 2; }
}
@media screen and (min-width: 768px) and (max-width: 1023px) {
  .sea-grid > label:not(.col-num) { grid-column: 1 / -1; }
  .sea-grid > .col-num { grid-column: span 4; }
}
table.month tr.cur { display: table-row; margin: 0; font-size: inherit; color: inherit; }
/* M154 at a tablet's width (768-1279 px): Settings' fields and buttons on the same two equal
   columns as Business details; a form's Cancel / Save the two field columns; Home's five quick
   buttons three a row (they wrapped 4 + 1) */
@media screen and (min-width: 768px) and (max-width: 1279px) {
  .set-row, .set-row.long { grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; }
  form.entry-form .button-group.pair, form.entry-form.laid .form-side .button-group.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
}
@media screen and (min-width: 768px) and (max-width: 999px) {
  .quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media screen and (min-width: 768px) { table.report td.act { text-align: right; } } /* M174: Remove at the table's right edge */
