/*
 * The house style for a control in a job - the counterpart of Resources/Styles/Layouts.xaml.
 * A card, a toolbar, a grid cell, a totals row, a dialog: things whose look depends on where
 * they are rather than on what they are.
 */

/* ==========================================================================
   Page

   Every screen is a column: header, then whatever the screen is. The screen own content row is
   the one that takes the remainder, which is what lets a table scroll inside the page instead of
   the page scrolling as a whole.
   ========================================================================== */

/*
   A column, and deliberately flex rather than grid.

   Which child fills the leftover height has to be a fact about that child, not about its
   position: an error banner is on screen sometimes and gone the rest of the time, and a grid
   whose 1fr row is the second one would hand the remainder to the toolbar the moment a banner
   appeared above it - silently, and only on the screens that had just failed at something.
*/
.page {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-height: 100%;
    min-width: 0;
}

/*
   Nothing on a page shrinks below what it holds. A flex child shrinks by default where a grid
   auto row does not, and a compacted screen is meant to give up padding, never to squash a
   totals strip until its figures clip. The one child that may flex says so below.
*/
.page > * { flex-shrink: 0; }

.page__body { min-height: 0; min-width: 0; display: grid; gap: var(--space-4); }

/*
 * The child that takes whatever height is left - a table, usually.
 *
 * A column rather than a grid, and the difference matters the moment there is more than one child.
 * grid-template-rows: 1fr names the FIRST row, so a body holding a button and a table underneath
 * it stretched the BUTTON to fill the screen and left the table sitting at the bottom of a page of
 * empty space. That is the customer screen's Quotations tab. A flex column sizes everything to its
 * content and hands the remainder to the last child, which is the table on every one of these
 * screens, and behaves identically where there is only one.
 */
.page__body--fill { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page__body--fill > :last-child { flex: 1; min-height: 0; }

.page-header {
    display: flex;
    align-items: flex-end;
    gap: var(--space-4);
    flex-wrap: wrap;
    min-width: 0;
}

.page-header__titles { min-width: 0; flex: 1; }

/* The breadcrumb says where you are; the one Back, which says how to leave, is in the shell. */
.crumb {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pos-text-subtle);
}

.page-header__subtitle { font-size: var(--text-sm); color: var(--pos-text-muted); }

/* A screen own actions live here. Anything on every screen belongs in the shell top bar. */
.page-header__actions { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ==========================================================================
   Cards and toolbars
   ========================================================================== */

/*
 * Glass, and the plainest statement of what that means here: a translucent two-stop fill with a
 * specular strip in it, a lit top edge, a shaded bottom one - and no blur.
 *
 * The translucency is the point rather than a side effect. A card over the teal pool in the app
 * ground comes out faintly warmer than a card at the other end of the page, which is what stops a
 * screen of cards reading as a screen of white rectangles. It costs one paint; blurring what is
 * behind a card would cost a composited layer per card and change nothing anybody can see,
 * because what is behind a card is the ground.
 */
.card {
    padding: var(--card-padding);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--grad-glass);
    box-shadow: var(--elev-1), var(--glass-edge);
    min-width: 0;
}
/* Recessed on purpose, so it gives up the fill AND the lit top edge: a gloss strip on a sunken
   panel says raised, which is the opposite of what the modifier is for. */
.card--sunken { background: var(--pos-surface-sunken); box-shadow: var(--elev-1); }

.card__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--card-padding);
    border-bottom: 1px solid var(--pos-border);
}

.card__title { font-size: var(--text-base); font-weight: 650; flex: 1; min-width: 0; }

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--toolbar-padding);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--grad-glass);
    box-shadow: var(--elev-1), var(--glass-edge);
    min-width: 0;
}

.toolbar__spacer { flex: 1; min-width: var(--space-4); }

/*
 * A row of small tiles drawn INSIDE the toolbar, under its filters - the sales list's Total /
 * Unpaid / Paid / Overdue figures. In the same card rather than a card of their own because they
 * describe the set the filters above them produced: a second card would read as a summary of the
 * page, and it is a summary of the filter.
 *
 * A full-width item, so it always drops onto its own line under the filters, ruled off from them
 * with a hairline rather than a gap - the filters are what somebody changes, the figures are
 * what changes in answer. auto-fill, never auto-fit: these are meant to stay small tiles, and
 * auto-fit would stretch four of them into four banners on a counter monitor.
 */
.toolbar__stats {
    flex-basis: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--stat-tile-width), 1fr));
    gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--pos-border);
    min-width: 0;
}

/*
 * COMPACT TILES, a trial: the caption and the count share the first line and the amount has the
 * second, with the small Count / Owed labels dropped (the amount's own title says which it is).
 * Two lines a tile instead of three, and narrower, so a whole row of them fits on one line.
 */
.toolbar__stats { grid-template-columns: repeat(auto-fill, minmax(var(--stat-tile-width), 1fr)); gap: var(--space-2); padding-top: var(--space-2); }
.toolbar__stats .stat-tile {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--space-2);
    row-gap: 0;
    align-items: baseline;
    padding: var(--space-1) var(--space-3);
}
.toolbar__stats .stat-tile__label { display: none; }
.toolbar__stats .stat-tile__caption { grid-column: 1; grid-row: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar__stats .stat-tile__cell:nth-child(2) { grid-column: 2; grid-row: 1; }
.toolbar__stats .stat-tile__cell:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }

/*
 * THE FILTERS STAY WHERE THEY ARE; ONLY THE ROWS SCROLL. A listing page whose body takes the
 * remainder is given the height of the window, so the table scrolls inside its own frame (its
 * header already sticks) and nothing above it moves. Where the page as a whole still scrolls - a
 * screen with no fill body - the toolbar sticks to the top instead. Opaque under the glass, or the
 * rows passing beneath would show through it.
 */
.page:has(> .page__body--fill) { height: 100%; min-height: 0; }
.page > .toolbar { position: sticky; top: 0; z-index: 4; background-color: var(--pos-surface); }

/* Refresh and the screen's own button, at the right-hand end of the filter card after Reset. */
.toolbar__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

/* The same tiles used as the session screen's tabs. They sit in a card of their own rather than
   under a toolbar's filters, so there is nothing above them to rule off. */
.session-tabs { padding-top: 0; border-top: 0; }

/*
 * ALL EIGHT ON ONE LINE, and nothing on them cut off - asked for directly. The standard tile is
 * 200px wide, which is eight tiles to about 1,670px and two rows on a counter monitor. Here each
 * tile is folded to two lines instead - the caption with the count beside it, then the amount on
 * a line of its own - and the small "Count" / "Cash in" labels go, the tooltip still saying which.
 *
 * A flex row, not a grid, because the floor is the CONTENT rather than a figure: min-content lets
 * a caption break between its words ("Paid to / supplier") while the amount, which is nowrap, sets
 * the least a tile may be. So an amount is never ellipsised, and the row wraps only when the
 * window is genuinely too narrow for eight whole amounts - never a sideways scroll, which was
 * refused.
 */
.session-tabs { display: flex; flex-wrap: wrap; }
.session-tabs .stat-tile {
    flex: 1 1 0;
    min-width: min-content;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
}
.session-tabs .stat-tile__label { display: none; }
.session-tabs .stat-tile__caption { grid-column: 1; }
.session-tabs .stat-tile__cell:nth-child(3) { grid-column: 1 / -1; }
.session-tabs .stat-tile__value { overflow: visible; text-overflow: clip; }

/*
 * One tile: a caption across the top, then the count and the amount side by side, each under a
 * small label of its own. The two figures sit in the same two columns on every tile, so a reader
 * scanning along the row compares counts with counts and amounts with amounts.
 *
 * Amber throughout - asked for - and one tone rather than four, because these are four readings
 * of one set: a green Paid beside a red Overdue would colour a figure by its direction, which is
 * the fault the KPI polarity rule exists to avoid. Left-aligned like every other column of
 * figures in the application; tabular numerals keep the digits in stripes.
 *
 * A button, because pressing one narrows the list to it; the tile matching the picker is drawn
 * filled, so the row also says which narrowing is on.
 */
.stat-tile {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    column-gap: var(--space-3);
    row-gap: var(--space-1);
    align-items: end;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--pos-warning);
    border-radius: var(--radius-surface);
    background: var(--pos-warning-soft);
    color: var(--pos-warning);
    font: inherit;
    text-align: left;
    min-width: 0;
    cursor: pointer;
    transition: background-color var(--motion-instant) var(--ease-standard),
                color var(--motion-instant) var(--ease-standard);
}
.stat-tile:hover { background: var(--pos-warning); color: var(--pos-on-brand); }
.stat-tile--on { background: var(--pos-warning); color: var(--pos-on-brand); }
.stat-tile:focus-visible { outline: 1px solid var(--pos-focus); outline-offset: 1px; }

.stat-tile__caption {
    grid-column: 1 / -1;
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-tile__cell { display: grid; gap: 0; min-width: 0; }
.stat-tile__label { font-size: var(--text-xs); opacity: 0.8; }
.stat-tile__value {
    font-size: var(--text-base);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Forms

   A two-column label-and-field grid on a roomy screen, one column when there is not the width
   for two. The label stays above its field in both, because a label beside a field costs the
   width the field needs on the narrow screens this head now has to serve.
   ========================================================================== */

.form { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form--single { grid-template-columns: minmax(0, 1fr); }
.form--triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form--quad { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/*
 * THE PARTY FORMS (customer, supplier): three across on a wide window, two on a tablet, one on a
 * phone. Spans are shares of the row, so .field--half (two columns) is the whole row once the grid
 * is two wide, and every span is the whole row on one column.
 */
.form--cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 900px) {
    .form--cols3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .form--cols3 { grid-template-columns: minmax(0, 1fr); }
    .form--cols3 > .field--half { grid-column: 1 / -1; }
}

@media (max-width: 1100px) {
    .form--quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form--quad > .field--three { grid-column: 1 / -1; }
}

/* Two legend boxes side by side inside one card - Schedule beside Bank, Allowances beside Deductions.
   Stacks again below the width where two columns of fields stop being readable. */
.legend-split { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.legend-split--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 1100px) {
    .form--quad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .legend-split, .legend-split--three { grid-template-columns: minmax(0, 1fr); }
}

/* A table kept to a few rows that scrolls itself, so a long history never pushes the form off screen. */
.scroll-short { max-height: 14rem; overflow-y: auto; }

/* One allowance or deduction on a setup: name, how it is worked out, the figure, remove. */
.payline { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 6.5rem auto; gap: var(--space-2); align-items: center; }
.payline + .payline { margin-top: var(--space-2); }

/* A legend box's right-hand corner action, level with the legend. */
.legend-box__tools { display: flex; justify-content: flex-end; gap: var(--space-2); }

/*
 * position: relative so a field can carry its own hint marker in the corner - see .field__info in
 * controls.css. It anchors nothing else: the lookup list a field may open is drawn on the window's
 * own overlay layer and positioned against the box's rendered rectangle, so it is unaffected.
 */
.field { display: grid; gap: var(--space-1); min-width: 0; position: relative; }
.field--wide { grid-column: 1 / -1; }

/*
 * Spans for a field on the four-column grid (.form--quad). A span is a share of the row, so on the
 * grids that have fewer columns it simply means "the whole row" - see the narrow-width rules.
 */
.field--half { grid-column: span 2; }
.field--three { grid-column: span 3; }

/*
 * WHAT IS WRONG WITH THIS FIELD, UNDER THE FIELD. Never a tooltip and never a dialog: a message
 * that has to be hovered for is a message nobody reads, and one that has to be dismissed is in the
 * way of fixing the thing it is complaining about.
 *
 * THAT STILL HOLDS, AND IT IS ABOUT VALIDATION. What used to share this class was a second thing
 * entirely - the standing explanation of what a box is for - and eighty-odd of those, one under
 * every control, is what made the forms read as cluttered. Those moved onto .field__info, a marker
 * on the field's own caption line, at the client's request. A hint that is genuinely page prose
 * rather than a note about a control kept this class and its line, because there is no control for
 * a marker to sit on.
 */
.field__hint { font-size: var(--text-xs); color: var(--pos-text-subtle); }

/* ==========================================================================
   Data grid

   Dense, and deliberately still a table on a small screen: this is an ERP, and a table that
   becomes a stack of cards on a tablet stops being readable at exactly the size where somebody
   is checking figures against a docket. It scrolls sideways instead.
   ========================================================================== */

/*
 * THE ONE SURFACE THAT TAKES THE EDGES AND REFUSES THE FILL, and the line this whole theme is
 * drawn along. A grid frame is lit like every other surface so it belongs to the same set; its
 * background stays flatly opaque, because the rows sitting on it are transparent and a
 * translucent frame would put the app ground behind every figure in the application. That is
 * exactly the readability a table is there for.
 *
 * Same reasoning keeps the fill off a form input. Dense data is solid; chrome is glass.
 */
.grid {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
    min-width: 0;
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--pos-surface);
    /* No shadow on a table, asked for directly: a fine border carries the edge. */
    overflow: hidden;
}

.grid__scroll { min-height: 0; overflow: auto; }

.grid__table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.35; }

.grid__table th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: var(--grid-header-height);
    padding: 0 var(--space-3);
    /*
     * A FILLED PRIMARY BAND, asked for directly - the same green the filled Save button and the
     * rail's active row wear, so a header, a filled action and the mark are demonstrably one
     * colour. It was a teal wash before that and a navy fill before that; what has not changed is
     * what the band is FOR, which is finding the head of a table at a glance down a screen
     * holding three of them.
     *
     * THE LABEL IS THE ON-BRAND INK, NEVER A TYPED WHITE. It resolves to #FFFFFF here and to a
     * near-black under [data-theme="dark"], where the primary is a LIGHT green - a hardcoded
     * white would be unreadable on it the day dark mode is switched on. No hairline under it: the
     * fill's own edge is the separator, and a light rule along the bottom of a band reads as a
     * rim.
     */
    background: var(--pos-grid-header-bg);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--pos-on-brand);
    text-align: left;
    white-space: nowrap;
}

/*
 * The header is sticky, so once the first row has scrolled under it it is genuinely floating
 * over the body rather than sitting beside it. The hairline alone does not say that; a shallow
 * shadow does, and it is drawn below the element so it never bleeds up over the toolbar.
 */
.grid__table th::after {
    content: "";
    position: absolute;
    inset: auto 0 -1px 0;
    height: 1px;
    box-shadow: 0 6px 10px -6px var(--pos-shadow-medium);
}

/*
 * A grid is inset at its right-hand end. Without it the last column sits hard against the frame
 * and reads as clipped. This was first noticed on the money columns, which were right-aligned at
 * the time and put the last digit of every figure against the border; now that every column is
 * left-aligned it is the action column that would touch the edge instead, so the inset stays and
 * only the reason for it has changed. The header and the rows must agree exactly.
 */
.grid__table th:last-child, .grid__table td:last-child { padding-right: var(--grid-edge-padding); }

/* Clicking a header reports a sort key and the page reloads from the server. It never sorts
   the rows in hand: that would reorder one page out of sixteen and look like a sorted table. */
.grid__table th.sortable { cursor: pointer; user-select: none; }

/* A shade, not a change of ink: the label is already at full strength on a filled band. */
.grid__table th.sortable:hover { background: var(--pos-grid-header-bg-hover); }
.grid__sort { margin-left: var(--space-1); opacity: 0.7; }

.grid__table td {
    /* A row height is a minimum, not a fixed size: a two-line cell makes its row taller. */
    height: var(--grid-row-height);
    padding: var(--grid-row-padding) var(--space-3);
    border-bottom: 1px solid var(--pos-grid-line);
    vertical-align: middle;
}

.grid__table tbody tr td { transition: background var(--motion-instant) var(--ease-standard); }

