/* ---------------------------------------------------------------------------
   Small Business Manager — screen styles.

   One card so far, because there is one screen so far. This file exists mainly
   so the stylesheet split is real for a second product: each product ships its
   own screen styles, and Core ships the shared ones.
   --------------------------------------------------------------------------- */

.sbm-screen {
  max-width: var(--content-max-width);
  display: flex;
  flex-direction: column;
  /* 32px rather than 24px. At 24px, cards on a long screen ran together and
     the page read as one column of boxes rather than as distinct answers to
     distinct questions — Jordan, 5 September 2026: "make sure there is
     sufficient spacing between cards". */
  gap: var(--space-5);
  padding-bottom: var(--space-6);
}

/* ---- A HOLDER STACKS LIKE THE SCREEN IT SITS IN ---------------------------
   [13 September 2026] Some screens mount a plain <div> into the screen and fill
   it later: Who owes me's cards, a problems area, a chart. The screen spaces its
   own children 32px apart, but nothing spaced what went INTO a holder. So on
   Who owes me the "Outstanding" card, the base rate card and every overdue
   invoice card sat 0px apart and read as one broken box (UI/UX audit H3). And
   an empty holder still took its share of the screen's gap, which is the blank
   band above the invoice list (audit M1).
   Matched by having no class, because every holder on these screens is made
   with el("div") and nothing else. A holder given a class later should get
   this rule under that class instead. */
.sbm-screen > div:not([class]) {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.sbm-screen > div:not([class]):empty {
  display: none;
}

.sbm-unbuilt-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-color: var(--accent-gold);
  background: rgba(232, 184, 75, 0.06);
}

/* ---- The entry form -------------------------------------------------------
   At the top of the screen rather than behind a button: recording money is why
   someone opened this screen, and a click to reveal the form is a click on
   every single entry. */
.sbm-entry-form {
  display: grid;
  /* min(180px, 100%) rather than a bare 180px: below a 180px column the track
     would otherwise refuse to shrink and push the page sideways. */
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: var(--space-3);
  /* TOP-ALIGNED, not bottom.
     `end` was chosen so single-line inputs sat level. It stopped working when
     the currency field began reserving a line for its error message — that
     cell is 86px tall against 63px for the others, so bottom-aligning pushed
     its label and input 22px ABOVE everything beside it. Jordan: "for some
     reason Amount is higher."
     Aligning to the top lines the LABELS up, which is what the eye actually
     reads along, and a taller cell then grows downwards into its own space
     instead of shoving itself upwards out of the row. */
  align-items: start;
}

/* A grid item's automatic minimum size is its MIN-CONTENT width, and an <input>
   carries an intrinsic one from its default `size` attribute — about 183px.
   So `1fr` could not shrink below that, and every form on every screen pushed
   the page wider than a 320px viewport however the columns were declared. That
   is why the small-screen rules appeared to do nothing: they were applying, and
   being overruled by the inputs themselves. */
.sbm-entry-form > * {
  min-width: 0;
}

/* ---- Only FIELDS belong in the columns -----------------------------------
   Everything in this card was a grid item, so `auto-fit` turned the heading,
   the explanatory paragraph and the Save button into columns standing BESIDE
   the inputs. On the Mileage screen that squeezed "You cannot use both methods
   for the same vehicle…" into a six-line ribbon under the button, with the
   fields floating away to the right and a band of empty space between.

   Jordan pointed at the symptom on 5 September 2026 — "I don't like how [it] is
   underneath the button" — on three separate screens. It is one cause: a
   heading is not a column, and neither is a sentence.

   Titles, prose, banners and actions now span the full width; the fields keep
   the responsive columns they were the point of. This is why the same fix
   improves Money in, Money out, Customers, Quotes, Invoices and Stock without
   any of them being touched. */
.sbm-entry-form > h2,
.sbm-entry-form > h3,
.sbm-entry-form > h4,
.sbm-entry-form > p,
.sbm-entry-form > details,
.sbm-entry-form > .alert-banner,
.sbm-entry-form > .sbm-form-help {
  grid-column: 1 / -1;
}

/* The action sits on its own row and keeps its natural width, rather than
   stretching the whole way across — a button as wide as the form reads as a
   page-level action, not as "save this entry". */
.sbm-entry-form > button {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: var(--space-2);
}

.sbm-entry-form input,
.sbm-entry-form select,
.sbm-entry-form textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.sbm-entry-form__error:empty {
  display: none;
}

