﻿/* 
 * The counter. 
 * 
 * Its own file because its vertical budget is a real constraint rather than a detail: every row on 
 * this screen is auto-height except the lines grid, which takes the remainder, so any height added 
 * above or below it is subtracted from the sale being rung up. In the XAML head that came to ~554px 
 * of furniture against ~651px on a 1366x768 counter monitor, leaving a header and one line. 
 * 
 * The compaction rules here follow the same principle: what tightens is how much room the 
 * furniture may take, never what is on the screen. No figure and no control is dropped to win 
 * space. The single exception is the shortcut hint line, at the shortest band only, because every 
 * shortcut it names is also a visible button. 
 */ 
 
.sale { 
    gap: var(--space-3); 
 
    /* 
     * THE SCREEN IS THE WINDOW, not the sum of what is on it. 
     * 
     * .page carries min-height: 100%, which makes a short screen fill the host and lets a long one 
     * grow past it - right for a list, and wrong here. Nothing on this screen asked for the 
     * leftover height, so the lines grid sat at its own content height and the whole page scrolled 
     * the moment a sale outgrew it: a cashier scrolling a document to see the line they had just 
     * scanned, with the totals and the Save button somewhere below the fold. 
     * 
     * A definite height is what lets the grid take the remainder and scroll INSIDE itself, which 
     * is what every other screen in the app already does with its table. It follows the window on 
     * its own: the shell is a 100vh grid and .shell__page is a 1fr row with min-height: 0, so 
     * resizing re-measures with no reflow of our own and no JS. 
     */ 
    height: 100%; 
 
    /* 
     * THE FLOOR UNDER THE LINES GRID, in rows rather than in pixels - a header and five lines, so 
     * it says what it means and grows with the reader's text size exactly as the rows it is 
     * counting do. 
     * 
     * It is a floor and not a ceiling. Given more window the grid takes all of it; given less it 
     * holds here and the page scrolls rather than squeezing the bill down to a header and one row, 
     * which is the state that made somebody scroll on every sale. 
     */ 
    --sale-lines-min: calc(var(--grid-header-height) + var(--grid-row-height) * 5); 
} 
 
/* ========================================================================== 
   ONE COLUMN, TOP TO BOTTOM 
 
   The screen was briefly two columns - the bill on the left, the furniture beside it - and went 
   back at the client's request. `.sale__main` and `.sale__side` are the wrappers that arrangement 
   needed; they are dissolved here, so their children are laid out by `.sale__work` directly and 
   the order on screen is the order in NewSale.razor. 
 
   Kept rather than deleted because going back is then this one block again rather than a rebuild. 
   They cost nothing: display:contents draws nothing and lays out nothing. 
   ========================================================================== */ 
 
.sale__work { 
    display: flex; 
    flex-direction: column; 
    gap: var(--space-3); 
    min-width: 0; 
 
    /* 
     * IT TAKES WHATEVER THE PAGE HAS LEFT, and it has to say so itself for the same reason the 
     * lines grid does: a header and an error banner are each on screen sometimes and gone the 
     * rest of the time, so a rule counting children would hand the remainder to the wrong one on 
     * exactly the sales that had just gone wrong. 
     * 
     * flex-grow alone, never the `flex` shorthand: .page > * sets flex-shrink: 0 at a higher 
     * specificity than a single class, and the shorthand would appear to set it and be 
     * overridden. Growing is all that is wanted here anyway - the basis stays at the content, so 
     * a window too short to hold the furniture overflows and .shell__page scrolls, rather than 
     * the foot being crushed until the Save button is unreachable. 
     */ 
    flex-grow: 1; 
    min-height: 0; 
} 
 
.sale__main, 
.sale__side { display: contents; } 
 
/* ========================================================================== 
   Bill To 
 
   Open by default and persists its fold between sales - whoever folded it wants it folded for the 
   next customer too. Folded, it still says who is being billed and whether the sale needs an 
   account, which are the two things it must not hide. 
   ========================================================================== */ 
 
/* 
 * ONE ROW: a box to find the customer, the due date, and the account read back as labels. 
 * 
 * It was a heading over a three-column grid of four boxes, which on a small screen is three lines 
 * of the bill spent on something decided once per sale. What is left is one decision - who is 
 * being billed - and a statement of what that decision means. 
 */ 
.sale__billto-row { 
    display: flex; 
    align-items: flex-end; 
    gap: var(--space-3); 
    min-width: 0; 
 
    /* Wraps rather than overflows, like every other row on this screen - which is why nothing on 
       it carries flex-shrink: 0. */ 
    flex-wrap: wrap; 
} 
 
/* A QUARTER OF THE ROW, asked for directly. A flex basis rather than a width, so it is a share of
   the row and not a fixed measurement - and it may shrink, so a narrow window wraps the row rather
   than pushing it off the screen. The floor stops the lookup list becoming too narrow to read a
   name in, which is the one thing this box exists for. The ceiling stops the opposite: with
   flex-grow left uncapped, wrapping onto a line of its own let it stretch to the row's full width
   whenever .sale__who wrapped away from it - a customer box wider than the screen is meant to share
   with the due date. Capped at half the row, which is still far more than a name needs. */
.sale__customer { flex: 1 1 25%; min-width: 180px; max-width: 50%; }
 
/* 
 * THE CAPTION AND THE BALANCE ON ONE LINE, asked for directly. 
 * 
 * .field is a grid, so the caption already had a row to itself with nothing else on it - putting 
 * the badge there costs no height at all and hands the box back the width the figure used to take 
 * out of it. It is inside the <label>, which means pressing the figure puts the caret in the box 
 * beside it rather than doing nothing. 
 * 
 * The caption may shrink and the badge may not: a figure with a digit missing is worse than a 
 * caption reading "Custom...", and on a quarter-width cell one of the two has to give. 
 */ 
.sale__customer-label { 
    display: flex; 
    align-items: center; 
    gap: var(--space-2); 
    min-width: 0; 
} 
 
.sale__customer-label > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; } 
 