/*
 * A LIGHT LINE BETWEEN CELLS, asked for directly, for reading across a wide row. Fainter than the
 * row line beneath it (--pos-grid-cell-line against --pos-grid-line) so the stripes and the rows
 * stay the structure and the columns are only a guide. The last cell has none: the frame is its
 * edge. On the filled header band the divider is its own token, because a dark line on a green fill
 * is a different colour problem from a faint line on white.
 */
.grid__table td:not(:last-child) { border-right: 1px solid var(--pos-grid-cell-line); }
.grid__table th:not(:last-child) { border-right: 1px solid var(--pos-grid-header-divider); }

/*
 * ZEBRA STRIPING, and then a money tint over the top of it.
 *
 * ORDER IS THE WHOLE MECHANISM HERE, so do not move these below the hover rule. All five
 * selectors below carry the SAME specificity - two class-level tokens (.grid__table plus a
 * pseudo-class or a row class) and three elements - so which one wins is decided purely by which
 * comes last. Striping and the money tint are written first precisely so that hover and selection,
 * declared after them, still paint over both. Reordering this block silently kills the hover
 * highlight on every other row of every table in the application, and nothing but the eye can
 * catch it.
 *
 * The tint REPLACES the stripe rather than layering with it: three shades of green on alternate
 * rows would say something the data does not, and the point of the colour is that it means money
 * went one way rather than the other.
 */
.grid__table tbody tr:nth-child(even) td { background: var(--pos-grid-row-stripe); }

.grid__table tbody tr.grid__row--in td { background: var(--pos-grid-row-in); }
.grid__table tbody tr.grid__row--out td { background: var(--pos-grid-row-out); }

/*
 * A DRAFT ROW - a parked sale shown on the Sales list, never a sale itself. The tint is the same
 * mechanism as the money rows above rather than a second one: it replaces the stripe, not layers
 * over it, so the eye reads "this row is a different kind of thing" rather than "this row made
 * money" or "this row lost money" - the info hue rather than green or red, matching the "Parked"
 * badge Drafts.razor already draws these rows under.
 */
.grid__table tbody tr.grid__row--changed td { background: var(--pos-warning-soft); }
.grid__table tbody tr.grid__row--draft td { background: var(--pos-grid-row-draft); }
/* A sale raised by handing a customer's own goods back - bluer than a parked draft, so the two never read as one. */
.grid__table tbody tr.grid__row--job td { background: var(--pos-grid-row-job); }

.grid__table tbody tr:hover td { background: var(--pos-grid-row-hover); }
.grid__table tbody tr.is-selected td { background: var(--pos-grid-row-selected); }

/*
 * A TOTAL ROW INSIDE THE TABLE - a subtotal or a closing figure on a reconciliation. Declared
 * after hover on purpose: a total is a fixed point the eye returns to, and it must not change
 * shade under the mouse the way a data row does. The rule along its top is what says "the rows
 * above add up to this"; the sunken fill is the same one the totals strip on New Sale uses.
 */
.grid__table tbody tr.grid__row--total td {
    background: var(--pos-surface-sunken);
    border-top: 1px solid var(--pos-border-strong);
    font-weight: 650;
}
.grid__table tbody tr.clickable { cursor: pointer; }
.grid__table tbody tr:last-child td { border-bottom: 0; }

/*
 * A SHARED-STOCK CHILD ROW - a price-only sibling folded under the line that actually received
 * something (PurchaseLineGrouping). The same sunken fill a total row uses, because this too is a
 * detail rather than a delivery of its own: nothing on it moved stock or cost anything by itself.
 */
.grid__table tbody tr.grid__row--nested td { background: var(--pos-surface-sunken); }
.grid__row--nested-cell { padding-left: var(--space-5); }

.grid__cell--numeric { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid__cell--actions { text-align: right; white-space: nowrap; }
.grid__cell--tight { width: 1%; white-space: nowrap; }

/*
 * A COLUMN OF PROSE - an address, a note, a reason. Capped and wrapped.
 *
 * NOT `.truncate`, and this is the distinction worth keeping. That class is nowrap plus an
 * ellipsis, which works perfectly on a flex item: the item has a definite share of the row, so the
 * text is clipped inside it. A TABLE CELL HAS NO SUCH SHARE. The grid is auto-layout, so a column
 * is as wide as its widest cell wants to be, and `white-space: nowrap` tells that cell it wants to
 * be as wide as the whole string - so an address ran the table off the right-hand edge of the
 * window and put a horizontal scrollbar under every other column. Nothing was ever clipped and no
 * ellipsis was ever drawn; the overflow was the fault and the scrollbar was only the messenger.
 *
 * `overflow-wrap: anywhere` rather than `break-word`, and that is what makes the cap bind: only
 * `anywhere` also shrinks the cell's MINIMUM content width, so a single unbroken run - a pasted
 * address with no spaces in it - is broken rather than being allowed to widen the column past the
 * maximum in spite of it.
 *
 * The row grows instead, which the row height already allows for: it is a minimum, not a fixed
 * size.
 */
.grid__cell--prose {
    max-width: var(--grid-cell-prose);
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Two lines in one cell: a name over a code, a branch over who is signed in there. */
.grid__stack { display: grid; gap: 1px; }
.grid__stack small { font-size: var(--text-xs); color: var(--pos-text-subtle); }

.grid__empty, .grid__busy {
    display: grid;
    place-items: center;
    gap: var(--space-3);
    padding: var(--space-7) var(--space-5);
    color: var(--pos-text-muted);
    font-size: var(--text-sm);
    text-align: center;
}

/*
 * The empty state. Three lines at most and a way out of it.
 *
 * "No records found" tells somebody nothing they cannot already see. What they actually need is
 * which of the things they typed is responsible and how to undo it, which is why the action
 * matters more than the picture: the commonest cause of an empty list is a filter still applied
 * from ten minutes ago that has scrolled out of view.
 */
.empty {
    display: grid;
    justify-items: center;
    gap: var(--space-2);
    padding: var(--space-7) var(--space-5);
    text-align: center;
}

/*
 * The icon is deliberately quiet - a soft disc with a muted glyph rather than the large coloured
 * illustration this pattern usually attracts. Nothing has gone wrong here, and an empty product
 * list on a busy morning should not look like an error.
 */
.empty__icon {
    display: grid;
    place-items: center;
    width: calc(var(--icon-size-tile) * 2);
    height: calc(var(--icon-size-tile) * 2);
    margin-bottom: var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--pos-surface-sunken);
    color: var(--pos-text-subtle);
}

.empty__title { font-size: var(--text-base); font-weight: 650; color: var(--pos-text); }
.empty__text { max-width: 44ch; font-size: var(--text-sm); color: var(--pos-text-muted); }
.empty__action { margin-top: var(--space-3); display: flex; gap: var(--space-3); }

/*
 * The first-load skeleton. It stands in for rows that are coming, so it is built to the grid's
 * own row height - a skeleton of the wrong height makes the page jump when the data lands, which
 * is the one thing it exists to prevent.
 */
.skeleton { padding: var(--space-2) 0; }

.skeleton__row {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    height: var(--grid-row-height);
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--pos-grid-line);
}

.skeleton__bar {
    height: var(--space-3);
    flex: 1;
    border-radius: var(--radius-sm);
    background: var(--pos-surface-sunken);

    /*
     * The sweep is what says "still working" - a static grey bar is indistinguishable from a
     * table that has loaded badly. Slow and low contrast on purpose: this sits behind whatever
     * somebody is about to read, and it must not compete for attention with the data replacing
     * it. Switched off entirely under prefers-reduced-motion by the global rule in app.css.
     */
    background-image: linear-gradient(
        90deg,
        transparent 0%,
        var(--pos-surface-hover) 50%,
        transparent 100%);
    background-size: 200% 100%;
    animation: skeleton-sweep 1.4s ease-in-out infinite;
}

.skeleton__bar--wide { flex: 2.4; }
.skeleton__bar--narrow { flex: 0.6; }

/* Staggered, so the row reads as one object arriving rather than three bars blinking together. */
.skeleton__row:nth-child(2n) .skeleton__bar { animation-delay: 0.12s; }
.skeleton__row:nth-child(3n) .skeleton__bar { animation-delay: 0.24s; }

@keyframes skeleton-sweep {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/*
 * A list keeps its current rows while a new search runs rather than blanking. This is what that
 * looks like: the rows stay readable and say they are going stale.
 */
.grid__scroll--stale { opacity: 0.55; pointer-events: none; }

.pager {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--pos-border);
    font-size: var(--text-sm);
    color: var(--pos-text-muted);
}

.pager__spacer { flex: 1; }

/*
 * The same pager drawn ABOVE a grid as well as in its footer, so a long list can be turned from
 * either end. It sits outside the grid frame, so the footer's rule along its top has nothing to
 * separate it from and goes; and Pager renders nothing at all for an empty list, so an empty
 * wrapper is hidden rather than left as a strip of padding over the grid's own empty state.
 */
.pager--top { border-top: 0; padding-block: 0; }
.pager--top:empty { display: none; }

/*
 * THE PINNED-DRAFTS COURTESY on the Sales list — what is parked, shown above page 1 of the
 * ordinary view. Its own grid frame rather than a row inside the one below it: these are not
 * sales, and a shared border would say they belonged to the same table.
 */
.list-pinned { margin-bottom: var(--space-4); flex-shrink: 0; }
.list-pinned__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

/*
 * IT MAY NEVER PUSH THE LIST OFF THE SCREEN. The Sales page fills the window and the invoice grid
 * takes what is left, so six parked rows on a short window left the grid nothing at all - its
 * header and pager drawn touching, with no invoices between them. The panel is a reminder, not
 * the list: about three rows, then it scrolls inside its own frame ("See all" is under it).
 */
.list-pinned .grid__scroll { max-height: var(--list-pinned-max-height); }

/*
 * And the list under it keeps a floor of its own. Short of room for the filters, the panel and
 * that floor, the page scrolls (.shell__page) rather than squeezing the list to nothing.
 */
.page__body--fill:has(> .list-pinned) > :last-child { min-height: var(--list-under-pinned-min-height); }

/* ==========================================================================
   Tabs

   A tab identity and its position are different numbers. Reading the strip index as an identity
   is how a role that cannot see one tab silently opens the wrong one - the markup here only ever
   draws what it is given, and the page keeps the identity.
   ========================================================================== */

.tabs {
    display: flex;
    gap: var(--space-1);
    /*
     * The chips no longer sit ON the rule - they are outlined, so a tab pressed against a
     * hairline reads as two borders meeting. The padding is what holds them off it.
     */
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--pos-border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

/*
 * A TAB IS AN OUTLINED CHIP AND THE SELECTED ONE IS FILLED, asked for directly and applied to
 * every HORIZONTAL tab strip in the application rather than to one screen's - the tender strip
 * on New Sale follows the identical rule, so a tab reads the same wherever it is met sideways.
 * The one vertical strip (Settings, below) carries its own look instead - see .tabs--vertical.
 *
 * It was an underline before: no border, no fill, and a 2px rule under whichever one was showing.
 * The two things that treatment got right are kept rather than lost. The strip must not MOVE when
 * the selection changes, which an outline that appeared on selection would do - so every tab
 * carries its border all the time and only the fill changes. And the ink on the filled one is
 * --pos-on-brand rather than a typed white, because the primary is a LIGHT green under
 * [data-theme="dark"] and white on it would be unreadable the day that is switched on.
 */
.tab {
    height: var(--control-height);
    padding: var(--tab-padding);
    border: 1px solid var(--pos-primary);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--pos-primary);
    font: inherit;
    font-size: var(--text-base);
    white-space: nowrap;
    cursor: pointer;
    transition:
        color var(--motion-instant) var(--ease-standard),
        background var(--motion-instant) var(--ease-standard);
}

/* Scoped off the active tab deliberately: :hover carries more specificity than
   .tab--active, so a plain .tab:hover would wash the fill off the selected one. */
.tab:not(.tab--active):hover { background: var(--pos-primary-soft); }

.tab--active {
    background: var(--pos-primary);
    color: var(--pos-on-brand);
    font-weight: 650;
}

/*
 * A COLUMN DOWN THE SIDE RATHER THAN A STRIP ACROSS THE TOP - Settings' own shape, asked for
 * directly. It is a surface of its own now rather than the outlined chip turned sideways: white,
 * bordered and raised the same way a card is, so it reads as joined to the cards beside it
 * instead of as a separate colour standing next to them. Flat --pos-surface rather than the
 * cards' own --grad-glass - glass is for things that float above the page, and a settings nav is
 * closer kin to a dense form than to the lookup list or the gate card that wear it.
 * --rail-width rather than a figure of its own: it is already this application's answer to "how
 * wide is a column of things you pick from", and reusing it is one less width to keep in step by
 * hand.
 */
.tabs--vertical {
    flex-direction: column;
    align-items: stretch;
    width: var(--rail-width);
    flex-shrink: 0;
    gap: 0;
    padding: 0;
    overflow-x: visible;
    overflow-y: auto;
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    box-shadow: var(--elev-1);
}

/*
 * The point cut into the right edge (--tab-arrow-depth) is what makes a plain row read as a TAB
 * rather than a line of a list: it is the whole of the shape, and it replaces the base .tab's
 * rounded corners outright - a clip-path draws over a border-radius rather than combining with
 * it, so border-radius is set to nought here instead of left to clash with it silently.
 */
.tabs--vertical .tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    height: var(--control-height-lg);
    padding: 0 var(--space-5) 0 var(--space-4);
    border: none;
    border-radius: 0;
    background: none;
    color: var(--pos-text);
    text-align: left;
    clip-path: polygon(
        0 0, calc(100% - var(--tab-arrow-depth)) 0,
        100% 50%,
        calc(100% - var(--tab-arrow-depth)) 100%, 0 100%);
}

/* A wash of the strip's own ground, the identical treatment a hovered rail entry gets over the
   rail's. Scoped off the active tab: :hover carries more specificity than .tab--active, so a
   plain :hover would wash the selected tab's own tint out. */
.tabs--vertical .tab:not(.tab--active):hover { background: var(--pos-surface-hover); }

/*
 * SELECTED READS EXACTLY LIKE THE CURRENT ENTRY ON THE NAVIGATION RAIL, asked for directly - the
 * same accent tint, the same lit line, the same soft glow, reused rather than a second "this is
 * the current one" language invented beside it.
 */
.tabs--vertical .tab--active {
    background: var(--grad-accent-tint);
    color: var(--pos-on-accent-soft);
    border-color: var(--pos-rail-active-line);
    font-weight: 600;
    box-shadow: var(--glow-accent-soft), var(--glass-edge);
}

.tabs--vertical .tab .icon { flex-shrink: 0; opacity: 0.85; }
.tabs--vertical .tab--active .icon { opacity: 1; color: var(--pos-rail-active); }

/* A long section name must not run past the point cut into the tab, or it prints through the
   angled edge rather than stopping short of it. */
.tabs--vertical .tab__label { overflow: hidden; text-overflow: ellipsis; }

/*
 * THE TWO SIDES STRETCH TO ONE ANOTHER'S HEIGHT AND SIT A SLIGHT MARGIN APART, asked for
 * directly - stretch rather than start, so the shorter of the strip and the pane it opened
 * always grows to match the taller, and the two read as one joined block rather than two
 * columns that happen to start at the same line. --space-2 rather than --space-6: a "slight"
 * margin is what is left of the gap once "joined" is the point of it.
 *
 * FILLS WHATEVER HEIGHT THE PAGE HAS TO GIVE, asked for directly - flex: 1 and min-height: 0
 * are the identical trick .page__body--fill already uses to take "whatever is left" rather than
 * only its own content's height, overriding .page > *'s flex-shrink: 0 by appearing later in the
 * cascade at equal specificity. Both columns then stretch to that full height rather than only
 * to each other's - a short tab like Danger fills the same frame a long one does, instead of
 * leaving a gap of page underneath it.
 */
.tabs-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-2);
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

