/* The approvals tab's stylesheet (WP-APPROVALS-TAB-01 U-3; the layout is WP-APPROVALS-TAB-UX-01's).
 *
 * A FILE, not an inline block, because the service sends `style-src 'self'` with no
 * `unsafe-inline` (PAG-2): a `<style>` element or a `style="…"` attribute would be dropped by the
 * browser and the page would render unstyled with nothing to say why. Every rule lives here.
 *
 * NO ANIMATIONS AND NO TRANSITIONS, deliberately: the tester diffs rendered output at two widths,
 * and a transition turns a screenshot into a race.
 *
 * ONE CARD PER INVOICE, AT EVERY WIDTH (WP-APPROVALS-TAB-UX-01). The markup is still a table -
 * the twelve headings and every cell are in the DOM - but it is never LAID OUT as one. Twelve
 * columns do not fit the widths this tab is opened at: in a desktop Teams window they shared a
 * 1100px column and the values wrapped mid-word. So `thead` is hidden at every width, each row
 * is a card on a grid, and each cell prints its own column name from `attr(data-label)`, which
 * is what the phone layout always did.
 *
 * THREE STEPS, by the width of the viewport Teams gives the tab: two columns up to 640px, four
 * from 641px, six from 1024px. The cells are placed BY NAME (`grid-template-areas`), so the
 * reading order is chosen per step instead of being inherited from the column order: who and
 * how much, then the identifiers, then what the system found, and the actions in a full-width
 * row at the foot of the card, where the reject drawer and a result sentence have room.
 *
 * EVERY CELL HAS AN AREA, AND EVERY TEMPLATE NAMES EVERY AREA ITS ROW SHAPE CAN CARRY. Three
 * ways that can go wrong, and where each lands (stated from the grid placement rules, not from a
 * rendering, and corrected twice by the independent review):
 *   - a cell whose area its row's template does not name is placed in an implicit column beside
 *     the card's own, where it squeezes them;
 *   - a cell that LOSES its area is auto-placed into the first free slot, which is the slot it
 *     just left, one column wide whatever that area spanned;
 *   - a cell the script ADDS with no area, when every area is taken, drops into an implicit row
 *     under the actions.
 * The card keeps the width of its container in all three, so NONE OF THEM SHOWS AS A SIDEWAYS
 * SCROLL OR AS A BOX OUTSIDE ITS PARENT. It is simply the wrong layout. What shows the first is
 * the count of column tracks; what shows the second and third is a cell whose `grid-row-start`
 * computes `auto`. The script's four row shapes are `fields` (twelve cells), and `done`,
 * `unavailable` and `version-unknown` (a status cell, one spanning cell, and for the first two a
 * match, a review and an actions cell).
 *
 * PAG-5 IS A STYLING REQUIREMENT AS WELL AS A MARKUP ONE. Field cells — the ones carrying text an
 * attacker e-mailed in — are visually bounded, sit on their own background, and never use the
 * chrome vocabulary: the status mark and the match text are rendered from computed values and are
 * styled as chrome, so a supplier name reading "VERIFIED — matched by Finance" still renders inside
 * a bordered field cell that looks nothing like the status mark. `unicode-bidi: isolate` keeps a
 * cell's directionality inside that cell even though PAG-8 has already cleaned the value.
 */

/* --- the two palettes (WP-APPROVALS-TAB-UX-01 U-6) ----------------------------------------
 *
 * EVERY COLOUR THIS STYLESHEET SETS IS A VARIABLE DECLARED HERE, AND NO RULE BELOW TYPES ONE.
 * That is what makes a dark mode possible at all: a colour typed straight into a rule would
 * stay light when the palette goes dark, and nothing would say so. A test CI runs
 * (`tests/approvalsapi/test_page_theme.py`) refuses a hex literal or a colour function in any
 * rule below; it cannot see a named colour. The colours the BROWSER paints by itself are not
 * this stylesheet's and are not variables: see `color-scheme` at the end of this note.
 *
 * LIGHT is the palette the page has always had; its values are unchanged.
 *
 * DARK IS DECLARED TWICE, AND THE TWO BLOCKS MUST CARRY THE SAME DECLARATIONS. Once inside a
 * `prefers-color-scheme` query, for a person who has made no choice and whose device is set to
 * dark; once under `data-theme="dark"`, for a person who chose dark with the control in the page
 * head. A stylesheet cannot say "this block, under either condition", and resolving the device's
 * setting in the script instead would paint the shell light first for everybody on a dark
 * device. The same test holds the two blocks equal.
 *
 * `data-theme` is set on the root element by the page script and by nothing else. `light` there
 * keeps a dark device light, which is why the query excludes it.
 *
 * `color-scheme` tells the browser which palette its OWN parts should use: the radio buttons,
 * the note box, the progress bar, the scroll bars, and the default colour of a link. */
:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #ffffff;
  --ink: #1b1b1f;
  --muted: #55555f;
  --line: #d5d5dd;
  --field-bg: #fbfbfd;
  --chrome-bg: #ececf2;
  --ground: #f5f5f9;
  --selected: #eef2fb;
  --attention: #fffaf0;
  --drawer-bg: #f6f8fd;
  --overlay-bg: rgba(20, 20, 30, 0.45);
  --accent: #2f4f8f;
  --accent-ink: #ffffff;
  --warn-bg: #fff4d6;
  --warn-line: #c79a16;
  --stop-bg: #fde8e8;
  --stop-line: #b23b3b;
  --good-bg: #e6f4ea;
  --good-line: #2f7a43;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #1b1b1f;
    --surface: #26262b;
    --ink: #f1f1f4;
    --muted: #b4b4bf;
    --line: #4b4b55;
    --field-bg: #1e1e23;
    --chrome-bg: #33333a;
    --ground: #131316;
    --selected: #283350;
    --attention: #302b1c;
    --drawer-bg: #232b40;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --accent: #8fa8e8;
    --accent-ink: #10182b;
    --warn-bg: #3a3112;
    --warn-line: #d9a521;
    --stop-bg: #402020;
    --stop-line: #e57373;
    --good-bg: #183622;
    --good-line: #63c483;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1b1b1f;
  --surface: #26262b;
  --ink: #f1f1f4;
  --muted: #b4b4bf;
  --line: #4b4b55;
  --field-bg: #1e1e23;
  --chrome-bg: #33333a;
  --ground: #131316;
  --selected: #283350;
  --attention: #302b1c;
  --drawer-bg: #232b40;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --accent: #8fa8e8;
  --accent-ink: #10182b;
  --warn-bg: #3a3112;
  --warn-line: #d9a521;
  --stop-bg: #402020;
  --stop-line: #e57373;
  --good-bg: #183622;
  --good-line: #63c483;
}

/* A stated width is the width of the BOX, padding and border included. Without this a
 * `width: 100%` with padding is wider than its parent, which is how the batch header came to be
 * 28px wider than the batch and lost the right edge of its toggle to `overflow: hidden`. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

#approvals-root {
  margin: 0 auto;
  padding: 10px;
  max-width: 1100px;
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

h2 {
  margin: 0;
  font-size: 16px;
}

.notice {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chrome-bg);
}

.notice[data-tone="stop"] {
  background: var(--stop-bg);
  border-color: var(--stop-line);
}

.notice[data-tone="warn"] {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

/* The theme control and Reload, kept together at the end of the head line. */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

/* --- buttons ----------------------------------------------------------------------------- */

button {
  font: inherit;
  color: inherit;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--chrome-bg);
}