/* 
 * THE THREE FACTS ABOUT THE ACCOUNT, AS ONE SET OF BADGES - the balance beside the caption, then 
 * the telephone number and the address on the strip across the row. Amber on all three, asked for 
 * directly: they are what the counter reads off the account, and one shared ground is what makes 
 * them read as one set rather than as three unrelated scraps of text. 
 * 
 * .pill in controls.css is the house badge and is deliberately NOT reused. It is a status - it 
 * carries border: 1px solid currentColor, so its edge is always its ink - and these three carry no 
 * status at all. What they share with it is the shape and the caption size, which is the part 
 * worth matching. 
 */ 
.sale__badge { 
    display: inline-flex; 
    align-items: center; 
    gap: var(--space-1); 
    min-width: 0; 
    max-width: 100%; 
    padding: 2px var(--space-2); 
    border: 1px solid var(--pos-warning-soft); 
    border-radius: var(--radius-pill); 
    background: var(--pos-warning-soft); 
    font-size: var(--text-xs); 
    font-weight: 700; 
    white-space: nowrap; 
} 
 
/* 
 * The figure never wraps and never shrinks - it is the reason the badge is there - and it is the 
 * one of the three that reads its own digits, so it gets the tabular figures. 
 */ 
/* 
 * The Holds badge is pressed to see the products and their dates, so it is a button drawn as the 
 * badge beside it - the same shape and ink - and it says it can be pressed only by its edge on 
 * hover and the pointer. 
 */ 
.sale__badge--button { 
    font: inherit; 
    font-size: var(--text-xs); 
    font-weight: 700; 
    color: inherit; 
    cursor: pointer; 
} 
 
.sale__badge--button:hover:not(:disabled) { border-color: var(--pos-warning); } 
 
.sale__badge--button:disabled { cursor: default; } 
 
.sale__balance { flex-shrink: 0; font-variant-numeric: tabular-nums; color: var(--pos-text-muted); } 
 
/* 
 * AMBER INK, and only while there is something owed. The ground stays amber either way so the row 
 * of badges holds together; what changes is the figure itself. Owing money is ordinary trade, so 
 * the colour is amber rather than red - the rule the Unpaid badge and the customer header already 
 * follow - and nothing owed is not a warning at all, so colouring a nought would teach the eye to 
 * skip the colour on the accounts where it means something. 
 */ 
.sale__balance--owing { color: var(--pos-warning); }

/* The same figure, one line down in the customer lookup's own result row - see the Row fragment
   in NewSale.razor for why it is not the badge. */
.sale__lookup-balance { font-variant-numeric: tabular-nums; }
 
/* A date box holds a date. There is no reading of it that needs more room. */
.sale__due,
.sale__date { flex: 0 1 150px; }

/* Two radios side by side hold their own width; capped so the row wraps rather than the pair
   stretching to fill whatever is left beside the dates. */
.sale__pricing { flex: 0 1 200px; }
.sale__pricing .row { gap: var(--space-4); }

/* 
 * THE REMAINING THREE QUARTERS: what the account already knows, stated rather than typed. 
 * 
 * A row of labels rather than a grid, because they are of wildly different lengths - a code is six 
 * characters and an address is a sentence - and equal columns would give the code a quarter of the 
 * strip while truncating the address inside its own. 
 */ 
.sale__who { 
    flex: 1 1 55%; 
    min-width: 0; 
    display: flex; 
    align-items: baseline; 
    flex-wrap: wrap; 
    gap: var(--space-1) var(--space-3); 
 
    /* It sits beside boxes that carry a caption above them, so it needs a little height under it to 
       line up with their inputs rather than with their captions. */ 
    padding-bottom: var(--space-1); 
    font-size: var(--text-xs); 
    color: var(--pos-text-muted); 
} 
 
/* Walk-in is the resting state and is said out loud - the one thing no field on this row can show. */ 
.sale__who-walkin { font-style: italic; } 
 
/* 
 * THE PHONE AND THE ADDRESS, HIGHLIGHTED AND READ-ONLY. 
 * 
 * A badge rather than a run of muted text, because these are read at a glance - on the telephone, 
 * or writing a delivery slip - and a findable block with its own glyph is what that needs. The 
 * name and the code that used to sit beside them are gone: the box above states both, and 
 * repeating them spent the width of this strip saying twice what one control already says. 
 * 
 * They take .sale__badge's amber ground with the page's own ink rather than amber ink, which is 
 * what keeps them a step behind the balance beside them: one set of badges, and inside it the 
 * figure somebody has to act on is still the loudest thing. 
 */ 
.sale__chip { color: var(--pos-text); } 
 
/* The glyph is the label; it must not shrink away and leave the badge unlabelled. */ 
.sale__chip .icon { flex-shrink: 0; color: var(--pos-warning); } 
 
/* An address is a sentence where a telephone number is a fixed twelve characters, so it is the 
   one that gives up room first - and it keeps its whole text in a title, because a truncated 
   address is not one anybody can deliver to. */ 
.sale__chip--address { flex: 0 1 auto; min-width: 0; } 
 
/* Pushed to the end of the strip: it is the way back, rather than one of the facts. */ 
.sale__who-clear { margin-left: auto; } 
 
/* ========================================================================== 
   The entry row 
 
   The product box keeps the caret unless a line was just added. Every control on this row is 
   always present and only ever greys out: one that comes and goes as products are picked re-flows 
   the row under the cashier's hands mid-sale. 
   ========================================================================== */ 
 
/* 
 * ONE CARD HOLDING BOTH, at the client's request - who is being billed, then what is being added. 
 * The card carries no padding of its own: each of the two rows pads itself and a hairline divides 
 * them, which is a border and a gap cheaper than two cards. 
 */ 
.sale__entry { padding: 0; } 
 
.sale__entry > .sale__billto-row, 
.sale__entry > .sale__entry-row { padding: var(--space-3) var(--card-padding); } 
 
.sale__entry > .sale__entry-row { border-top: 1px solid var(--pos-border); } 
 
/* The warning belongs to the row above it, so it is inset to that row's edge, not the card's. */ 
.sale__entry > .warning-text { display: block; padding: 0 var(--card-padding) var(--space-2); } 
 