/*
 * ONE SOLID WHITE CARD, asked for directly, rather than the several separate cards Settings used
 * to stack one tab's fields into - the Printer tab alone was three of them. Flat --pos-surface
 * rather than the ordinary card's --grad-glass, matching the tab strip beside it: this reads as
 * a form, not something that floats, and the two ought to be the same kind of surface. Each
 * former card lost its own border and padding and became a plain .settings-section instead - see
 * below for the hairline that now marks where one used to end and the next began.
 *
 * FLEX, NOT .detail'S GRID - this pane holds one tab's sections, stacked, and a plain column
 * already gives each its natural height with nothing to stretch. min-height: 0 is what lets it
 * shrink inside the row .tabs-layout now stretches it to, rather than forcing that row to grow
 * around its own content; overflow-y is what a tab longer than the available height does instead
 * of pushing the tab strip beside it taller than the screen.
 */
.tabs-layout__content {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
    min-height: 0;
    padding: var(--card-padding);
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    box-shadow: var(--elev-1);
    overflow-y: auto;
}

/*
 * THE HAIRLINE WHERE A SEPARATE CARD USED TO SIT. The flex gap above still carries the base
 * spacing; this adds only the rule and the little extra room below it, so two sections read as
 * two things inside one card rather than as one uninterrupted list of fields.
 */
.settings-section + .settings-section {
    border-top: 1px solid var(--pos-border);
    padding-top: var(--space-4);
}

/* ==========================================================================
   Dialogs

   The scrim colour is the one translucent token in the palette, and like every other colour it
   is named once in tokens.css and carries a dark twin.
   ========================================================================== */

.dialog-scrim {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: var(--space-5);
    background: var(--pos-overlay);

    /*
     * Blurred as well as dimmed. Dimming alone leaves the page behind legible enough to keep
     * reading, which is exactly what a modal is for stopping. Kept shallow - 2px is enough to
     * push it out of focus, and backdrop-filter over a full window is the most expensive thing
     * this stylesheet asks for.
     */
    backdrop-filter: blur(2px);
    animation: scrim-in var(--motion-fast) var(--ease-out);
}

@keyframes scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog {
    display: grid;
    grid-template-rows: auto 1fr auto;
    width: var(--dialog-wide);
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
    border-radius: var(--radius-surface);

    /*
     * Glass, and DELIBERATELY WITHOUT A BACKDROP-FILTER OF ITS OWN. The scrim underneath already
     * blurs the page, so a filter here would be a second blurred layer stacked on the first -
     * over most of the window, on counter hardware, for no visible gain. What shows through this
     * pane is the scrim's own already-blurred image, which is the glass read for free.
     */
    background: var(--pos-glass);
    border: 1px solid var(--pos-glass-border);
    box-shadow: var(--elev-4), var(--glass-edge);
    overflow: hidden;

    /*
     * Rises the last few pixels rather than appearing. Short enough that a cashier opening the
     * return dialog forty times a shift never waits for it, long enough to say where it came
     * from - which is what stops a modal reading as the screen having been replaced.
     */
    animation: dialog-in var(--motion-base) var(--ease-out);
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.dialog--compact { width: var(--dialog-compact); }
.dialog--full { width: var(--dialog-full); }
.dialog--xl { width: var(--dialog-xl); }

.dialog__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--pos-border);
}

.dialog__title { font-size: var(--text-lg); font-weight: 700; flex: 1; min-width: 0; }
.dialog__body { min-height: 0; overflow: auto; padding: var(--space-5); display: grid; gap: var(--space-4); }

.dialog__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--pos-border);
    background: var(--pos-surface-sunken);
}

.dialog__footer .dialog__footer-lead { margin-right: auto; }

/* ==========================================================================
   Lookup

   The result list is drawn on an overlay layer, not in the box own layout, so opening it moves
   nothing. In its own layout it pushed everything below it down the screen - in a dialog the
   fields shifted under the hand typing into them, and on New Sale the entry card grew and took
   the height straight out of the sale being rung up.
   ========================================================================== */

.lookup { position: relative; min-width: 0; }

/*
 * A result row whose text will not share a line.
 *
 * The counter's customer names run past fifty characters, and the list is drawn at the width of
 * the box it belongs to - which in New Sale's side column is under 300px. Name, code and phone on
 * one row truncated the name to nothing, which is the one part anybody searches by. Stacked, the
 * name gets the whole width and the code and phone sit quietly underneath.
 */
.lookup__stack { display: grid; gap: 1px; min-width: 0; flex: 1; }
.lookup__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/*
 * PartyFilter's own box on a toolbar, widened. Unset, a text input with nothing constraining it
 * falls back to the browser's own narrow default - and the result list is drawn at the box's own
 * width (see pos.place), so a cramped box meant a cramped list cutting customer names off exactly
 * where .lookup__name's ellipsis above was papering over it. Asked for directly.
 */
.party-filter { min-width: 220px; }

/*
 * A lookup filter on a toolbar - customer, supplier, who did it - has ONE fixed width, so the box
 * is the same size empty, typed into and chosen. The x that takes a choice off sits INSIDE the
 * box (see .sselect), so it costs the text a little room and never the toolbar a pixel: nothing
 * beside it moves when it appears. Fixed rather than flexible for that reason, and wide because
 * the result list is drawn at the box's own width and a customer's name and number need the room.
 */
.party-filter,
.staff-filter { flex: 0 0 var(--filter-width); width: var(--filter-width); min-width: 0; }

/* The product picker on a report toolbar, wider than the other lookups: a product's name and form run
   long, and the result list is drawn at the box's own width. Placed after the rule above so it wins
   where an element carries both classes. */
.product-filter { flex: 0 0 var(--filter-width-wide); width: var(--filter-width-wide); min-width: 0; }
.product-filter .lookup { width: 100%; min-width: 0; }

/*
 * A stock register's summary, ABOVE its table: the headline and the Quick Info lines as one strip of
 * figures, then the pie charts. It was a column of bars down the right-hand edge; the client asked
 * for charts over the table.
 */
.report-summary { display: grid; gap: var(--space-3); }

/*
 * FIGURES ON THE LEFT, CHARTS ON THE RIGHT, wherever a report carries both - the arrangement the
 * account-register card uses. The figures wrap onto the next line when they run out of room rather
 * than being forced into a single column.
 */
.report-summary--split {
    grid-template-columns: minmax(var(--filter-width), 1fr) minmax(0, 3fr);
    column-gap: var(--space-5);
    align-items: start;
}

.report-summary--split > .report-summary__facts,
.report-summary--split > .report-summary__tiles { align-content: start; }

.report-summary__tiles { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.report-summary__tiles > * { flex: 1 1 var(--bi-card-min-width); min-width: 0; }

.report-summary__charts { min-width: 0; margin-top: 0; }

@media (max-width: 900px) {
    .report-summary--split { grid-template-columns: minmax(0, 1fr); }
}

.report-summary__facts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.report-summary__facts > * { flex: 1 1 var(--bi-card-min-width); }

.report-summary__fact {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    align-items: baseline;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--pos-surface);
    font-variant-numeric: tabular-nums;
}

.report-summary__fact > span:first-child { color: var(--pos-text-muted); font-size: var(--text-sm); }
.report-summary__fact > span:last-child { font-weight: 650; }

/* The headline: a filled brand band, the way a table header is. */
.report-summary__fact--head { background: var(--pos-primary); border-color: var(--pos-primary); color: var(--pos-on-brand); }
.report-summary__fact--head > span:first-child { color: var(--pos-on-brand); }

/* A table's own CSV / PDF pair, at the right-hand end just above it. */
.report-table__tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.report-table__note { font-size: var(--text-xs); margin-right: auto; }

/* A table's heading and its CSV / PDF pair on one line, the heading left and the buttons right. */
.report-table__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.report-table__head .section-heading { margin: 0; }
.report-table__head .report-table__tools { margin: 0; }

/*
 * A report table drawn as a card (ReportTable's Title): a header carrying the table's name and its
 * own export buttons, and a body holding the rows. The card is the frame, so the grid inside gives
 * up its own border; the rows scroll inside the body past a fixed height, with the column headings
 * held at the top, so a long list never pushes the next table off the page.
 */
.report-card { padding: 0; overflow: hidden; }
.report-card .report-table__tools { margin: 0; }
.report-card .grid { border: 0; border-radius: 0; }
.report-card .grid__scroll { max-height: var(--report-card-max-height); }

/* A report's grand total, held at the foot of the page while the rows scroll above it. */
.report-total {
    position: sticky;
    bottom: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--pos-primary);
    color: var(--pos-on-brand);
    font-size: var(--text-lg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}


/* A lookup on a toolbar, where an unset box falls back to the browser's own narrow default - and the
   list is drawn at the box's own width. */
.toolbar .lookup, .toolbar .multi { min-width: 180px; }

/*
 * PartyLookupRow: name and balance share the first line (the balance holds the far edge instead of
 * leaving it empty), and code / phone / address sit on a muted second line that wraps and stops at
 * two lines rather than running past the box.
 */
.lookup__party { display: grid; gap: 1px; min-width: 0; flex: 1; }
.lookup__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); min-width: 0; }
.lookup__head .lookup__name { flex: 1; min-width: 0; }
.lookup__right { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.lookup__detail {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

/*
 * The generic twins of sale.css's .sale__lookup-balance / .sale__balance--owing, for a lookup row
 * outside New Sale that wants to show a balance the same way - a payment popup's own customer
 * search, most likely. Amber only while something is actually owed; a settled or credit balance
 * keeps the muted tone, because nothing owed is not a warning.
 */
.lookup__balance { font-variant-numeric: tabular-nums; }
.balance--owing { color: var(--pos-warning); }

/*
 * A standalone line stating what is owed right now - "Outstanding 4,500.00" - rather than a
 * balance sitting quietly beside a name. Bold as well as amber: this is the one figure on the
 * form that decides what happens next, not a fact read in passing.
 */
.field__hint--owing { color: var(--pos-warning); font-weight: 700; }

.lookup__list {
    position: fixed;
    z-index: 200;

    /* Read by pos.place: a result list takes its box's width, but never less than this, so a lookup in
       a small box still has room for a long product name and its prices. */
    --lookup-list-min-width: var(--lookup-min-width);
    max-height: calc(var(--grid-row-height) * 8);
    overflow-y: auto;
    border: 1px solid var(--pos-glass-border);
    border-radius: var(--radius-surface);

    /*
     * Glass, and one of the few places in the app that gets it. A result list is unambiguously
     * floating over the row it belongs to, so letting a hint of that row through is what says
     * so - where the same treatment on a data table would cost the readability the figures are
     * there for.
     *
     * The background is 88% opaque, not 40%. What sells this is the blur and the hairline, not
     * the transparency, and a cashier reading a product name through a table underneath it would
     * be a decoration that got somebody's order wrong.
     */
    background: var(--pos-glass);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--elev-3), var(--glass-edge);
    animation: lookup-in var(--motion-fast) var(--ease-out);
}

@keyframes lookup-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.lookup__option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
}

.lookup__option:hover { background: var(--pos-surface-hover); }

/* A hairline between result rows, so two-line rows read as separate choices. The last row has none
   - the list's own border closes it. */
.lookup__option + .lookup__option { border-top: 1px solid var(--pos-border); }

/*
 * Nothing is highlighted until an arrow key is pressed. A scanner is a keyboard that sends the
 * code and then Enter itself, so a pre-highlighted row would let that Enter ring up whatever the
 * half-typed text matched instead of what was scanned.
 */
.lookup__option {
    position: relative;
    transition: background var(--motion-instant) var(--ease-standard);
}

/*
 * The keyboard highlight is deliberately louder than hover, and carries a bar down its leading
 * edge that hover does not. They mean different things: hover is where the mouse happens to be,
 * this is what Enter is about to choose. A cashier working the keyboard has to be able to tell
 * at a glance, and a shared background colour cannot say it.
 */
.lookup__option--active {
    background: var(--pos-primary-soft);
    font-weight: 600;
}

.lookup__option--active::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--pos-primary);
}

.lookup__empty { padding: var(--space-3); font-size: var(--text-sm); color: var(--pos-text-muted); }

/*
 * A product result row: the picture on the left, then two rows of two cells - the name and what it
 * sells at in its unit on the first, the stock and the second unit on the other. The right-hand
 * column is as wide as its widest figure line and the name takes the rest, so a long product name
 * is the thing that gives way. Left-aligned, like every column in the application.
 */
.lookup__product {
    display: flex;
    flex-wrap: wrap;
    column-gap: var(--space-4);
    row-gap: 1px;
    flex: 1;
    min-width: 0;
}

/*
 * THE NAME TAKES THE WHOLE ROW AND MAY RUN TO TWO LINES; the prices and stock sit together under
 * it. It used to share a line with the price block, which was sized to its widest figure line, so a
 * long name was squeezed to nothing while the prices were crammed into a column down the side. Two
 * lines and then an ellipsis, with the full name on hover (the title on the span).
 */
.lookup__product .lookup__title {
    flex: 1 0 100%;
    min-width: 0;
    display: flex;
    align-items: baseline;
    column-gap: var(--space-4);
}

.lookup__product .lookup__name {
    flex: 1;
    min-width: 0;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* The code at the right-hand end of the line: never shrunk, never wrapped. */
.lookup__code { flex: 0 0 auto; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Each fact is one unbreakable piece: a line too long for the row drops WHOLE pieces to the next
   line, so a price is never split mid-figure. A piece with nothing in it takes no room. */
.lookup__facts { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lookup__facts:empty { display: none; }

/* The figures somebody scans a product list for - prices and stock - in the amber the rest of the
   application already uses for a figure that decides what happens next. */
.lookup__amber { color: var(--pos-warning); font-weight: 600; }

/*
 * The product form: one card holding legend-bordered boxes, each a 12-column grid. A field's width
 * is a number of twelfths (.pform__3 is a quarter), so nothing here is a measurement - and below
 * the narrow-window breakpoint every cell but the full-width ones folds to two across.
 */
.legend-stack { display: grid; gap: var(--space-4); }

.legend-box {
    min-width: 0;
    margin: 0;
    padding: var(--space-3) var(--space-4) var(--space-4);
    /* The group's frame is the brand green, and the boxes typed into inside it keep the neutral grey:
       a frame and a field in one grey were indistinguishable on a form of four boxes and a dozen
       inputs. The legend is already the accent, so title and frame read as one. */
    border: 1px solid var(--pos-legend-border);
    border-radius: var(--radius-surface);
}

.legend-box > legend {
    padding: 0 var(--space-2);
    font-size: var(--text-sm);
    font-weight: 700;

    /* The teal-green the application uses for a positive, rather than the grey of a caption: a legend
       is a title for the box, and it is what the eye finds first on a form of four of them. */
    color: var(--pos-accent);
}

/*
 * A table inside a legend box has the box's own frame round it and no shadow of its own: a raised
 * card inside a bordered box is two edges where one is wanted. The form below it sits clear.
 */
.legend-box .grid { box-shadow: none; border-color: var(--pos-border-strong); }
.legend-box .detail__payments { margin-bottom: var(--space-4); }

.pform {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-3);
    align-items: start;
}

.pform > * { min-width: 0; }

/*
 * EVERY FIELD IN A ROW IS THE SAME WIDTH. A row is one, two, three, four or six equal cells, and
 * which it is depends only on how many fields the row holds - so no field is wider than its
 * neighbour for any reason other than the row having fewer of them. Unequal spans were what made
 * the form read as broken.
 */
.pform__2 { grid-column: span 2; }
.pform__3 { grid-column: span 3; }
.pform__4 { grid-column: span 4; }
.pform__6 { grid-column: span 6; }
.pform__12 { grid-column: 1 / -1; }

@media (max-width: 860px) {
    .pform__2, .pform__3, .pform__4, .pform__6 { grid-column: span 6; }
}

/* A phone is too narrow for two boxes across, and a tag-filled Branches box was what pushed the
   whole form sideways. */
@media (max-width: 560px) {
    .pform__2, .pform__3, .pform__4, .pform__6 { grid-column: 1 / -1; }
}

/* The buttons under a form's card sit clear of the last box above them. */
.card > .row--actions { margin-top: var(--space-4); }

/*
 * A lookup with its buttons INSIDE the box: one border round the input and the + (and the x), a
 * hairline between them. The input gives up its own border and focus ring to the frame, so the
 * whole thing hovers and focuses as one control instead of reading as an input with a button
 * stuck beside it.
 */
.sselect {
    display: flex;
    align-items: stretch;
    min-width: 0;
    height: var(--field-height);
    border: 1px solid var(--pos-border-strong);
    border-radius: var(--radius);
    background: var(--pos-surface);
    transition: border-color var(--motion-instant) var(--ease-standard);
}
.sselect:hover:not(.sselect--disabled) { border-color: var(--pos-text-subtle); }
.sselect:focus-within { border-color: var(--pos-focus); outline: 1px solid var(--pos-focus); }
.sselect--disabled { background: var(--pos-surface-sunken); }

.sselect > .grow { display: flex; }
.sselect .lookup { flex: 1; display: flex; }
.sselect .field__input,
.sselect .field__input:hover,
.sselect .field__input:focus {
    height: 100%;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: none;
}

.sselect__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--field-height);
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--pos-border-strong);
    background: none;
    color: var(--pos-text);
    cursor: pointer;
}
.sselect__btn:hover { background: var(--pos-surface-hover); }
.sselect__btn:focus-visible { outline: 1px solid var(--pos-focus); outline-offset: -1px; }