.sbm-entry-form__error {
  color: var(--text-negative, var(--accent-red, #b3261e));
  grid-column: 1 / -1;
}

.sbm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.sbm-money__summary {
  font-weight: 600;
}

/* ---- A ledger row ---------------------------------------------------------
   A grid rather than a table because the row is replaced individually when one
   record changes, and a grid row can be swapped without disturbing the others'
   column widths. */
/* ---- ONE COLUMN SYSTEM FOR EVERY LIST -------------------------------------
   [13 September 2026, UI/UX audit H2] Each row is its own grid, so two rows —
   or a row and its heading row — line up only if every track comes out the
   same width in both. A content-sized (`auto`) track cannot: an "Outstanding"
   chip is 113px and a "Paid" chip 60px, so on Money in the amounts moved 53px
   between rows and AMOUNT stood 144px to the right of its figures. Jordan:
   "numbers not aligning in columns and tables. That looks unprofessional."

   So no track in these lists is sized by what is in it. Each is a fixed
   length, a fixed range such as minmax(4.5rem, 8.5rem), or a share of the space
   with a floor. A fixed range grows to its maximum before any share is handed
   out, so every row works out the same widths from the same card width,
   whatever it holds.

   Two columns come and go without changing the number of tracks:
   - THE ACTIONS CELL (Edit and Remove) is placed in the last track by name, so
     a row with a cell fewer cannot slide it left.
   - THE SEND COLUMN is 0px unless the list really has send controls, when the
     list card sets --sbm-send-track (below). The package without the
     calculator never has them.

   Money out uses this base row: date, description, amount, category, send,
   actions. */
.sbm-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(6rem, 1fr) 6.5rem minmax(7rem, 10rem) var(--sbm-send-track, 0px) minmax(4.5rem, 8.5rem);
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-row > .sbm-row__actions {
  grid-column: -2 / -1;
}

/* A chip is as wide as its word, at the start of its column. Stretched to fill
   the track it read as a bar, and a column of bars of different lengths. */
.sbm-row > .status-chip {
  justify-self: start;
}

/* Money out's send column, only where something is in it: a tick, "Sent to
   calculator", or "Send again" (the one bare button a money row carries).
   Money in has no send column; its control sits under the status chip (see
   .sbm-row--income). */
.sbm-list-card:has(.sbm-row__send-tick, .sbm-row__send-note, .sbm-row__sent, .sbm-row:not(.sbm-row--stock) > button) {
  --sbm-send-track: minmax(4.5rem, 9rem);
}

.sbm-row__amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sbm-row__description {
  overflow-wrap: anywhere;
}

.sbm-breakdown__row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-breakdown__row:last-child {
  border-bottom: none;
}

.sbm-first-run-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.sbm-comparison {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* ---- Documents ------------------------------------------------------------
   An invoice has to look like it came from a real business, so the print view
   is a document rather than a screenshot of the app. */
.sbm-print-root { display: none; }

.sbm-doc__header,
.sbm-doc__parties {
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.sbm-doc__lines {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}

.sbm-doc__lines th,
.sbm-doc__lines td {
  text-align: left;
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-doc__lines th:last-child,
.sbm-doc__lines td:last-child { text-align: right; }

.sbm-doc__totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.sbm-doc__grand-total { font-size: 1.25rem; }

.sbm-doc__cancelled {
  margin-top: var(--space-4);
  font-weight: 700;
}

/* A leading column for the print tickbox, added 5 September 2026. A grid with
   fewer columns than it has children wraps them onto a second row without any
   error — the row simply looks broken — so the count here must follow the
   markup. Quotes use this same row class and gained the same tick. */

/* ---- A flexible column must have a floor ---------------------------------
   `1fr` does not mean "at least something". Once the fixed and content-sized
   columns have taken what they need, a 1fr track is free to collapse to its
   item's MIN-CONTENT width — which for a sentence is one character. Jordan saw
   the result on Money in: descriptions one or two characters wide and hundreds
   of pixels tall.

   Measured before the fix, at a 1440px window: fine. At 1280px: description
   172px. At 1100px: 10px, and the row 521px tall. The sidebar is 248px, so a
   1280px or 1366px laptop — the commonest sizes there are — sits inside that
   failure band. The stacked layout only began at 767px, leaving a wide dead
   zone in between where the grid was too tight and the reflow had not started.

   minmax() gives every flexible column a floor, and the fixed columns are a
   little tighter so the floors fit sooner. The stacked layout now starts at
   1100px as well, so there is no width at which neither works. */
/* Invoices and quotes: tick, number, customer, date, amount, status, actions.
   [13 September 2026, UI/UX audit H2] Status and actions were `auto` tracks,
   so a "Converted" chip (100px) beside a "Sent" one (61px) moved the quote
   amounts 65px from one row to the next. Status is now a fixed width that holds
   the longest status there is; the actions share the space with the customer's
   name and wrap inside their own column. */
.sbm-row--invoice { grid-template-columns: 1.6rem 5.5rem minmax(6rem, 1fr) 6rem 6rem 6.5rem minmax(7rem, 1.5fr); }
.sbm-row--customer { grid-template-columns: minmax(8rem, 1fr) minmax(8rem, 1fr) 7rem 7rem minmax(4.5rem, 8.5rem); }

.sbm-row__actions {
  display: flex;
  gap: var(--space-2);
  /* WRAPS AT EVERY WIDTH, not only below the stacking breakpoint.
     
     An `auto` grid track cannot be squeezed below its min-content, and the
     min-content of a flex row that will not wrap is ALL of its buttons laid
     end to end. An invoice row carries four (Print, Mark paid, Cancel, Part
     payment) where a quote carries two, so between roughly 1100px — where the
     stacked layout stops — and about 1230px, the invoice row could not fit and
     spilled "Part payment" straight out through the side of the card. Only
     invoices, because only invoices have four.
     
     Reported by Jordan on 5 September 2026, in Chrome and Safari, at a window
     that was not full width. Wrapping gives the track a min-content of one
     button instead of four, so the row fits and the buttons take a second line
     for the few hundred pixels where they must. */
  flex-wrap: wrap;
}

@media print {
  /* Only the document prints. Everything else is the application, and nobody
     wants a sidebar on their invoice.

     SCOPED TO body.sbm-printing, 14 OCTOBER 2026, AND THE SCOPE IS THE WHOLE
     POINT. This used to read `body > *:not(.sbm-print-root)`, which applied to
     EVERY print rather than only to an invoice or a quote — and `.sbm-print-root`
     exists only while export/printDocument.js is printing one. So any other
     print hid every element on the page and produced a blank sheet.
     It cost five print paths, not one. In the BUNDLE this stylesheet loads
     beside the calculator's, so it silenced the calculator's own four prints
     too: ui/taxBreakdown.js, ui/dashboard.js, ui/hmrcBoxMapping.js and
     ui/taxAuditReportScreen.js all worked in the calculator sold alone and
     printed nothing in the bundle. Found by the marketing session while
     filming on 14 October, measured by printing a PDF from the published
     bundle: 3,371 characters on screen, 1.0 KB and zero characters printed.
     `!important` is why it won: core/css/print.css asks for `.app-body` to be
     displayed without it, so load order never came into it.
     printDocument.js now adds `sbm-printing` to the body for exactly as long
     as the print root is there, so every other print falls through to
     core/css/print.css, which hides the chrome and prints the screen. */
  body.sbm-printing > *:not(.sbm-print-root) { display: none !important; }
  .sbm-print-root { display: block !important; }
  .sbm-doc { color: #000; background: #fff; }

  /* ---- The browser's own header and footer ---------------------------------
   *
   * Jordan, 4 September 2026: can the file reference at the bottom of a quote
   * or invoice be removed? It is not ours — Small Business Manager prints no
   * footer at all. It is the BROWSER's print chrome: the file:/// path along
   * the bottom and the page title along the top, which browsers draw into the
   * page margin.
   *
   * A page cannot switch that off directly. What it can do is claim the margin:
   * Chrome and Edge draw those lines INSIDE the @page margin, so setting it to
   * zero leaves them nowhere to go. The document then supplies its own margin
   * as padding, so nothing ends up against the paper edge.
   *
   * NOT VERIFIED IN EVERY BROWSER, and said honestly rather than assumed:
   * Firefox and Safari may still show theirs, where the customer can untick
   * "Headers and footers" (Chrome, Edge) or "Print headers and footers"
   * (Safari) in the print dialog. That is in the user guide rather than left to
   * be discovered on a document already sent to a client.
   */
  @page {
    margin: 0;
  }

  /* The margin the page no longer provides. Generous enough to look like a
     letter rather than a screenshot, and in millimetres because this is paper. */
  .sbm-doc {
    padding: 18mm 16mm;
    box-sizing: border-box;
  }
}

.sbm-mode-switch {
  display: flex;
  gap: var(--space-2);
}

.sbm-overdue-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sbm-vat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
}

.sbm-vat-boxes {
  display: flex;
  flex-direction: column;
}

/* ---- VAT: "If you register for VAT" ---------------------------------------
   [13 September 2026, UI/UX audit H10] For a business that is not registered,
   the return figures and the Flat Rate Scheme sit folded inside one card. The
   heading is the fold's own control, so it keeps its size rather than turning
   into a link. Each part inside is ruled off from the one before rather than
   boxed, because a card inside a card was an audit finding of its own (M9). */
.sbm-vat-if-registered summary {
  cursor: pointer;
}

.sbm-vat-if-registered summary > h2 {
  display: inline;
}

.sbm-vat-if-registered details > * + * {
  margin-top: var(--space-3);
}

.sbm-vat-if-registered__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-hairline);
}

.sbm-vat-if-registered__section > .button {
  align-self: flex-start;
}

/* The Overview's "What does being under the threshold actually mean?". Its
   paragraphs sat 0px apart and read as one grey block, the first hard under
   the question that opens it (UI/UX audit H3). 13 September 2026. */
.sbm-vat-explainer > * + * {
  margin-top: var(--space-3);
}

.sbm-vat-explainer > summary {
  cursor: pointer;
}

/* "What this does not cover" on VAT: the items ran together with no space
   between them (audit L7). */
.sbm-vat-limits > li + li {
  margin-top: var(--space-2);
}

.sbm-row--import {
  grid-template-columns: 6rem 1fr 7rem 12rem;
}

/* Six columns now: item, held, cost each, sells for each, value at cost, value
   at your prices — plus the Remove button. Sale price and retail value were
   captured by the form from the start and never displayed. */
/* THE LAST TRACK IS FIXED, NOT `auto`.
   The heading row's final cell is empty and the data rows' is a Remove button,
   so an `auto` track measured ~0 on one and ~62px on the other. The 1fr column
   absorbed the difference, and every column after it sat ~62px further right on
   the headings than on the figures below — Jordan, twice: "the columns and the
   rows do not align."
   Matching the classes was necessary but not sufficient: two rows only line up
   if their TRACKS are the same width, and a content-sized track cannot be when
   the content differs. */
.sbm-row--stock { grid-template-columns: minmax(8rem, 1fr) 5.5rem 7rem 7rem 7rem 7rem 5.5rem; }

.sbm-year-end-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}

/* The actions track is a fixed range, not `auto`, like every list (see "One
   column system" at .sbm-row). 13 September 2026. */
.sbm-row--journey { grid-template-columns: 6rem minmax(6rem, 1fr) 8rem 7rem minmax(4.5rem, 8.5rem); }

.sbm-vehicle-card,
.sbm-mileage-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}

/* Money in carries a customer column; money out does not — an expense has a
   supplier, which is a different thing. */
/* EIGHT columns, not seven: date, customer, description, amount, category,
   paid/outstanding chip, the send control, and the actions (Edit and Remove).
   The send control was added on 4 September 2026 and pushed the eighth child
   onto a second line — one entry occupying two rows, which Jordan reported. A
   grid with fewer columns than children does not error, it just wraps. */
/* THE TRACKS. [13 September 2026, UI/UX audit H2] Seven, the same in both
   packages: date, customer, description, amount, category, status, actions.
   Status is a fixed width, at least that of an "Outstanding" chip, so a "Paid"
   row no longer puts its amount 53px to the right of the row above.

   THE WORDS GET THE SPACE. Customer and description share what is left with
   the category and the actions, all as shares of the space (0.9, 1.2, 0.5 and
   0.7) rather than fixed ranges, because a fixed range is widened before any
   share is handed out. The first version gave the send and actions columns
   their full 138px and 136px first, and left a customer's name 56px and its
   description 72px wide at 1280px — five lines to a row (found by the records
   work the same day). The actions keep a floor wide enough for Edit and Remove
   side by side, so a one-line entry stays one line.
   Measured at a 918px row, a 1280px window, and at 739px, the narrowest
   before the rows stack. */
.sbm-row--income {
  grid-template-columns:
    4rem
    minmax(4rem, 0.9fr)
    minmax(5.5rem, 1.2fr)
    6rem
    minmax(4.5rem, 0.5fr)
    var(--sbm-status-track, 7.25rem)
    minmax(var(--sbm-actions-min, 8.5rem), 0.7fr);
}

/* Below a 1280px window the words matter more than Edit and Remove sharing a
   line: with the 8.5rem floor, a 1101px window left the customer 68px and the
   description 91px. Here the two actions may stack instead. */
@media (max-width: 1279px) {
  .sbm-row--income {
    --sbm-actions-min: 5rem;
  }
}

/* ---- WITH THE TAX CALCULATOR: THE SEND CONTROL SITS UNDER THE STATUS -------
   [13 September 2026] Where the calculator is installed and sharing is on,
   every money-in row gains a send control: a tick, "Not paid yet", "Send
   again", or "Sent to calculator" with "Remove from calculator" beneath it. As
   a column of its own that took a track the rest of the row could not spare.
   Under the paid or outstanding chip it is read as what it is — more of the
   row's status — and the columns are the same seven as without the
   calculator. The status column widens to take "Sent to calculator", and
   everything else in the row centres across the two lines.
   Wide rows only: stacked, the control keeps a line of its own. */
@media (min-width: 1101px) {
  /* These rows are two lines tall already, so Edit and Remove may take two
     lines as well, and give their width to the customer and the description. */
  /* 9.75rem holds "Sent to calculator" on one line; at 9rem the chip broke
     into a two-line pill. */
  .sbm-list-card:has(.sbm-row--income > :is(.sbm-row__sent, .sbm-row__send-note, .sbm-row__send-tick, button)) {
    --sbm-status-track: 9.75rem;
    --sbm-actions-min: 5rem;
  }

  /* "Remove from calculator" lines up under the chip it belongs to, rather than
     centring itself when it wraps. */
  .sbm-row--income .sbm-row__unsend {
    text-align: left;
  }

  .sbm-row--income:has(> :is(.sbm-row__sent, .sbm-row__send-note, .sbm-row__send-tick, button)) {
    row-gap: var(--space-1);
  }

  .sbm-row--income:has(> :is(.sbm-row__sent, .sbm-row__send-note, .sbm-row__send-tick, button)) > * {
    grid-row: 1 / span 2;
  }

  .sbm-row--income:has(> :is(.sbm-row__sent, .sbm-row__send-note, .sbm-row__send-tick, button)) > .status-chip {
    grid-column: 6;
    grid-row: 1;
    align-self: end;
  }

  .sbm-row--income > :is(.sbm-row__sent, .sbm-row__send-note, .sbm-row__send-tick, button) {
    grid-column: 6;
    grid-row: 2;
    justify-self: start;
    align-self: start;
  }
}

.sbm-row__customer { overflow-wrap: anywhere; }

/* ---- Small screens --------------------------------------------------------
   WCAG 1.4.10 requires content to reflow at 320px without scrolling sideways,
   and every screen here failed it. Small Business Manager is far more tabular
   than the calculator, so it has much more to get wrong — and the cause was
   ordering rather than absence: an earlier block already stacked `.sbm-row`,
   but each `.sbm-row--*` variant is declared afterwards with its own
   grid-template-columns, so the variants won at every width and the rule did
   nothing.

   This block sits at the END of the file deliberately, and names every variant,
   so a new row type added later inherits the stacked layout rather than
   silently reintroducing the failure. */
/* 1100px, not 767px. The dense rows carry up to eight columns and the sidebar
   takes 248px of the window, so a 1280px laptop leaves about 1030px of content
   — and below roughly 1100px of window the columns can no longer all fit at a
   readable width even with the floors above. Reflowing sooner is better than
   holding a grid together at ten pixels a column. */
@media (max-width: 1100px) {
  /* The import review keeps the single column it had. Its columns belong to
     the "Data & records" block at the end of this file. */
  .sbm-row--import {
    grid-template-columns: 1fr;
    gap: var(--space-1);
    padding: var(--space-3) 0;
  }

  /* ---- STACKED ROWS STILL KEEP THEIR FIGURES IN A COLUMN ------------------
     [13 September 2026, UI/UX audit H2] Stacked, every cell took a line of its
     own and the amount sat left-aligned under the date, so down a list the
     figures ran ragged: 18px on Money in, 16px on Money out, 13px on Invoices
     at a phone's width. (The note that stood here said a right-aligned amount
     floats away from its row — on a line of its own, it would.)

     The amount now shares the FIRST line with the date (with the tick and the
     number on invoices and quotes), right-aligned at the edge of the row. So
     every figure in a list ends in the same place and still reads as part of
     its row. Everything else takes a full line beneath, in the order it had.
     The heading row goes, because its words no longer sit over anything. */
  /* 7rem for the amount, not `auto`: an auto track is as wide as each row's
     own amount, so the column beside it would change width from row to row. */
  .sbm-row:not(.sbm-row--import, .sbm-row--stock) {
    grid-template-columns: minmax(0, 1fr) 7rem;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0;
  }

  .sbm-row:not(.sbm-row--import, .sbm-row--stock) > * {
    grid-column: 1 / -1;
  }

  .sbm-row:not(.sbm-row--import, .sbm-row--stock) > .sbm-row__date:first-child {
    grid-column: 1;
    grid-row: 1;
  }

  .sbm-row:not(.sbm-row--import, .sbm-row--stock) > .sbm-row__amount {
    grid-column: -2;
    grid-row: 1;
    text-align: right;
  }

  .sbm-row.sbm-row--invoice {
    grid-template-columns: auto minmax(0, 1fr) 7rem;
  }

  .sbm-row.sbm-row--invoice > .sbm-row__tick {
    grid-column: 1;
    grid-row: 1;
  }

  .sbm-row.sbm-row--invoice > .sbm-row__tick + .sbm-row__date {
    grid-column: 2;
    grid-row: 1;
  }

  /* Stock: a line per figure, with its column's name beside it (each cell
     carries data-label), so the figures share a right-hand edge. */
  .sbm-row.sbm-row--stock {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
    padding: var(--space-3) 0;
  }

  .sbm-row--stock > [data-label] {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    text-align: right;
  }

  .sbm-row--stock > [data-label]::before {
    content: attr(data-label);
    color: var(--text-secondary);
    text-align: left;
  }

  .sbm-row--stock > button {
    justify-self: start;
  }

  .sbm-row--head,
  .sbm-row--headings {
    display: none;
  }

  /* One field per line. auto-fit with a 180px minimum still overflows once
     the sidebar drawer's padding is taken off a 320px viewport. */
  .sbm-entry-form {
    grid-template-columns: 1fr;
  }

  .sbm-filters,
  .sbm-mode-switch,
  .sbm-first-run-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* Long descriptions and reference numbers are the usual culprits: they have
     no spaces to break at, so they push the page wider than the viewport. */
  .sbm-row__description,
  .sbm-row__customer,
  .sbm-breakdown__row {
    overflow-wrap: anywhere;
  }

  /* An invoice is a fixed-width document by nature. It scrolls inside its own
     box rather than making the whole page scroll. */
  .sbm-doc__lines {
    display: block;
    overflow-x: auto;
  }
}

/* A file input is not a plain text field: its intrinsic width is the "Choose
   file" button plus room for a filename, which came to 299px inside a card
   whose padding leaves 288px at a 320px viewport. Eleven pixels over is still
   a horizontal scrollbar, and still WCAG 1.4.10. */
.sbm-file-input {
  max-width: 100%;
  box-sizing: border-box;
}

/* The six records the traditional basis requires, listed at year end. */
.sbm-required-records {
  margin: var(--space-1) 0 0;
  padding-left: var(--space-4);
  color: var(--text-secondary);
}

.sbm-required-records li {
  margin-bottom: var(--space-1);
}

/* ---- The title block every screen opens with ----------------------------- */
.sbm-screen-header {
  margin-bottom: var(--space-4);
}

.sbm-screen-header__title {
  margin: 0;
}

.sbm-screen-header__context {
  margin: var(--space-1) 0 0;
  color: var(--text-secondary);
}

/* Column headings for a ledger. Inherits the row's own grid template through
   .sbm-row, so the headings cannot drift out of line with the cells beneath
   them the way a separately-declared header grid would. */
.sbm-row--head {
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-1);
  font-size: var(--text-label-size, 12px);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sbm-row--head:hover {
  background: none;
}

/* The form's submit button gets a row of its own rather than a grid cell.
   Sharing a track with the fields squeezed it to the width of the narrowest
   one, so "Save and add another" wrapped onto two lines and the button grew
   into a block twice the height of everything beside it. */
.sbm-entry-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: start;
  white-space: nowrap;
}