.sale__entry-row { 
    display: flex; 
 
    /* 
     * WRAPS AT EVERY WIDTH, not only below 860px, and that was a real horizontal scrollbar. 
     * 
     * This row carries about 650px that cannot shrink - Qty 90, Unit 130, Batch 200, Price 120, 
     * Discount 110, all deliberately flex-shrink: 0 so a figure box is never squeezed to three 
     * characters - plus the Add button and the product box. Wrapping was switched on only in the 
     * narrow media query, so between roughly 860 and 1000 the row had more rigid content than 
     * line and no permission to fold: it overflowed, and the page grew a sideways scrollbar. 
     * 
     * Wrap costs nothing on a wide screen - it only ever acts when the line is genuinely full - 
     * so there is no reason for it to be conditional. The rule that gives the product box a whole 
     * line of its own stays in the 860 query, because that is about proportion rather than fit. 
     */ 
    flex-wrap: wrap; 
 
    align-items: flex-end; 
    gap: var(--space-3); 
    min-width: 0; 
} 
 
.sale__qty { width: 90px; flex-shrink: 0; } 
.sale__unit { width: 130px; flex-shrink: 0; } 
 
/* Wider than its neighbours because it carries a whole label - the lot number and the date it 
   arrived - where they carry a figure. Drawn only where the shop chooses batches, so the row keeps 
   its old proportions everywhere else. */ 
.sale__batch { width: 200px; flex-shrink: 0; } 
.sale__price { width: 120px; flex-shrink: 0; } 
.sale__discount { width: 110px; flex-shrink: 0; } 
 
/* What the line will come to, immediately before Add - the last thing read before it goes on the 
   bill. Wider than the boxes beside it because it carries a currency symbol as well as the digits, 
   and a total is the one figure on this row that must never wrap. */ 
.sale__amount { width: 130px; flex-shrink: 0; } 
 
/* 
 * A FIGURE THE SCREEN WORKS OUT, wearing a box's shape so it lines up with the boxes beside it and 
 * a shade of the page's ground so it does not read as one that can be typed into. Flex rather than 
 * a line-height because it is a div and not an input: an input centres its own text and this has 
 * to be told to. 
 */ 
.sale__readout { 
    display: flex; 
    align-items: center; 
    background: var(--pos-surface-sunken); 
    color: var(--pos-text); 
    font-weight: 700; 
    overflow: hidden; 
    white-space: nowrap; 
} 
 
/* 
 * What the counter reads while pricing: stock on hand, last purchase, the tiers. 
 * 
 * A RESERVED HEIGHT, not an auto one. This used to only exist in the markup once there was 
 * something to say, so the moment a product was picked the row appeared from nothing and pushed 
 * the lines grid - and everything below it - down the screen under the cashier's hands. The 
 * markup now always renders the div (see NewSale.razor); min-height is what keeps it the same 
 * size whether it holds a sentence or nothing at all. 1.4em tracks the row's own font-size, so it 
 * still scales with the reader's text size the way every other measurement on this screen does. 
 */ 