/* A field's caption with something small on its right - the second unit's "default" tick. */
.field__caption { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }

.check--small { font-size: var(--text-xs); gap: var(--space-1); }
.check--small .check__box { width: var(--check-box-size-sm); height: var(--check-box-size-sm); }

/*
 * A searchable multi-select: the chosen items sit inside the box as tags, and the box wraps onto a
 * second line rather than scrolling sideways. It takes the field's own border, radius and focus
 * edge so it reads as the same control as the single-select beside it; only the height differs,
 * because a box that holds tags has to grow with them.
 */
.multi {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--field-height);
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--pos-border-strong);
    border-radius: var(--radius);
    background: var(--pos-surface);
    cursor: text;
}
.multi:hover:not(.multi--disabled) { border-color: var(--pos-text-subtle); }
.multi:focus-within { border-color: var(--pos-focus); outline: 1px solid var(--pos-focus); }
.multi--disabled { background: var(--pos-surface-sunken); cursor: default; }

.multi__tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    max-width: 100%;
    padding: 0 var(--space-2);
    border-radius: var(--radius);
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
    font-size: var(--text-sm);
}
.multi__tag-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi__tag-remove {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.multi__input {
    flex: 1;
    min-width: 6ch;
    padding: var(--space-1) var(--space-1);
    border: 0;
    outline: 0;
    background: none;
    color: var(--pos-text);
    font: inherit;
}

.lookup__spinner { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); }

/* ==========================================================================
   Summary figures and totals
   ========================================================================== */

.tiles { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/*
 * Tiles standing beside something else in a row, rather than filling a card on their own.
 *
 * A flex item shrinks below its content by default, and an auto-fit grid answers a narrow
 * container by dropping to fewer columns - so a strip of tiles put next to a name block collapsed
 * to a single column and stood the tiles on top of one another, with the width they should have
 * had sitting empty to the left of them. That is the whole of the payment screen's header.
 *
 * flex-basis auto is what fixes it: the tiles ask for the width their content needs and take a
 * share of what is left over, instead of being squeezed by a neighbour that asked for everything.
 * On a genuinely narrow card the row wraps them onto their own line, which is what .row--wrap is
 * for, and the grid still drops a column at the end of that.
 */
.row > .tiles { flex: 1 1 auto; }

.tile {
    padding: var(--card-padding);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--grad-glass);
    box-shadow: var(--elev-1), var(--glass-edge);
    min-width: 0;
}

.tile__label { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--pos-text-muted); }
.tile__value { font-size: var(--text-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.tile__note { font-size: var(--text-xs); color: var(--pos-text-subtle); }

.tile--accent .tile__value { color: var(--pos-accent); }

/*
 * A tile carrying a breakdown - Inflow and Outflow's own chips, DrawerDayTiles. The headline figure
 * drops from --text-2xl to --text-xl here, deliberately: it now shares the tile with a row of chips
 * underneath, and "take less space" was asked for directly rather than growing the tile to fit both
 * at full size.
 */
.tile--breakdown .tile__value { font-size: var(--text-xl); }

.tile__breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-2);
}

/*
 * One category inside an Inflow or Outflow tile - an icon, a short label, a figure. A real <button>
 * (DrawerDayTiles wires every chip to OnCategoryClick), styled to read as a small pill rather than
 * as a control, so five or six of them in a row still read as one line of detail and not a toolbar.
 */
.tile__chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--pos-surface-sunken);
    color: inherit;
    font: inherit;
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    cursor: pointer;
}

.tile__chip:hover { background: var(--pos-border); }

/* A chip with nowhere to go - the Sales/Payments In/Expenses/Payments Out tiles' own breakdown,
   SessionMoneyBreakdown, which names an account rather than a document kind, so there is no matching
   tab to jump to. Same look, no pointer, no hover. */
.tile__chip--static { cursor: default; }
.tile__chip--static:hover { background: var(--pos-surface-sunken); }

/*
 * The totals strip along the bottom of a document screen.
 *
 * NEW SALE IS THE ONLY SCREEN THAT DRAWS IT, which is why every treatment of it - the right
 * alignment, the tightened row gap, the buttons taking a line of their own inside it - lives in
 * sale.css. It was briefly turned into a column there, while the counter had a docket down the
 * side; that was reverted with the docket, and .sale__totals no longer exists.
 */
.totals {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-wrap: wrap;
    padding: var(--space-3) var(--card-padding);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--pos-surface-sunken);
}

.totals__item { display: grid; gap: 1px; min-width: 0; }
.totals__label { font-size: var(--text-xs); color: var(--pos-text-muted); }
.totals__value { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.totals__item--grand .totals__value { font-size: var(--text-2xl); color: var(--pos-primary); }

.totals__spacer { flex: 1; }

/* ==========================================================================
   Detail screens

   One record, read top to bottom: what it is, what is on it, what it came to. The page scrolls
   as a whole rather than each panel scrolling in its own box - somebody checking an invoice
   against a docket reads it in one pass, and three independent scrollbars is three places to
   lose your position.

   The two tables inside are capped instead. A forty-line invoice must not push the totals off
   the bottom of the screen, which is the one figure the reader almost always came for.
   ========================================================================== */

/* The page scrolls in the shell, not in here: a nested scroller would give the reader
   two places to lose their position in one document. */
.detail { align-content: start; }

/*
 * A detail body inside something that has already been given a height - a tab, in practice.
 *
 * It was being asked for in markup and defined nowhere, so the wrapper had no display of its own
 * and none of the house gap: on the customer's Products Ledger tab the button, the holdings table,
 * the heading and the movements table all sat flush against each other. .detail alone cannot
 * supply it, because .detail is a modifier on .page__body everywhere else and that is what was
 * providing the grid.
 */
.detail--fill {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-height: 0;
}

.detail--fill > :last-child { flex: 1; min-height: 0; }

/* Heading at its own height, table filling the rest of what the section was given. */
.detail--fill .detail__section { min-height: 0; grid-template-rows: auto 1fr; }

.detail__section { display: grid; gap: var(--space-2); min-width: 0; }

/*
 * THE BREAK BETWEEN TWO SECTIONS, and it is not the same thing as the gap between page blocks.
 *
 * A section holds its heading 6px above its own table. Left at the page body's 14, a heading
 * between two tables sits 14 from the one above and 6 from the one below - close enough to be read
 * as a caption on the WRONG table, and close enough that two bordered frames look like one
 * interrupted table. The complaint was that they felt almost overlapping, and on the report screens
 * they genuinely were: ReportSurface's wrapper had swallowed the gap entirely and the measured
 * distance was 0.
 *
 * A margin on the second section rather than a wider gap on each container, because these stack
 * inside three different ones - .page__body on a detail screen, .detail--fill inside a tab, and
 * .report-stack on a report - and all three are grids, where an item's margin adds to the gap. One
 * rule, one result: 24px between sections everywhere, against 6px within one.
 */
.detail__section + .detail__section { margin-top: var(--space-3); }

/*
 * A TAB THAT STACKS SEVERAL SECTIONS, rather than one table with a button row above it.
 *
 * .detail--fill was written for the second shape and its two sizing rules say so: every section is
 * forced to `auto 1fr` (a heading and ONE thing under it) and the last child is given the leftover
 * height. That is right for the Accounts tabs, which are a row of buttons and a ledger. It is wrong
 * for the customer's Products Ledger, which is now FOUR sections - what they hold, what is out on
 * loan, what is in our care, and how the holding got that way - several of which carry a button row
 * and two tables. There the `1fr` lands on whichever child happens to be second and the last table
 * balloons to fill the tab, so the four blocks are sized by their position rather than by what is
 * in them, and they read as one long run of tables.
 *
 * SO THE SIZING IS HANDED BACK TO THE CONTENT and the tab scrolls as a whole, which is also what
 * lets a fourth section exist at all: with each table taking its own height there is no budget to
 * divide up and nothing to squeeze.
 *
 * A MODIFIER RATHER THAN A CHANGE TO .detail--fill, because the two Accounts tabs genuinely want
 * the old behaviour - one ledger, filling the tab, scrolling inside itself.
 */
.detail--sections {
    /* The whole tab scrolls, so a section is as tall as what it holds. Each grid keeps its own
       horizontal scroller, which is what stops a wide table forcing this one sideways - see the
       note on .sale__foot for why overflow-y quietly turns overflow-x on as well. */
    overflow-y: auto;
}

/* Content-sized, not `auto 1fr`: these sections hold a heading, sometimes a button row, and one or
   two tables, and the second child is not special. */
.detail--sections > .detail__section { grid-template-rows: none; }

/* Nothing is singled out to absorb the remainder - see above. */
.detail--sections > :last-child { flex: 0 0 auto; min-height: auto; }

/*
 * NOTHING SHRINKS, AND THAT IS WHAT LETS THE TAB SCROLL. .detail--fill is a flex column whose
 * children carry min-height: 0, so every section was squeezed into the tab's own height - tables a
 * few pixels tall whose rows could not be reached even by scrolling. Here each block keeps the
 * height of what it holds and the tab scrolls instead.
 */
.detail--sections > * { flex-shrink: 0; }
.detail--sections .detail__section,
.detail--sections .grid { min-height: auto; }

/*
 * THE BREAK MADE VISIBLE. Four heading-and-table blocks separated by space alone read as one
 * interrupted table, which is exactly the complaint .detail__section + .detail__section was written
 * for at a smaller scale - there two tables felt "almost overlapping" and the answer was 24px. At
 * four sections space is no longer enough on its own, so the break is drawn.
 *
 * The rule sits at the top of the second section and after its margin, so the reading is 24px of
 * air, the line, then 20px before the heading it belongs to - the heading is plainly BELOW the
 * break rather than floating between two tables.
 */
.detail--sections > .detail__section + .detail__section {
    border-top: 1px solid var(--pos-border-strong);
    padding-top: var(--space-5);
}

/*
 * FULL-STRENGTH INK ON THE HEADINGS HERE, where everywhere else they are muted.
 *
 * A muted caption is right over a single table: it names something the reader is already looking
 * at. These four have to be FOUND - somebody opens this tab to answer one of four different
 * questions - and a heading that recedes as far as the body text around it makes the reader scan
 * the tables to work out which is which.
 */
.detail--sections .section-heading { color: var(--pos-text); }

/*
 * AN EMPTY SECTION IS A STRIP, NOT A PANEL.
 *
 * The full empty state - a tiled icon, a headline and a sentence, centred in a lot of air - is
 * right where it is the whole screen: nothing else is competing for the reader's attention and it
 * has to say what is missing and offer the way out of it. Here there are four sections and two of
 * them are empty on most customers, so at full height the tab becomes several screens of "nothing
 * to see" between the two tables somebody opened it for.
 *
 * The frame is what matters and is kept: it is what says the emptiness belongs to THIS heading
 * rather than being a gap in the page. The icon goes, because at this size it is decoration
 * carrying no information the sentence beneath it does not.
 */
.detail--sections .grid__empty { padding: var(--space-5) var(--space-4); }
.detail--sections .empty__icon { display: none; }

.detail__lines .grid__scroll { max-height: 26rem; }
.detail__payments .grid__scroll { max-height: 18rem; }

/* Send stock (TransferNew.razor): the entry row and the product just picked sit in the same card as
   the table of what is going, and without a gap the table's header band touched the inputs above it. */
.transfer__picked,
.transfer__lines { margin-top: var(--space-4); }

/* --------------------------------------------------------------------------
   The supplier bill entry row (PurchaseNew.razor)

   The same shape New Sale's own entry row uses - a card is not a counter, so there is no vertical
   budget to protect and no reason to compact it, but a bill has more fields to type than a sale
   line does (cost, three price tiers, a lot number), so wrapping is the ordinary case rather than
   the exception. Figure boxes are flex-shrink: 0 for the same reason sale.css's are: a box
   squeezed to three characters is a box nobody can read what they typed into. */
.purchase__entry-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
    min-width: 0;

    /* Air between the entry row and the bill's lines beneath it. */
    margin-bottom: var(--space-5);
}

/* Wide enough to read a product name in full rather than eliding it against the boxes beside it -
   the one field on this row somebody is reading rather than typing figures into.
   .purchase__entry-row .purchase__product, not the bare class: .grow's own min-width: 0 sits
   later in this file and would otherwise win the tie on equal specificity. */
.purchase__entry-row .purchase__product { min-width: 320px; }

/* Groups the fields after the product box so one handler can listen to them without laying out
   as a box of its own. */
.purchase__entry-fields { display: contents; }

.purchase__qty { width: 90px; flex-shrink: 0; }
.purchase__unit { width: 130px; flex-shrink: 0; }
.purchase__cost { width: 110px; flex-shrink: 0; }
.purchase__price { width: 130px; flex-shrink: 0; }
.purchase__batch { width: 160px; flex-shrink: 0; }
.purchase__amount { width: 130px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   The send-to-supplier entry row (ProcessingSend.razor)

   The same shape as .purchase__entry-row above, with fewer fields: there is no cost or price
   here, only how much is going, in which unit, and what the supplier has agreed to charge for
   working on it. */
.processing__entry-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
    min-width: 0;

    /* Air between the entry row and the docket's lines beneath it. */
    margin-bottom: var(--space-5);
}

.processing__entry-row .processing__product { min-width: 320px; }

.processing__qty { width: 90px; flex-shrink: 0; }
.processing__unit { width: 130px; flex-shrink: 0; }
.processing__charge { width: 130px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   The variant-receiving matrix (ProcessingReceiveVariants.razor)

   One product per block, its outstanding forms as columns and Coming back/Charge/Sale/Wholesale/
   Min as rows - the transpose of every other grid in the app, which is why it is a plain table
   rather than DataGrid: that component is one row per record, and there is no record here to give
   a row to. Figures reuse .cell-input as they do everywhere else; this only supplies the table's
   own frame. */
.variant-block { margin-top: var(--space-4); }

.variant-matrix {
    width: 100%;
    border-collapse: collapse;
}

.variant-matrix th,
.variant-matrix td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--pos-grid-line);
    text-align: left;
    white-space: nowrap;
}

/* The row label column - "Quantity", "Cost", ... - reads like a header though it sits in <tbody>,
   because it names what the row holds rather than a record the row is about. */