/* .sbm-screen is a flex column, so a bare button stretches to the full width of
   the content area — which made "Export to a spreadsheet" read as the main action
   on a screen whose main job is recording entries. */
.sbm-screen > .button {
  align-self: flex-start;
}

/* The period total, under the table it totals. Weighted so it reads as the
   answer to the column above it rather than as another row. */
.sbm-period-total {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
  font-weight: 600;
}

/* ---- Overview: period bar, owed, VAT position, trend ----------------------
 *
 * Added 4 September 2026. The Overview totalled every month under a header
 * naming the latest one, and said nothing about money owed until it was
 * already overdue. These are the styles for what it says now.
 */
.sbm-period-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.sbm-owed .text-title.numeric,
.sbm-trend__row .numeric {
  font-variant-numeric: tabular-nums;
}

.sbm-owed .text-title.numeric {
  font-size: 1.75rem;
  margin: var(--space-1) 0 var(--space-2);
}

/* ---- The last six months, as a table ---------------------------------------
   [13 September 2026, UI/UX audit H2 and H8] This card's own bars went — the
   Overview keeps one chart of money in against money out, not two — and the
   words "in", "out" and "profit" moved off every figure into a heading row, so
   the figures can be right-aligned and their pence line up. */
.sbm-trend__table {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.sbm-trend__row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
  align-items: baseline;
}