.sale__facts {
    margin-top: var(--space-2);
    min-height: 1.4em;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

/*
 * AN AMBER BADGE rather than a line of muted text, asked for directly - the same warm chip the
 * phone and address badges wear (see .sale__badge, .sale__chip in the row above), so what the
 * counter is reading while it prices a line is grabbed at a glance.
 *
 * HIDDEN RATHER THAN REMOVED WHEN EMPTY. The badge carries its own padding and border, which is
 * taller than a bare line of text - so if it only existed once .sale__facts held something, the
 * row would grow the moment a product was picked, the exact jump .sale__facts's own reserved
 * height was built to stop. Keeping the box in the layout and switching off only its visibility is
 * what makes the two states - a product being priced, and nothing chosen yet - the same height.
 */
.sale__facts-badge--empty { visibility: hidden; }

/* An editable figure inside a grid cell. Shorter than a form field, and no wider than its number. */ 
.sale__cell { 
    height: var(--control-height-sm); 
    width: 92px; 
    padding: 0 var(--space-2); 
    display: inline-block; 
} 
 
/* ========================================================================== 
   The lines, and the price history over them 
 
   The history panel is drawn over the lines rather than taking a row of its own. Opening it moves 
   nothing - which is the whole point, because a panel that pushed the grid down would take the 
   height out of the sale while somebody was pricing a line. 
 
   It is positioned AGAINST THE PRICE BOX, by pos.placeUnder, for the same reason a lookup list is 
   positioned against its own box: it answers a question asked with the caret in that field, and it 
   used to be pinned to the bottom-right corner of the lines grid - which on a full sale is the far 
   side of the screen from the figure being typed, so the answer and the question could not be read 
   together. 
   ========================================================================== */ 
 
/* 
 * THE ROW THAT TAKES THE REMAINDER, and the only one on the screen that does. 
 * 
 * flex: 1 against a basis of 0, so however many rows are on the bill the grid is whatever height 
 * the window has left over - it does not grow as lines are added and it does not collapse when 
 * there are none, which is what stops the foot jumping up and down the screen while somebody is 
 * ringing a sale up. The scrolling happens inside .grid__scroll, which is why the totals and the 
 * buttons stay put on a forty-line sale. 
 * 
 * The floor is --sale-lines-min. min-height: 0 is what it replaces, and that value was load-bearing 
 * for a different reason - it is what lets a flex item be shorter than its own content - so the 
 * floor has to be a real figure rather than nothing, or a long sale would push the foot off the 
 * bottom of the window instead of scrolling within the grid. 
 */ 
.sale__lines { 
    position: relative; 
    display: grid; 
 
    /* 
     * minmax(0, 1fr), never a bare auto row. An auto row is sized to what is in it, and a table of 
     * forty lines is taller than the box - so the grid frame would grow straight through the 
     * bottom of the window and .grid__scroll would never have a height small enough to scroll 
     * against. The explicit 1fr with a zero floor pins the frame to this box, which is what hands 
     * the scrolling to the rows inside it. 
     */ 
    grid-template-rows: minmax(0, 1fr); 
 
    flex: 1 1 0; 
    min-height: var(--sale-lines-min); 
} 
 
.sale__history { 
    /* Fixed, and its left and top are written by pos.placeUnder against the price box. */ 
    position: fixed; 
    z-index: 5; 
    width: min(460px, calc(100vw - var(--space-4) * 2)); 
    overflow: auto; 
 
    /* 
     * A floating surface, so it takes the floating level and the glass that goes with it - the 
     * same treatment as a lookup list, and for the same reason: it is unambiguously over the 
     * lines grid rather than beside it, and letting a hint of the sale through is what says so. 
     * 
     * Nothing here adds height. This panel shares the grid's cell and is drawn over it rather 
     * than taking a row of its own, and every rule in this file is written to keep that true: 
     * on a 1366x768 counter monitor the furniture already comes to most of the screen, and a 
     * pixel added above the lines grid is a pixel taken out of the sale being rung up. 
     */ 
    border-radius: var(--radius-surface); 
    background: var(--pos-glass); 
    backdrop-filter: var(--glass-blur); 
    box-shadow: var(--elev-3), var(--glass-edge); 
    animation: sale-history-in var(--motion-fast) var(--ease-out); 
} 
 
@keyframes sale-history-in { 
    from { opacity: 0; transform: translateY(6px); } 
    to { opacity: 1; transform: none; } 
} 
 
/* ========================================================================== 
   The foot: settlement, then the totals strip 
 
   The totals are a strip along the bottom, not a column down the side - a column costs width the 
   lines grid needs, and this screen is short far more often than it is narrow. 
   ========================================================================== */ 
 
/* 
 * ONE CARD, NOT TWO, at the client's request - the settle row and the docket, divided by a 
 * hairline instead of by a border, a gap and a second border. 
 * 
 * The same move .sale__entry already made with Bill To and the entry row, and for the same reason: 
 * two bordered boxes stacked with a gap between them say one thing - how this sale is paid - in 
 * the space of one and a bit. The card owns the frame; each row inside it still pads itself. 
 * 
 * gap: 0 because the hairline IS the separation now. A gap as well would draw a stripe of the 
 * card's own ground between two rows that are meant to read as one surface. 
 */ 
.sale__foot { 
    display: grid; 
    gap: 0; 
    border: 1px solid var(--pos-border); 
    border-radius: var(--radius-surface); 
    background: var(--pos-surface-sunken); 
 
    /* The rows inside square off against the frame, so the corners have to clip them - otherwise 
       the top row's fill sits outside the radius at all four corners. */ 
    overflow: hidden; 
} 
 
/* 
 * LINE 1 OF THE FOOT, in the order asked for: 
 * 
 *     [Delivered by] [Fee] [Bill discount] [Remarks] [Paid by] 
 * 
 * The widths are deliberately unequal. A grid was tried and is wrong for this row, because every 
 * track in an auto-fill grid is the same width - and the two money boxes hold four digits while 
 * Remarks wants whatever is left over. 
 * 
 * IT WRAPS RATHER THAN OVERFLOWS, which is the distinction this row has got wrong before. Fixed 
 * widths in a flex row do not wrap, they push the row off the edge of the window: so nothing here 
 * carries flex-shrink: 0, and a narrow window costs a second line rather than the right-hand end 
 * of the row and a horizontal scrollbar. 
 */ 
.sale__settle { 
    display: flex; 
    flex-wrap: wrap; 
 
    /* 
     * Aligned at the TOP of the row, not the bottom. The Paid by cell is taller than the ones 
     * beside it - the tender panel carries a "Split the payment" link under its picker - so 
     * bottom alignment pushed every other caption down to meet it, stranding them in mid-air. 
     * Captions line up across a row; a cell with more to say says it downwards. 
     */ 
    align-items: flex-start; 
    gap: var(--space-2) var(--space-3); 
 
    /* 
     * A ROW INSIDE THE FOOT'S CARD, so it carries padding and nothing else - the border, the radius 
     * and the sunken fill are the card's now. It used to carry all four itself, which is what made 
     * the foot two boxes with a gap down the middle of it. 
     */ 
    padding: var(--space-3) var(--card-padding); 
} 
 
/* Small because four digits is what goes in them, and shrinkable because a rigid width on a flex 
   row is exactly what stops the row wrapping. */ 
.sale__money { width: 110px; } 
 
/* 
 * REMARKS, RIGHT AFTER BILL DISCOUNT ON THE SETTLE ROW - moved here at the client's request, and 
 * top-aligned with the rest of the row (.sale__settle already sets align-items: flex-start) rather 
 * than stacked underneath its own field. It is a plain text input now, not a textarea, so it needs 
 * no height rule of its own - .field__input already sets the ordinary control height. 
 * 
 * flex: 1 1 220px is the same shape .sale__tenders uses for a cell that should take whatever the 
 * row has left over rather than a fixed measurement - a note is still the field here most worth 
 * extra room, same as when it lived on the totals strip. 
 */ 
.sale__remarks { 
    flex: 1 1 220px; 
    min-width: 160px; 
} 
 
/* 
 * THE SUMMARY, AS A BORDERED TABLE - asked for directly, in place of the flex strip it was. 
 * 
 *     | Sold | Bill discount | TOTAL | CHANGE | 
 * 
 * A table draws the rule between one figure and the next on its own, which a row of divs only 
 * ever implied with a gap - so it reads as one grouped instrument rather than a loose row of 
 * numbers, and it wears the same border and surface tokens as every other bordered surface on 
 * this screen (.sale__foot, .tenders__panel) so it matches the theme instead of introducing one. 
 * 
 * The wrapper carries the frame - border, radius, clipping - and the table itself is 
 * border-collapse: so the cell borders inside are single hairlines rather than doubled ones. 
 */ 
.sale__totals-wrap { 
    flex: 1 1 auto; 
    min-width: 0; 
    overflow-x: auto; 
    border: 1px solid var(--pos-border); 
    border-radius: var(--radius-surface); 
} 
 
/* 
 * FIXED COLUMN WIDTHS - asked for directly, because a bordered docket that moves under the 
 * cashier's eye the moment a figure changes digit-count is worse than no border at all. 
 * 
 * table-layout: auto (the default) measures every cell's content on every render and 
 * recomputes column widths from it. The column COUNT here was already fixed - every column 
 * always renders, dash-filled where it does not apply (see NewSale.razor) - but the WIDTHS 
 * still moved: "Bill discount" going from "—" to "− Rs. 1,250.00", or CHANGE gaining a digit, 
 * each nudged every column after it sideways. table-layout: fixed stops the table reading its 
 * own cells for sizing at all; only the declared widths below decide it now. 
 * 
 * Percentages rather than pixels, so the table still fills .sale__totals-wrap and shrinks with 
 * it under overflow-x: auto - fixed is what stops CONTENT re-deriving them, not what stops them 
 * being responsive. 
 */ 
.sale__totals-table { 
    width: 100%; 
    table-layout: fixed; 
    border-collapse: collapse; 
} 
 
/* ON ACCOUNT TOOK A POINT FROM EACH OF THESE TWO, because it is the one header carrying a 
   control as well as a caption and 12% could not hold both on one line. They are the widest 
   columns here and hold an ordinary money figure, so a point off either costs nothing 
   readable. */ 
/* EIGHT COLUMNS SINCE ROUND OFF JOINED THE ROW, and they have to add up to 100%: they added up
   to it with seven, so the eighth - CHANGE - was squeezed off the end and the Refund tick looked
   as though it did nothing. */
.sale__totals-table th:nth-child(1),
.sale__totals-table td:nth-child(1) { width: 12%; } /* Sold */

.sale__totals-table th:nth-child(2),
.sale__totals-table td:nth-child(2) { width: 11%; } /* Taken back */

.sale__totals-table th:nth-child(3),
.sale__totals-table td:nth-child(3) { width: 13%; } /* Bill discount */

.sale__totals-table th:nth-child(4),
.sale__totals-table td:nth-child(4) { width: 11%; } /* Delivery */

.sale__totals-table th:nth-child(5),
.sale__totals-table td:nth-child(5) { width: 10%; } /* Round off */

.sale__totals-table th:nth-child(6),
.sale__totals-table td:nth-child(6) { width: 15%; } /* TOTAL */

.sale__totals-table th:nth-child(7),
.sale__totals-table td:nth-child(7) { width: 15%; } /* On account */

.sale__totals-table th:nth-child(8),
.sale__totals-table td:nth-child(8) { width: 13%; } /* CHANGE */ 
 
.sale__totals-table th, 
.sale__totals-table td { 
    padding: var(--space-2) var(--space-3); 
    text-align: left; 
    white-space: nowrap; 
    border: 1px solid var(--pos-border); 
    overflow: hidden; 
    text-overflow: ellipsis; 
} 
 
/* The frame's own border already draws the outer edge; collapsing it here would double it up 
   against .sale__totals-wrap's border on all four sides. */ 
.sale__totals-table tr > :first-child { border-left: 0; } 
.sale__totals-table tr > :last-child { border-right: 0; } 
.sale__totals-table thead tr:first-child th { border-top: 0; } 
.sale__totals-table tbody tr:last-child td { border-bottom: 0; } 
 
/* Captions across the top, muted and small like every other field-label on this screen - a 
   header row rather than a caption over each value, which is what a table buys over the strip. */ 
.sale__totals-table thead th { 
    background: var(--pos-surface-sunken); 
    font-size: var(--text-xs); 
    font-weight: 700; 
    color: var(--pos-text-muted); 
} 
 
/* The figures themselves, tabular so the column lines up on its own digits. */ 
.sale__totals-table tbody td { 
    font-variant-numeric: tabular-nums; 
    font-weight: 700; 
    color: var(--pos-text); 
} 
 
/* 
 * TOTAL AND CHANGE STAND A STEP ABOVE THE ORDINARY COLUMNS - xl rather than the row's own 
 * text-sm-ish default - same as when the docket was a strip or a column: they are the two figures 
 * a cashier reads while a queue waits, so they keep their own size wherever this table lives. 
 */ 
.sale__totals-table--grand { font-size: var(--text-xl); } 
 
/* 
 * COLOUR NOW CARRIES WHAT EACH FIGURE DOES TO THE TOTAL, asked for directly, on top of the 
 * tabular-nums / bold weight every cell already has from .sale__totals-table tbody td above. 
 * 
 * GREEN FOR WHATEVER ADDS TO THE TOTAL - Sold, Delivery - at the ordinary cell size, and TOTAL 
 * itself in the SAME green but at grand size, so it still reads as the figure the green columns 
 * sum into rather than as an unrelated colour of its own. --pos-accent is reused rather than a new 
 * token: it is already this app's green, the same one .tenders__tab-figure wears for money that 
 * has been committed to a method. 
 * 
 * RED FOR WHATEVER COMES OFF IT - Taken back, Bill discount. --pos-danger is not a token this app 
 * had before this table; the fallback is what shows if a shop's own theme.css has not defined one. 
 * 
 * THE +/- SIGN IS TEXT, NOT COLOUR ALONE - asked for directly, in NewSale.razor.cs's SignedMoney - 
 * so the row still reads correctly for anybody who cannot rely on colour to carry the meaning. 
 */ 
.sale__amt-add { color: var(--pos-accent); } 
.sale__amt-subtract { color: var(--pos-danger); } 
.sale__amt-total { color: var(--pos-accent); } 
 
/* Shrinkable, unlike their twins on the entry row above - flex-shrink: 0 is right there, where 
   whole fields wrap onto new lines, and is what would stop this row wrapping at all. */ 
.sale__driver { width: 190px; } 
 
/* 
 * PAID BY DOES NOT GROW. It carried flex-grow: 1 once, which on a counter monitor pulled it far 
 * wider than a payment method - a name out of a short list - ever needs to be. Dropping the grow 
 * costs the picker nothing (220 still holds the longest method name and the "Split the payment" 
 * link under it) and hands the remainder to Remarks instead. 
 * 
 * Still shrinkable, like everything else on this row, or the row could not wrap. 
 */ 
.sale__tenders { flex: 0 1 220px; min-width: 0; } 
 
/* 
 * .sale__refund is gone. The "Goods taken back" / "Out of" pickers it belonged to were removed 
 * from the counter - what came back is folded into CHANGE now rather than asking the cashier to 
 * choose a refund mode - so there is no longer any markup that wears this class. 
 */ 
 
/* 
 * LINE 2 OF THE FOOT is the totals table, then the buttons on the line below it. Remarks lives on 
 * the settle row above now, beside Bill discount - see .sale__remarks - so this row is nothing but 
 * the summary table and the action buttons. 
 * 
 * CASH GIVEN USED TO RIDE THIS ROW AND NO LONGER DOES. It was the one item here that could be 
 * typed into, captioned with .totals__label so it sat among the figures; it moved up to the settle 
 * row at the client's request, where it is an ordinary .sale__money box like Fee and Bill discount 
 * beside it. The .sale__cash rule went with it rather than being left inert - a class nothing 
 * draws is the stale CSS this file has been cleared of once already. 
 */ 
 
/* 
 * THE BUTTONS RIDE THEIR OWN LINE AT THE END OF THE STRIP. 
 * 
 * They were a row of their own, which on this screen is a line of the sale. On the totals row they 
 * cost nothing vertically and sit beside the figures they act on. The captions are short - Return, 
 * Lend, Reclaim, Draft, Save, Save and print - and visible: they were briefly icons alone with the 
 * words in a hover popover, and that was withdrawn. 
 */ 
.sale__actions { 
    display: flex; 
    align-items: center; 
    gap: var(--space-2); 
    flex-wrap: wrap; 
 
    /* 
     * A LINE OF ITS OWN INSIDE THE TOTALS STRIP, not a row of its own outside it. Asked for 
     * directly - "take the buttons to the next row in the same card where they are now" - so this 
     * is flex-basis: 100% on a wrapping flex container rather than a third box in .sale__foot, 
     * which would have been a fourth border and a fourth padding to say one thing. 
     * 
     * They used to ride the end of the figures on margin-left: auto. That kept them on the 
     * right-hand edge whatever the row was carrying, and it worked - until the row got long 
     * enough on a sale with goods coming back that the wrap put them somewhere unpredictable. 
     */ 
    flex: 0 0 100%; 
    justify-content: flex-end; 
} 
 
/* 
 * THE FIGURES READ LEFT NOW, and that is the direct consequence of Remarks leaving this row: 
 * nothing here needs pushing off a note any more, so the strip reads Sold → Bill discount → TOTAL 
 * → CHANGE in the plain order they are written in the markup, the same as any other strip in the 
 * app. 
 * 
 * The row gap is tightened from the strip's own space-5 (which is the gap BETWEEN FIGURES on a 
 * strip with nothing else on it) while the column gap is left exactly as it was. .totals is drawn 
 * by this screen and by nothing else, which is why the override lives here. 
 */ 
.sale__foot .totals { 
    justify-content: flex-start; 
    gap: var(--space-3) var(--space-5); 
 
    /* 
     * THE DOCKET IS THE SECOND ROW OF THE FOOT'S ONE CARD. The frame is the card's, so what is 
     * left here is the padding and the hairline that divides this row from the settle row above - 
     * exactly what .sale__entry does between Bill To and the entry row. 
     * 
     * The hairline goes on THIS row rather than under the one above it, so a foot that ever loses 
     * its settle row cannot be left drawing a rule against nothing. 
     */ 
    border: 0; 
    border-top: 1px solid var(--pos-border); 
    border-radius: 0; 
    background: transparent; 
 
    /* Aligned at the top, so the button row wrapping onto its own line underneath does not pull 
       the figures down to meet it. */ 
    align-items: flex-start; 
} 
 
/* 
 * WHAT TO COUNT BACK INTO THE CUSTOMER'S HAND, IN AMBER - asked for directly. It used to share 
 * that colour with On account, as the two figures on this screen somebody has to act on before the 
 * customer walks away; On account has since moved to blue (see .sale__on-account) to read as owed 
 * information rather than a same-visit action, which leaves amber for CHANGE alone now. 
 * 
 * THERE IS NO SHORT BY READING ANY MORE. It existed while the tender and the note on the counter 
 * were two boxes and the note could fall short of the tender; with one box too little is a part 
 * payment and is stated as ON ACCOUNT instead. .totals__item--short went with it rather than being 
 * left as a rule nothing sets. 
 */ 
.sale__totals-table .sale__change { color: var(--pos-warning); } 
 
/* The last thing the screen gives up - and now the only place the shortcuts are written down, the 
   button captions that used to carry them having become icons. */ 
.sale__hints { font-size: var(--text-xs); } 
 
 
/* 
 * BLUE, asked for directly - moved off the amber it used to share with CHANGE and the customer's 
 * account balance. What is owed here is exactly as real as what those two say, but it is not the 
 * same kind of thing: a walk-in cannot generate it at all (see NeedsCustomer), and it is stated 
 * rather than acted on at this counter - the account is settled elsewhere, not by this screen. The 
 * fallback is what shows if a shop's own theme.css has not defined this token. 
 */ 
.sale__totals-table .sale__on-account { color: var(--pos-info); } 
 
/* 
 * THE REFUND TICK RIDES THE ON ACCOUNT CAPTION, ON THE SAME LINE - asked for directly, and the 
 * whole of what makes it fit is that the tick is smaller than the app's own. It briefly wrapped 
 * onto a second line, which made the header row taller than it needed to be; on this screen a 
 * line of the header is a line of the sale. 
 * 
 * IT IS THE CAPTION THAT GIVES WAY, NEVER THE TICK. The tick is a control somebody has to hit 
 * and its label is the only thing saying what it does, so it does not shrink; the caption 
 * ellipsises instead, which on a genuinely narrow window costs a word nobody is reading twice 
 * rather than a control nobody can press. The ellipsis is on the caption rather than on the cell 
 * because text-overflow does not reach a flex item. 
 * 
 * .check is otherwise not re-cut - the label inherits the header's own size, weight and ink, so 
 * the tick reads as part of the caption it qualifies rather than as a control dropped onto the 
 * totals. 
 */ 
.sale__on-account-head { 
    display: flex; 
    align-items: center; 
    gap: var(--space-2); 
    min-width: 0; 
} 
 
.sale__on-account-head > span { 
    /* min-width: 0 as well as overflow, or nothing happens: a flex item defaults to min-width 
       auto, which refuses to shrink below its own content and would push the tick out of the 
       cell instead of trimming the caption. */ 
    min-width: 0; 
    overflow: hidden; 
    text-overflow: ellipsis; 
} 
 
.sale__refund-excess { 
    flex-shrink: 0; 
    gap: var(--space-1); 
    font-size: inherit; 
    font-weight: inherit; 
    color: inherit; 
} 
 
.sale__refund-excess .check__box { 
    width: var(--check-box-size-sm); 
    height: var(--check-box-size-sm); 
} 
 
/* ========================================================================== 
   Compaction 
 
   Worth about 150 units, which is what puts 1920x1080 at 150% scaling and a 1366x768 counter 
   monitor back into comfort. Nothing is removed except the hint line, and only at the tightest 
   band. 
   ========================================================================== */ 
 
/* 
 * 760, NOT 700, AND THE FIGURE IS MEASURED RATHER THAN CHOSEN. 
 * 
 * This band exists for the 1366x768 counter monitor - it says so at the head of the section - and 
 * 700 never actually caught one. The query reads the WINDOW, and what this screen gets is the 
 * window less the title bar, less the top bar and less the shell's padding: a maximised 768 machine 
 * arrives here at about 730, and sat in the comfortable band it was 18 units too tall and scrolled 
 * on every sale. Measured either side of the change, not eyeballed. 
 */ 
@media (max-height: 760px) { 
    .sale { gap: var(--space-2); } 
    .sale__entry > .sale__billto-row, 
    .sale__entry > .sale__entry-row, 
    .sale__settle, 
 
    /* 
     * THE TOTALS STRIP TIGHTENS TOO, and it did not before. It was the one box in the foot left 
     * out of this band, which mattered little while it was a single row of figures and matters a 
     * great deal now that it holds a column of them: the foot is the tallest thing on the screen 
     * that is not the bill. 
     */ 
    .sale__foot .totals { padding: var(--space-2) var(--card-padding); } 
 
    .sale__facts { margin-top: var(--space-1); } 
 
    /* The table closes up with everything else - a shorter cell padding rather than a change to 
       the border, which stays a hairline at every band. */ 
    .sale__totals-table th, 
    .sale__totals-table td { padding: var(--space-1) var(--space-2); } 
 
    /* 
     * TOTAL AND CHANGE COME DOWN ONE MORE STEP on a short window - xl to lg, which is level with 
     * the ordinary columns beside them. 
     * 
     * This is the band where the whole screen is fighting for the last few units, and two rows at 
     * four units each is what the tab strip costs. Nothing is lost by it: the two are told apart 
     * from the ordinary columns by WEIGHT and by their header already being in the same row, which 
     * is what was doing that job on the old strip too. 
     */ 
    .sale__totals-table--grand { font-size: var(--text-lg); } 
 
    /* The floor comes down with the furniture, or the two would fight: a grid still demanding five 
       rows on a window that has given up its padding to find them is a grid that pushes the Save 
       button off the bottom. Four here, three at the tightest band - still a readable bill, and 
       still every control on the screen. */ 
    .sale { --sale-lines-min: calc(var(--grid-header-height) + var(--grid-row-height) * 4); } 
} 
 
/* 
 * Three rows rather than four. The floor is only ever reached on a window this short, and this is 
 * where it stops being a floor holding the bill up and starts being the thing pushing the Save 
 * button off the bottom - the grid takes every unit above it either way. 
 */ 
@media (max-height: 680px) { 
    .sale { --sale-lines-min: calc(var(--grid-header-height) + var(--grid-row-height) * 3); } 
} 
 
@media (max-height: 540px) { 
    /* Every shortcut this names is also a visible button, which is what makes it the one thing 
       on the screen that may go. */ 
    .sale__hints { display: none; } 
    .sale__facts { display: none; } 
} 
 
 
@media (max-width: 860px) { 
    .sale__entry-row { flex-wrap: wrap; } 
 
    /* Half a line each once the row folds, like the figure boxes beside them. The Amount readout 
       joins them rather than being left at its own width, which would put one 130px box on a row 
       of two half-width ones. */ 
    .sale__amount { width: calc(50% - var(--space-3)); } 
 
    /* The whole width once the settle row has stopped sharing a line with the picker beside it - 
       at this size the row is a column, and a narrow sliver is not a note anybody can read. */ 
    .sale__remarks { flex: 1 1 100%; } 
 
    /* 
     * The product box takes a whole line of its own once the row wraps. 
     * 
     * `.grow` is flex:1 with min-width:0, so with a 50%-wide Qty beside it the box was squeezed to 
     * nothing - and a field squeezed to nothing does not take its CAPTION with it: "Product" ran 
     * straight out of its own column and printed on top of "Qty". It is the box everything on this 
     * row is typed into first, so it is the last one that should be giving up width. 
     */ 
    .sale__entry-row > .grow { flex: 1 0 100%; } 
    .sale__qty, .sale__unit, .sale__price, .sale__discount, .sale__batch { width: calc(50% - var(--space-3)); } 
    .sale__history { width: calc(100vw - var(--space-4) * 2); } 
}
/*
 * THE PAYMENTS PANEL INSIDE THE FOOT. The foot's rows each pad themselves (gap is 0 and the card
 * itself carries no padding), so the panel - drawn here on an invoice's Edit screen - has to as
 * well, or its heading sits against the card's left edge and is clipped by its rounded frame.
 */
.sale__foot > .detail__section {
    padding: var(--space-3) var(--card-padding);
    border-top: 1px solid var(--pos-border);
}

/* ==========================================================================
   The bill summary on a phone

   The strip is eight columns - Sold, Taken back, Bill discount, Delivery, Round off, TOTAL, On
   account, CHANGE - and on a phone each got a few characters and an ellipsis. It is drawn as a
   list instead: caption on the left, figure on the right, one line per figure, with TOTAL and
   CHANGE set apart at the foot. The same markup, re-laid by CSS alone: the table's header cells
   come first in the document and its figure cells after them, so a grid that fills DOWN a column
   puts the eight captions in the first column and the eight figures beside them.

   That only works while there are always eight of each, which the markup guarantees on purpose
   (a figure that does not apply is a dash, never a missing cell - see the note in NewSale.razor).
   ========================================================================== */
@media (max-width: 860px) {
    .sale__totals-wrap { overflow: visible; }

    .sale__totals-table {
        display: grid;
        grid-auto-flow: column;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: repeat(8, auto);
        width: 100%;
    }

    .sale__totals-table thead,
    .sale__totals-table tbody,
    .sale__totals-table tr { display: contents; }

    .sale__totals-table th,
    .sale__totals-table td {
        display: block;
        width: auto !important;
        padding: var(--space-2) var(--space-3);
        border: 0;
        border-bottom: 1px solid var(--pos-border);
        font-size: var(--text-base);
        letter-spacing: normal;
        text-transform: none;
        white-space: normal;
    }

    .sale__totals-table th { text-align: left; font-weight: 600; color: var(--pos-text-muted); background: transparent; }
    .sale__totals-table td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

    /* A figure that does not apply says so quietly, and its caption goes with it. */
    .sale__totals-table td.subtle { font-weight: 400; }

    /* TOTAL and CHANGE are what the cashier reads out. */
    .sale__totals-table th.sale__totals-table--grand,
    .sale__totals-table td.sale__totals-table--grand {
        padding-block: var(--space-3);
        background: var(--pos-surface-sunken);
        font-size: var(--text-xl);
        font-weight: 700;
    }
    .sale__totals-table th.sale__totals-table--grand { color: var(--pos-text); }

    .sale__totals-table tr > :last-child { border-bottom: 0; }

    .sale__on-account-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

    /* The buttons: two to a line, Save and print across the whole width under them. */
    .sale__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-2);
        width: 100%;
        margin-left: 0;
    }
    .sale__actions > .btn { width: 100%; justify-content: center; }
    .sale__actions > .btn--primary { grid-column: 1 / -1; height: var(--control-height-lg); }

    /* Keyboard shortcuts mean nothing without a keyboard. */
    .sale__hints { display: none; }
}