.variant-matrix tbody th {
    color: var(--pos-text-muted);
    font-weight: 500;
    width: 10rem;
}

/* --------------------------------------------------------------------------
   The facts panel

   A field that was left blank is left out rather than shown empty, so this wraps rather than
   sitting on a fixed column count: a row of captions over blanks reads as missing data rather
   than as an absent choice.
   -------------------------------------------------------------------------- */

.facts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-6);
    min-width: 0;
}

.fact { display: grid; gap: 2px; min-width: 8rem; align-content: start; }

/* A fact that is a sentence rather than a value - a bill's remarks - takes the whole row, and
   wraps rather than pushing the facts beside it off the card. */
.fact--wide { flex-basis: 100%; }
.fact--wide .fact__value { font-weight: 500; white-space: pre-line; overflow-wrap: anywhere; }

/* A report cell holding several lines - a customer's name, phone and address - keeps them. */
.grid__cell--lines { white-space: pre-line; }

.fact__value { font-size: var(--text-base); font-weight: 600; }

/* --------------------------------------------------------------------------
   The totals panel

   A column of caption-and-figure rows, right-aligned and tabular so the decimal points line up.
   Distinct from .totals, which is the horizontal strip the counter reads while ringing a sale
   up - this is the one a finished document is checked against.
   -------------------------------------------------------------------------- */

.totals-panel {
    display: grid;
    gap: var(--space-2);
    margin-left: auto;
    min-width: min(22rem, 100%);
}

.totals-panel__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-5);
    font-size: var(--text-sm);
    color: var(--pos-text-muted);
}

.totals-panel__row .numeric { font-size: var(--text-base); color: var(--pos-text); font-weight: 600; }

.totals-panel__row--grand { color: var(--pos-text); font-weight: 650; }
.totals-panel__row--grand .numeric { font-size: var(--text-xl); font-weight: 700; color: var(--pos-primary); }

.totals-panel__rule { height: 1px; background: var(--pos-border); }

/*
 * An editable figure inside a grid cell. Shorter than a form field, and no wider than its number:
 * a full-height input in a dense table makes every row taller than the ones around it.
 */
.cell-input {
    height: var(--control-height-sm);
    width: 6rem;
    padding: 0 var(--space-2);
    display: inline-block;
}

/* --------------------------------------------------------------------------
   The product form's picture

   Big enough to be sure of what has been chosen. The card says "sent on Save" while a picture is
   waiting, because a picture that looks stored and is not is the one that gets lost.
   -------------------------------------------------------------------------- */

.product__picture { align-items: flex-start; gap: var(--space-5); }
.product__picture .thumb--large { width: 8rem; height: 8rem; flex-shrink: 0; }
.product__picture .col { gap: var(--space-2); align-items: flex-start; }

/* --------------------------------------------------------------------------
   One expense

   The figure on the right, what it was for on the left. Struck through when cancelled, because a
   cancelled expense that still reads as an ordinary amount is one somebody will add up.
   -------------------------------------------------------------------------- */

.expense__headline { justify-content: space-between; align-items: flex-start; }
.expense__what { font-size: var(--text-lg); font-weight: 650; }