.sbm-trend__row:last-child { border-bottom: none; }

.sbm-trend__row > .numeric { text-align: right; }

.sbm-trend__row--head {
  border-bottom-color: var(--border-strong, var(--border-hairline));
  color: var(--text-secondary);
}

/* On a phone the month takes a line of its own and the three figures sit in
   three columns beneath it, headings included, so they still line up. Four
   columns could not hold their numbers, and a figure that wraps mid-amount is
   worse than a month on a line by itself. */
@media (max-width: 640px) {
  .sbm-trend__row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: var(--space-1);
  }

  .sbm-trend__row > :first-child {
    grid-column: 1 / -1;
  }
}

/* ---- Overview: itemised owed list and open quotes -------------------------
 *
 * Both are tables of a handful of rows, not paginated lists — a sole trader
 * with fifty unpaid invoices has a different problem than this card can help
 * with, and the screens themselves handle volume.
 */
.sbm-owed__list {
  margin: var(--space-3) 0;
  border-top: 1px solid var(--border-hairline);
}

/* 16px between columns, not 8px: with the figures right-aligned, "£1,622.00"
   ended 8px from "90 days overdue" beside it. */
.sbm-owed__row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)) minmax(0, 1.1fr);
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
  align-items: baseline;
  position: relative;
}

/* The quotes table has one column fewer. */
.sbm-quotes-card__row {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr);
}

.sbm-owed__row--head { border-bottom: 1px solid var(--border-strong, var(--border-hairline)); }

/* Figures, and the headings over them, end on the same edge.
   [13 September 2026, UI/UX audit H2] */
.sbm-owed__row > .numeric { text-align: right; }

