/* ============================================================
   pos.css — the counter screen.

   Written mobile-first and thumb-first, unlike the rest of the
   app: this is the one surface used standing up, one-handed, on
   a phone propped next to a till. Every tappable target is at
   least 56px, because a mis-tap here charges the wrong money.

   Deliberately its own file rather than more rows in
   components.css — nothing outside /pos uses these, and the
   sizing rules here would be wrong everywhere else.
   ============================================================ */

/* ── Shell ───────────────────────────────────────────────── */

.pos-shell {
    /* The till's own tints, kept here rather than in tokens.css because
       nothing outside /pos should inherit them. The board deliberately
       runs a shade or two deeper than the rest of the app: the standard
       near-white surfaces are restful on a page you read for a minute
       and tiring on one you stare at for an eight-hour shift. */
    --pos-chrome: #eef0f6;   /* search bar, tabs — one step off the board */
    --pos-board-bg: #e8eaf2; /* behind the tiles, so tiles read as raised */
    --pos-panel: #f7f8fc;    /* the cart, lighter so figures stay crisp */
    --pos-total-bg: #eceefb; /* the totals block — faint brand tint */

    display: flex;
    flex-direction: column;
    /* vh first as the fallback, then svh. Small viewport height keeps
       mobile browser chrome from pushing the tender pad under the
       address bar; the vh line covers browsers without svh. */
    height: 100vh;
    height: 100svh;
    /* And then minus whatever the keyboard is covering. This shell is
       overflow:hidden, so anything the keyboard lands on top of cannot be
       scrolled to at all -- which on this screen is the tender pad. 0 on
       Chrome, where the viewport meta already shrank the viewport the svh
       above resolves against. See app.js. */
    height: calc(100svh - var(--viewport-bottom-inset, 0px));
    background: var(--color-bg);
    overflow: hidden;
}

/* Counter-wide touch hygiene. A till gets tapped hard and fast, and the
   defaults all misbehave under that: iOS paints a grey flash on every
   tap, a quick double-tap selects the price text or zooms the page, and
   a fast scroll flings the whole document. */
.pos-shell button,
.pos-shell .pos-tile,
.pos-sheet button {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation; /* kills the 300ms double-tap-zoom delay */
}

/* This project has NO global box-sizing reset — reset.css is a
   mis-named copy of tokens.css and declares none, which is why
   components.css patches .form-control individually. So every POS box
   that mixes width:100% with padding has to opt in explicitly, or its
   padding is ADDED to the width and it overflows its parent. */
.pos-shell *,
.pos-shell *::before,
.pos-shell *::after,
.pos-sheet,
.pos-sheet *,
.pos-panel,
.pos-panel * {
    box-sizing: border-box;
}

/* An in-page panel, as distinct from .pos-sheet (a modal). The till and
   returns screens were reusing .pos-sheet for stacked page content,
   which dragged four modal-only behaviours in with it: a 92svh cap and
   its own scrollbar (nested inside an already-scrolling page), a
   bottom-sheet corner radius on a panel that isn't at the bottom, and
   home-indicator padding on one that isn't at the edge. */
.pos-panel {
    width: 100%;
    max-width: 520px;
    margin: 0 auto var(--space-4);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* Blanket 16px floor on every field anywhere in the POS surface. The
   design system's base size is 15px, and iOS zooms the page on focusing
   anything smaller — so a till screen that inherited the app default
   would jerk on every tap. Applied to the container rather than each
   field so a new POS screen can't quietly reintroduce it. */
.pos-shell input,
.pos-shell select,
.pos-shell textarea,
.pos-sheet input,
.pos-sheet select,
.pos-sheet textarea {
    font-size: max(16px, 1rem);
}

/* Scrolling one pane must never pull-to-refresh or scroll the page
   behind it — losing a half-rung basket to an accidental refresh is
   exactly the failure this whole screen is built to avoid. */
.pos-tiles,
.pos-cart-lines,
.pos-sheet,
.pos-tabs {
    overscroll-behavior: contain;
}

/* Dark, like the app's own sidebar. A till is looked at for a whole
   shift, and a white bar across the top of a white screen is the main
   source of glare — anchoring the top in the brand's dark tone drops the
   overall brightness a long way before a single tile changes. */
.pos-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-sidebar-bg);
    color: var(--color-white);
    border-bottom: 1px solid var(--color-sidebar-bg-darker);
    flex: 0 0 auto;
    min-height: 56px;
}