.expense__amount {
    align-items: flex-end;
    font-size: var(--text-2xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.struck { text-decoration: line-through; color: var(--pos-text-muted); }

/* --------------------------------------------------------------------------
   The party header

   Who they are on the left, what they come to on the right. It stays put across tabs: the name
   and the figures are the context every tab is read in.
   -------------------------------------------------------------------------- */

.party-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    flex-wrap: wrap;
}

.party-header__who { display: grid; gap: var(--space-2); min-width: 0; }

.party-header__actions {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-top: var(--space-3);
    border-top: 1px solid var(--pos-border);
}

/* The period sits at the far end of the action row, bottom-aligned with the buttons. */
.party-header__actions { align-items: flex-end; }
.party-header__period { margin-left: auto; }

.party-header__figures { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.party-header__figures .tile { min-width: 7rem; padding: var(--space-2) var(--space-3); }
.party-header__figures .tile__value { font-size: var(--text-xl); }

/*
 * The balance tile is the only filled one, because it is the figure somebody came to find out.
 * Red while money is owed, green when it is not - owing nothing is not a warning.
 */
.tile--filled { border: 0; }
.tile--owing { background: var(--pos-danger); }
.tile--settled { background: var(--pos-accent); }

.tile--filled .tile__label,
.tile--filled .tile__value,
.tile--filled .tile__note { color: var(--pos-on-brand); }

/* --------------------------------------------------------------------------
   The party statement

   The grid has no height of its own, deliberately. In the XAML head it was a fixed 320, which is
   what stopped a statement using the room a page actually had: short on a tall screen and
   clipped on a short one.
   -------------------------------------------------------------------------- */

.ledger { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: var(--space-2); min-height: 0; }

.ledger__head {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    padding: 0 var(--space-1);
}

.ledger__balance { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   The cash register's short forms

   Amount, reason, button - three of them on one screen, and they have to line up with each
   other or the card reads as three unrelated panels. The button sits on the baseline of the
   boxes rather than of their captions, which is what align-items: flex-end buys.
   -------------------------------------------------------------------------- */

.cash__form { align-items: flex-end; }

/* A button on this row is a box's height, not a button's. The row lines its items up by their
   bottom edge, so a 36px button beside 32px boxes stood 4px proud of them at the top - which read
   as the buttons sitting too high. */
.cash__form > .btn { height: var(--field-height); }

/* Wide enough for "Counted in the drawer *" on one line, and told never to wrap it: a caption
   whose required-marker drops to a line of its own pushes its box below the ones beside it. */
.cash__amount { width: 12rem; flex-shrink: 0; }
.cash__form .field-label { white-space: nowrap; }
.cash__reason { width: 20rem; flex: 1; min-width: 12rem; }

/* --------------------------------------------------------------------------
   The receipt preview

   Monospaced and never wrapped: preview and paper come from one composition, so if it wraps
   oddly the configured paper width is wrong - which is the whole reason the preview exists.
   Wrapping it here would hide exactly the fault it is meant to show.
   -------------------------------------------------------------------------- */

.receipt-preview {
    font-family: var(--pos-font-mono);
    font-size: var(--text-sm);
    line-height: 1.45;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--pos-surface-sunken);
    color: var(--pos-text);
}

/* ==========================================================================
   Responsive

   The breakpoints are the tokens the XAML head measures against, used here as media queries.
   Compaction changes how much room the furniture may take, never what is on the screen: no
   figure and no control is dropped to win space.
   ========================================================================== */

@media (max-height: 700px) {
    /*
     * THE SHELL IS NOT TOUCHED HERE, AND THE LINE THAT USED TO BE WAS THE BUG.
     *
     * It read `.shell { padding: var(--space-3); gap: var(--space-3); }`, and while the shell
     * itself carried `padding: var(--space-4); gap: var(--space-4)` that was honest compaction:
     * 14 down to 10 on a short window.
     *
     * Then the rail was made ATTACHED and the shell's own padding and gap were removed, so the
     * base became nothing - and this line stopped reducing anything and started ADDING ten pixels
     * back. A compaction rule that expands.
     *
     * What it looked like is the fault, not the ten pixels: .shell is the grid holding the rail in
     * one column and the page in the other, so padding on it insets THE RAIL as well. Three of the
     * rail's edges stopped being the window's edges and it read as a card hovering over the ground
     * - on short windows only, which is why it was fine on a desk monitor and floating on a laptop.
     * The media query reads the WebView's viewport, so a 1080-tall screen at 150% scaling is about
     * 650 CSS pixels once the title bar and the taskbar are off it: comfortably under 700.
     *
     * The height it was said to buy back is given back by removing it, not by keeping it.
     */
    .shell__main { gap: var(--space-2); }
    .card { padding: var(--card-padding-tight); }
    .toolbar { padding: var(--toolbar-padding-tight); }
    .page { gap: var(--space-3); }
}

/* The top bar's menu button only exists at the width the rail becomes a drawer; wider, the button
   lives in the rail's own head. */
.topbar__rail-toggle { display: none; }
@media (max-width: 860px) {
    .topbar__rail-toggle { display: inline-flex; }

    /* The rail is off-screen here, so its own button would be one for a drawer that is shut. */
    .rail__toggle { display: none; }
}

/* The scrim belongs to the drawer. Unstyled above the drawer width it is an empty block in the
   shell's grid - and it takes a cell, pushing the page a row down. */
.rail-scrim { display: none; }

@media (max-width: 860px) {
    /* The rail becomes a drawer rather than shrinking to unreadable. */
    .shell { grid-template-columns: 1fr; }

    .rail {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 300;
        width: var(--rail-width);
        transform: translateX(-100%);
        transition: transform 0.18s ease;

        /* Square and hard against the edge: a drawer slides out of the side of the window, and a
           floating panel that arrives from off-screen reads as a dialog that landed badly.

           NOW THE SAME AS THE BASE RULE, which is a confirmation rather than a coincidence: the
           wide layout was changed to attach the rail to the window edges, and it arrived at what
           the drawer had already worked out. Kept rather than deleted so this block still states
           what a drawer needs, instead of inheriting it by luck from a rule written for the wide
           layout and free to change again. */
        border-radius: 0;
        border-width: 0 1px 0 0;
        padding-top: var(--space-4);
    }

    .rail--open { transform: none; }

    /* A phone has no room beside the drawer for a flyout and no hover to open one. A group opens
       INLINE, under its own row, like an accordion - the same rows, in the same panel, simply in
       the flow. Position static also makes the left/top that pos.placeFlyout writes irrelevant,
       and the "placing" hide pointless: nothing is being measured. */
    .rail__flyout {
        position: static;
        min-width: 0;
        max-width: none;
        margin: 0 0 var(--space-1) var(--space-3);
        box-shadow: none;
        max-height: none !important;
    }

    .rail__flyout--placing { visibility: visible; }

    /* Search is a keyboard shortcut and a desktop habit; the header has no room for it here. */
    .topbar__search { display: none; }

    .rail-scrim { display: block; position: fixed; inset: 0; z-index: 299; background: var(--pos-overlay); }

    .form, .form--triple, .form--quad { grid-template-columns: minmax(0, 1fr); }
    .form--quad > .field--half, .form--quad > .field--three { grid-column: 1 / -1; }
    .legend-split, .legend-split--three { grid-template-columns: minmax(0, 1fr); }
    .dialog, .dialog--compact, .dialog--full, .dialog--xl { width: 100%; }
    .page-header { align-items: flex-start; }
}


/* ==========================================================================
   Utilities. A short list on purpose - a long one is a second stylesheet.
   ========================================================================== */

.row { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }

/* Take customer goods in: the two boxes that name the item take the room, because a product's
   full name has to fit, and the two figures beside them are half the share of everything else. */
.job-entry { align-items: flex-end; }

/* The heading over the shared line editor's entry row, inset to the row's own edge because the card
   it sits in carries no padding of its own (see .sale__entry). */
.doc-entry__title { margin: 0; padding: var(--space-3) var(--card-padding) 0; }
.job-entry__wide { flex: 4 1 0; min-width: 0; }
.job-entry__figure { flex: 1 1 0; min-width: 0; }
.job-grid__item { width: 50%; }

/* A customer's item with what came in with it, drawn as a hierarchy: the item (picture, name,
   notes) and under it a plain indented list of its components. Indentation is a space token and the
   rule down the side is the ordinary hairline - no figure of its own. */
.job-item { display: flex; align-items: flex-start; gap: var(--space-3); min-width: 0; }
.job-item__body { display: grid; gap: var(--space-1); min-width: 0; }
.job-item__notes { color: var(--pos-text-muted); }
.job-components {
    list-style: none;
    margin: var(--space-1) 0 0;
    padding: 0 0 0 var(--space-4);
    border-left: 1px solid var(--pos-border);
    display: grid;
    gap: var(--space-1);
}
.job-component { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; }
.job-component__notes { color: var(--pos-text-muted); }
/* The hand-back page: each item a ruled block - a read-only head (the item and how many go home) and
   its editable parts beneath. Spacing and the hairline are the ordinary tokens. */
.job-handback-item {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--pos-border-strong);
    border-radius: var(--radius-surface);
    background: var(--pos-surface);
}
.job-handback-item + .job-handback-item { margin-top: var(--space-4); }
.job-handback-item__head { display: flex; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.job-handback-item__what { flex: 1 1 16rem; min-width: 0; }
.job-handback-item__figure { width: 8rem; }
.job-handback-item__parts {
    display: grid;
    gap: var(--space-2);
    padding-left: var(--space-4);
    border-left: 1px solid var(--pos-border);
}
.job-item__pictures { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* The parts used on an item are its children: the same indented list, with the amount pushed to the
   end of each line so a column of them reads as a sum. */
.job-part { justify-content: space-between; flex-wrap: nowrap; }
.job-part__amount { font-variant-numeric: tabular-nums; }

/* An item's pictures on the job screen: each at a readable size with its remove button beneath. */
.job-pictures { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.job-pictures__item { display: grid; gap: var(--space-2); justify-items: start; }

/* The "With" block on the take-in form: what is coming in with the item being entered, boxed off
   inside the entry card so it reads as belonging to that item and not to the job. */
.job-with {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
}
.job-with__title { margin: 0; }
.job-picture { display: flex; align-items: center; gap: var(--space-2); }
.row--wrap { flex-wrap: wrap; }
/*
 * A page's own action area, left-aligned like everything else on the page.
 *
 * The house default is that actions start where the content starts, so the eye does not have to
 * travel to the far edge to find the button for the form it has just filled in. A DIALOG footer
 * is the deliberate exception and stays right-aligned: that is the platform convention on
 * Windows, macOS and Fluent alike, and a modal is a different context with its own established
 * pattern rather than an inconsistency.
 *
 * Cancel still precedes Save in the markup, so the tab order is unchanged. Reversing them
 * visually with flex order or row-reverse would put the tab order and the reading order into
 * disagreement, which costs a keyboard user far more than the arrangement gains anybody.
 */
/*
 * A page's own action area, left-aligned like everything else on the page: actions start where
 * the content starts, so the eye does not travel to the far edge to find the button for the form
 * it has just filled in.
 *
 * A DIALOG footer is the deliberate exception and stays right-aligned. That is the convention on
 * Windows, macOS and Fluent alike, and the brief leaves modal actions to whatever reads as most
 * natural provided it is consistent - which it is, across every dialog in the app.
 *
 * Cancel still precedes Save in the markup and that is left alone. Reversing them visually with
 * flex order or row-reverse would put the tab order and the reading order into disagreement,
 * which costs a keyboard user more than the arrangement gains anybody.
 */
.row--actions { justify-content: flex-start; }
.col { display: grid; gap: var(--space-3); min-width: 0; }
.grow { flex: 1; min-width: 0; }

/*
 * A party's extra phone numbers: the name is a short label and the number is what is read, so the
 * name takes 30% of the row and the number 70%. .field__input is width: 100%, which as a
 * flex item let the name claim the whole row and squeezed the number to a sliver.
 */
.phone-name { flex: 3 1 0; width: auto; min-width: 0; }
.row > .field__input.grow { flex: 7 1 0; width: auto; min-width: 0; }

/*
 * The Dr/Cr picker beside an opening balance. .field__input is width: 100%, so as a flex item the
 * select claimed the whole row and left the amount a sliver; it is given a width of its own and
 * stops flexing, which hands the rest of the row to the amount - the box that is typed into.
 * Built from the space scale rather than a figure, so it follows any retune of the tokens.
 */
.opening-balance__side { flex: 0 0 auto; width: calc(var(--space-7) * 3); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ==========================================================================
   The attendance sheet

   A list of people rather than a table, because every column but the name was one word wide and
   the only thing anybody does here is press a button on a row. The month summary underneath is
   context, so it folds away: as a second full-height table it pushed the marking - the reason
   anybody opened the screen - below the fold on a counter monitor.
   ========================================================================== */

.daynav { display: flex; align-items: center; gap: var(--space-2); }

.daynav .field__input { width: 160px; }

.daynav__label { color: var(--pos-text-muted); font-size: var(--text-sm); white-space: nowrap; }

.sheet {
    display: grid;
    gap: var(--space-2);
    align-content: start;
    overflow-y: auto;
    padding-right: var(--space-1);
}

.sheet__row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--grad-glass);
    box-shadow: var(--glass-edge);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius);
}

/* Nobody should have to hunt for who is left. A left edge is enough - a whole row in amber
   would make an ordinary sheet look like a list of problems. */
.sheet__row--unmarked { border-left: 3px solid var(--pos-warning); }

.sheet__who { flex: 1; min-width: 0; }

.sheet__name { font-weight: 600; }

.sheet__meta {
    color: var(--pos-text-subtle);
    font-size: var(--text-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sheet__leave { color: var(--pos-info); }

.sheet__note { color: var(--pos-text-muted); }

.sheet__progress { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }

/* Check-in and check-out, side by side, each with its caption above it. */
.sheet__times { display: flex; align-items: flex-end; gap: var(--space-3); }
.sheet__time { display: grid; gap: var(--space-1); }
.sheet__time .field__input { width: var(--time-field-width); }

.sheet__month { margin-top: var(--space-5); }

.sheet__month > summary {
    cursor: pointer;
    font-size: var(--text-lg);
    font-weight: 600;
    padding: var(--space-2) 0;
}

.sheet__month > summary::marker { color: var(--pos-text-subtle); }

/* ==========================================================================
   Permission grid

   A card per category and a checkbox per permission, in columns rather than one long stack:
   there are ninety-odd of them, and a single column would be a screen and a half of scrolling to
   grant a role six things.
   ========================================================================== */

.perms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

/* A section inside one module's card (Customers: Payments, Account...). A whole row of the grid. */
.perm__section {
    grid-column: 1 / -1;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--pos-text-muted);
    padding-top: var(--space-2);
    border-top: 1px solid var(--pos-border);
}

.perm__section:first-child { border-top: 0; padding-top: 0; }

.perm__implied { font-size: var(--text-sm); color: var(--pos-text-muted); font-style: italic; }

.perm { display: flex; gap: var(--space-2); align-items: flex-start; cursor: pointer; }

.perm__text { display: grid; min-width: 0; }

.perm__name { font-size: var(--text-base); }

/* Shown as well as the name: it is what the API checks and what the audit trail records, so
   somebody diagnosing a refusal has to be able to read it. */
.perm__code {
    font-family: var(--pos-font-mono), monospace;
    font-size: var(--text-xs);
    color: var(--pos-text-subtle);
}

.perm__note { font-size: var(--text-sm); color: var(--pos-text-muted); }

/* The date range under a permission that needs one: a whole row of the grid, not one cell of it. */
.perm__cell { display: grid; gap: var(--space-2); align-content: start; min-width: 0; }

/* Under its own permission, in the same cell, lined up with the text beside the tick. */
.perm__range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    padding-left: var(--space-6);
}

/* ==========================================================================
   Report family tile

   A card that is a button. The whole card opens the family, not only the word "Open" inside it —
   a tile that looks pressable and is not is the most irritating kind of tile.
   ========================================================================== */

.report-tile {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

/*
 * A report tile is a button, so it gets the lift a plain card does not. Applied here rather than
 * by adding a modifier in the markup: the tile is already a <button class="card">, and the rule
 * belongs with the other things that know a tile is pressable.
 */
.report-tile {
    cursor: pointer;
    transition:
        background var(--motion-fast) var(--ease-out),
        border-color var(--motion-fast) var(--ease-out),
        box-shadow var(--motion-fast) var(--ease-out),
        transform var(--motion-fast) var(--ease-out);
}

/*
 * The background override went. A tile is a .card now, so it already carries the glass fill, and
 * swapping that for a flat hover colour was the one thing that could take the gloss off exactly
 * while somebody is looking at it. The lift and the shadow say pressed just as well - which is
 * what the reference does too.
 */
.report-tile:hover {
    border-color: var(--pos-border-strong);
    box-shadow: var(--elev-2), var(--glass-edge);
    transform: translateY(-1px);
}

.report-tile:active { transform: translateY(0); box-shadow: var(--elev-1), var(--glass-edge); }

.report-tile__text { display: grid; gap: var(--space-1); min-width: 0; flex: 1; }

/* The reports inside the family, so the tile says what it holds rather than only what it is
   called. */

/* ==========================================================================
   Report section grid

   The hub is a set of destinations, not a list to be read down, so the sections stand side by
   side and fill the width rather than stacking into a column somebody scrolls.

   auto-fill rather than auto-fit: on a wide counter monitor auto-fit stretches seven tiles into
   seven banners, and a tile four times as wide as it is tall has stopped being a tile.
   ========================================================================== */

.report-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    align-content: start;
}

/*
 * A section tile that carries only the glyph and the name.
 *
 * The hub used to print a blurb and a list of every report inside each family under it, which is
 * right for a page read once and wrong for one opened every morning: by the third visit it is
 * three lines of prose between the reader and the tile they always press. The name is the whole
 * label once somebody knows where they are going.
 */
.report-tile--inline {
    gap: var(--space-3);
    padding: var(--space-4);
}

/*
 * A section with nothing behind it yet, drawn quieter - and it is not a <button> in the markup,
 * so none of the lift above applies to it. That is deliberate: a tile that answers the mouse and
 * then does nothing when it is clicked is worse than one that never offered.
 */
.report-tile--waiting { cursor: default; }

/* The base tile lifts on hover because it is normally a button. This one is not, so it must not
   answer the mouse at all - the lift IS the promise that clicking will do something. */
.report-tile--waiting:hover {
    border-color: var(--pos-border);
    box-shadow: var(--elev-1), var(--glass-edge);
    transform: none;
}

.report-tile--waiting .card__title { color: var(--pos-text-muted); }

.report-tile--waiting .report-tile__icon {
    background: var(--pos-surface-sunken);
    color: var(--pos-text-subtle);
}

/* ==========================================================================
   Reporting

   The shared pieces every report screen is built from. Deliberately short: a report is a table,
   some cards and a toolbar, all of which the application already has - what it needed was the
   three states around them and somewhere to put an icon on a section tile.
   ========================================================================== */

/*
 * The loading / empty / error states, which share a shape: a glyph, two lines of text, and
 * optionally a way out. One rule rather than three, because the only thing that differs between
 * them is the colour they inherit from the banner or card they sit in.
 */
/*
 * What a report is actually made of, stacked.
 *
 * THIS EXISTED AS AN UNSTYLED DIV AND THAT WAS THE WHOLE BUG. ReportSurface wraps the report in one
 * element so it can be dimmed while a re-run is in flight, and .page__body's own grid gap therefore
 * applied between the toolbar, the banner and that ONE wrapper - not between the blocks inside it.
 * So every report screen carrying more than one table drew them flush against each other: a
 * measured 0px between the bottom of one bordered table and the heading of the next, on a page
 * whose own gap is 14. They read as one continuous table with a stray heading in the middle of it.
 *
 * It restores exactly what .page__body would have given and no more. The extra air two stacked
 * TABLES need is not this rule's business - see .detail__section + .detail__section below, which
 * is where that belongs, because report screens are not the only place sections stack.
 */
.report-stack {
    display: grid;
    gap: var(--space-4);
    align-content: start;
    min-width: 0;
}

.report-state {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.report-state__text { display: grid; gap: var(--space-1); min-width: 0; flex: 1; }
.report-state__title { font-weight: 650; }

/* The empty state is the one of the three that is not a failure, so it gets room to breathe
   rather than the tight padding of a banner. */
.report-state--empty { padding: var(--space-6) var(--card-padding); }

/* A section tile's glyph, in the brand's soft tint - the same treatment a quick action gets, so a
   tile that opens a screen looks the same wherever it is. */
.report-tile__icon {
    display: grid;
    place-items: center;
    width: var(--control-height-lg);
    height: var(--control-height-lg);
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--pos-primary-soft);
    color: var(--pos-primary);
}

/*
 * A report's totals row. It is the server's own figure rather than a sum of the rows on screen,
 * so it is set apart from them: a rule above it in the brand colour, the way the printed report
 * does it, and never a fourth border-bottom that would read as one more row.
 */
.grid__totals td {
    border-top: 2px solid var(--pos-primary);
    border-bottom: 0;
    font-weight: 700;
    background: var(--pos-surface-sunken);
}

/*
 * ACCOUNT REGISTER: a register on the left, breakdown tabs on the right - asked for in that shape
 * for the Cash Book and reused as-is by Business Book and Payment Out, because all three are the
 * identical layout question (a list of money movements beside a way to slice the same list) with
 * different rows in it. Named for the shape rather than for Cash Book, which was its first and is
 * no longer its only tenant - the same reasoning that keeps every shared component named after
 * what it does rather than after whichever screen asked for it first.
 *
 * Its own rule rather than a corner of .report-stack, because that one is a plain vertical stack
 * and this is the one shape with a genuine two-column body.
 *
 * THE SUMMARY SITS ABOVE THE TABLE, ACROSS THE PAGE - asked for directly. It used to be a column
 * down the right with its breakdown drawn as bars; the client wanted the figures and a chart over
 * the table instead, the change Item Register and Stock Adjustments had first. `order: -1` puts the
 * card first without every screen having to move its markup.
 */
.account-register {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
}

.account-register__side { order: -1; }

/*
 * A FIXED HEIGHT WITH ITS OWN SCROLL, so a long list does not push the buttons above it down the
 * page. .grid already carries the machinery for this (grid-template-rows: auto 1fr auto, and
 * .grid__scroll's own overflow: auto); it only ever needed a bounded height to shrink against.
 */
.account-register__book .grid { height: 600px; }

/*
 * ONE SOLID CARD, not the glass every floating panel gets. This sits on the page exactly like the
 * grid beside it - a dense panel of figures to be read, not something hovering over the page - so
 * it takes .card's border, radius and padding but a flatly opaque background, the same reasoning
 * that already keeps the fill off a data table and a form input.
 */
.account-register__side {
    display: grid;
    background: var(--pos-surface);

    /*
     * FIGURES ON THE LEFT, THE CHART ON THE RIGHT - asked for directly. The headline and Quick Info
     * take the left quarter, one under the other; the chart and its view tabs take the rest. Every
     * screen sharing this card gets it from these rules without moving its markup.
     */
    grid-template-columns: minmax(var(--filter-width), 1fr) minmax(0, 3fr);
    grid-auto-flow: row dense;
    column-gap: var(--space-5);
    row-gap: var(--space-4);
    align-items: start;
}

.account-register__side > * { grid-column: 1; }

.account-register__side > .account-register__breakdown {
    grid-column: 2;
    grid-row: 1 / span 6;
    padding-left: var(--space-5);
    border-left: 1px solid var(--pos-border);
}

/* The figures down the left read as one block with a break between them. */
.account-register__balance + .account-register__quick-info {
    padding-top: var(--space-4);
    border-top: 1px solid var(--pos-border);
}

/* Too narrow for two columns: the figures first, the chart under them. */
@media (max-width: 900px) {
    .account-register__side { grid-template-columns: minmax(0, 1fr); }

    .account-register__side > .account-register__breakdown {
        grid-column: 1;
        grid-row: auto;
        padding-left: 0;
        border-left: 0;
    }
}

/* The headline balance or total stands alone above the tabs, at the KPI's own size - it is the
   register's own headline, not one of the "Quick Info" figures below it. */
.account-register__balance { display: grid; gap: var(--space-1); }

.account-register__breakdown { display: grid; gap: var(--space-3); }

/* The pie that replaced the breakdown's bars. */
.report-pie { display: grid; gap: var(--space-2); }

.account-register__quick-info { display: grid; gap: var(--space-2); }

.account-register__quick-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Session money row

   The session screen's Sales / Payments In / Expenses & Payments Out cards: an icon chip, a label
   and a right-aligned figure. Tried first as KpiBarRow bars and taken back out - that component's
   caption is built to read over one fill colour that covers most of its own track, and most of
   these rows are nought or a sliver of a much larger total (every account the branch may use is
   listed, active or not), so the caption spilled onto the bare unfilled track and washed out. A
   plain row never has that problem, because .kpi-bar__icon (reused as-is) carries the colour and
   the label sits on the card's own background rather than on a fill that might not reach it.
   ========================================================================== */

.session-money { display: grid; }

.session-money__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    font-variant-numeric: tabular-nums;
}

.session-money__row + .session-money__row { border-top: 1px solid var(--pos-border); }

.session-money__row--total { font-size: var(--text-base); }
.session-money__row--total .strong { font-size: var(--text-lg); }

/* An account nothing moved through this session is still listed - every account the branch may
   use, at the client's own request - but reads quietly: it is a roster entry, not a figure to
   weigh against the ones beside it. */
.session-money__row--muted { opacity: 0.55; }

/* ==========================================================================
   Profit and Loss Summary

   A proper income statement - sections, running subtotals, a net result - rather than the
   tiles-and-grid shape every other report in this application uses. Every other report is a list
   of movements read a different way, which is what the shared components are built for; a P&L is
   a different kind of document, so this is the one screen with a bespoke layout of its own.

   ALIGNMENT STILL FOLLOWS THE HOUSE RULE: every column is left-aligned, money included - the same
   reasoning that keeps a data grid's numeric columns left-aligned everywhere else. A right-aligned
   ledger of figures reads as a spreadsheet; this reads as a document, and a document's numbers sit
   where the eye already is, right after the label.
   ========================================================================== */
.pnl {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    padding: var(--space-6);
    display: grid;
    gap: var(--space-5);
}

.pnl__section { display: grid; gap: var(--space-1); }

.pnl__section-title {
    font-weight: 700;
    color: var(--pos-text-muted);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--pos-border);
}

.pnl__row {
    display: grid;
    grid-template-columns: 1fr 140px 70px;
    gap: var(--space-4);
    align-items: baseline;
    padding: var(--space-1) 0;
}

.pnl__amount, .pnl__percent { font-variant-numeric: tabular-nums; text-align: left; }
.pnl__percent { color: var(--pos-text-subtle); font-size: var(--text-sm); }

/* A line item under a section heading - "Sales", an expense category, "Cost of Goods Sold" - in
   the primary colour, the same tint a document's own drill-through text carries elsewhere. */
.pnl__row--item .pnl__label { color: var(--pos-primary); }

/* A section's own total: bold, ruled off from what it sums. */
.pnl__row--total {
    font-weight: 700;
    border-top: 1px solid var(--pos-border-strong);
    padding-top: var(--space-2);
    margin-top: var(--space-1);
}

/* Gross Profit - a total OF a total, so it carries the same weight one indent further in, under
   its own rule rather than the section total's. */
.pnl__row--subtotal {
    font-weight: 700;
    padding-left: var(--space-6);
    border-top: 1px solid var(--pos-border-strong);
    padding-top: var(--space-2);
    margin-top: var(--space-1);
}

/* Total Non Operating Income/Expense - a coloured band rather than a ruled row, because it is
   always nought today (see ProfitLossSummaryReport's own remarks) and a band says "this is the
   whole of the section" without a rule implying there was something above it to total. */
.pnl__row--band {
    grid-template-columns: 1fr 140px;
    background: var(--pos-primary);
    color: var(--pos-on-brand);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-4);
    font-weight: 700;
}

/* The statement's own last line, heavier than any section total - it is the answer the whole
   document was building toward. */
.pnl__row--net {
    font-weight: 700;
    font-size: var(--text-lg);
    border-top: 2px solid var(--pos-border-strong);
    padding-top: var(--space-3);
    margin-top: var(--space-1);
}

.pnl__footer {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius);
    font-weight: 700;
    color: var(--pos-on-brand);
}