/* ==========================================================================
   New Sale on a phone: the bill-to row and the lines
   ========================================================================== */
@media (max-width: 860px) {
    /* The customer is the one box this row is for, so it gets the whole line; the dates share the
       one under it. */
    .sale__customer { flex: 1 1 100%; min-width: 0; max-width: 100%; }
    .sale__billto-row > :not(.sale__customer) { flex: 1 1 40%; min-width: 0; }

    /* The lines are as tall as the bill, and the page scrolls. The grid used to be pinned to a share of
       the window with its rows scrolling inside it, which is right on a counter monitor and, drawn as
       cards on a phone, let the cards run straight over the settle row beneath them. */
    .sale__lines { display: block; flex: 0 0 auto; min-height: 0; }
}

/* ==========================================================================
   The settle row, as two columns

       [Delivered by] [Delivery] [Record as] [Bill discount]      | Payment 1  +
       [Remarks ..........................................]       | Date  Method  Amount

   The boxes that are decided about the sale are on the left, with Remarks under them across their
   whole width; how it is paid is the panel on the right, its three boxes on ONE line. Before, five
   boxes and a tall panel shared a wrapping row, which left a block of empty space under the boxes
   and made the panel three lines high.
   ========================================================================== */
.sale__settle:has(> .sale__settle-left) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: var(--space-4);
}