/* Topbar controls sit on dark, so they invert: a translucent fill reads
   as a button against the bar without needing its own hard border. */
.pos-topbar .pos-topbar-btn,
.pos-topbar .pos-icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
    color: var(--color-white);
}

.pos-topbar .pos-topbar-btn:hover,
.pos-topbar .pos-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Exit is the one destructive-ish action up here — a soft red rather
   than the full danger token, which would shout on a dark bar. */
.pos-topbar .pos-topbar-btn.is-danger { color: #ff9b9b; }

.pos-topbar .pos-icon-btn.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}

/* SMALL PHONES. Eight controls sit on this bar and it does not wrap, so at
   320px they measured 326px of content in a 304px bar and Exit -- the one that
   gets you out of the till -- hung 14px off the right-hand edge, inside a shell
   that is overflow:hidden and so cannot be scrolled to reach it. The title had
   already been squeezed to zero width and there was nothing left to give.

   Tightening the gaps and the side padding recovers about 50px, which is more
   than enough, and costs nothing at any size where the bar already fitted. */
@media (max-width: 380px) {
    .pos-topbar {
        gap: var(--space-1);
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }
}

.pos-topbar-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* min-width:0 is load-bearing, not tidiness. A flex item's default
       min-width is auto, which refuses to shrink below the text's own
       width — so without this the ellipsis never triggers and a long
       business name shoves the Exit button off the right of a phone. */
    flex: 0 1 auto;
    min-width: 0;
}

.pos-topbar-spacer { flex: 1 1 auto; }

.pos-topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}

.pos-topbar-btn:hover { background: var(--color-bg); }
.pos-topbar-btn.is-danger { color: var(--color-danger); }

/* Till state, always visible — a cashier must never have to go
   looking for whether the drawer is open. */
.pos-till-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full, 999px);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.pos-till-pill.is-open {
    background: var(--color-success-light);
    color: var(--color-success-text);
}

.pos-till-pill.is-closed {
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

/* ── Body: board + cart ──────────────────────────────────── */

.pos-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0; /* lets the children scroll instead of the page */
}

.pos-board {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* Shown INSTEAD of the board when the business requires an open drawer and
   hasn't got one. Centred and alone on the body, because the point is that
   there is nothing else on this screen to do — a panel tucked above a live
   board would read as advice rather than as a stop. */
.pos-till-gate {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: var(--space-6);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-align: center;
}

.pos-search-row {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    background: var(--pos-chrome);
    flex: 0 0 auto;
}

.pos-search-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 48px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    /* 16px literal, NOT --font-size-base (15px). iOS Safari auto-zooms
       the page whenever a focused input is under 16px, and on a till
       that means the board jumps every single time the cashier taps the
       barcode box. Never lower this. */
    font-size: 16px;
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.pos-icon-btn {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
}

.pos-icon-btn:hover { background: var(--color-bg); }
.pos-icon-btn.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* Category tabs — horizontally scrollable, never wrapping, so the
   board area below keeps a stable height. */
.pos-tabs {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    flex: 0 0 auto;
    background: var(--pos-chrome);
    border-bottom: 1px solid var(--color-border);
}

.pos-tab {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-full, 999px);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    cursor: pointer;
}

.pos-tab.is-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.pos-tiles {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-3);
    background: var(--pos-board-bg);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-3);
    align-content: start;
}

.pos-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 96px;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    /* Stops a long product name blowing the grid out sideways. */
    word-break: break-word;
}

/* A soft lift against the deeper board, so the grid reads as physical
   keys rather than flat colour patches — which is what makes a coloured
   board scannable instead of just busy. */
.pos-tile {
    box-shadow: 0 1px 2px rgba(27, 24, 48, 0.08);
    transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.pos-tile:active {
    transform: scale(0.97);
    box-shadow: none;
}

.pos-tile-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-tile-price {
    margin-top: var(--space-1);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
}

.pos-tile-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.9;
}