/* Overdue is marked with a rule, not a background: a red row for every late
   invoice turns the card into a wall of alarm and stops being read.
   THE RULE IS DRAWN BESIDE THE ROW, NOT IN IT. [13 September 2026, UI/UX audit
   H2] It was a left border plus padding on the overdue row alone, which made
   that row's columns narrower than every other row's. Its figures sat 13-22px
   out of line, and "Invoiced" and "Still owed" missed their columns. Drawn in
   the card's padding to the left of the row, it moves nothing. */
.sbm-owed__row--overdue::before {
  content: "";
  position: absolute;
  top: var(--space-1);
  bottom: var(--space-1);
  left: calc(-1 * var(--space-3));
  width: 3px;
  border-radius: 2px;
  background: var(--colour-attention);
}

.sbm-owed .numeric,
.sbm-quotes-card .numeric { font-variant-numeric: tabular-nums; }

@media (max-width: 767px) {
  /* 5.5rem for the number, not `auto`, so every customer name starts at the
     same place rather than wherever each row's own number ends. */
  .sbm-owed__row,
  .sbm-quotes-card__row {
    grid-template-columns: 5.5rem minmax(0, 1fr);
    row-gap: var(--space-1);
  }

  .sbm-owed__row--head { display: none; }

  /* Invoice and customer share the first line. Every figure after them takes a
     line of its own, named by its data-label (set in overviewScreen.js) and
     right-aligned, so the figures still line up once the headings have gone. */
  .sbm-owed__row > :nth-child(n + 3) {
    grid-column: 1 / -1;
  }

  .sbm-owed__row > [data-label] {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    text-align: right;
  }

  .sbm-owed__row > [data-label]::before {
    content: attr(data-label);
    color: var(--text-secondary);
    text-align: left;
  }
}

/* The part-payment control sits on its own line beneath an invoice row.
   An <input> has an intrinsic minimum width of roughly 180px; inside the row's
   `auto` actions column that took 485px and squeezed the customer name to ten
   pixels, one letter per line. Spanning the grid instead gives both their
   space. */
.sbm-invoice__part-payment {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding-top: var(--space-2);
}

.sbm-invoice__part-payment .text-field {
  max-width: 16rem;
  min-width: 0;
}

/* ---- VAT: turnover month by month ------------------------------------------
 *
 * Replaced a progress ring, which was small and whose figures ran past its
 * edge. A ring answers "how close am I today"; the question that matters for a
 * threshold you cross by accident is which way you are heading, and which
 * months are carrying it.
 *
 * Scrolls horizontally rather than squeezing: a business with three years of
 * records has 36 bars, and thirty-six 8px slivers tell nobody anything.
 */
.sbm-vat__headline {
  font-size: 2rem;
  margin: var(--space-2) 0 0;
  font-variant-numeric: tabular-nums;
}

/* ---- The month-by-month bar chart ---------------------------------------
   Shared by VAT turnover, money in and money out — see ui/monthlyBarChart.js.
   Renamed from .sbm-vat-chart when Jordan asked for the same chart on money in
   and money out; one implementation, one set of styles, so the three cannot
   drift apart. */
.sbm-month-chart__bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-3) 0 0;
  min-height: 200px;
}

/* Columns SHARE the width rather than each taking a fixed 4.5rem. With three
   months of records the bars occupied the left third of a full-width card and
   the rest was blank, which reads as missing content rather than as a small
   dataset. `flex: 1` spreads them; the min-width stops twelve months becoming
   slivers, at which point the container scrolls as it always did. */
.sbm-month-chart__col {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-width: 4.5rem;
  max-width: 9rem;
  height: 180px;
}

.sbm-month-chart__bar {
  width: 60%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--border-strong, var(--text-secondary));
  opacity: 0.35;
}

/* The twelve months actually counting towards the threshold today. */
.sbm-month-chart__col.is-counted .sbm-month-chart__bar {
  background: var(--accent-teal);
  opacity: 1;
}

/* The figure the threshold is tested against. */
.sbm-month-chart__bar--total { background: var(--accent-navy); opacity: 1; }

/* PINNED TO THE RIGHT-HAND EDGE, AT THE WIDTH ITS FIGURE NEEDS.
   [13 September 2026, UI/UX audit H8] As one more shared-width column it was
   squeezed to 4.5rem and pushed off the end of the scrolling row, so the total
   — the point of the chart — read "£27,…" on Money in and "£32,…" on VAT. It
   keeps its own width now and sticks to the edge while the months scroll
   beneath it; its background hides them as they pass. */
.sbm-month-chart__col--total {
  position: sticky;
  right: 0;
  z-index: 1;
  flex: 0 0 auto;
  max-width: none;
  border-left: 1px solid var(--border-hairline);
  padding-left: var(--space-3);
  background: var(--surface-card);
}

.sbm-month-chart__value,
.sbm-month-chart__label {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}


/* Money in reads as the business's own colour; money out as the loss colour,
   matching the profit and loss figures on the Overview. */
.sbm-month-chart.is-income .sbm-month-chart__col .sbm-month-chart__bar { background: var(--accent-teal); opacity: 1; }
.sbm-month-chart.is-expense .sbm-month-chart__col .sbm-month-chart__bar { background: var(--accent-coral); opacity: 1; }
.sbm-month-chart.is-income .sbm-month-chart__bar--total,
.sbm-month-chart.is-expense .sbm-month-chart__bar--total { background: var(--accent-navy); }

/* The selected month's figures, above the entry form. The total already
   existed at the bottom of the screen under a long list — the wrong end for the
   question that makes somebody open the screen. */
.sbm-month-headline__value {
  font-size: 2rem;
  margin: var(--space-1) 0 var(--space-2);
  font-variant-numeric: tabular-nums;
}

/* The customer's own logo. Height-capped in both places: on screen so the
   preview cannot dominate My Business, and on a document so a large image
   cannot push an invoice onto a second page. */
.sbm-logo-preview__image {
  max-height: 80px;
  max-width: 260px;
  margin: var(--space-2) 0;
}

.sbm-doc__logo {
  max-height: 70px;
  max-width: 240px;
  margin-bottom: var(--space-2);
  display: block;
}

@media print {
  .sbm-doc__logo { max-height: 60px; }
}

/* The capital question on money out. A checkbox rather than a select, because
   it is a yes/no that most people answer "no" to — and its wording changes with
   the recording basis, since the correct answer does. */


.sbm-capital-help {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.sbm-capital-help p { margin: var(--space-2) 0; }

/* The "change your basis" button sits inside a caption line, so it has to read
   as part of the sentence rather than as a call to action. */
.sbm-capital-field__change {
  padding: 0;
  min-height: 0;
  font-size: inherit;
  vertical-align: baseline;
}

/* ---- The year-end summary tables ----------------------------------------
   Real tables, because this is the page a customer prints and hands to an
   accountant. Figures right-aligned and tabular-lining so the columns line up
   on the printed page; the total rules off above itself the way a set of
   accounts does. */
.sbm-summary-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0;
}