/* A loss is the one true warning on this screen, so it is the only row on it allowed to read as
   one - danger red, the same colour reserved everywhere else for something that has gone wrong. */
.pnl__footer--loss { background: var(--pos-danger); }
.pnl__footer--profit { background: var(--pos-primary); }

/* ==========================================================================
   Server folder list

   Choosing where the branch server writes its backups. Built from the same
   pieces as a lookup's result list rather than a new idea: a scrolling column
   of rows you click to go into. It has its own height because it is inside a
   dialog, where the alternative is a list that pushes the buttons off screen.
   ========================================================================== */

.folder-list {
    display: grid;
    align-content: start;
    max-height: 42vh;
    overflow-y: auto;
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-surface);
    background: var(--pos-surface);
}

.folder-list__row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
}

.folder-list__row:hover { background: var(--pos-surface-hover); }

.folder-list__row:focus-visible {
    outline: 1px solid var(--pos-focus);
    outline-offset: -1px;
}

.folder-list__empty {
    padding: var(--space-3);
    font-size: var(--text-sm);
}

/* A stack trace, folded away on the fault screen. Monospace and scrolling in its own box: it is
   the one thing on that page aimed at somebody on a telephone rather than at the counter. */
.fault__stack {
    max-height: 30vh;
    overflow: auto;
    margin: var(--space-2) 0 0;
    padding: var(--space-3);
    border-radius: var(--radius-surface);
    background: var(--pos-bg);
    color: var(--pos-text-muted);
    font-family: var(--pos-font-mono), monospace;
    font-size: var(--text-xs);
    white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   What a payment settles

   AllocationPanel, inside the payment popups. It was a mode picker plus a scrolling table of open
   documents; the table is gone, so the only rule left is the stack. A customer with forty open
   invoices is now forty entries in a <select>, which the browser scrolls for us - the reason the
   dialogs went back to the default width.

   No colours and no figures: the picker is an ordinary field and the summary is an ordinary
   field hint. A second set of rules for the same job is what drifts.
   -------------------------------------------------------------------------- */
.alloc {
    display: grid;
    gap: var(--space-3);
}

/* --------------------------------------------------------------------------
   One session's record

   SessionDetail. Seven cards of heading, sentence and table, read top to bottom by somebody
   reconciling a drawer against a count - which is a different reading from a list screen, where
   the rows are scanned for one.

   ROOMIER THAN A LIST, asked for directly. The house row is sized for a page of sixty invoices;
   here a table is six lines of figures and a total, and at list density the total sat on top of
   the row above it. So the rows get vertical padding and the columns a wider gutter, and the card
   itself becomes a grid so the heading, the sentence under it and the table are spaced rather than
   stacked flush - the complaint was that the subheadings were congested, and they were: a card has
   no gap of its own, so h2, p and table sat against each other at the reset's zero margin.

   A modifier on the page body rather than a change to .card or .grid__table: every other screen
   wants the density it has.
   -------------------------------------------------------------------------- */
.session-report .card {
    display: grid;
    gap: var(--space-4);
    align-content: start;
    padding: var(--space-5);
}

.session-report .card > .field__hint { margin-top: calc(var(--space-2) * -1); }

.session-report .grid__table th { padding-inline: var(--space-4); }

.session-report .grid__table td {
    padding: var(--space-3) var(--space-4);
}

/* A FIXED HEIGHT, AND THE SCROLL INSIDE THE TABLE - asked for directly. The page no longer grows
   by a screenful on a busy day, and switching tabs does not move the movements card up and down.
   .grid is already header / 1fr / footer with .grid__scroll overflowing, so a height is all it
   takes; the header band is sticky and stays put while the rows scroll under it. */
.session-report .grid { height: calc(var(--grid-header-height) + var(--grid-row-height) * 10); }

/* The closing note sits under the reconciliation as a section of its own, ruled off. */
.session-report .detail__section {
    margin-top: 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--pos-border);
}

/* ===== Row context menu =====
   Right-click on a list row. The row's own action buttons are still in the DOM - they are what the
   menu lists and presses - but are not drawn, so the actions live in one place. Floats over the page
   like the lookup list, so it gets the same glass. */
.grid--menu .grid__table td .btn--small.btn--link { display: none; }

/* THE ACTIONS COLUMN GOES WITH THE BUTTONS. With the buttons hidden the column was an empty strip at
   the right-hand edge of every listing. The cells stay in the table, so the buttons are still in the
   page for the menu to find - pos.rowButtons asks the DOM, not the screen - and only the column's
   space is given back. */
.grid--menu .grid__cell--actions { display: none; }

/* Says where the actions went. Drawn only when there is something to find: a role that may not edit
   anything has no buttons in its rows, so telling it to right-click would be a promise of nothing. */
.grid__menuhint {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    color: var(--pos-text-subtle);
}

.grid--menu:not(:has(td .btn--small.btn--link)) .grid__menuhint { display: none; }

.ctxmenu__scrim { position: fixed; inset: 0; z-index: 399; }

.ctxmenu {
    position: fixed;
    z-index: 400;
    min-width: 12rem;
    padding: var(--space-1);
    border: 1px solid var(--pos-glass-border);
    border-radius: var(--radius-surface);
    background: var(--pos-glass);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--elev-3), var(--glass-edge);
    animation: lookup-in var(--motion-fast) var(--ease-out);
}

.ctxmenu__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    background: transparent;
    color: var(--pos-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.ctxmenu__item:hover, .ctxmenu__item:focus-visible { background: var(--pos-primary-soft); outline: none; }
.ctxmenu__item--danger { color: var(--pos-danger); }
.ctxmenu__item--danger:hover, .ctxmenu__item--danger:focus-visible { background: var(--pos-danger-soft); }
.ctxmenu__item svg { flex: none; }

/* ==========================================================================
   Touch and small screens

   A PHONE (up to 860px, where the shell's rail already becomes a drawer) AND A TOUCH TABLET.
   Nothing here changes a wide window: every rule is either inside a media query or hides a piece
   that only the narrow layout draws. Sizes come from tokens.css, which raises the control and
   field heights under the same query.

   Three shared pieces, each opt-in per screen so a ledger or a report stays a table:
     FilterToolbar  - the search and period stay on the page, the other filters fold into a sheet
     DataGrid Cards - a row is drawn as a card made of the cells that name a slot
     the row's ...  - the touch way to a row's actions, which a right-click menu cannot offer
   ========================================================================== */

/* ---- Drawn only when narrow: hidden everywhere else ---- */

.toolbar__filters, .sheet__body, .sheet__foot { display: contents; }
.sheet__head, .sheet__done, .toolbar__filters-btn, .toolbar__scrim, .fab { display: none; }
.grid__cell--more { display: none; }

.toolbar__badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.4em;
    padding: 0 var(--space-1);
    border-radius: var(--radius-lg);
    background: var(--pos-primary);
    color: var(--pos-on-brand);
    font-size: var(--text-xs);
    font-weight: 700;
}

.toolbar__badge--dot { min-width: 0; width: var(--space-2); height: var(--space-2); padding: 0; }

/* ---- Row actions without a right-click: a phone, a tablet, or any touch-first screen ---- */

@media (pointer: coarse), (max-width: 860px) {
    .grid--menu .grid__cell--more {
        display: table-cell;
        width: var(--touch-target);
        padding: 0;
        text-align: center;
    }

    .grid__menuhint { display: none; }

    .rowmore {
        display: inline-grid;
        place-items: center;
        width: var(--touch-target);
        height: var(--touch-target);
        border: 0;
        border-radius: var(--radius-surface);
        background: transparent;
        color: var(--pos-text-muted);
        cursor: pointer;
    }
    .rowmore:active { background: var(--pos-primary-soft); }

    /* A role with nothing to do on this row has nothing behind the button either. */
    .grid--menu tr:not(:has(td .btn--small.btn--link)) .rowmore { display: none; }

    .ctxmenu__item { min-height: var(--touch-target); }
}

/* ---- Phone ---- */