.sale__settle-left {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-2) var(--space-3);
    min-width: 0;
}

/* A whole line of its own, whatever the four boxes above it add up to. */
.sale__settle-left > .sale__remarks { flex: 1 1 100%; min-width: 0; }

/* The panel is as wide as its three boxes, and no wider. */
.sale__settle:has(> .sale__settle-left) > .tenders__panel { flex: none; width: max-content; max-width: 100%; }
.sale__settle:has(> .sale__settle-left) .tenders__fields { flex-wrap: nowrap; gap: var(--space-2); }
.sale__settle:has(> .sale__settle-left) .tenders__fields .tenders__ref { width: 9.5rem; }
.sale__settle:has(> .sale__settle-left) .tenders__fields .tenders__amount { width: 7.5rem; }

/* Less air under the buttons: the foot is the last thing on the screen, and every unit under it is a
   unit taken out of the lines above. */
.sale__foot .totals { padding-bottom: var(--space-2); }
.sale__hints { margin-top: 0; padding-top: 0; }

@media (max-width: 1100px) {
    /* Not enough width for two columns: the panel goes under the boxes and wraps as it used to. */
    .sale__settle:has(> .sale__settle-left) { grid-template-columns: minmax(0, 1fr); row-gap: var(--space-2); }
    .sale__settle:has(> .sale__settle-left) > .tenders__panel { width: auto; }
    .sale__settle:has(> .sale__settle-left) .tenders__fields { flex-wrap: wrap; }
}