.sbm-summary-table th,
.sbm-summary-table td {
  padding: var(--space-2) 0;
  text-align: left;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-summary-table th[scope="row"] { font-weight: 400; }

.sbm-summary-table .numeric,
.sbm-summary-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sbm-summary-table thead th { color: var(--text-secondary); }

.sbm-summary-table__total th,
.sbm-summary-table__total td {
  font-weight: 600;
  border-top: 2px solid var(--border-strong, var(--border-hairline));
  border-bottom: none;
}

.sbm-summary-table__profit { color: var(--accent-teal-text); }
.sbm-summary-table__loss { color: var(--accent-coral-text); }

.sbm-summary-heading {
  margin-top: var(--space-4);
  display: block;
}

/* The claims sub-heading inside a breakdown card. Sets the allowances apart
   from the nine HMRC categories above them without looking like a new card. */
.sbm-breakdown__heading {
  margin: var(--space-3) 0 var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  display: block;
}

/* The stock list's column headings. Aligned to the same grid as its rows, so a
   heading cannot drift away from the column it names. */
.sbm-row--headings {
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: var(--space-1);
  color: var(--text-secondary);
  align-items: end;
}

/* The link to the expenses-vs-capital guidance. Reads as a question the form
   is answering for you, not as an action that changes anything. */
.sbm-capital-help__open {
  align-self: flex-start;
  padding-left: 0;
  padding-right: 0;
  text-align: left;
}

/* ---- The box mapping tables ----------------------------------------------
   Real tables: this is the page a customer prints and works from while filling
   in a return, so the columns must line up and a screen reader must be able to
   say which column a figure is in. */
.sbm-box-table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-3) 0 0;
}

.sbm-box-table th,
.sbm-box-table td {
  padding: var(--space-2) var(--space-2) var(--space-2) 0;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-box-table thead th { color: var(--text-secondary); }
.sbm-box-table th[scope="row"] { font-weight: 400; }

.sbm-box-table__box {
  white-space: nowrap;
  width: 5.5rem;
}

.sbm-box-table__amount,
.sbm-box-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A note belongs under the row it qualifies, not in its own column — it is
   often a sentence and would wreck the column widths. */
.sbm-box-table__note {
  margin: var(--space-1) 0 0;
  color: var(--text-secondary);
}

.sbm-box-table__total th,
.sbm-box-table__total td {
  font-weight: 600;
  border-top: 2px solid var(--border-hairline);
  border-bottom: none;
}

/* Entering HMRC's published rate for a year this copy predates. Laid out as
   rows so several years can be filled in without the card becoming a maze. */
.sbm-rate-entry__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-rate-entry__row > .text-label { flex: 1 1 100%; }

/* One document per sheet in a bulk print run. `break-after` is set inline per
   page so a single-document print is untouched; this only guarantees the page
   itself is never split across sheets mid-document. */
.sbm-print-page { break-inside: auto; }

/* The quote win rate, given the size the figure deserves — it is the whole
   point of the card, and at body size it read as an aside. */
.sbm-winrate {
  font-size: 2.5rem;
  margin: var(--space-2) 0 0;
  color: var(--accent-teal-text);
  font-variant-numeric: tabular-nums;
}

/* A field that is taller than one line — an address, a note — takes its own
   row. The entry grid bottom-aligns its items so that single-line inputs sit
   level; a multi-line box in the same row defeats that and drags every label
   beside it downwards. */
.sbm-entry-form > .sbm-field--wide {
  grid-column: 1 / -1;
}

/* ---- The bar that appears when rows are ticked ---------------------------
   It had no styles at all, so "Send to the tax calculator", "Delete" and
   "Clear selection" stacked hard against each other with the count line jammed
   on top — Jordan, 5 September 2026: "add some spacing between the buttons".

   The count gets its own row because it is the thing to read before choosing;
   the actions sit on one line with room between them, and the destructive one
   is separated from the others so it is never the button you hit by accident. */
.sbm-send-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.sbm-send-bar > p {
  flex: 1 1 100%;
  margin: 0;
}

/* Pushes anything after it — Delete, Clear — away from the primary action, so
   the gap itself says "these are different kinds of thing". */
.sbm-send-bar .button--danger,
.sbm-send-bar .button--tertiary {
  margin-left: auto;
}

.sbm-send-bar .button--danger ~ .button--tertiary {
  margin-left: 0;
}

/* The per-row print tickbox. Sized like the money-screen ticks so the same
   gesture looks the same wherever it appears. */
/* ---- Tick boxes, at an accessible size -----------------------------------
   WCAG 2.2 AA (2.5.8, Target Size Minimum) asks for 24x24 CSS pixels. These
   were ~17px, and they are not decorative: they choose which records are sent
   to a tax return, and which are deleted. Fiddly on a trackpad, and a miss on
   the wrong row has consequences.

   The visual box stays modest — 18px, which suits the row — and the TARGET is
   brought up to 24px with padding, so the hit area meets the criterion without
   the control dominating the line. */
.sbm-row__tick,
.sbm-row__send-tick,
.sbm-capital-field__box {
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 3px;
  box-sizing: content-box;
  align-self: center;
  margin: 0;
  cursor: pointer;
}

.sbm-capital-field__box {
  margin-right: var(--space-2);
}

/* An empty selection bar must not draw its rule or claim its space — on the
   Invoices screen it left a horizontal line and a band of gap above the list
   with nothing in it. */
.sbm-send-bar:empty {
  display: none;
}

/* The category breakdown inside the money headline card. Compact — it sits
   under a large figure and must not compete with it. */
.sbm-headline-breakdown {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-3);
}

.sbm-headline-breakdown th,
.sbm-headline-breakdown td {
  padding: var(--space-1) 0;
  text-align: left;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-headline-breakdown th[scope="row"] { font-weight: 400; }

.sbm-headline-breakdown td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 7rem;
}

.sbm-headline-breakdown td:last-child { width: 3.5rem; color: var(--text-secondary); }

/* The "Sent to calculator" chip and its "Remove from calculator" action share
   one grid cell — see the note in moneyScreen.js. Stacked, because side by side
   they force the row's other columns to shrink. */
.sbm-row__sent {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

.sbm-row__unsend {
  padding: 0;
  min-height: 0;
  font-size: var(--text-caption-size);
}

/* The stock quantity column, so its heading and its figures share an
   alignment. */
.sbm-row__quantity { text-align: right; }

/* ---- A list, contained ----------------------------------------------------
   Lists now sit in cards like the forms above them. Two adjustments follow
   from that: rows already carry their own separators, so the card must not
   add padding that makes the first row look inset; and an empty state inside
   a card should sit in the middle of it rather than hard against the corner. */
.sbm-list-card {
  padding: var(--space-3) var(--space-4);
}

.sbm-list-card .windowed-list__count,
.sbm-list-card > .text-caption:first-child {
  color: var(--text-secondary);
  margin: 0 0 var(--space-2);
}

/* The "nothing here yet" line, which used to float on the page background in
   small grey type where it was easy to miss entirely. */
.sbm-list-card .windowed-list__empty,
.sbm-list-card > p:only-child {
  margin: 0;
  padding: var(--space-5) 0;
  text-align: center;
  color: var(--text-secondary);
}

/* ---- Getting started ------------------------------------------------------
   A checklist on the empty Overview. Each row is tick · text · action, so the
   eye runs down the ticks to find the first thing still to do. */
.sbm-getting-started__step {
  display: grid;
  grid-template-columns: 1.75rem 1fr auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-getting-started__step:last-child { border-bottom: none; }

.sbm-getting-started__mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-teal-text);
  font-weight: 600;
}

.sbm-getting-started__step.is-done .sbm-getting-started__mark {
  border-color: var(--accent-teal);
  background: rgba(47, 184, 172, 0.14);
}