/* When a tile has a photo the text sits on a scrim, so a pale
   product shot can never make the price unreadable. */
.pos-tile.has-image .pos-tile-text {
    position: relative;
    z-index: 1;
    padding: var(--space-2);
    margin: calc(var(--space-3) * -1);
    margin-top: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72) 38%);
    color: #fff;
}

.pos-tile-stock {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    z-index: 1;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

.pos-tile-stock.is-out {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

/* Blocked by PreventOverselling — greyed and inert, so the refusal
   is visible before the tap rather than as an error afterwards. */
.pos-tile.is-blocked {
    opacity: 0.45;
    cursor: not-allowed;
}

.pos-tile.is-blocked:active { transform: none; }

/* ── Cart ────────────────────────────────────────────────── */

.pos-cart {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--pos-panel);
    border-left: 1px solid var(--color-border);
}

.pos-cart-lines {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-2);
}

.pos-cart-empty {
    padding: var(--space-8) var(--space-4);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.pos-cart-line {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border-bottom: 1px solid var(--color-border);
}

.pos-cart-line-main { flex: 1 1 auto; min-width: 0; }

.pos-cart-line-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pos-cart-line-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.pos-cart-line-total {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.pos-qty {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    flex: 0 0 auto;
}

.pos-qty-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
}

.pos-qty-value {
    min-width: 28px;
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* The quantity read-out is a button now, but must not LOOK like the two
   steppers either side of it -- it does something different, and three
   identical buttons in a row would read as three steppers. Same size and
   weight as the old span, with a dotted underline as the only affordance. */
.pos-qty-edit {
    border: none;
    background: none;
    padding: 4px 2px;
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 1px dashed var(--color-border);
    border-radius: 0;
}

.pos-qty-edit:hover { border-bottom-color: var(--color-primary); }

/* ── Type-a-quantity keypad ──────────────────────────────── */

.pos-qtypad-value {
    margin: var(--space-3) 0;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    text-align: right;
    font-size: 28px;
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.pos-qtypad-unit {
    margin-left: var(--space-2);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-muted);
}

.pos-qtypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-2);
}

/* 56px, not the 36px the steppers use. This is a keypad someone types a
   weight into under time pressure, and the same 16px floor that stops iOS
   zooming an input applies to reading a digit at arm's length. */
.pos-qtypad-key {
    height: 56px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: 20px;
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    touch-action: manipulation;
}

.pos-qtypad-key:active { background: var(--color-bg); }

.pos-cart-totals {
    flex: 0 0 auto;
    padding: var(--space-3);
    border-top: 1px solid var(--color-border);
    background: var(--pos-total-bg);
}

/* Discount and Clear sale, side by side. auto-fit rather than a fixed 1fr 1fr
   because Discount is only rendered when the operator may give one, and a lone
   Clear sale should span the row rather than sit in a half-width stub. */
.pos-cart-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.pos-total-row {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-1);
}

.pos-total-row.is-grand {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}


/* ── Counter discounts ── */
/* Money off reads in the same colour as money back elsewhere in the app, so a
   discount and a refund look related rather than like an error. */
.pos-total-row.pos-total-discount {
    color: var(--color-success-text);
    font-weight: var(--font-weight-semibold);
}

.pos-discount-reason {
    font-weight: var(--font-weight-normal);
    color: var(--color-text-muted);
}

.pos-cart-line-discount {
    color: var(--color-success-text);
}

/* Sits with the row total rather than the quantity stepper: it changes what
   the line is worth, and belongs beside the figure it changes. */
.pos-line-discount-btn {
    display: block;
    margin-top: 2px;
    margin-left: auto;
    padding: 0 var(--space-2);
    min-height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.pos-line-discount-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* A preset is two lines — what it's for, then what it does — so the button
   stacks rather than inheriting pos-denom-btn's single centred figure. */
.pos-denom-btn.pos-discount-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-2);
}

.pos-discount-preset-label {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: 1.1;
}

.pos-discount-preset-value {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-normal);
    color: var(--color-text-muted);
}