/* ==========================================================================
   A bill line as a card on a phone

       [product, across the card]
       [Type]  [Unit]  [Amount]        <- what the line is, and what it comes to: read, not typed
       [Qty]   [Price] [Discount]      <- the three boxes somebody edits, side by side
       [remove]

   The editable boxes share one line so a correction is one glance and one thumb; Amount takes the
   place Discount had, in the line above, because it is read-only and costs nothing to move.
   ========================================================================== */
@media (max-width: 860px) {
    .sale__lines .grid.grid--auto tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    .sale__lines .grid.grid--auto tbody tr > td.line-type { order: 1; }
    .sale__lines .grid.grid--auto tbody tr > td.line-unit { order: 2; }
    .sale__lines .grid.grid--auto tbody tr > td.line-amount { order: 3; }
    .sale__lines .grid.grid--auto tbody tr > td.line-qty { order: 4; }
    .sale__lines .grid.grid--auto tbody tr > td.line-price { order: 5; }
    .sale__lines .grid.grid--auto tbody tr > td.line-discount { order: 6; }
    .sale__lines .grid.grid--auto tbody tr > td.grid__cell--actions { order: 9; grid-column: 1 / -1; }

    /* A batch, where the shop chooses them, goes with what the line is. */
    .sale__lines .grid.grid--auto tbody tr > td:not([class*="line-"]):not(.card-first):not(.card-hide):not(.grid__cell--actions) { order: 3; }
}