/* Done steps recede rather than disappear — the list is also a record of what
   has been covered, which is reassuring on a first visit. */
.sbm-getting-started__step.is-done .sbm-getting-started__text { opacity: 0.65; }

.sbm-getting-started__text p { margin: 0; }
.sbm-getting-started__text p + p { margin-top: var(--space-1); }

/* The bulk-import route, offered under the checklist rather than beside it. */
.sbm-getting-started__bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

/* Confirmation that an entry saved, beside the button that saved it. */
.sbm-saved-note {
  grid-column: 1 / -1;
  margin: var(--space-1) 0 0;
  color: var(--accent-teal-text);
}

/* "Add a customer" beneath the customer select, sized as a hint rather than an
   action competing with the form's own button. */
.sbm-inline-add {
  padding: var(--space-1) 0 0;
  min-height: 0;
  font-size: var(--text-caption-size);
  align-self: flex-start;
}

/* ---- Line items -----------------------------------------------------------
   A row per thing being charged for. Wider columns for the description, since
   that is the part a customer reads on the document; the numbers keep the
   narrow columns they need and nothing more. */
.sbm-line-items {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border-hairline);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

/* h2 as well as h3. The heading became an h2 for heading order, this rule still
   named only h3, and "What you are charging for" sat 0px above the first line
   on both the invoice and the quote forms (UI/UX audit H3, 13 September 2026). */
.sbm-line-items__header :is(h2, h3) { margin: 0 0 var(--space-2); }

.sbm-line-item {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) 6rem 9rem 7rem auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-2) 0;
}

/* The line's own total is a figure, not a field — no box round it, so the eye
   reads it as an answer rather than something to fill in. */
.sbm-line-item__total .text-body {
  padding-top: var(--space-2);
  display: block;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sbm-line-items__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.sbm-line-items__total {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Stacked on a narrow screen, like every other dense row in this product. */
@media (max-width: 1100px) {
  .sbm-line-item {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .sbm-line-item__total .text-body { text-align: left; }
}

/**
 * The paired series — money in against money out.
 *
 * Two bars per month sharing one scale. Existing accents only: the income
 * tone and the expense tone this product already uses on its two separate
 * charts, so a reader moving between the screens sees the same colour mean
 * the same thing.
 */
.sbm-month-chart__legend {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.sbm-month-chart__legend-item { display: flex; align-items: center; gap: var(--space-1); }

.sbm-month-chart__swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  display: inline-block;
}

.sbm-month-chart__swatch--primary { background: var(--accent-teal-button); }
.sbm-month-chart__swatch--compare { background: var(--accent-coral); }

.sbm-month-chart__pair {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  flex: 1;
  width: 100%;
}

/* THE BARS ARE THE COLOURS THE LEGEND NAMES. [13 September 2026, UI/UX audit
   H8] The legend showed Money in as teal, but a paired bar was never given a
   colour of its own. It kept the chart's base grey at 35% opacity, which is
   how the VAT chart draws a month OUTSIDE its rolling window. Money out was
   coral but faded by the same opacity, so it matched its swatch in hue only.
   Each bar now takes exactly its swatch's colour, at full strength. */
.sbm-month-chart__bars.is-paired .sbm-month-chart__bar {
  width: 45%;
  background: var(--accent-teal-button);
  opacity: 1;
}

.sbm-month-chart__bar--compare,
.sbm-month-chart__bars.is-paired .sbm-month-chart__bar--compare { background: var(--accent-coral); }

/* A paired month's two values, shown over its column on hover and on keyboard
   focus instead of printed above every pair (see monthlyBarChart.js). At either
   end of the row the box is anchored to the column's outer edge, so the first
   and the last stay inside the card. */
.sbm-month-chart__value--on-demand {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-hairline);
  border-radius: 6px;
  background: var(--surface-card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  text-align: left;
}

.sbm-month-chart__value--on-demand > span { display: block; }

.sbm-month-chart__col:hover > .sbm-month-chart__value--on-demand,
.sbm-month-chart__col:focus-visible > .sbm-month-chart__value--on-demand {
  display: block;
}

.sbm-month-chart__col:first-child > .sbm-month-chart__value--on-demand {
  left: 0;
  transform: none;
}

.sbm-month-chart__col:last-child > .sbm-month-chart__value--on-demand {
  left: auto;
  right: 0;
  transform: none;
}

/* The gap between the two bars, stated rather than estimated by eye. */
.sbm-month-chart__outcome {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---- Data & records (13 September 2026) ----------------------------------
   Rules for the UI/UX audit's data, records and invoicing findings (C2, C3,
   H4, H5, H7, H13). All in one block, at the end, so they can be read apart
   from the list-alignment work elsewhere in this file and never disturb it.
   Every class is new except .sbm-row--import, whose columns change because a
   tick column joined it. Borders that mark a row are inset shadows, so marking
   a row never moves its content sideways. */

/* H7: the invoice form's problems and its success banner span the form. As
   one grid cell, "Invoice created" was squeezed into a column about 180px
   wide. */
.sbm-entry-form > .sbm-invoice-problems {
  grid-column: 1 / -1;
}

/* H7: "Print INV-0005" and "Create another", inside the success banner. */
.sbm-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* H7: the "Add a customer" dialog on Invoices — one field per line, spaced. */
.sbm-dialog-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sbm-dialog-form input,
.sbm-dialog-form textarea,
.sbm-dialog-form select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* H13: Save and "Cancel editing" share the form's last row. They sit in a
   holder now rather than as a bare button, so the holder takes the spacing
   the button had. */
.sbm-entry-form > .sbm-form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.sbm-form-actions > [hidden] {
  display: none;
}

/* H13: which entry the form is correcting, and the form and row concerned. */
.sbm-editing-note {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--accent-teal);
}

.sbm-entry-form.is-editing,
.sbm-row.is-editing {
  box-shadow: inset 3px 0 0 var(--accent-teal);
}

/* H5: the file picker is a normal button with the chosen file's name beside
   it; the browser's own control is visually hidden (.sr-only). */
.sbm-file-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-1);
}

.sbm-file-picker__name {
  overflow-wrap: anywhere;
}

/* C3 and H5: the import review. A tick column leads, the category select
   fills the last column with no label of its own (one heading above it), and
   a matched row carries its explanation and choice on a full-width line. The
   small left padding is where a matched or invalid row's marker is drawn, on
   every row including the headings, so the columns still line up. */
.sbm-row--import {
  grid-template-columns: 1.6rem 7.5rem minmax(8rem, 1fr) 7rem minmax(10rem, 14rem);
  padding-left: var(--space-2);
}

.sbm-row--import > .sbm-row__category {
  margin: 0;
}

.sbm-import-match {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-1) 0 var(--space-1) calc(1.6rem + var(--space-3));
}

.sbm-import-match > p {
  flex: 1 1 100%;
  margin: 0;
}

.sbm-import-match > .field {
  margin: 0;
  min-width: 16rem;
}

.sbm-row--matched {
  box-shadow: inset 3px 0 0 var(--accent-teal);
}

.sbm-row--invalid {
  box-shadow: inset 3px 0 0 var(--accent-coral);
}

.sbm-row--invalid select[aria-invalid="true"] {
  border-color: var(--accent-coral);
  outline: 1px solid var(--accent-coral);
}