.pos-discount-custom-label {
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.pos-discount-custom {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

/* A segmented pair, not two loose buttons — they are one choice. */
.pos-discount-mode {
    display: flex;
    flex: 0 0 auto;
}

.pos-discount-mode-btn {
    min-width: 52px;
    min-height: 56px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.pos-discount-mode-btn:first-child {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.pos-discount-mode-btn:last-child {
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    margin-left: -1px; /* one shared border, not two touching */
}

.pos-discount-mode-btn.is-active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    position: relative; /* keep the active edge above its neighbour */
}

/* Not .form-control: that is 40px tall and sits half the height of the
   buttons either side of it. The till's own controls are 56px. */
.pos-discount-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 56px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    text-align: right;
}

.pos-discount-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.pos-sheet-actions.is-single {
    grid-template-columns: 1fr;
}

.pos-discount-warning {
    margin-top: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--color-warning);
    border-radius: var(--radius-sm);
    background: var(--color-warning-light);
    color: var(--color-warning-text);
    font-size: var(--font-size-xs);
}

.pos-sheet-note {
    margin: var(--space-3) 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.pos-discount-approval {
    margin-bottom: var(--space-3);
}

.pos-discount-approval-label {
    display: block;
    margin-bottom: var(--space-1);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}


.pos-pay-btn {
    width: 100%;
    min-height: 56px;
    margin-top: var(--space-3);
    border: none;
    border-radius: var(--radius-lg);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
}

.pos-pay-btn:disabled {
    background: var(--color-border);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* ── Tender pad ──────────────────────────────────────────── */

.pos-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.pos-sheet {
    width: 100%;
    max-width: 520px;
    max-height: 92svh;
    overflow-y: auto;
    background: var(--color-surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-4);
    /* Clears the iOS home indicator so the confirm button is reachable. */
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 640px) {
    .pos-sheet-backdrop { align-items: center; }
    .pos-sheet { border-radius: var(--radius-lg); }
}

.pos-sheet-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-3);
}

.pos-method-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.pos-method-btn {
    min-height: 56px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.pos-method-btn.is-active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.pos-denoms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.pos-denom-btn {
    min-height: 56px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.pos-denom-btn:active { transform: scale(0.97); }

.pos-denom-btn.is-exact {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pos-tender-input {
    width: 100%;
    min-height: 56px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    text-align: right;
    background: var(--color-surface);
    color: var(--color-text-primary);
}

/* A manager's override PIN, on the till open/close sheets and the
   refund panel. Its own class rather than .pos-search-input so the
   16px is stated here too: this box is typed on a phone held by
   someone leaning over the counter mid-queue, and an iOS auto-zoom
   at that moment loses the sheet's scroll position. Never lower it —
   see the blanket floor near the top of this file.

   Wide letter-spacing because the value is masked: with the digits
   hidden, the dots are the only feedback that a keypress landed. */
.pos-pin-input {
    width: 100%;
    min-height: 48px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 16px;
    letter-spacing: 0.35em;
    background: var(--color-surface);
    color: var(--color-text-primary);
}

/* The number the cashier actually acts on — deliberately the
   biggest thing on the screen. */
.pos-change {
    margin: var(--space-3) 0;
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--color-success-light);
    color: var(--color-success-text);
    text-align: center;
}

.pos-change-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.pos-change-value {
    font-size: 2.25rem;
    font-weight: var(--font-weight-bold);
    line-height: 1.1;
}

.pos-change.is-short {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.pos-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.pos-sheet-btn {
    min-height: 56px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

/* Icon-only variant — the base button assumes a text label, which leaves a
   lone SVG sitting off-centre. */
.pos-sheet-btn.is-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.pos-sheet-btn.is-primary {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}

.pos-sheet-btn.is-primary:disabled {
    background: var(--color-border);
    border-color: var(--color-border);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

/* An out-of-stock extra, greyed the same way its tile is — the refusal has
   to be visible before the tap, not arrive afterwards as a toast. */
.pos-sheet-btn.is-blocked {
    opacity: 0.45;
    cursor: not-allowed;
}

.pos-sheet-error {
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-danger-light);
    color: var(--color-danger);
    font-size: var(--font-size-sm);
}

/* ── Edit mode (tile board editor) ───────────────────────── */

/* An explicit mode, not a long-press: HTML5 drag events don't fire
   on touch at all, so arranging uses pointer events and has to be
   unambiguously separate from tapping to sell. */
.pos-arrange-banner {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.pos-tile.is-dragging {
    opacity: 0.5;
    /* Stops the browser from scrolling/selecting mid-drag. */
    touch-action: none;
}

.pos-tile.is-drop-target {
    outline: 2px dashed var(--color-primary);
    outline-offset: 2px;
}

/* Drag is started from a handle, NOT from the tile body.
   `touch-action:none` is what lets a touch drag happen at all — but put
   it on the whole tile and the browser stops treating any touch that
   starts on a tile as a scroll, so a board of 50 products becomes
   impossible to scroll on a phone (you'd have to find the gaps between
   tiles). Confining it to a small handle gives both: drag from the
   handle, scroll from anywhere else. */
.pos-tile-handle {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 2;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.85);
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

.pos-tile-handle:active { cursor: grabbing; }

.pos-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.pos-swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
}

.pos-swatch.is-active { border-color: var(--color-text-primary); }

/* ── Edit mode: stacked group sections ───────────────────── */

/* Edit mode replaces the tabs with every group stacked down one
   scroller. That is what makes a cross-group drag possible at all —
   you cannot drop a tile onto a group that a tab is hiding. */
.pos-sections {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--space-3);
    background: var(--pos-board-bg);
}

.pos-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    overflow: hidden;
}

.pos-section + .pos-section,
.pos-section-add { margin-top: var(--space-3); }

.pos-section.is-dragging { opacity: 0.5; }

.pos-section.is-drop-target {
    outline: 2px dashed var(--color-primary);
    outline-offset: 2px;
}

.pos-section-head {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--pos-chrome);
    border-bottom: 1px solid var(--color-border);
    /* Carries the group's own colour as a stripe. The tabs signalled it
       with a border colour; a stacked header has no equivalent edge, and
       without it a recoloured group looks identical to every other one. */
    border-left: 4px solid transparent;
}

.pos-section-name {
    flex: 1 1 auto;
    /* Same load-bearing min-width as .pos-topbar-title: without it a long
       group name refuses to shrink and pushes the buttons off a phone. */
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* Same story as .pos-tile-handle above: `touch-action:none` is confined
   to the grip. Put it on the header and a board of ten groups becomes
   nearly unscrollable on a phone, because the headers are most of what
   a thumb lands on. */
.pos-section-grip {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1;
    cursor: grab;
    touch-action: none;
}

.pos-section-grip:active { cursor: grabbing; }

.pos-section-btn {
    flex: 0 0 auto;
    min-width: 40px;
    min-height: 40px;
    padding: 0 var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}

.pos-section-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.pos-section-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-3);
    padding: var(--space-3);
    align-content: start;
}

/* An empty group still needs a body: it is the target you drag the
   first tile onto, and for Ungrouped it is how a tile gets back out of
   a group without opening the picker. */
.pos-section-empty {
    grid-column: 1 / -1;
    padding: var(--space-5) var(--space-3);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.pos-section-empty.is-drop-target {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pos-section-add {
    width: 100%;
    min-height: 48px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}

/* ── Receipt (print only) ────────────────────────────────── */

.pos-receipt { display: none; }

/* Without this the receipt lays out as a 72mm column in the middle of an
   A4 sheet, with Chrome's own URL/date/page-number headers around it —
   which is what every receipt printed before this rule existed.
   `margin: 0` is also what makes Chrome drop those headers.
   Caveat: `size` sets OUR page box and is only a HINT to the print
   dialog's paper picker. It cannot force the physical paper, and the
   operator can always override it. */
@page {
    size: 72mm auto;
    margin: 0;
}

@media print {
    .pos-shell, .pos-sheet-backdrop { display: none !important; }

    /* Each receipt starts a new slip. Rendering the block more than once
       is the ONLY way to get multiple copies from a browser — there is
       no web API for copy count — so the kitchen slip is a second
       .pos-receipt in the DOM, not a printer setting. */
    .pos-receipt + .pos-receipt { break-before: page; }

    .pos-receipt {
        display: block;
        width: 72mm;
        margin: 0 auto;
        font-family: ui-monospace, "Courier New", monospace;
        font-size: 12px;
        color: #000;
    }

    .pos-receipt-center { text-align: center; }
    .pos-receipt-line {
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }
    .pos-receipt-rule {
        border-top: 1px dashed #000;
        margin: 6px 0;
    }

    /* Extras and removal notes hang off the line above them. */
    .pos-receipt-line.is-modifier {
        padding-left: 10px;
        font-size: 11px;
    }
    .pos-receipt-total {
        font-weight: bold;
        font-size: 14px;
    }

    /* Sized so the modules stay chunky enough for a phone camera to resolve
       off thermal paper — a full-width QR on a 72mm roll prints too fine. */
    .pos-receipt-qr {
        width: 30mm;
        height: 30mm;
        margin: 6px auto 2px;
        display: block;
    }
}

/* ── Phone layout ────────────────────────────────────────── */

@media (max-width: 860px) {
    /* The cart becomes a bottom sheet: on a phone the board needs the
       whole width, and a 380px side panel would leave ~40px of tiles. */
    .pos-body { flex-direction: column; }

    /* 62svh, not 45. The cart's FIXED furniture -- a 44px toggle plus a totals
       block that reaches 267px once the sale can be discounted -- came to
       311px on its own, while 45svh is 256px on a 568px phone and 300px on a
       667px one. The lines list is the only child that can shrink (its
       overflow-y lets its automatic minimum size collapse to zero), so it
       absorbed the whole shortfall: measured at 12px, a sliver of one 57px
       row, on every phone up to 720px tall. The overflow also pushed Clear
       sale past the bottom of a screen that does not scroll, so it could not
       be reached at all.

       Shrinking the furniture was the other half of this -- see
       .pos-cart-actions, which put Discount and Clear on one row. Together
       they leave roughly two rows visible on the shortest phone and four on a
       tall one, with nothing overflowing. */
    .pos-cart {
        flex: 0 0 auto;
        max-height: 62svh;
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    /* Keeps the secondary actions above the 44px touch minimum while giving
       the lines list back 16px. Scoped to the cart: the sheets use the full
       56px, where there is no competition for the space. */
    .pos-cart-totals .pos-sheet-btn { min-height: 48px; }

    /* Collapsed, the cart is just its totals + Pay button — which is all
       a cashier needs while they're still adding items, and it hands the
       rest of a short screen back to the board. */
    .pos-cart.is-collapsed { max-height: none; }
    .pos-cart.is-collapsed .pos-cart-lines { display: none; }

    .pos-tiles,
    .pos-section-tiles {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    }

    /* 36px is fine for a mouse and too small for a thumb, and these two
       sit right next to each other — a mis-tap here changes what the
       customer is charged. */
    .pos-qty-btn { width: 44px; height: 44px; }
}

/* Phone-width topbar. Below this the business name is the first thing
   to go: the cashier knows which shop they're standing in, and the
   actions have to stay reachable. */
@media (max-width: 560px) {
    .pos-topbar { gap: var(--space-2); padding: var(--space-2) var(--space-3); }
    .pos-topbar-title { display: none; }
    .pos-topbar-btn { padding: 0 var(--space-2); font-size: var(--font-size-xs); }
    .pos-till-pill { padding: var(--space-1) var(--space-2); }
}

/* The cart's collapse handle — only ever shown on phone layouts, where
   .pos-cart is a bottom sheet rather than a side rail. */
.pos-cart-toggle { display: none; }

@media (max-width: 860px) {
    .pos-cart-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-2);
        width: 100%;
        min-height: 44px;
        padding: 0 var(--space-3);
        border: none;
        border-bottom: 1px solid var(--color-border);
        background: var(--color-bg);
        color: var(--color-text-secondary);
        font-size: var(--font-size-sm);
        font-weight: var(--font-weight-medium);
        cursor: pointer;
    }
}

/* ── Recipe sheet rows ─────────────────────────────────────
   A list row, not a button. pos-sheet-btn is an ACTION style —
   using it here made six identical full-width slabs with no
   hierarchy, so the Extras heading read as just more ingredients.
   These sit quieter and let the section titles carry the structure. */
.pos-ingredient-row {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    margin-bottom: var(--space-2);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    color: var(--color-text-primary);
    text-align: left;
    /* Not `pointer` any more: neither list's row is clickable itself — both
       carry their own −/+ buttons, and a hand cursor over dead space is a
       promise the row can't keep. */
    cursor: default;
}

/* Name plus its one-line status, stacked. min-width:0 is what lets the
   name's ellipsis actually work inside a flex row. */
.pos-ingredient-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pos-ingredient-name {
    font-weight: var(--font-weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* What this row is currently doing — left out, bumped, or why it can't be
   bumped. Wraps rather than ellipsing: a blocked reason the cashier can
   only read half of is no reason at all. */
.pos-ingredient-note {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* The action, not the state — kept quiet so the name reads first. */
.pos-ingredient-action {
    flex: 0 0 auto;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
}

/* Left out: struck through, so the basket reads at a glance. */
.pos-ingredient-row.is-removed {
    background: var(--color-danger-light);
    border-color: var(--color-danger-text);
}

.pos-ingredient-row.is-removed .pos-ingredient-name {
    text-decoration: line-through;
    color: var(--color-danger-text);
}

.pos-ingredient-row.is-removed .pos-ingredient-note {
    color: var(--color-danger-text);
}

/* Bumped above what the recipe says — the surplus is a charged extra, so it
   reads in the same green as an added one. */
.pos-ingredient-row.is-added .pos-ingredient-note {
    color: var(--color-success-text);
    font-weight: var(--font-weight-medium);
}

.pos-ingredient-row.is-removed .pos-ingredient-action {
    color: var(--color-danger-text);
    font-weight: var(--font-weight-semibold);
}

/* Added as a paid extra. */
.pos-ingredient-row.is-added {
    background: var(--color-success-light);
    border-color: var(--color-success-text);
}

.pos-ingredient-row.is-added .pos-ingredient-action {
    color: var(--color-success-text);
    font-weight: var(--font-weight-semibold);
}

.pos-ingredient-row.is-blocked {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Sticky sheet footer.
   Opt-in rather than applied to every .pos-sheet-actions: only the
   modifier sheet is long enough to need it, and the tender and
   sale-complete sheets have content BELOW their actions row that a
   sticky footer would sit on top of.

   The negative bottom cancels .pos-sheet's own padding so the bar sits
   flush against the sheet edge, and the padding is re-added inside it —
   including the iOS home-indicator inset, which is why the sheet has
   that padding in the first place. */
.pos-sheet-actions.is-sticky {
    position: sticky;
    bottom: calc(-1 * (var(--space-4) + env(safe-area-inset-bottom, 0px)));
    z-index: 2;
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

/* ── Edit mode: the till's own cash buttons ──────────────── */

/* Sits under the tile options in the Arrange panel, and stays put
   while tiles are tapped — it is about the counter, not about any
   one tile. The top rule is what separates it from the tile block
   above when a tile happens to be selected. */
.pos-arrange-section {
    padding: var(--space-3);
    border-top: 1px solid var(--color-border);
}

.pos-note-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

/* Reads as the button it is going to become on the cash screen. */
.pos-note-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-alt, var(--color-surface));
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 28px, not the 44px a primary control gets: it removes a note that
   is one tap to put back, and at full size it competes with the
   value beside it for the thumb. */
.pos-note-chip-x {
    min-width: 28px;
    min-height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    line-height: 1;
    cursor: pointer;
}

.pos-note-chip-x:hover { color: var(--color-danger); }

/* The field takes the room and the button takes what it needs, so a
   narrow till panel never wraps Add onto its own line. 16px on the
   input is the iOS zoom floor — see the note on .pos-tender-input. */
.pos-note-add {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.pos-note-add .form-control {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 16px;
}

.pos-note-add .pos-sheet-btn { flex: 0 0 auto; }