button[data-variant="primary"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

button[data-variant="primary"]:disabled {
  border-color: var(--line);
  background: var(--chrome-bg);
  color: var(--muted);
}

/* --- the two counter-filters ------------------------------------------------------------- */

.counters {
  display: flex;
  gap: 12px;
  margin: 16px 0 8px;
}

/* `min-height: auto`, and it is not decoration. Every button on the page is given a minimum
 * height so a finger can find it, and on a phone these two stack in a COLUMN with a flex basis
 * of zero. There the minimum height is the only thing that sizes them: with the 40px every
 * button gets (44px for a finger), each counter was that tall and no taller, and its label was
 * cut off under the count. The package owner found it in the preview; the first build of the
 * card layout shipped it. `auto` puts back the minimum a flex item has by default, which is the
 * height of what is in it. (Reasoned from the flex sizing rules and from his capture; no
 * browser run by the builder.) */
.counter {
  flex: 1 1 0;
  display: block;
  min-height: auto;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.counter[data-active="true"] {
  border-color: var(--accent);
  border-width: 2px;
  background: var(--selected);
}

.counter[data-count="0"] {
  color: var(--muted);
  background: var(--chrome-bg);
}

.counter-count {
  display: block;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.counter-label {
  display: block;
  font-size: 13px;
}

.filter-line {
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

/* --- chips -------------------------------------------------------------------------------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.chip[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

/* WP-APPROVALS-STATUS-LIST-01 U-2. "Waiting (12)": the count reads as part of the chip's name. */
.chip-count {
  font-variant-numeric: tabular-nums;
}

/* --- search and sort (WP-TAB-SEARCH-SORT-01) ------------------------------------
 *
 * One line under the chips that wraps on a phone. Every control keeps `min-width: 0` and a
 * `max-width` of its line, so a long typed search cannot push a phone into a sideways scroll.
 *
 * ON A PHONE (up to 640px) EACH CONTROL TAKES A FULL LINE OF ITS OWN, in the phone block near
 * the end of this file (WP-TAB-MOBILE-TOOLS-01). */

.list-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: flex-end;
  margin: 0 0 16px;
}

.search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  flex: 1 1 280px;
  min-width: 0;
  max-width: 100%;
}

.search-label {
  flex: 0 0 100%;
  font-size: 13px;
  color: var(--muted);
}

.search input {
  font: inherit;
  color: inherit;
  flex: 1 1 200px;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.sort {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.sort-label {
  font-size: 13px;
  color: var(--muted);
}

.sort select {
  font: inherit;
  color: inherit;
  min-width: 0;
  max-width: 100%;
  min-height: 40px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

/* WP-TAB-SEAT-RIGHT-01 (Stefan, 20 Oct 2026). THE SEAT LIST KEEPS THE RIGHT END OF ITS LINE.
 * In the full view it sat at the right end only because the search box grows and takes the
 * free space. Under a payment seat (WP-TAB-SEAT-VIEW-01) the line holds the Seat list alone,
 * nothing grows, and the list jumped to the left when the person chose that seat. An automatic
 * left margin takes whatever free space the line has, so the list stays at the right end on
 * either line; where the search box grows there is no free space and nothing moves. On a
 * phone the control is as wide as its line and the phone block clears this margin
 * (WP-TAB-MOBILE-TOOLS-01). */
.list-tools .seat {
  margin-left: auto;
}

/* --- the list (WP-APPROVALS-STATUS-LIST-01) ---------------------------------------------- */

/* One list where the day boxes were. It keeps the box's frame, so the cards still sit on a
 * ground one shade apart from them and one invoice ends where the next begins without a second
 * heavy border. */
.status-list {
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.list-body {
  padding: 10px;
  background: var(--ground);
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

/* --- the rows: one card per invoice ------------------------------------------------------- */

table,
tbody {
  display: block;
  width: 100%;
}

/* Hidden at EVERY width. The headings stay in the markup; each cell prints its own. */
thead {
  display: none;
}

caption {
  display: block;
  text-align: left;
  padding: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

tbody tr {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "status  received"
    "detail  detail"
    "match   match"
    "review  review"
    "actions actions";
  gap: 10px 12px;
  align-items: start;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

tbody tr:last-child {
  margin-bottom: 0;
}

tbody tr[data-row-shape="fields"] {
  grid-template-areas:
    "status   received"
    "supplier supplier"
    "total    ordertotal"
    "number   date"
    "order    order"
    "site     site"
    "file     file"
    "match    match"
    "review   review"
    "actions  actions";
}

/* Two cells and no more: three empty rows under them would still cost their gaps. */
tbody tr[data-row-shape="version-unknown"] {
  grid-template-areas:
    "status status"
    "detail detail";
}

/* WP-EDIT-BUSY-CARD-01. A card whose run is re-matching or renaming carries ONE more cell, the
 * status line at its head (`busy`), and the same template under it. Only a busy card names the
 * area: an empty first row on a card that is not busy would cost its gap. The two shapes a busy card
 * can take are `fields` and `done` (a waiting row the service read no fields for); a card of
 * a version this page does not read is never busy. */
tbody tr[data-row-busy] {
  grid-template-areas:
    "busy    busy"
    "status  received"
    "detail  detail"
    "match   match"
    "review  review"
    "actions actions";
}

tbody tr[data-row-busy][data-row-shape="fields"] {
  grid-template-areas:
    "busy     busy"
    "status   received"
    "supplier supplier"
    "total    ordertotal"
    "number   date"
    "order    order"
    "site     site"
    "file     file"
    "match    match"
    "review   review"
    "actions  actions";
}

/* WP-HOLD-ONLY-01: a held row in the final reviewer's view is under no chip ("hold") and keeps
 * the same tint it had under "Needs attention". */
tbody tr[data-chip="attention"],
tbody tr[data-chip="hold"] {
  background: var(--attention);
}

/* `overflow-wrap` on the cell itself, not only on the field boxes inside it: a state or a match
 * word this build does not know is rendered as it arrived, and a file name the page refused to
 * link is plain text. An unbroken one would otherwise run past a cell 130px wide. */
td {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  overflow-wrap: anywhere;
}

/* The column name, printed by the cell itself. EVERY cell, at every width: the actions cell
 * prints its own too, on a line to itself (see `.cell-actions::before`). */
td::before,
.payment-cell::before {
  content: attr(data-label);
  display: block;
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* Where each cell goes. The names are the ones the templates above and below spell. */
.cell-status {
  grid-area: status;
}

/* WP-APPROVALS-STATUS-LIST-01 U-3. Beside the status, at the top of every card the page reads:
 * the day box that said when the invoices arrived is gone, so each card says it. */
.cell-received {
  grid-area: received;
}

td[colspan] {
  grid-area: detail;
}

td[data-field="supplier"] {
  grid-area: supplier;
}

td[data-field="invoice_number"] {
  grid-area: number;
}

td[data-field="invoice_date"] {
  grid-area: date;
}

td[data-field="po_number"] {
  grid-area: order;
}

td[data-field="site_address"] {
  grid-area: site;
}

td[data-field="total"] {
  grid-area: total;
}

td[data-field="order_total"] {
  grid-area: ordertotal;
}

td[data-field="document"] {
  grid-area: file;
}

.cell-match {
  grid-area: match;
}

.cell-review {
  grid-area: review;
}

.cell-actions {
  grid-area: actions;
}

/* WP-EDIT-BUSY-CARD-01. The status line at the head of a busy card, and the cells under it.
 * The line is chrome (the page's own sentence, never a value) and prints no column name. The
 * cells are inert (the script sets the attribute: nothing in them can be focused or pressed)
 * and are drawn dimmed, so the card reads as waiting rather than as broken. */
.cell-busy {
  grid-area: busy;
  padding: 8px 10px;
  border: 1px solid var(--warn-line);
  border-radius: 6px;
  background: var(--warn-bg);
  color: var(--ink);
  font-weight: 600;
}

.cell-busy::before {
  content: none;
}

.busy-line::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 8px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: rename-turn 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .busy-line::before { animation: none; }
}

tbody tr[data-row-busy] > td[inert] {
  opacity: 0.5;
  pointer-events: none;
}

/* The status mark and the match text are CHROME: computed by the service, never a field value. */
.cell-status {
  font-weight: 600;
}

/* The words wrap inside the mark: the longest state is wider than the cell it shares a row
 * with, and a mark that could not wrap would run across its neighbour. */
.state-mark {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--chrome-bg);
  font-size: 12px;
}

.state-mark[data-tone="good"] {
  background: var(--good-bg);
  border-color: var(--good-line);
}

.state-mark[data-tone="warn"] {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.state-mark[data-tone="stop"] {
  background: var(--stop-bg);
  border-color: var(--stop-line);
}

/* WP-REVIEWER-VIEW-01: the site seat a row is addressed to, in the confirming seat's view. */
.addressed-to {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* WP-HOLD-01: a parked invoice, under its state. */
.on-hold {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border: 1px solid var(--muted);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* WP-LEDGER-STATUS-01: whether the invoice is in the accounts system yet, under its state. */
.ledger-mark {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border: 1px solid var(--warn-line);
  border-radius: 4px;
  background: var(--warn-bg);
  font-size: 12px;
}

.ledger-mark[data-entered="true"] {
  border-color: var(--good-line);
  background: var(--good-bg);
}

.cell-match {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Section 3.8 (#413). THE SYSTEM'S QUESTION, under the match words and on a line of its own.
 * Shaped like neither neighbour (PAG-5): not the status mark's pill - a second pill reads as a
 * second status - and not the field cells' bordered box, which is what a value a supplier
 * authored looks like. The left rule and the darker ink mark that it CARRIES a value (the order
 * number, cleaned by `fieldsblock.clean_value` before it was inserted) without dressing it as
 * one. The system is asking; the number is the only part of it a document influenced. */
.question-line {
  display: block;
  margin-top: 4px;
  padding-left: 6px;
  border-left: 2px solid var(--line);
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* U-3c. THE SYSTEM'S REVIEW LINE, AND IT IS SHAPED LIKE NEITHER OF ITS NEIGHBOURS (PAG-5).
 * Not the status mark's pill - a second pill on the same row reads as a second status - and
 * not the field cells' bordered box, which is what a value a supplier authored looks like.
 * Plain running text, on the match cell's muted scale, in a cell of its own. */
.cell-review {
  font-size: 13px;
}

.review-line {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.review-line[data-review="absent"],
.review-line[data-review="not-yet"] {
  font-style: italic;
}

/* Package C. WHAT TO LOOK AT, under the review line. The tenant's sentence, chosen by a name; it
 * carries no value, so it takes the ink colour of running text and no box or pill (PAG-5). */
.look-at-line {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* WP-REMATCH-SEAT-FLAG-01: the corrected order is for a site of a different supervisor. Bold,
 * so the approver reads it before approving. */
.look-at-line[data-order-seat] {
  font-weight: 600;
}

/* WP-TAB-RENAME-01 (U-6). The rename control, under the file's name. The box holds what a
 * person types and nothing from a document, so it takes the page's ink and line colours. */
.rename-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 6px;
}

.rename-line [data-testid="rename-extension"] {
  margin: 0 10px 0 4px;
}

.rename-input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 40px;
  padding: 4px 6px;
  flex: 1 1 16em;
  min-width: 0;
  box-sizing: border-box;
}

.rename-button {
  margin: 4px 8px 0 0;
}

/* WP-TAB-RENAME-WAIT-01. Save while the rename runs: a turning ring before "Saving", still for
 * a person who asks for less motion. WP-RENAME-BUSY-01: the same ring before the row's own
 * "Renaming the file…" line, which every person who sees the row sees. */
.rename-pending {
  display: inline-block;
  margin: 4px 10px 0 0;
  color: var(--ink);
}

.rename-pending::before,
.rename-button[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 6px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: rename-turn 0.8s linear infinite;
}

@keyframes rename-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .rename-pending::before,
  .rename-button[aria-busy="true"]::before { animation: none; }
}

.rename-note {
  flex: 1 0 100%;
  margin-top: 4px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* THE FIELD CELLS. Bounded, on their own background, never chrome-shaped (PAG-5). */
.field {
  display: block;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--field-bg);
  unicode-bidi: isolate;
  overflow-wrap: anywhere;
}

.field[data-field-value="marker"] {
  color: var(--muted);
  font-style: italic;
}

.field-flag {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--warn-line);
}

/* WP-TAB-STATED-VALUES-01: a value the document did not confirm, and the line that says so. */
.field[data-field-value="stated"] {
  border-color: var(--warn-line);
}

.field-unconfirmed {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warn-line);
}

/* WP-MANUAL-EDIT-01: a value a person corrected, the line that says who and what was read, and
 * the control. The cell positions the Edit button in its own top-right corner, over the printed
 * column name; the button is faint until the cell is hovered or holds the keyboard focus. */
td[data-field] {
  position: relative;
}

.field[data-field-value="edited"] {
  border-color: var(--accent);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* WP-EDIT-BUSY-CARD-01: one line, cut with an ellipsis; the whole sentence is the tooltip. */
.field-edited {
  display: block;
  max-width: 100%;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-edit {
  position: absolute;
  top: 0;
  right: 0;
  min-height: 24px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  line-height: 24px;
  opacity: 0;
  transition: opacity 120ms ease-in-out;
}

td[data-field]:hover .field-edit,
td[data-field]:focus-within .field-edit,
.field-edit:focus-visible {
  opacity: 1;
}

.field-edit:hover,
.field-edit:focus-visible {
  border-color: var(--accent);
  background: var(--selected);
}

.field-edit:disabled {
  opacity: 0;
}

/* WP-RENAME-BUSY-01. Greyed because the file is being renamed: the button still shows on
 * hover, dimmed, with the reason as its title, so the person sees why it will not press. */
td[data-field]:hover .field-edit[data-waiting="rename"]:disabled,
td[data-field]:focus-within .field-edit[data-waiting="rename"]:disabled {
  opacity: 0.45;
  cursor: wait;
}

.field-edit-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.field-edit-input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 4px;
  min-height: 40px;
  padding: 4px 6px;
  flex: 1 1 12em;
  min-width: 0;
  box-sizing: border-box;
}

.field-edit-button {
  min-height: 36px;
  padding: 4px 10px;
}

.field-edit-button[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 6px;
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: rename-turn 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .field-edit-button[aria-busy="true"]::before { animation: none; }
}

.field-edit-note {
  display: block;
  flex: 1 0 100%;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.field-edit-note[data-tone="ok"] {
  color: var(--good-line);
}

.field-edit-note[data-tone="stop"] {
  color: var(--stop-line);
}

.done-link {
  overflow-wrap: anywhere;
}

/* --- the foot of the card: the actions, the reason, the result, the drawer ---------------- */

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  /* WP-TAB-FOOTER-MODALS-01 (the developer's request, 18 Nov 2026): the button groups sit at
   * the RIGHT end of the foot. Everything that takes a whole line (the heading, the trail, a
   * sentence, a result, a drawer) is unmoved by this. */
  justify-content: flex-end;
  gap: 8px 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* WP-TAB-FOOTER-MODALS-01. The foot's own sentence ("No decision to make", why a row is
 * reject-only) takes a line to itself, at the left, so it does not sit among the buttons that
 * are now at the right end. */
.cell-actions > .subtle {
  flex: 1 1 100%;
}

/* The cell is a flex row, so its printed heading would sit beside the first control. It takes
 * the whole first line instead, as the heading does over each of the rest. */
.cell-actions::before {
  flex: 1 1 100%;
  margin: 0;
}

/* A row with nothing to offer and nothing to say draws no rule over an empty foot. */
.cell-actions:empty {
  display: none;
}

/* On a phone the two controls share the card's width, so each is a target a thumb can find. */
.actions {
  display: flex;
  flex: 1 1 100%;
  gap: 8px;
}

.actions button {
  flex: 1 1 0;
}

.row-result {
  flex: 1 1 100%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--chrome-bg);
  font-size: 13px;
}

.row-result[data-tone="good"] {
  background: var(--good-bg);
  border-color: var(--good-line);
}

.row-result[data-tone="warn"] {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.row-result[data-tone="stop"] {
  background: var(--stop-bg);
  border-color: var(--stop-line);
}

/* --- the reject drawer -------------------------------------------------------------------- */

.drawer {
  flex: 1 1 100%;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--drawer-bg);
}

/* `min-width: 0`: a fieldset's default minimum is the width of its widest line, and a long
 * reason label would hold the card wider than a phone. */
.drawer fieldset {
  min-width: 0;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.drawer label {
  display: block;
  padding: 6px 0;
}

.drawer textarea {
  font: inherit;
  width: 100%;
  min-height: 70px;
}

/* The one-line box for the right value, in the "Not right" drawer. `box-sizing` so the full
 * width includes its border and it cannot push the card wider than a phone. */
.drawer input[type="text"] {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
}

.drawer button {
  margin: 10px 8px 0 0;
}

/* Package N, part B (N-15): the Send-to choice. The full width of the card and never wider, so
 * a long name does not push a phone into a sideways scroll. */
.drawer select {
  font: inherit;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 6px;
  min-height: 36px;
}

/* --- payments (WP-PAYMENT-RELEASE-TAB-01 U-14) ---------------------------------------------- */

.notice[data-tone="good"] {
  background: var(--good-bg);
  border-color: var(--good-line);
}

.payments {
  margin-top: 20px;
}

.payment-group {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.payment-group-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--chrome-bg);
}

.payment-group-head h3 {
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.payment-count {
  color: var(--muted);
  font-size: 13px;
}

/* U-28. The line that says why a group's button cannot be pressed: a line to itself under
 * the heading, so it is read with the button it explains. */
.payment-group-head [data-testid="payment-why"] {
  flex-basis: 100%;
}

/* U-28. A row's tick box. */
.payment-tick {
  width: 16px;
  height: 16px;
  margin: 0;
  align-self: center;
}

.payment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.payment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

/* U-24. The six cells of a payment row: a line to themselves under the file's name, each
 * printing its own column name as a table cell does. As many to a line as the width holds. */
.payment-cells {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 12px;
}

.payment-cell {
  min-width: 0;
  overflow-wrap: anywhere;
}

.payment-fact {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.payment-row .row-result {
  flex-basis: 100%;
  margin-top: 0;
}

.payment-notice {
  margin: 12px 0;
}

.payment-group > p {
  margin: 0;
  padding: 10px 14px;
}

/* WP-PAID-PAGES-01. The foot of the Paid list: the press that shows the next page, and how
 * much of the list is on screen. */
.payment-more {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  border-top: 1px solid var(--line);
}

/* --- a finger needs a bigger target than a mouse pointer does ----------------------------- */

@media (pointer: coarse) {
  button {
    min-height: 44px;
  }

  /* WP-MANUAL-EDIT-01: a phone has no hover, so the Edit button is always drawn there. */
  .field-edit {
    opacity: 1;
    min-height: 32px;
  }

  .drawer label {
    padding: 10px 0;
  }
}

/* --- phone only ---------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .counters {
    flex-direction: column;
  }

  /* WP-TAB-MOBILE-TOOLS-01 (Stefan, 21 Oct 2026). THE TOOLS STACK, ONE FULL LINE EACH. On a
   * phone the wrapping line left the Sort list at the left as wide as its words, and the Seat
   * list alone at the right end of a third line, its label away from both. Here the search box,
   * the Sort list and the Seat list each take the whole width of their line, label over control,
   * and the Seat list's automatic left margin (WP-TAB-SEAT-RIGHT-01) is cleared: a control as
   * wide as its line has no free space to take and no right end to keep. The child selector is
   * deliberate: `test_seat_list_position.py` counts the `.list-tools .seat` blocks with media
   * queries flattened and holds the count at one, so the phone rule must not spell that
   * selector. `test_tools_phone_layout.py` holds the rules below inside this block. */
  .list-tools {
    gap: 12px;
  }

  .list-tools > * {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .list-tools > .seat {
    margin-left: 0;
  }

  .sort select {
    width: 100%;
  }

  /* WP-REJECT-REASSIGN-01: the History table folds to two columns, the date on a line of its
   * own above each step. */
  .history-table {
    grid-template-columns: 1fr 1fr;
  }

  .history-head {
    display: none;
  }

  .history-row span:first-child {
    grid-column: 1 / -1;
    border-top: 2px solid var(--line);
  }
}

/* --- from 641px: four columns --------------------------------------------------------------- */

@media (min-width: 641px) {
  #approvals-root {
    padding: 16px;
  }

  .list-body {
    padding: 12px 14px;
  }

  /* The detail keeps its three columns: "Received" goes under the status, beside it. */
  tbody tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "status   detail  detail  detail"
      "received detail  detail  detail"
      "match    match   review  review"
      "actions  actions actions actions";
    gap: 12px 14px;
    padding: 14px;
  }

  tbody tr[data-row-shape="fields"] {
    grid-template-areas:
      "status  received   supplier supplier"
      "total   ordertotal number   date"
      "order   site       site     site"
      "file    file       file     file"
      "match   match      review   review"
      "actions actions    actions  actions";
  }

  tbody tr[data-row-busy] {
    grid-template-areas:
      "busy     busy    busy    busy"
      "status   detail  detail  detail"
      "received detail  detail  detail"
      "match    match   review  review"
      "actions  actions actions actions";
  }

  tbody tr[data-row-busy][data-row-shape="fields"] {
    grid-template-areas:
      "busy    busy       busy     busy"
      "status  received   supplier supplier"
      "total   ordertotal number   date"
      "order   site       site     site"
      "file    file       file     file"
      "match   match      review   review"
      "actions actions    actions  actions";
  }

  tbody tr[data-row-shape="version-unknown"] {
    grid-template-areas: "status detail detail detail";
  }

  .actions {
    flex: 0 0 auto;
  }

  .actions button {
    flex: 0 0 auto;
    min-width: 96px;
  }
}

/* --- from 1024px: six columns --------------------------------------------------------------- */

@media (min-width: 1024px) {
  tbody tr {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-areas:
      "status  received detail  detail  detail  detail"
      "match   match    match   review  review  review"
      "actions actions  actions actions actions actions";
  }

  tbody tr[data-row-shape="fields"] {
    grid-template-areas:
      "status  received supplier supplier total   ordertotal"
      "number  date     order    site     site    site"
      "file    file     file     file     file    file"
      "match   match    match    review   review  review"
      "actions actions  actions  actions  actions actions";
  }

  tbody tr[data-row-busy] {
    grid-template-areas:
      "busy    busy     busy    busy    busy    busy"
      "status  received detail  detail  detail  detail"
      "match   match    match   review  review  review"
      "actions actions  actions actions actions actions";
  }

  tbody tr[data-row-busy][data-row-shape="fields"] {
    grid-template-areas:
      "busy    busy     busy     busy     busy    busy"
      "status  received supplier supplier total   ordertotal"
      "number  date     order    site     site    site"
      "file    file     file     file     file    file"
      "match   match    match    review   review  review"
      "actions actions  actions  actions  actions actions";
  }

  tbody tr[data-row-shape="version-unknown"] {
    grid-template-areas: "status detail detail detail detail detail";
  }
}

/* WP-TAB-TRAIL-01 U-4: who decided before the reader. A plain list, no markers.
 * WP-TRAIL-OWN-LINE-01: in the foot of an open card the list is a flex item beside the controls,
 * and "Approved by <address> on <date>" is long enough to push them onto a second line. It takes
 * the whole line to itself, so the controls under it sit on one line of their own. */
.trail {
  flex: 1 1 100%;
  list-style: none;
  margin: 0 0 0.4rem;
  padding: 0;
}

/* --- WP-REJECT-REASSIGN-01: the History box and the payment-row controls ------------------ */

/* The box sits over the page and never wider than it: a long file name or a long comment
 * wraps inside the box, and the box scrolls when the steps run long. */
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay-bg);
}

.history-box {
  box-sizing: border-box;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-box h2 {
  margin: 0 0 12px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

/* WP-DESK-PAGE-FIXES-01: the Close question. The same box as History, narrow, with its two
 * buttons under the sentence. */
.confirm-box {
  max-width: 520px;
}

/* WP-TAB-FOOTER-MODALS-01. A box's buttons sit in its foot, at the right end: History,
 * Matching, the Close question, the hold's reason and the sweep's question alike. */
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* The one-line box for a reason, in a box over the page: the box's full width, never wider. */
.modal-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

/* A table of its own, drawn from divs so the invoice cards' table rules never reach it. */
.history-table {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1.4fr) minmax(120px, 1.2fr)
    minmax(90px, 1fr) minmax(120px, 1.6fr);
  gap: 0;
  margin: 0 0 12px;
  font-size: 14px;
}

.history-row {
  display: contents;
}

.history-row span {
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.history-head span {
  border-top: 0;
  color: var(--muted);
  font-size: 13px;
}

/* WP-TAB-FOOTER-MODALS-01. `.actions-history` had a top margin of its own, which in a foot
 * that centres its groups pushed History and Matching a few pixels below the buttons beside
 * them. The foot's row gap already separates the groups when they stack. */

.actions-history button,
.payment-controls button {
  flex: 0 0 auto;
}

.payment-controls {
  flex-basis: 100%;
}

/* WP-ROW-ACTIONS-01: a payment row's History sits at the row's right end, after its actions. */
.payment-controls .payment-history {
  margin-left: auto;
}

.payment-rejected {
  margin: 0.2rem 0 0.4rem;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* --- WP-MATCHING-DETAIL-01: the Matching box ----------------------------------------------- */

/* The same box and rows as History; only the columns differ: a label, two values, a
 * difference and the check's words. The three value columns are figures or names and may be
 * long (a site address); they wrap. */
.matching-table {
  grid-template-columns: minmax(80px, 0.8fr) minmax(120px, 1.4fr) minmax(120px, 1.4fr)
    minmax(90px, 0.9fr) minmax(140px, 1.6fr);
}

.matching-line {
  margin: 0 0 8px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* --- WP-REMATCH-TOAST-01: the toast an act that worked gets ------------------------------- */

/* At the top of the window, centred (WP-ACTION-BUSY-CARD-01, the developer's request of 6 Nov
 * 2026; it sat at the foot, right, before), above the History box, never wider than the window
 * less its gutters. The host lets presses through to the page; a toast itself takes a press
 * (closes). */
.toast-host {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  box-sizing: border-box;
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid var(--good-line);
  border-radius: 6px;
  background: var(--good-bg);
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
  box-shadow: 0 4px 14px var(--overlay-bg);
  cursor: pointer;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}

.toast[data-tone="warn"] {
  border-color: var(--warn-line);
  background: var(--warn-bg);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
}