/* H5: set a category on several rows at once. */
.sbm-import-bulk {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-hairline);
  border-bottom: 1px solid var(--border-hairline);
}

.sbm-import-bulk > .sbm-import-bulk__title,
.sbm-import-bulk > .sbm-import-bulk__note {
  flex: 1 1 100%;
  margin: 0;
}

.sbm-import-bulk > .field {
  margin: 0;
  min-width: 14rem;
}

/* H5: "4 of 6 categorised", and the refusal beside the Import button. */
.sbm-import-counter {
  margin: var(--space-3) 0 var(--space-2);
  font-variant-numeric: tabular-nums;
}

.sbm-import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-4);
}

.sbm-import-error {
  flex: 1 1 18rem;
  margin: 0;
  color: var(--accent-coral-text);
}

/* H7: "How to pay" on a printed invoice, clear of the totals above it and of
   the notes below it — without the gap the notes sat flush under the account
   number. */
.sbm-doc__payment {
  margin-top: var(--space-4);
}

.sbm-doc__payment + .sbm-doc__notes {
  margin-top: var(--space-4);
}

/* H3 on Who owes me: the holder for "Outstanding", the base rate and each
   overdue invoice was a plain div, so the cards sat 0px apart. A column with
   the gap cards get elsewhere. Hidden when empty — on "All invoices" it holds
   nothing, and an empty holder still took the screen's flex gap (audit M1). */
.sbm-owed-holder {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sbm-owed-holder:empty {
  display: none;
}

/* Stacked rows below 1100px, as every other row type in this file. Repeated
   here because the import columns above are declared after that rule. The
   heading row goes: stacked, it became a column of words ("DESCRIPTION /
   AMOUNT / CATEGORY") over rows whose cells no longer sit under them. Each
   select keeps its own accessible name, and the bulk control still reaches
   every money in or money out row.

   Amounts stay RIGHT-aligned here, unlike the other stacked lists: "+£1,000.00"
   and "−£86.40" left-aligned ended 7px apart at 390px, and on a statement the
   pence are what a person runs their eye down. */
@media (max-width: 1100px) {
  .sbm-row--import {
    grid-template-columns: 1fr;
  }

  .sbm-row--import.sbm-row--head {
    display: none;
  }

  .sbm-row--import > .sbm-row__amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .sbm-import-match {
    padding-left: 0;
  }
}

/* ---- The tax year shown ----------------------------------------------------
   14 September 2026. One control shared by Overview, Mileage, Year end, Where
   your figures go and Yearly HMRC figures (ui/yearSwitch.js), with the note
   that a newer tax year has begun and the line saying a year has no recording
   basis of its own. Tokens only, so dark mode follows themes.css.

   THE SWITCH SITS IN THE HEADER'S ROW, at the right of the line beneath the
   title (Jordan, 14 September 2026). On a row of its own, with a sentence
   beneath it, it pushed every figure down by about 200px. On a phone it drops
   beneath that line at full width. Placed with `order` rather than by markup,
   because setContext() can add the context line after the switch is there. */
.sbm-screen-header--with-year {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-4);
  row-gap: var(--space-2);
}

.sbm-screen-header--with-year .sbm-screen-header__title {
  order: 0;
  flex: 1 0 100%;
}

.sbm-screen-header--with-year .sbm-screen-header__context {
  order: 1;
  flex: 1 1 16rem;
  margin: 0;
}

.sbm-screen-header .sbm-year-switch__field {
  order: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 0 auto;
  width: auto;
  max-width: 100%;
}

.sbm-screen-header .sbm-year-switch__field .field__label {
  margin: 0;
  white-space: nowrap;
}

.sbm-screen-header .sbm-year-switch__select {
  width: auto;
  min-width: 0;
}

/* Below the header only the notes are left, and with neither, nothing. */
.sbm-year-switch {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.sbm-year-switch:empty {
  display: none;
}

/* Where a screen does not pass its header, the switch stands on its own. */
.sbm-year-switch__field {
  margin: 0;
  width: 100%;
  max-width: 32rem;
}

.sbm-year-switch__select {
  width: 100%;
}

@media (max-width: 767px) {
  .sbm-screen-header .sbm-year-switch__field {
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    margin-left: 0;
  }

  .sbm-screen-header .sbm-year-switch__select {
    width: 100%;
  }
}

.sbm-year-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-hairline);
  border-left: 4px solid var(--accent-teal);
  border-radius: var(--radius-control);
  background: var(--surface-card);
  max-width: 100%;
}

.sbm-year-note p {
  margin: 0;
}

/* ---- Keep a copy of a tax year that has ended ----------------------------- */
.sbm-year-copy__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.sbm-year-copy__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sbm-year-copy__folder {
  margin: 0;
  color: var(--text-secondary);
}

/* ---- Year end step 3: closing stock for the year -------------------------- */
.sbm-closing-stock {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  max-width: 32rem;
}

.sbm-closing-stock .sbm-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* A phone: long button labels ("Use my stock list's value today (£1,234.00)")
   wrap inside a full-width button rather than running off the card. */
@media (max-width: 480px) {
  .sbm-year-copy__buttons .button,
  .sbm-closing-stock .sbm-form-actions .button,
  .sbm-year-note .button {
    width: 100%;
    white-space: normal;
  }
}

/* ---- HMRC figures a customer can enter ----------------------------------------
   14 September 2026. ui/hmrcFigureField.js — the one entry for every HMRC
   figure, rate or percentage, with the responsibility statement before its
   Save button — and the Yearly HMRC figures screen. Tokens only, so dark mode
   follows themes.css; everything wraps at 390px. */
.sbm-figure-entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 44rem;
  min-width: 0;
}

.sbm-figure-entry + .sbm-figure-entry {
  margin-top: var(--space-5, 1.5rem);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-hairline);
}

.sbm-figure-entry__figure {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.sbm-figure-entry__name,
.sbm-figure-entry__figure > p,
.sbm-figure-entry__source p,
.sbm-figure-entry__history p {
  margin: 0;
  overflow-wrap: anywhere;
}

.sbm-figure-entry__status,
.sbm-figure-entry__list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.sbm-figure-entry__field {
  margin: 0;
  max-width: 22rem;
}

.sbm-figure-entry__input {
  width: 100%;
  box-sizing: border-box;
}

.sbm-figure-entry__error {
  margin: 0;
  color: var(--text-negative, var(--accent-coral));
}

.sbm-figure-entry__error:empty {
  display: none;
}

/* The responsibility statement: body text on a quiet panel, so it reads as
   part of saving the figure rather than small print under it. */
.sbm-figure-entry__statement {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-hairline);
  border-left: 4px solid var(--accent-gold, var(--accent-teal));
  border-radius: var(--radius-control);
  background: var(--surface-card);
  overflow-wrap: anywhere;
}

.sbm-figure-entry__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sbm-figure-entry__source,
.sbm-figure-entry__history {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sbm-hmrc-figures__section > .text-caption {
  margin-top: 0;
}

.sbm-figure-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2) 0;
}

.sbm-figure-note p {
  margin: 0;
  flex: 1 1 18rem;
  overflow-wrap: anywhere;
}

@media (max-width: 480px) {
  .sbm-figure-entry__field { max-width: 100%; }
  .sbm-figure-entry__actions .button,
  .sbm-figure-note .button {
    width: 100%;
    white-space: normal;
  }
}