@media (max-width: 860px) {

    .hide-narrow { display: none !important; }

    /* The top bar's Back button: a phone has its own back gesture and button, and the bar's width
       is better spent on the title. */
    .btn--back, .btn.btn--back { display: none !important; }

    /* The filters sheet. The search and the period stay in the row; the button opens the rest. */
    /* :where() so this rule weighs nothing and the search's own full-line rule below can beat it. */
    .toolbar--sheet > :where(:not(.toolbar__filters-btn):not(.toolbar__scrim):not(.toolbar__filters):not(.toolbar__stats)) {
        flex: 1 1 8rem;
        min-width: 0;
    }

    /* The search gets a whole line - its placeholder is a sentence - and the period and the
       Filters button share the one under it, level with the bottoms of their boxes. */
    .toolbar--sheet { align-items: flex-end; }
    .toolbar--sheet > :first-child { flex: 1 1 100%; }

    .toolbar--sheet .toolbar__filters-btn { display: inline-flex; flex: 0 0 auto; height: var(--field-height); }
    .toolbar--sheet .toolbar__filters { display: none; }

    .toolbar--open .toolbar__scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 149;
        background: var(--pos-overlay);
    }

    /* Solid, no backdrop-filter: a filter would make this the containing block of the lookup lists
       inside it, which are fixed to the window. */
    .toolbar--open .toolbar__filters {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: auto 0 0 0;
        z-index: 150;
        max-height: 85dvh;
        border-radius: var(--radius-surface) var(--radius-surface) 0 0;
        border-top: 1px solid var(--pos-border);
        background: var(--pos-surface);
        box-shadow: var(--elev-4);
        animation: sheet-up var(--motion-base) var(--ease-out);
    }

    .sheet__head {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-2) var(--space-4);
        border-bottom: 1px solid var(--pos-border);
    }
    .sheet__title { flex: 1; font-weight: 700; font-size: var(--text-lg); }

    .toolbar--open .sheet__body {
        display: grid;
        gap: var(--space-4);
        padding: var(--space-4);
        min-height: 0;
        overflow: auto;
    }
    .sheet__body .field, .sheet__body .field__input, .sheet__body .field__select { width: 100%; min-width: 0; }

    .toolbar--open .sheet__foot {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
        border-top: 1px solid var(--pos-border);
        background: var(--pos-surface-sunken);
    }
    .sheet__foot .toolbar__spacer { display: none; }
    .sheet__foot .btn { flex: 1; }
    .sheet__done { display: inline-flex; }

    /* The figures: one row that scrolls sideways, each still pressable to narrow the list. */
    .toolbar--sheet .toolbar__stats {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-bottom: var(--space-2);
    }
    .toolbar--sheet .toolbar__stats > .stat-tile {
        flex: 0 0 auto;
        min-width: 10rem;
        scroll-snap-align: start;
    }

    .sheet__body .toolbar__spacer { display: none; }

    /* ---- Detail pages, forms and settings ---- */

    /* The page's own buttons take the line under the title instead of squeezing beside it. */
    .page-header__actions { width: 100%; }
    .page-header__actions > .btn { flex: 1 1 auto; }

    /* Facts two to a line; a sentence still takes the whole line. */
    .facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
    .fact { min-width: 0; }
    .fact--wide { grid-column: 1 / -1; }
    .fact__value { overflow-wrap: anywhere; }

    /* The save / cancel row of a form: the buttons share the line rather than hanging off its end. */
    .row--actions { flex-wrap: wrap; }
    .row--actions > .btn { flex: 1 1 auto; }

    /* ---- Explanatory text under a heading ----
       The sentence a card puts under its title ("Moves cash out of ... Unlike a Pay out ...") is
       for somebody learning the screen at a desk. On a phone it pushes the thing the card is FOR a
       screen further down, so it goes - everywhere, in one rule. Only text that sits directly under
       a heading is meant: a hint that qualifies a box, a total or a refusal stays, because that is
       a fact somebody acts on rather than an explanation. */
    :is(h1, h2, h3, h4, legend, .section-heading, .card__title, .page-header__titles) + .field__hint,
    .page-header__subtitle { display: none; }

    /* ---- Pay in / Pay out and every other cash form: one thing to a line ---- */
    .cash__form { flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
    .cash__form > *, .cash__amount, .cash__reason { width: 100%; min-width: 0; flex: 0 0 auto; }
    .cash__form > .btn { width: 100%; justify-content: center; }

    /* ---- The session's document tabs: a strip that scrolls, not eight squeezed tiles ---- */
    .session-tabs { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: var(--space-2); }
    .session-tabs .stat-tile { flex: 0 0 auto; min-width: 9rem; scroll-snap-align: start; }

    /* Lookups with a fixed width (customer, staff, product) are as wide as the line they sit on. */
    .party-filter, .staff-filter, .product-filter { flex: 1 1 100%; width: 100%; min-width: 0; }

    /* A multi-select (the product form's Branches) is as wide as its field, and its tags wrap
       inside it instead of pushing the page sideways. */
    .field:has(> .multi) { min-width: 0; }
    .multi { min-width: 0; max-width: 100%; }
    .multi__tag { min-width: 0; }
    .multi__input { min-width: 0; flex: 1 1 5rem; }

    /* The customer or supplier header: figures in a row of their own, the balance first and wide,
       the buttons two to a line, the period across the bottom. */
    .party-header { gap: var(--space-3); }
    .party-header__figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .party-header__figures .tile:first-child { grid-column: 1 / -1; }
    .party-header__figures .tile { min-width: 0; }
    .party-header__actions { align-items: stretch; }
    .party-header__actions > .btn, .party-header__actions > .menu { flex: 1 1 calc(50% - var(--space-3)); min-width: 0; }
    .party-header__period { margin-left: 0; flex: 1 1 100%; }

    /* Settings: the vertical tab strip becomes a strip along the top that scrolls sideways. */
    .tabs-layout { grid-template-columns: minmax(0, 1fr); }
    .tabs--vertical { flex-direction: row; width: auto; overflow-x: auto; overflow-y: hidden; }
    .tabs--vertical .tab { width: auto; flex: 0 0 auto; clip-path: none; padding: 0 var(--space-4); white-space: nowrap; }
    .tabs-layout__content { overflow-y: visible; }

    /* ---- A toolbar that has not been folded into a sheet ----
       Two to a line, the search on a whole line of its own, and nothing wider than the screen. The
       listings with the most filters use FilterToolbar and fold them away instead. */
    .toolbar:not(.toolbar--sheet) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
        gap: var(--space-3);
    }
    .toolbar:not(.toolbar--sheet) > * { min-width: 0; }
    .toolbar:not(.toolbar--sheet) > :first-child,
    .toolbar:not(.toolbar--sheet) > .toolbar__stats,
    .toolbar:not(.toolbar--sheet) > .field--wide { grid-column: 1 / -1; }
    .toolbar:not(.toolbar--sheet) > .toolbar__spacer { display: none; }
    .toolbar:not(.toolbar--sheet) > .btn { width: 100%; }
    .toolbar:not(.toolbar--sheet) .field, .toolbar:not(.toolbar--sheet) .field__input,
    .toolbar:not(.toolbar--sheet) .lookup, .toolbar:not(.toolbar--sheet) .multi { width: 100%; min-width: 0; }

    .toolbar:not(.toolbar--sheet) > .toolbar__stats {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-bottom: var(--space-2);
    }
    .toolbar:not(.toolbar--sheet) > .toolbar__stats > .stat-tile {
        flex: 0 0 auto;
        min-width: 10rem;
        scroll-snap-align: start;
    }

    /* A field that spans two columns in a one-column form made a second, invisible column. */
    .field--half, .field--three { grid-column: 1 / -1; }
    .form--cols3 { grid-template-columns: minmax(0, 1fr); }

    /* ---- A row as a card ----
       Only a cell that names a slot is drawn. Every slot is placed in an explicit row, so the order
       the cells are written in cannot move one: an auto-placed cell with a column but no row would
       drop under the money line. */
    .grid--cards { border: 0; background: transparent; overflow: visible; }
    .grid--cards .grid__scroll { overflow: visible; max-height: none; }
    .grid--cards .grid__table { display: block; }
    .grid--cards thead { display: none; }
    .grid--cards tbody { display: grid; gap: var(--space-4); padding: var(--space-1) 0; }

    .grid--cards tbody tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
        column-gap: var(--space-3);
        row-gap: var(--space-1);
        align-items: start;
        padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
        /* A card has to read as a thing apart from the page: a visible edge, a heavier bar down its
           left side in the brand green, and a shadow that lifts it off the ground. */
        border: 1px solid var(--pos-border-strong);
        border-left: var(--space-1) solid var(--pos-primary);
        border-radius: var(--radius-lg);
        background: var(--pos-surface);
        box-shadow: var(--elev-2);
    }
    .grid--cards tbody tr.grid__row--draft { background: var(--pos-grid-row-draft); }
    .grid--cards tbody tr.grid__row--job { background: var(--pos-grid-row-job); }
    .grid--cards tbody tr.clickable:active { background: var(--pos-primary-soft); }

    .grid--cards tbody tr td {
        display: none;
        /* The table's row height is a fixed height on a block, so a two-line cell spilled into the
           row under it. A card cell is as tall as what it holds. */
        height: auto;
        padding: 0;
        border: 0 !important;
        background: transparent !important;
        min-width: 0;
    }

    .grid--cards td.card-title { display: block; grid-area: 1 / 1 / 2 / 3; font-size: var(--text-base); font-weight: 700; }
    .grid--cards td.card-badge { display: block; grid-area: 1 / 3 / 2 / 4; justify-self: end; }
    .grid--cards td.card-sub { display: block; grid-area: 2 / 1 / 3 / 4; white-space: normal; max-width: none; }
    .grid--cards td.card-meta { display: block; grid-area: 3 / 1 / 4 / 3; font-size: var(--text-xs); color: var(--pos-text-muted); }
    .grid--cards td.card-meta--end { grid-area: 3 / 3 / 4 / 4; text-align: right; }

    /* The figures sit under a rule, so the card reads as a header, a body and a total. */
    .grid--cards td.card-money {
        display: block;
        grid-row: 4;
        margin-top: var(--space-2);
        padding-top: var(--space-2);
        border-top: 1px solid var(--pos-border) !important;
        font-weight: 600;
    }
    .grid--cards td.card-money::before {
        content: attr(data-label);
        display: block;
        font-size: var(--text-xs);
        font-weight: 400;
        color: var(--pos-text-muted);
    }

    .grid--cards td.grid__cell--more { display: flex; grid-area: 1 / 4 / 5 / 5; align-self: center; width: auto; }

    /* ---- EVERY OTHER LISTING: the same card, drawn automatically ----
       A listing grid (RowMenu) with no slots of its own still becomes cards on a phone: the first
       cell is the title and each other cell is a heading over its value, two to a line. The
       headings come from pos.labelCells, so no screen had to be touched. A grid that wants a
       hand-made card (Sales) names its slots and opts in with Cards. */
    .grid.grid--auto { border: 0; background: transparent; overflow: visible; }
    .grid.grid--auto .grid__scroll { overflow: visible; max-height: none; }
    .grid.grid--auto .grid__table { display: block; }
    .grid.grid--auto thead { display: none; }
    .grid.grid--auto tbody { display: grid; gap: var(--space-4); padding: var(--space-1) 0; }

    .grid.grid--auto tbody tr {
        position: relative;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-2) var(--space-3);
        padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
        border: 1px solid var(--pos-border-strong);
        border-left: var(--space-1) solid var(--pos-primary);
        border-radius: var(--radius-lg);
        background: var(--pos-surface);
        box-shadow: var(--elev-2);
    }
    /* Room for the ⋯ button down the right-hand side. */
    .grid--menu.grid.grid--auto tbody tr { padding-right: var(--touch-target); }
    .grid.grid--auto tbody tr.grid__row--total { border-left-color: var(--pos-text-subtle); background: var(--pos-surface-sunken); }
    .grid.grid--auto tbody tr.grid__row--draft { background: var(--pos-grid-row-draft); }
    .grid.grid--auto tbody tr.grid__row--job { background: var(--pos-grid-row-job); }
    .grid.grid--auto tbody tr.clickable:active { background: var(--pos-primary-soft); }

    .grid.grid--auto tbody tr > td {
        display: block;
        height: auto;
        min-width: 0;
        padding: 0;
        border: 0 !important;
        background: transparent !important;
        white-space: normal;
        max-width: none;
        overflow-wrap: anywhere;
        text-align: left;
    }

    /* The first cell is what the row IS: whole line, bold, no heading of its own. */
    .grid.grid--auto tbody tr > td:first-child {
        grid-column: 1 / -1;
        font-size: var(--text-base);
        font-weight: 700;
    }

    .grid.grid--auto tbody tr > td:not(:first-child)::before {
        content: attr(data-label);
        display: block;
        font-size: var(--text-xs);
        font-weight: 400;
        color: var(--pos-text-muted);
    }

    /* No heading means no meaning to show (the actions column, a spare cell), and an empty cell is
       a heading over nothing. */
    .grid.grid--auto tbody tr > td[data-label=""]:not(:first-child):not(:has(button, input, select, textarea, a, .btn)),
    .grid--menu.grid.grid--auto tbody tr > td.grid__cell--actions,
    .grid.grid--auto tbody tr > td:empty { display: none; }

    .grid.grid--auto tbody tr > td[data-label=""]::before { display: none; }

    /* A cell that holds controls (a bill line's quantity box, its Remove button) keeps them, full
       width, under its heading. */
    .grid.grid--auto tbody tr > td .field__input,
    .grid.grid--auto tbody tr > td select,
    .grid.grid--auto tbody tr > td .lookup { width: 100%; min-width: 0; }

    /* The row's own buttons, where the grid has no menu to hold them: a line of their own. */
    .grid.grid--auto:not(.grid--menu) tbody tr > td.grid__cell--actions {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
        grid-column: 1 / -1;
        padding-top: var(--space-2);
        border-top: 1px solid var(--pos-border) !important;
    }

    .grid.grid--auto tbody tr > td.grid__cell--more {
        display: flex;
        position: absolute;
        top: var(--space-2);
        right: var(--space-1);
        width: auto;
        padding: 0;
    }

    /* The cash register's tables were given a fixed ten-row height; cards are as tall as they are. */
    .session-report .grid.grid--auto { height: auto; }
    .session-report .grid.grid--auto .grid__table td { padding: 0; }
    .session-report .grid.grid--auto .grid__table th { display: none; }

    /* Cells a screen has marked: one that means nothing on a card (a row number), and one that is the
       card's title wherever it sits in the row. A cell's own table width is a share of the TABLE and
       would squeeze it to a sliver here, which stacked its letters one above the next. */
    .grid.grid--auto tbody tr > td { width: auto; }
    .grid.grid--auto tbody tr > td.card-hide { display: none; }
    .grid.grid--auto tbody tr > td.card-first {
        grid-column: 1 / -1;
        order: -1;
        font-size: var(--text-base);
        font-weight: 700;
    }
    .grid.grid--auto tbody tr > td.card-first::before { display: none; }

    /* ---- A SHORT TABLE IS A LIST, NOT A STACK OF CARDS ----
       Product / Held / Unit is three words a row; a bordered, shadowed card for each is a lot of
       furniture round very little, and a screen of them (a customer's holdings, a bill's totals)
       reads as heavy. Three columns or fewer draw as one framed list: the first cell on the left,
       the rest beside it, a hairline between rows. Four or more are cards, because that is when a
       row has enough in it to need the room. */
    .grid.grid--auto:not(:has(tbody tr > td:nth-child(4))) {
        border: 1px solid var(--pos-border-strong);
        border-radius: var(--radius-lg);
        background: var(--pos-surface);
        overflow: hidden;
    }
    .grid.grid--auto:not(:has(tbody tr > td:nth-child(4))) tbody { gap: 0; padding: 0; }

    .grid.grid--auto tbody tr:not(:has(> td:nth-child(4))) {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: var(--space-1) var(--space-3);
        padding: var(--space-3) var(--space-4);
        border: 0;
        border-bottom: 1px solid var(--pos-border);
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }
    .grid.grid--auto tbody tr:not(:has(> td:nth-child(4))):last-child { border-bottom: 0; }

    .grid.grid--auto tbody tr:not(:has(> td:nth-child(4))) > td:first-child { flex: 1 1 55%; font-size: var(--text-base); }
    .grid.grid--auto tbody tr:not(:has(> td:nth-child(4))) > td:not(:first-child) { flex: 0 0 auto; text-align: right; }
    .grid.grid--auto tbody tr:not(:has(> td:nth-child(4))) > td:not(:first-child)::before {
        display: inline;
        margin-right: var(--space-1);
    }

    /* The footer pager is the only one: a card list is turned from its foot. */
    .pager--top { display: none; }
    .grid--cards .pager { border-top: 0; padding-inline: 0; }

    /* ---- New document, floating ----
       The page leaves room under its last row for the button, or the pager's Next sits under it. */
    .page:has(.fab) { padding-bottom: calc(var(--fab-size) + var(--space-5)); }

    .fab {
        display: grid;
        place-items: center;
        position: fixed;
        right: var(--space-4);
        bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
        z-index: 40;
        width: var(--fab-size);
        height: var(--fab-size);
        border: 0;
        border-radius: 50%;
        background: var(--pos-primary);
        color: var(--pos-on-brand);
        box-shadow: var(--elev-3);
        cursor: pointer;
    }

    /* ---- A dialog is a sheet from the foot of the screen ---- */
    .dialog-scrim { padding: 0; place-items: end stretch; }

    .dialog, .dialog--compact, .dialog--full, .dialog--xl {
        width: 100%;
        max-height: 92dvh;
        border-radius: var(--radius-surface) var(--radius-surface) 0 0;
        animation: sheet-up var(--motion-base) var(--ease-out);
    }

    .dialog__header, .dialog__body, .dialog__footer { padding: var(--space-3) var(--space-4); }
    .dialog__footer { flex-wrap: wrap; }
    .dialog__footer .btn { flex: 1 1 auto; }

    /* A row's action list, as a sheet. The inline left/top the script sets are overridden. */
    /* Solid and dark, the rail's own green, so it cannot blend with the list behind it: the glass the
       desktop menu wears lets the cards show through, which is unreadable over a screen of text. */
    .ctxmenu {
        left: 0 !important;
        right: 0;
        top: auto !important;
        bottom: 0;
        width: 100%;
        padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
        border: 0;
        border-top: 1px solid var(--pos-rail-flyout-border);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        background: var(--grad-rail);
        backdrop-filter: none;
        box-shadow: 0 -8px 24px var(--pos-rail-flyout-shadow);
    }
    .ctxmenu__item { color: var(--pos-rail-text-strong); border-radius: var(--radius-lg); }
    .ctxmenu__item svg { color: var(--pos-rail-icon); }
    .ctxmenu__item:hover, .ctxmenu__item:focus-visible, .ctxmenu__item:active { background: var(--pos-rail-nav-fill); }
    .ctxmenu__item--danger { color: var(--pos-danger-soft); }
    .ctxmenu__item--danger svg { color: var(--pos-danger-soft); }
    .ctxmenu__scrim { background: var(--pos-overlay); }

    /* The filters sheet: the same dark green for its head and foot, the form between them stays light. */
    .toolbar--open .sheet__head, .toolbar--open .sheet__foot {
        background: var(--grad-rail);
        border-color: var(--pos-rail-border);
        color: var(--pos-rail-text-strong);
    }
    .sheet__head .btn { color: var(--pos-rail-text-strong); }
}

/* ==========================================================================
   Icons drawn beside a row's status (take the money, remind, print, discard)

   A row's actions normally live behind its menu. These few are pressed so often, and mean so
   little to look up, that they sit where the eye already is. A plain icon button - not
   .btn--link, which is what the menu lists and hides.
   ========================================================================== */
.rowicons { display: inline-flex; align-items: center; flex-wrap: wrap; gap: var(--space-1); }

/* The buttons in a table row sit at the row's right-hand edge, icon buttons and text buttons alike. */
.grid__table td:has(> .rowicons),
.grid__table th.grid__cell--actions { text-align: right; }
.grid__table td:has(> .rowicons) .rowicons { justify-content: flex-end; }
.grid__table td.grid__cell--actions { text-align: right; }
.grid.grid--auto:not(.grid--menu) tbody tr > td.grid__cell--actions { justify-content: flex-end; }

.rowicon {
    width: var(--control-height-sm);
    height: var(--control-height-sm);
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--pos-primary);
}
.rowicon:hover:not(:disabled) { background: var(--pos-primary-soft); }
.rowicon--danger { color: var(--pos-danger); }
.rowicon--danger:hover:not(:disabled) { background: var(--pos-danger-soft); }

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

/* ---- Report charts (Sales by Parent Group) -------------------------------------------------------
 * The canvases are drawn by wwwroot/js/charts.js; everything here is the frame around them. Heights
 * are tokens, widths are the grid's, and every colour is a token - a chart colour is --pos-chart-N,
 * resolved over there. A canvas needs a definite height or it draws at nought, which is why each
 * chart box states one rather than sizing to content.
 */
.bi-chart { width: 100%; height: var(--bi-chart-height); }
.bi-chart--tall { height: var(--bi-chart-height-tall); }

.bi-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
    gap: var(--space-4);
    min-width: 0;
}

.bi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--bi-card-min-width), 1fr));
    gap: var(--space-4);
    min-width: 0;
}

.bi-card {
    display: grid;
    gap: var(--space-2);
    padding: var(--card-padding);
    border: 1px solid var(--pos-border);
    border-top: 3px solid var(--bi-card-colour);
    border-radius: var(--radius-surface);
    background: var(--pos-surface);
    box-shadow: var(--elev-1);
    min-width: 0;
}

.bi-card__head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.bi-card__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bi-card-colour); flex: none; }
.bi-card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bi-card__figure { font-size: var(--text-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.bi-card__facts { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); color: var(--pos-text-muted); }
.bi-card__up { color: var(--pos-accent); font-weight: 600; }
.bi-card__down { color: var(--pos-danger); font-weight: 600; }
.bi-spark { width: 100%; height: var(--bi-spark-height); }

/* ==========================================================================
   Reports read like the payslip

   Asked for directly: "reports design should be like payslip, which is very clean". The payslip is
   a document head (the shop on the left, the title in capitals on the right, one line in the brand
   colour beneath), small capital section labels, plain rows on thin rules, and a shaded total. The
   same here, scoped to a report's own body (.report-stack, which every report screen draws its
   figures inside), so the lists elsewhere keep their filled header band.
   ========================================================================== */

.report-doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--pos-primary);
}

.report-doc-head__shop { font-size: var(--text-lg); font-weight: 700; color: var(--pos-primary); }
.report-doc-head__meta { font-size: var(--text-xs); color: var(--pos-text-muted); }
.report-doc-head__right { text-align: right; }
.report-doc-head__title { font-size: var(--text-lg); font-weight: 700; letter-spacing: 0.04em; color: var(--pos-primary); }
.report-doc-head__period { font-size: var(--text-sm); font-weight: 600; }

.report-stack .grid { border-color: transparent; background: transparent; }

.report-stack .grid__table th {
    /* Opaque, because the header stays put while the rows scroll under it. */
    background: var(--pos-surface);
    color: var(--pos-text-muted);
    border-bottom: 1px solid var(--pos-primary);
}

.report-stack .grid__table th::after { display: none; }

.report-stack .grid__table th:not(:last-child),
.report-stack .grid__table td:not(:last-child) { border-right: 0; }

.report-stack .grid__table tbody tr:nth-child(even) td { background: transparent; }

.report-stack .grid__totals td {
    background: var(--pos-surface-sunken);
    border-top: 1px solid var(--pos-primary);
    font-weight: 700;
}
