/* =============================================================================
   css/components.css
   Every reusable piece of the app, styled once, in one section each.

   How this file is meant to be used (docs/05-ux-spec.md section 8):

     * Changing how a button looks anywhere in the app means editing the .btn
       section below, and nothing else.
     * Every value is a var() from tokens.css. No raw colours, no raw sizes.
     * Screen files position these. They never restyle them.
     * Class names are a contract. JavaScript must hook onto data-* attributes
       instead, so that renaming or restyling a class cannot break behaviour.

   Phase 0 shipped the components the app shell and the back office need. The
   login module added the number pad, the PIN dots and the staff tile. The
   catalog cache added the item tile, the tile grid and the chip row (the
   product browser). The Sell screen added the bottom sheet, the bill line,
   the bill totals, the segmented control, the tappable amount, the unit
   option, the pick list and the saved overlay.
   ============================================================================= */


/* =============================================================================
   ICON
   Lucide, drawn from one sprite file (docs/05-ux-spec.md section 7):
     <svg class="icon"><use href="assets/icons/lucide-sprite.svg#package"/></svg>
   Icons take their colour from the text around them, so a button does not have
   to style its icon separately.
   ============================================================================= */

.icon {
  width: var(--icon-size, 24px);
  height: var(--icon-size, 24px);
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--small { --icon-size: 20px; }
.icon--large { --icon-size: 32px; }
.icon--huge  { --icon-size: 48px; }


/* =============================================================================
   BUTTON
   Every button in the app. An icon next to every label is the house rule
   (docs/05-ux-spec.md rule 2.8), which is why .btn is a flex row by default.

   Sizes are not decoration. 56px is the floor for anything tappable and 64px
   is for the primary action on a counter screen (rule 2.2). Design polish
   later may change colour and radius freely; it must not shrink these.
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: var(--space-2) var(--space-4);

  font-size: var(--text-body);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  text-align: center;
  text-decoration: none;

  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);

  cursor: pointer;
  transition: background var(--speed-fast) ease, border-color var(--speed-fast) ease;
}

.btn:hover:not(:disabled) {
  background: var(--color-surface-sunken);
}

/* The pressed state does the work that hover does on a laptop, because the
   counter is all touch and hover never happens there (rule 2.10). */
.btn:active:not(:disabled) {
  background: var(--color-border);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Variants ------------------------------------------------------------- */

.btn--primary {
  color: var(--color-on-primary);
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn--primary:active:not(:disabled) { background: var(--color-primary-dark); }

.btn--danger {
  color: var(--color-text-inverse);
  background: var(--color-danger);
  border-color: var(--color-danger);
}
.btn--danger:hover:not(:disabled),
.btn--danger:active:not(:disabled) { filter: brightness(0.92); }

/* Quiet button for the less important of two choices. Still full tap size. */
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-primary);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-primary-faint); }

/* --- Sizes ---------------------------------------------------------------- */

.btn--lg {
  min-height: var(--tap-primary);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
}

.btn--block {
  display: flex;
  width: 100%;
}

/* An icon on its own, such as the header menu. The label still exists for
   screen readers via .sr-only; it is only hidden from sight. */
.btn--icon {
  padding: var(--space-2);
  width: var(--tap-min);
}

/* --- Hold to confirm ------------------------------------------------------
   Open Day, Close Day and Void ask for a two second press rather than a second
   dialog (rule 2.6). The ring fills while the finger is down and resets if it
   lifts early.

   JavaScript sets --hold-progress from 0 to 1 on the button. That is the one
   kind of inline style the rules allow, because it is a live value rather than
   a look (docs/05-ux-spec.md section 8).
   -------------------------------------------------------------------------- */

.btn--hold {
  position: relative;
  /* A two second press must never become the browser's own long press:
     no text selection, no context menu, no scroll starting under the thumb. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Feedback while the finger is down (set by js/ui/hold.js). */
.btn--hold[data-holding] {
  filter: brightness(0.92);
}

.btn__ring {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  /* Filled portion in the current text colour, the rest a faint track. */
  background: conic-gradient(
    currentColor calc(var(--hold-progress, 0) * 360deg),
    rgba(255, 255, 255, 0.35) 0
  );
  /* Punch out the middle so it reads as a ring, not a pie. */
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
  mask: radial-gradient(circle, transparent 58%, #000 60%);
}

/* On a light button the faint track needs to be dark, not white. */
.btn:not(.btn--primary):not(.btn--danger) .btn__ring {
  background: conic-gradient(
    currentColor calc(var(--hold-progress, 0) * 360deg),
    var(--color-border) 0
  );
}


/* =============================================================================
   INPUT AND FIELD
   Text entry. Note that on counter screens numbers are never typed here: they
   go through the app's own number pad (rule 2.3). This is for the search box,
   names, references and notes.
   ============================================================================= */

.input {
  display: block;
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);

  font-size: var(--text-body);
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
}

.input::placeholder {
  color: var(--color-text-faint);
}

.input:disabled {
  background: var(--color-surface-sunken);
  color: var(--color-text-faint);
}

.input--invalid {
  border-color: var(--color-danger);
}

.input--search {
  font-size: var(--text-line);
}

/* The browser draws its own clear (x) inside a search box; the app draws a
   56px one instead, because the built-in one is too small to tap. */
.input--search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}

textarea.input {
  min-height: calc(var(--tap-min) * 2);
  resize: vertical;
}

/* A label, its control, and room for a message underneath. */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.field__hint {
  font-size: var(--text-small);
  color: var(--color-text-faint);
}

/* The same line turned into a warning while what was typed is wrong:
   "That is 11 digits. A phone number is ten…" (CUST-01). */
.field__hint--warning {
  color: var(--color-warning);
  font-weight: var(--font-medium);
}

.field__error {
  font-size: var(--text-small);
  color: var(--color-danger);
}

/* A field that appears because of something the person just did, and must
   be noticed: the "why did the price change?" box on the item form. Boxed
   in the brand colour so it reads as new, not as part of the form. */
.field--notice {
  padding: var(--space-3);
  background: var(--color-primary-faint);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
}

.field--notice .field__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-primary-dark);
}


/* =============================================================================
   CARD
   A panel. Dashboard figures, a supplier's details, a group of settings.
   ============================================================================= */

.card {
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.card--flat {
  box-shadow: none;
  border: var(--border-width) solid var(--color-border);
}

/* A whole card that can be tapped, such as a dashboard figure that opens its
   screen. Kept at full tap height. */
.card--tappable {
  display: block;
  width: 100%;
  min-height: var(--tap-min);
  text-align: left;
  border: none;
  cursor: pointer;
}

.card__title {
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

/* The number on a dashboard card. Big, and lined up with its neighbours. */
.card__value {
  font-size: var(--text-title);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  font-variant-numeric: tabular-nums;
}

.card__note {
  font-size: var(--text-small);
  color: var(--color-text-faint);
}


/* =============================================================================
   BADGE
   A short status word: VOID on a bill, "credit", "low", "not counted".
   ============================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);

  font-size: var(--text-small);
  font-weight: var(--font-medium);
  white-space: nowrap;

  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
}

.badge--success { color: var(--color-success); background: var(--color-success-faint); border-color: var(--color-success-faint); }
.badge--warning { color: var(--color-warning); background: var(--color-warning-faint); border-color: var(--color-warning-faint); }
.badge--danger  { color: var(--color-danger);  background: var(--color-danger-faint);  border-color: var(--color-danger-faint); }
.badge--info    { color: var(--color-primary); background: var(--color-primary-faint); border-color: var(--color-primary-light); }


/* =============================================================================
   CHIP
   A tappable filter, such as the category row on Sell, and the removable
   alias tags on the Add Item form.

   The default is full tap height because its main home is a counter screen.
   .chip--small is for forms, which are not counter screens and where a row of
   56px tags would swamp the page.
   ============================================================================= */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-4);

  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed='true'],
.chip--selected {
  color: var(--color-on-primary);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.chip--small {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-small);
}


/* =============================================================================
   SYNC DOT
   The header's standing answer to "is my work safe?" (SYNC-04, rule 2.5).
   Never shown on its own: it always sits next to words, because a coloured
   dot alone means nothing to someone who has not been told what it means.
   ============================================================================= */

.dot {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--color-text-faint);
}

.dot--ok      { background: var(--color-success); }
.dot--waiting { background: var(--color-warning); }
.dot--offline { background: var(--color-danger); }

/* A person's tile colour, next to their name in the header (AUTH-02). */
.dot--person  { background: var(--tile-colour, var(--color-primary)); }


/* =============================================================================
   TABLE
   Lists in the back office and reports. Rows are tall enough to tap on a
   phone, and figures are right aligned with .num--right from base.css.
   ============================================================================= */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body);
}

.table th,
.table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: var(--border-width) solid var(--color-border);
}

.table th {
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  white-space: nowrap;
}

/* Long lists keep their headings in view while scrolling. */
.table--sticky th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.table tbody tr {
  min-height: var(--tap-min);
}

.table--tappable tbody tr {
  cursor: pointer;
}

.table--tappable tbody tr:hover {
  background: var(--color-primary-faint);
}


/* =============================================================================
   DIALOG
   Confirmations, Open Day, Close Day. Built on the browser's own <dialog>, so
   it traps focus and closes on Escape without any code of ours.

   Rule 2.6: a destructive action asks once, and the safe option sits on the
   left and is the larger of the two. .dialog__actions does that by giving the
   first button the room.
   ============================================================================= */

.dialog {
  width: min(560px, calc(100vw - var(--space-6)));
  padding: 0;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

.dialog::backdrop {
  background: rgba(32, 33, 36, 0.5);
}

/* An open dialog never grows past the screen: its body scrolls instead,
   and buttons placed after the body (the sync dialog's Close and Send now)
   stay in view. On the tablet the sync dialog with two full lists was
   taller than the screen and the browser scrolled the whole box, leaving
   the buttons half cut off (19 September 2026). */
.dialog[open] {
  display: flex;
  flex-direction: column;
  max-height: calc(var(--app-height, 100dvh) - var(--space-6));
}

.dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.dialog__head,
.dialog > .dialog__actions {
  flex: none;
}

.dialog__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

/* The optional X in the corner (js/ui/dialog.js, closable). */
.dialog__close {
  margin-left: auto;
}

/* Open Day and Close Day put the figures beside the number pad, so they
   need more than the width of a question. */
.dialog--wide {
  width: min(960px, calc(100vw - var(--space-6)));
}

.dialog__title {
  flex: 1 1 auto;
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
}

.dialog__body {
  padding: 0 var(--space-5);
  font-size: var(--text-body);
}

.dialog__actions {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-5);
}

/* The safe choice comes first in the markup and takes the extra width. */
.dialog__actions > :first-child {
  flex: 2 1 0;
}

.dialog__actions > :last-child {
  flex: 1 1 0;
}

/* Actions drawn inside the body already sit within its side padding. */
.dialog__body > .dialog__actions {
  padding-left: 0;
  padding-right: 0;
}


/* =============================================================================
   TOAST
   Nothing happens silently (rule 2.5). Saved, queued, offline and failed all
   say so here, in plain words, above everything else on screen.
   ============================================================================= */

.toast-area {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: var(--z-toast);

  /* The strip is shown as a popover so it sits above dialogs and sheets
     (js/ui/toast.js). The browser's own popover styling is a centred box
     with a border and a white background; take that off. */
  inset: auto auto var(--space-5) 50%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  overflow: visible;
  height: auto;

  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;

  width: max-content;
  max-width: calc(100vw - var(--space-6));
  pointer-events: none;   /* taps pass through to the screen underneath */
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);

  font-size: var(--text-body);
  color: var(--color-text-inverse);
  background: var(--navy-900);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-raised);
  pointer-events: auto;   /* but the toast's own Retry button is tappable */
}

.toast--success { background: var(--color-success); }
.toast--warning { background: var(--color-warning); }
.toast--danger  { background: var(--color-danger); }

.toast__action {
  margin-left: var(--space-2);
  padding: var(--space-1) var(--space-2);
  color: inherit;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
}


/* =============================================================================
   EMPTY STATE
   Every list has one: an icon, one sentence, and the action that fills it
   (docs/05-ux-spec.md section 11). Never a blank screen.
   ============================================================================= */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
}

.empty .icon {
  color: var(--color-text-faint);
}

.empty__message {
  font-size: var(--text-line);
  max-width: 34ch;
}


/* =============================================================================
   SPINNER
   For the one or two places something genuinely takes a moment, such as the
   first catalog download. Short waits show nothing at all: a flash of spinner
   is worse than no spinner.
   ============================================================================= */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* =============================================================================
   NUMBER PAD
   The app's own keys for every number typed on a counter screen
   (docs/05-ux-spec.md rule 2.3). Drawn by js/ui/numpad.js. Three columns of
   digits, a bottom row of [decimal or clear] [0] [backspace], and an optional
   side column when a pad needs more than that.

   The keys are the largest tap targets in the app after the Save button:
   a finger has to land on the right digit first time while the customer
   waits.
   ============================================================================= */

.numpad {
  display: flex;
  gap: var(--space-2);
  --numpad-key: 72px;
}

.numpad__keys {
  display: grid;
  grid-template-columns: repeat(3, var(--numpad-key));
  grid-auto-rows: var(--numpad-key);
  gap: var(--space-2);
}

.numpad__side {
  display: grid;
  grid-auto-rows: var(--numpad-key);
  width: var(--numpad-key);
  gap: var(--space-2);
}

.numpad__key {
  display: flex;
  align-items: center;
  justify-content: center;

  font-size: var(--text-title);
  font-weight: var(--font-medium);
  font-variant-numeric: tabular-nums;

  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);

  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;   /* no double-tap zoom on a fast second press */
  transition: background var(--speed-fast) ease;
}

.numpad__key:active {
  background: var(--color-primary-light);
}

/* Backspace, clear and enter are quieter than the digits. */
.numpad__key--backspace,
.numpad__key--clear {
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
}

.numpad__key--enter {
  color: var(--color-on-primary);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

/* The bottom left slot when there is nothing to put in it. */
.numpad__key--empty {
  visibility: hidden;
}

/* Inside a dialog the keys are a little smaller so the pad, the figures and
   the hold button all fit the tablet's height without scrolling. Still well
   over the 56px minimum. */
.numpad--compact {
  --numpad-key: 64px;
}

/* On a phone the keys shrink a little so three columns fit with margins. */
@media (max-width: 480px) {
  .numpad {
    --numpad-key: 64px;
  }
}


/* =============================================================================
   AMOUNT
   A large figure with a label over it: the float at Open Day, the count at
   Close Day, the cash tendered at payment (PAY-01). It is a display, not an
   input: the number pad next to it is what changes it (rule 2.3).
   ============================================================================= */

.amount {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
}

.amount__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.amount__value {
  font-size: var(--text-total);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  white-space: nowrap;
}


/* =============================================================================
   SUMMARY
   Label on the left, figure on the right, one line each: the Close Day
   figures (DAY-07) and the Day report (REP-02). A --sub row is a part of the
   row above it; a --total row is the answer at the bottom.
   ============================================================================= */

.summary {
  display: flex;
  flex-direction: column;
}

.summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-1) 0;
  font-size: var(--text-body);
  border-bottom: var(--border-width) solid var(--color-border);
}

.summary__row--sub {
  padding-left: var(--space-5);
  color: var(--color-text-muted);
  border-bottom: none;
}

.summary__row--float {
  color: var(--color-text-muted);
}

.summary__row--total {
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  font-size: var(--text-line);
  font-weight: var(--font-bold);
  border-top: 2px solid var(--color-text);
  border-bottom: none;
}

.summary__label {
  flex: 1 1 auto;
}

.summary__value {
  flex: none;
  white-space: nowrap;
}


/* =============================================================================
   FIGURE
   A result that is good, neutral or bad, said in words with a colour behind
   them: the Close Day difference in green (over), grey (exact) or red
   (short) (DAY-03). The words carry the meaning; the colour only agrees.
   ============================================================================= */

.figure {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);

  font-size: var(--text-line);
  font-weight: var(--font-bold);
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-sm);
}

.figure[data-kind='over'] {
  color: var(--color-success);
  background: var(--color-success-faint);
}

.figure[data-kind='short'] {
  color: var(--color-danger);
  background: var(--color-danger-faint);
}


/* =============================================================================
   BANNER
   A strip under the header that stays until the thing it names is dealt
   with: "Yesterday is still open" (DAY-06). One sentence and one button.
   ============================================================================= */

.banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;

  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text);
  background: var(--color-warning-faint);
  border-bottom: var(--border-width) solid var(--color-warning);
}

.banner__text {
  flex: 1 1 auto;
}

.banner .icon {
  color: var(--color-warning);
}

/* The same strip when it is information, not a warning: "Past bill for
   Fri 18 Sept 14:30" above the lines on Sell (BILL-05). */
.banner--info {
  background: var(--color-primary-faint);
  border-bottom-color: var(--color-primary-light);
}

.banner--info .icon {
  color: var(--color-primary);
}


/* =============================================================================
   PIN DOTS
   Four dots that fill as the PIN is typed (AUTH-02). The digits themselves
   are never shown (SEC-04). On a wrong PIN the row shakes and empties.
   ============================================================================= */

.pin-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  min-height: var(--space-6);
}

.pin-dots__dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--color-border-strong);
  background: transparent;
  transition: background var(--speed-fast) ease, border-color var(--speed-fast) ease;
}

.pin-dots__dot.is-filled {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.pin-dots.is-shaking {
  animation: shake 400ms ease;
}

.pin-dots.is-shaking .pin-dots__dot.is-filled {
  background: var(--color-danger);
  border-color: var(--color-danger);
}

@keyframes shake {
  10%, 90%       { transform: translateX(-2px); }
  20%, 80%       { transform: translateX(4px); }
  30%, 50%, 70%  { transform: translateX(-8px); }
  40%, 60%       { transform: translateX(8px); }
}


/* =============================================================================
   STAFF TILE
   One person on the login screen (AUTH-01): their colour, their initials,
   their first name and their role. --tile-colour is set on the element by
   the screen from the staff row; that is a value from the database, which
   is the one kind of inline style the rules allow.
   ============================================================================= */

.staff-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  position: relative;

  min-width: var(--tile-min-w);
  min-height: 152px;
  padding: var(--space-4);

  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);

  cursor: pointer;
  touch-action: manipulation;
  transition: border-color var(--speed-fast) ease, background var(--speed-fast) ease;
}

.staff-tile:active {
  background: var(--color-surface-sunken);
}

.staff-tile.is-selected {
  border-color: var(--tile-colour, var(--color-primary));
  background: var(--color-primary-faint);
}

/* The coloured circle with initials in it. */
.staff-tile__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-2);

  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  color: var(--color-text-inverse);
  background: var(--tile-colour, var(--color-primary));
  border-radius: 50%;
}

.staff-tile__name {
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
}

.staff-tile__role {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

/* Locked: greyed, with a lock and a countdown across the bottom. Still
   tappable, because a tap explains why (never silent, rule 2.5). */
.staff-tile.is-locked {
  color: var(--color-text-faint);
  background: var(--color-surface-sunken);
}

.staff-tile.is-locked .staff-tile__mark {
  filter: grayscale(1);
  opacity: 0.5;
}

.staff-tile__lock {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-1);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  font-variant-numeric: tabular-nums;
  color: var(--color-danger);
}

/* display: flex above would beat the hidden attribute; put it back. */
.staff-tile__lock[hidden] {
  display: none;
}


/* =============================================================================
   RESTRICTED CONTROL
   A button a Staff user may not use (AUTH-03). js/auth.js restrict() marks it
   aria-disabled and adds a small lock; the tap still lands and says "Ask the
   owner or admin". The greying comes from .btn[aria-disabled] above.
   ============================================================================= */

.btn [data-lock] {
  display: inline-flex;
  margin-left: var(--space-1);
  color: var(--color-text-muted);
}


/* =============================================================================
   CHIP ROW
   A single scrolling line of chips: the category filter on Sell (SELL-03).
   Horizontal scroll with no scrollbar, because twelve categories do not fit
   in the browser column at 1180 wide and wrapping would eat two rows of
   tiles. A finger drag scrolls it; that is a scroll, not a hidden gesture.
   ============================================================================= */

.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) 0;              /* room for the focus ring */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips > .chip {
  flex: none;
}


/* =============================================================================
   ITEM TILE
   One item in the product browser (docs/05-ux-spec.md section 4): name on up
   to two lines, the default price, the primary shelf code, and a small note
   about stock ("12 pcs", "not counted", or "low" in orange, SELL-13). The
   category icon stands in for the photo until photos exist (ITEM-11).

   At least 150 x 96 (rule 2.2). The whole tile is the tap target; a tap adds
   one, or opens the unit chooser (SELL-05). No long press (rule 2.10).
   ============================================================================= */

.tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
  container-type: inline-size;            /* the foot asks how wide the tile is */

  min-width: var(--tile-min-w);
  min-height: var(--tile-min-h);
  padding: var(--space-3);

  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);

  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--speed-fast) ease, background var(--speed-fast) ease;
}

.tile:active {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

/* A tile that stays chosen: the load picked on the Full load sheet
   (COMM-01). Grid tiles on Sell never set it. */
.tile[aria-pressed='true'] {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

/* "Something else": the last tile of a row, for what is not set up. */
.tile--other {
  border-style: dashed;
  box-shadow: none;
}

/* Name: two lines at most, then an ellipsis. 18px, the bill line size,
   because this is what Dad reads to decide whether to tap. */
.tile__name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding-right: calc(20px + var(--space-2));   /* room for the corner icon */

  font-size: var(--text-line);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  min-height: calc(var(--text-line) * var(--leading-tight) * 2);
}

.tile__price {
  font-size: var(--text-line);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-top: auto;                       /* pins the price to the bottom */
}

/* When there are several selling units the price shown is the default one,
   and a small "+" says there are more to choose from (SELL-05). */
.tile__more {
  font-size: var(--text-small);
  font-weight: var(--font-regular);
  color: var(--color-text-muted);
  margin-left: var(--space-1);
}

/* Shelf code and the stock note. Side by side, the widest pair ("R-R10-S1"
   and "not counted") needs about 160px of tile inside the padding, which
   neither the four-across Sell grid (130px) nor a phone's two-across grid
   (149px) has, so there they are two quiet lines. On a wider tile (a
   laptop, a three-across grid) they share one line. The tile answers
   which, not the screen, so the same tile is right wherever it is placed. */
.tile__foot {
  display: flex;
  flex-direction: column;
  font-size: var(--text-small);
  line-height: var(--leading-normal);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.tile__foot > * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@container (min-width: 164px) {
  .tile__foot {
    flex-direction: row;
    justify-content: space-between;
    gap: var(--space-2);
  }
}

.tile__stock[data-stock='low'] {
  color: var(--color-warning);
  font-weight: var(--font-medium);
}

.tile__stock[data-stock='negative'] {
  color: var(--color-danger);
  font-weight: var(--font-medium);
}

/* The category icon in the top right corner, faint, where a thumbnail will
   sit once photos exist. */
.tile__icon {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  color: var(--color-text-faint);
}

.tile__icon .icon {
  --icon-size: 20px;
}


/* =============================================================================
   TILE GRID
   The item tiles laid out as many per row as fit, every tile the same width.
   auto-fill with the tile's own minimum, so the number of columns comes
   from the space (four at 1180 in the 60% column, two on a phone) and never
   from a breakpoint.
   ============================================================================= */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min-w), 1fr));
  /* max-content, not auto: when the grid is the scrolling part of a column
     that is shorter than its contents, auto rows shrink to the tile's
     minimum height and the tile's text is cut off. */
  grid-auto-rows: max-content;
  gap: var(--space-3);
  align-items: stretch;
}


/* =============================================================================
   PRODUCT BROWSER
   The search box, the chip row and the tile grid stacked (js/ui/catalog-
   browser.js). The grid is the part that scrolls; the search and the chips
   stay put above it, so the box is always visible (rule 2.4). Whatever
   mounts the browser gives it a height; it fills that.
   ============================================================================= */

.browser {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
  height: 100%;
}

.browser__search {
  position: relative;
  flex: none;
}

.browser > .chips {
  flex: none;
}

.browser__search .input {
  padding-left: calc(var(--space-3) + 24px + var(--space-2));
  padding-right: var(--tap-min);
}

.browser__search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}

.browser__clear {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--color-text-muted);
}

/* .btn's display would beat the hidden attribute; put it back. */
.browser__clear[hidden] {
  display: none;
}

.browser__count {
  flex: none;
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-text-muted);
  min-height: 1.2em;
}

.browser > .tile-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  align-content: start;
  padding-bottom: var(--space-4);
  -webkit-overflow-scrolling: touch;
}


/* =============================================================================
   QUICK ITEMS
   The most sold items of the last 30 days in one sideways-scrolling row above
   the grid (SELL-04). The same tiles as the grid, so a tap does the same.
   ============================================================================= */

.quick {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: none;
  min-width: 0;
}

.quick__label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-small);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.quick__row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.quick__row > .tile {
  flex: none;
  width: var(--tile-min-w);
}


/* =============================================================================
   SHEET
   A panel that slides up from the bottom over the bill (docs/05-ux-spec.md
   section 4): the line editor (SELL-06) and the payment step (PAY-01). Built
   on <dialog> by js/ui/sheet.js, so the page behind dims and focus stays in.
   The slide is a transition on data-open, set a frame after it appears.
   ============================================================================= */

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  width: min(1180px, 100vw);
  max-width: 100vw;
  max-height: calc(100dvh - var(--tap-min));
  padding: 0;

  display: flex;
  flex-direction: column;

  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-sheet);

  transform: translateY(100%);
  transition: transform var(--speed-slow) ease-out;
}

.sheet[data-open] {
  transform: translateY(0);
}

.sheet::backdrop {
  background: rgba(32, 33, 36, 0.4);
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  padding: var(--space-4) var(--space-5) var(--space-2);
}

.sheet__title {
  flex: 1 1 auto;
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
}

.sheet__close {
  margin-left: auto;
}

/* Something in the title row beside the title, such as a search box. */
.sheet__head-extra {
  flex: 0 1 360px;
  min-width: 0;
}

.sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--space-5) var(--space-5);
  font-size: var(--text-body);
  -webkit-overflow-scrolling: touch;
}

/* A row of buttons at the foot of a sheet. The quiet choice comes first;
   the primary action takes the room and stands 64px tall (rule 2.2). */
.sheet__actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-4);
}

.sheet__actions > .btn--primary {
  flex: 2 1 0;
  min-height: var(--tap-primary);
}


/* =============================================================================
   BILL LINE
   One item on the bill (docs/05-ux-spec.md section 4): name and unit on the
   first line; quantity x price, the discount if any, and the line total on
   the second. 18px (rule 2.9). The whole line is the tap target and opens
   the line editor (SELL-06). A note underneath in orange says the stock will
   go negative (SELL-13); a small tag says the price is for this bill only
   (SELL-07).
   ============================================================================= */

.bill-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-3);
  align-items: baseline;
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);

  font: inherit;
  font-size: var(--text-line);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bill-line:active,
.bill-line[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

.bill-line__name {
  grid-column: 1;
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-line__unit {
  font-weight: var(--font-regular);
  color: var(--color-text-muted);
}

.bill-line__total {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* "2 x 1,600.00   -100.00" */
.bill-line__detail {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-body);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.bill-line__discount {
  color: var(--color-success);
}

/* More than half off the line (SELL-06): red and bold, so a slip of the
   finger (10% typed as 100%) is seen on the bill before Save. */
.bill-line__discount--big {
  color: var(--color-danger);
  font-weight: var(--font-bold);
}

.bill-line__tag {
  padding: 0 var(--space-2);
  font-size: var(--text-small);
  color: var(--color-primary-dark);
  background: var(--color-primary-faint);
  border-radius: var(--radius-pill);
}

/* SELL-13: "Stock will go to -2 pcs" in orange under the line. */
.bill-line__note {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-body);
  color: var(--color-warning);
}


/* =============================================================================
   BILL TOTALS
   The footer of the bill panel (SELL-09): subtotal, the discount (a button,
   because tapping it opens the discount pad, SELL-08), and TOTAL in the
   largest type on the screen (rule 2.9: 40px bold).
   ============================================================================= */

.bill-totals {
  display: flex;
  flex-direction: column;
  padding: var(--space-2) var(--space-3) 0;
  border-top: 2px solid var(--color-border);
}

.bill-totals__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  min-height: var(--space-6);
  font-size: var(--text-line);
  font-variant-numeric: tabular-nums;
}

.bill-totals__row--total {
  align-items: center;
  font-weight: var(--font-bold);
}

.bill-totals__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}

.bill-totals__row--total .bill-totals__label {
  font-size: var(--text-heading);
  color: var(--color-text);
}

.bill-totals__value {
  white-space: nowrap;
}

.bill-totals__row--total .bill-totals__value {
  font-size: var(--text-total);
  line-height: var(--leading-tight);
}

/* The discount row is a button: tap to give or change a discount. Drawn
   as one, with a border and a chevron, because a row of figures gives no
   hint that it can be tapped (found on the tablet, 19 September 2026). */
.bill-totals__discount {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--tap-min);
  width: 100%;
  margin: var(--space-1) 0;
  padding: 0 var(--space-3);

  font: inherit;
  font-size: var(--text-line);
  color: var(--color-text);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.bill-totals__discount:active {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

.bill-totals__discount:disabled {
  color: var(--color-text-faint);
  cursor: default;
}

.bill-totals__discount .bill-totals__label {
  color: var(--color-primary-dark);
  font-weight: var(--font-medium);
}

.bill-totals__discount:disabled .bill-totals__label {
  color: var(--color-text-faint);
}

.bill-totals__discount[data-given] .bill-totals__value {
  color: var(--color-success);
}

/* More than half off the bill (SELL-08), as on a line. */
.bill-totals__discount--big .bill-totals__value,
.bill-totals__discount--big[data-given] .bill-totals__value {
  color: var(--color-danger);
  font-weight: var(--font-bold);
}

/* The chevron after the figure, saying "there is more here". */
.bill-totals__discount .bill-totals__value {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}


/* =============================================================================
   SEGMENTED CONTROL
   A row of choices where exactly one is chosen: Cash / Transfer / Credit /
   Split (PAY-01), rupees / percent on a discount (SELL-08). Every option is
   a full 56px tap target with an icon and a word (rule 2.8).
   ============================================================================= */

.segmented {
  display: flex;
  gap: var(--space-2);
}

.segmented__option {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: 0 var(--space-3);

  font: inherit;
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  min-width: 0;
}

.segmented__option[aria-pressed='true'] {
  color: var(--color-primary-dark);
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

.segmented__option[aria-disabled='true'] {
  color: var(--color-text-faint);
}

/* Icon above the word, for a row that has to fit four choices in a narrow
   column: the payment row on the bill panel. Still 56px tall. */
.segmented--stacked .segmented__option {
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-1) var(--space-2);
  line-height: var(--leading-tight);
}


/* =============================================================================
   AMOUNT, TAPPABLE
   The .amount box from Day, made a button: in the line editor several sit in
   a row (quantity, price, discount) and tapping one points the number pad at
   it. The pressed one is outlined in the brand colour.
   ============================================================================= */

.amount--tappable {
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  border-width: 2px;
}

.amount--tappable[aria-pressed='true'] {
  border-color: var(--color-primary);
  background: var(--color-primary-faint);
}

/* Smaller than the Day figure, so several fit beside a number pad. */
.amount--small .amount__value {
  font-size: var(--text-title);
}

.amount--warning .amount__value {
  color: var(--color-warning);
}

/* The money to hand over after a refund (RET-02): as big as change due,
   because it is the same moment at the counter (rule 2.9). */
.amount--large .amount__value {
  font-size: var(--text-change);
}

.amount__hint {
  font-size: var(--text-body);
  color: var(--color-text-muted);
}


/* =============================================================================
   UNIT OPTION
   One choice in the selling unit chooser (SELL-05): the unit's label on the
   left, its price on the right, 64px tall so a choice is one clear tap.
   Also the unit switch in the line editor (SELL-06).
   ============================================================================= */

.unit-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  min-height: var(--tap-primary);
  padding: var(--space-2) var(--space-4);

  font: inherit;
  font-size: var(--text-line);
  font-weight: var(--font-medium);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;   /* it is sometimes a link (the header menu) */
}

.unit-option:active,
.unit-option[aria-pressed='true'] {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

/* A choice that cannot be taken just now (a closed day in the past-bill
   chooser, BILL-05). Still tappable: the tap says why. */
.unit-option[aria-disabled='true'] {
  color: var(--color-text-faint);
  background: var(--color-surface-sunken);
}

.unit-option__price {
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.unit-option__note {
  font-size: var(--text-body);
  font-weight: var(--font-regular);
  color: var(--color-text-muted);
}

/* A column of them. */
.unit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}


/* =============================================================================
   PICK LIST
   A short list to choose one of: the customer picker at payment (PAY-02),
   with a name and a phone on each row. Every row is a 56px tap target.
   ============================================================================= */

.pick-list {
  display: flex;
  flex-direction: column;
  max-height: calc(var(--tap-min) * 4);
  overflow-y: auto;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

.pick-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex: none;
  min-height: var(--tap-min);
  padding: 0 var(--space-4);

  font: inherit;
  font-size: var(--text-body);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
}

.pick-list__item:last-child {
  border-bottom: none;
}

.pick-list__item:active,
.pick-list__item[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

.pick-list__detail {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pick-list__empty {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
}


/* =============================================================================
   OVERLAY
   The saved summary after a bill (PAY-01, PAY-06): the total, the change due
   in the biggest type on any screen (48px, rule 2.9), the payment in words,
   and the buttons for what comes next. Shown for five seconds, or until
   tapped. Built on <dialog> like everything else that stops the screen.
   ============================================================================= */

.overlay {
  width: min(640px, calc(100vw - var(--space-6)));
  padding: var(--space-6) var(--space-5) var(--space-5);
  text-align: center;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
}

.overlay::backdrop {
  background: rgba(32, 33, 36, 0.5);
}

.overlay__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  color: var(--color-success);
}

.overlay__bill {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
}

.overlay__figures {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--space-6);
  margin: var(--space-5) 0;
}

.overlay__label {
  font-size: var(--text-body);
  color: var(--color-text-muted);
}

.overlay__total {
  white-space: nowrap;
  font-size: var(--text-total);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  font-variant-numeric: tabular-nums;
}

.overlay__change {
  white-space: nowrap;
  font-size: var(--text-change);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--color-success);
  font-variant-numeric: tabular-nums;
}

.overlay__payment {
  font-size: var(--text-line);
  color: var(--color-text-muted);
}

.overlay__actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.overlay__actions > .btn {
  flex: 1 1 0;
}

.overlay__actions > .btn--primary {
  flex: 2 1 0;
  min-height: var(--tap-primary);
}

/* A bill kept on the tablet has no number yet (PAY-05). Said in words with
   the waiting icon, in the warning colour the header dot uses for the same
   state, so the two agree. */
.overlay__pending {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-warning);
}


/* =============================================================================
   SYNC LIST
   What is still on the tablet and what has been sent (SYNC-04), in the
   dialog behind the header's cloud. One row per thing: an icon that says
   which state it is in, what it is, and a line underneath saying when and
   how it is doing. The colour repeats the icon's meaning; the words carry
   it (rule 2.5, nothing silent; rule 2.8, plain words).
   ============================================================================= */

.sync-dialog {
  width: min(560px, calc(100vw - var(--space-6)));
}

.sync-dialog__state {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-line);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunken);
}

.sync-dialog__state[data-kind='ok']      { color: var(--color-success); background: var(--color-success-faint); }
.sync-dialog__state[data-kind='waiting'] { color: var(--color-warning); background: var(--color-warning-faint); }
.sync-dialog__state[data-kind='offline'],
.sync-dialog__state[data-kind='failed']  { color: var(--color-danger);  background: var(--color-danger-faint); }

.sync-dialog__heading {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.sync-list {
  display: flex;
  flex-direction: column;
  max-height: calc(var(--tap-min) * 4);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

.sync-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
}

.sync-list__item:last-child {
  border-bottom: none;
}

.sync-list__item[data-kind='waiting'] > .icon,
.sync-list__item[data-kind='sending'] > .icon { color: var(--color-warning); }
.sync-list__item[data-kind='failed']  > .icon { color: var(--color-danger); }
.sync-list__item[data-kind='sent']    > .icon { color: var(--color-success); }

.sync-list__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sync-list__label {
  font-size: var(--text-body);
}

.sync-list__detail {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.sync-list__item[data-kind='failed'] .sync-list__detail {
  color: var(--color-danger);
}


/* =============================================================================
   BILL ROW
   One bill in the history list (BILL-01): number and time on the first
   line, who and what on the second, the total on the right, badges for
   anything out of the ordinary (credit, void, entered later, still on the
   tablet). A 56px tap target; tapping opens the bill.
   ============================================================================= */

.bill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-3);
  align-items: center;
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);

  font: inherit;
  font-size: var(--text-body);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bill-row:last-child {
  border-bottom: none;
}

.bill-row:active,
.bill-row[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

.bill-row__head {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  font-weight: var(--font-medium);
}

.bill-row__no {
  font-variant-numeric: tabular-nums;
}

.bill-row__time {
  color: var(--color-text-muted);
  font-weight: var(--font-regular);
}

.bill-row__detail {
  grid-column: 1;
  font-size: var(--text-small);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bill-row__total {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* A voided bill is still listed (BILL-03) but reads as struck through. */
.bill-row[data-voided='true'] .bill-row__no,
.bill-row[data-voided='true'] .bill-row__total {
  text-decoration: line-through;
  color: var(--color-text-faint);
}

/* A list of bill rows: a bordered box, like .pick-list, but it grows with
   the page rather than scrolling inside itself. */
.bill-list {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}

/* A heading inside the list: "On this tablet", "Fri 19 Sept". */
.bill-list__heading {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-small);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  background: var(--color-surface-sunken);
  border-bottom: var(--border-width) solid var(--color-border);
}


/* =============================================================================
   TIMELINE
   The story of one bill (BILL-02): made, sent to the cloud, paid, voided.
   Each event is an icon, the time and one sentence.
   ============================================================================= */

.timeline {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) 0;
  border-bottom: var(--border-width) solid var(--color-border);
}

.timeline__item:last-child {
  border-bottom: none;
}

.timeline__item > .icon {
  align-self: center;
  color: var(--color-text-muted);
}

.timeline__item[data-kind='sent'] > .icon    { color: var(--color-success); }
.timeline__item[data-kind='payment'] > .icon { color: var(--color-success); }
.timeline__item[data-kind='void'] > .icon    { color: var(--color-danger); }
.timeline__item[data-kind='later'] > .icon   { color: var(--color-warning); }

.timeline__when {
  font-size: var(--text-small);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline__text {
  font-size: var(--text-body);
  overflow-wrap: anywhere;
}

.timeline__item[data-kind='void'] .timeline__text {
  color: var(--color-danger);
}


/* =============================================================================
   BILL LINE, PLAIN
   The Sell screen's bill line used to show a saved bill (BILL-02): the same
   shape, but nothing happens when it is tapped.
   ============================================================================= */

.bill-line--plain,
.bill-line--plain:active {
  cursor: default;
  background: var(--color-surface);
}


/* =============================================================================
   DIALOG BODY, PADDED
   For a dialog whose buttons sit inside its body rather than in a
   .dialog__actions row (the Day, Void, past-bill and stock dialogs), so
   the last button never touches the bottom edge. Found on the tablet with
   bill history; noted in CLAUDE.md as the tidier way to do it.
   ============================================================================= */

.dialog__body--padded {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
}


/* =============================================================================
   FORM
   The back office forms: Add Item (docs/05-ux-spec.md section 5), and later
   purchases, expenses and suppliers. One column on a phone; .form__row puts
   two fields side by side from 768px. .form__section is a heading with a
   line under it, so a long form reads in parts.
   ============================================================================= */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .form__row {
    grid-template-columns: 1fr 1fr;
  }

  .form__row--three {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.form__section {
  margin: var(--space-2) 0 0;
  padding-bottom: var(--space-2);
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  border-bottom: var(--border-width) solid var(--color-border);
}

/* A field with a small control beside it: the category dropdown with its
   "+ New" button. */
.form__with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: end;
}

/* The dropdown looks like the text box: same height, same border, with
   the arrow drawn by the app rather than the browser. */
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: calc(var(--space-3) * 3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

/* A number box on a back office form: typed on the keyboard (it is not a
   counter screen), figures aligned right like a column of money. */
.input--number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.input[readonly] {
  background: var(--color-surface-sunken);
  color: var(--color-text-muted);
}


/* =============================================================================
   SWITCH
   An on/off control with the words beside it: "Track stock" on the Add Item
   form (ITEM-07). A button with aria-pressed, 56px tall to tap, with a small
   track and knob that slide.
   ============================================================================= */

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-min);
  padding: 0 var(--space-2);

  font: inherit;
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.switch__track {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  background: var(--color-border-strong);
  border-radius: var(--radius-pill);
  transition: background 120ms ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--color-on-primary);
  border-radius: 50%;
  box-shadow: var(--shadow-card);
  transition: transform 120ms ease;
}

.switch[aria-pressed='true'] .switch__track {
  background: var(--color-primary);
}

.switch[aria-pressed='true'] .switch__track::after {
  transform: translateX(20px);
}

.switch__note {
  font-weight: var(--font-regular);
  color: var(--color-text-muted);
}


/* =============================================================================
   CHIP INPUT
   Several short words typed one at a time: the aliases on an item
   (docs/05-ux-spec.md section 5, field 2). Type, Enter (or a comma), and a
   chip appears with an x to remove it.
   ============================================================================= */

.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: text;
}

.chip-input:focus-within {
  border-color: var(--color-focus);
}

.chip-input__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 36px;
  padding: 0 var(--space-1) 0 var(--space-3);
  font-size: var(--text-body);
  color: var(--color-primary-dark);
  background: var(--color-primary-faint);
  border-radius: var(--radius-pill);
}

.chip-input__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: inherit;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.chip-input__remove:active {
  background: var(--color-primary-light);
}

.chip-input__text {
  flex: 1 1 120px;
  min-width: 120px;
  min-height: 36px;
  font: inherit;
  font-size: var(--text-body);
  color: var(--color-text);
  background: none;
  border: none;
  outline: none;
}


/* =============================================================================
   REPEAT
   A block that appears once per thing and can be added to: the selling
   units and the locations on the Add Item form. Each block is a bordered
   box with its fields in a row and a remove button at the end.
   ============================================================================= */

.repeat {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.repeat__block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-sunken);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
}

.repeat__block[data-chosen='true'] {
  border-color: var(--color-primary);
}

.repeat__fields {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
  align-items: end;
}

/* Two fields: a supplier and their price (migration 016). */
.repeat__fields--two {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

@media (max-width: 480px) {
  .repeat__fields {
    grid-template-columns: 1fr 1fr;
  }

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

.repeat__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* The code preview on a location block: "R-R07-S2". */
.repeat__code {
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  color: var(--color-primary-dark);
}

/* The preset buttons above the selling units: "Each", "Per kg", ... */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}


/* =============================================================================
   SIMILAR
   The "Similar items" panel under the name box on Add Item (ITEM-06). A
   warning strip listing the items whose names are close; the one that is
   the same name in other spelling is in bold.
   ============================================================================= */

.similar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-warning-faint);
  border: var(--border-width) solid var(--color-warning);
  border-radius: var(--radius-sm);
}

.similar__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-body);
  font-weight: var(--font-medium);
  color: var(--color-warning);
}

.similar__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.similar__item {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-body);
}

.similar__code {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* At the counter the rows are buttons: the person standing there is
   probably one of them, so tapping picks them (rule 2.2 tap size). */
.similar__pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2);

  font: inherit;
  font-size: var(--text-body);
  text-align: left;
  color: inherit;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
}

.similar__pick:active {
  background: var(--color-primary-faint);
}

/* One line of advice under the list: what to do about the clash. */
.similar__hint {
  margin: 0;
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.similar__item[data-exact='true'] {
  font-weight: var(--font-bold);
}


/* =============================================================================
   ITEM ROW
   One item in the Items list (ITEM-01, ITEM-12): the name with its code
   and category under it, the stock note, and the usual price on the
   right. A button, 56px, highlighted when it is the one open beside the
   list.
   ============================================================================= */

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-3);
  align-items: center;
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);

  font: inherit;
  font-size: var(--text-body);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.item-row:last-child {
  border-bottom: none;
}

.item-row:active,
.item-row[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

.item-row__name {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  font-weight: var(--font-medium);
}

.item-row__detail {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.item-row__detail > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.item-row__price {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.item-row[data-stock='low'] .item-row__stock      { color: var(--color-warning); font-weight: var(--font-medium); }
.item-row[data-stock='negative'] .item-row__stock { color: var(--color-danger); font-weight: var(--font-medium); }

.item-row[data-inactive='true'] .item-row__name {
  color: var(--color-text-faint);
}

/* A list of them, boxed. */
.item-list {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}


/* =============================================================================
   STICKY BAR
   The Save row pinned to the bottom of a long form (docs/05-ux-spec.md
   section 5, field 11), so it is always in reach on a phone.
   ============================================================================= */

.sticky-bar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: var(--border-width) solid var(--color-border);
  box-shadow: var(--shadow-raised);
}

/* Equal widths, one line each; the row wraps before a label does. */
.sticky-bar > .btn {
  flex: 1 1 200px;
  white-space: nowrap;
}

/* On a phone the bar would stack three tall buttons and eat a third of
   the screen: the primary and the second button take a row each at 56px,
   and the quiet Cancel steps aside (the back arrow at the top does the
   same job). */
@media (max-width: 480px) {
  .sticky-bar > .btn {
    flex: 1 1 100%;
    min-height: var(--tap-min);
  }

  .sticky-bar > .btn--ghost {
    display: none;
  }
}


/* =============================================================================
   ICON PICKER
   The grid of category icons in the "+ New category" dialog (ITEM-03).
   Each is a 56px button; the chosen one is outlined in the brand colour.
   ============================================================================= */

.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tap-min), 1fr));
  gap: var(--space-2);
  max-height: calc(var(--tap-min) * 4 + var(--space-2) * 3);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.icon-picker__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
  color: var(--color-text);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.icon-picker__option[aria-pressed='true'] {
  color: var(--color-primary-dark);
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}


/* =============================================================================
   IMPORT PREVIEW
   The table of checked rows on the Import screen (ITEM-09). A row is
   ready, skipped, or a problem, and says so in colour; the first column is
   the skip switch.
   ============================================================================= */

.table--preview td {
  vertical-align: top;
}

.table--preview tr[data-status='problem'] td {
  background: var(--color-danger-faint);
}

.table--preview tr[data-skip='true']:not([data-status='problem']) td {
  color: var(--color-text-faint);
}

.table--preview .table__messages {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-small);
  color: var(--color-danger);
}

.table--preview .table__warnings {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-small);
  color: var(--color-warning);
}

/* The table scrolls sideways on a phone rather than squashing. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}


/* =============================================================================
   CUSTOMER ROW
   One customer in the Customers list (CUST-02): the name with the phone
   beside it, a line about what they owe, and the balance on the right,
   biggest first. The whole row is the tap target and opens their page.
   ============================================================================= */

.customer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-3);
  align-items: center;
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);

  font: inherit;
  font-size: var(--text-body);
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: none;
  border-bottom: var(--border-width) solid var(--color-border);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.customer-row:last-child {
  border-bottom: none;
}

.customer-row:active,
.customer-row[aria-pressed='true'] {
  background: var(--color-primary-faint);
}

.customer-row__name {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  font-weight: var(--font-medium);
}

.customer-row__phone {
  font-size: var(--text-small);
  font-weight: var(--font-regular);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.customer-row__detail {
  grid-column: 1;
  font-size: var(--text-small);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-row__balance {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.customer-row[data-owing='true'] .customer-row__balance {
  color: var(--color-warning);
}

.customer-row[data-inactive='true'] .customer-row__name {
  color: var(--color-text-faint);
}

/* A list of them, boxed. */
.customer-list {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}


/* =============================================================================
   BUCKETS
   The three ageing figures on "Who owes us" (CUST-05): 0 to 30 days,
   31 to 60, over 60. Side by side on a tablet, stacked on a phone. The
   older the bucket, the warmer the figure.
   ============================================================================= */

.buckets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

@media (max-width: 480px) {
  .buckets {
    grid-template-columns: 1fr;
  }
}

.buckets__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-sm);
}

.buckets__label {
  font-size: var(--text-small);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
}

.buckets__value {
  font-size: var(--text-heading);
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
}

.buckets__note {
  font-size: var(--text-small);
  color: var(--color-text-faint);
}

.buckets__item[data-bucket='b31'][data-empty='false'] .buckets__value { color: var(--color-warning); }
.buckets__item[data-bucket='b61'][data-empty='false'] .buckets__value { color: var(--color-danger); }

/* The same colours in the per-customer table. */
.table td[data-age='warn'] { color: var(--color-warning); }
.table td[data-age='old']  { color: var(--color-danger); }


/* =============================================================================
   LOAD CARD
   A full load in bill history, in place of the lines (COMM-01, COMM-03):
   what the load is in a large line, then the summary rows (where, who, the
   two prices, the commission, its state), then Mark delivered. A summary
   row can say whether its figure is good or bad news with data-kind.
   ============================================================================= */

.load-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-sm);
}

.load-card .bills__section-title,
.load-card__what {
  margin: 0;
}

.load-card__what {
  font-size: var(--text-line);
  font-weight: var(--font-bold);
}

.load-card .btn {
  align-self: flex-start;
}

/* An address and a driver's phone are longer than a figure: they wrap
   rather than push the card wider than a phone (390 px). */
.load-card .summary__label {
  flex: 0 0 auto;
}

.load-card .summary__value {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  text-align: right;
  overflow-wrap: anywhere;
}

/* The truck beside the heading, not above it. */
.load-card .bills__section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.summary__row[data-kind='good'] .summary__value {
  color: var(--color-success);
  font-weight: var(--font-bold);
}

.summary__row[data-kind='bad'] .summary__value {
  color: var(--color-danger);
  font-weight: var(--font-bold);
}


/* =============================================================================
   BANNER, DANGER
   The strip when something is past its time: "2 bills are past the due
   date" on a supplier's page (SUP-03).
   ============================================================================= */

.banner--danger {
  background: var(--color-danger-faint);
  border-bottom-color: var(--color-danger);
}

.banner--danger .icon {
  color: var(--color-danger);
}


/* =============================================================================
   DUE DATES AND MONEY OWED (SUP-03)
   What we owe a supplier: orange while owed, red once a bill is past its
   due date. The same two colours on a list row, a card figure, a bill row's
   detail line and a table cell, so "red means overdue" holds everywhere.
   ============================================================================= */

.customer-row[data-overdue='true'] .customer-row__balance {
  color: var(--color-danger);
}

.card[data-overdue='true'] .card__value {
  color: var(--color-danger);
}

/* Warranty items waiting to go back: the count in orange (RET-03). */
.card[data-waiting='true'] .card__value {
  color: var(--color-warning);
}

[data-due='overdue'] {
  color: var(--color-danger);
  font-weight: var(--font-medium);
}

[data-due='today'],
[data-due='soon'] {
  color: var(--color-warning);
}

/* A row in a .bill-list that opens nothing (a purchase before Purchases
   has a page of its own): it keeps the look but not the press. */
.bill-row[data-static] {
  cursor: default;
}

.bill-row[data-static]:active {
  background: var(--color-surface);
}


/* =============================================================================
   WARRANTY ROW
   One item swapped under warranty, on its way back to the supplier (RET-03):
   what and how many, the bill it came from (a link), when, why and who took
   it back; a badge for the step it is on; and the button for the next step
   (Mark sent back, Replacement received), 56 px. On a phone the badge and
   the button drop under the words.
   ============================================================================= */

.warranty-list {
  display: flex;
  flex-direction: column;
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}

.warranty-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  min-height: var(--tap-min);
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}

.warranty-row:last-child {
  border-bottom: none;
}

@media (max-width: 600px) {
  .warranty-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .warranty-row__main {
    grid-column: 1 / -1;
  }

  .warranty-row__action {
    justify-self: end;
  }
}

.warranty-row__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.warranty-row__what {
  font-weight: var(--font-medium);
}

.warranty-row__detail {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

/* The bill number inside the detail line: a link to the bill. */
.warranty-row__link {
  padding: 0;
  font: inherit;
  color: var(--color-primary);
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
}

.warranty-row[data-status='replaced'] .warranty-row__what {
  color: var(--color-text-muted);
}


/* =============================================================================
   PICKER
   A search box with its matches floating under it, for choosing one of
   many (the supplier on the item form, U7 on the tablet: twenty suppliers in
   a dropdown is a long scroll). Type to narrow; tap a match. The list is a
   .pick-list, raised above what follows.
   ============================================================================= */

.picker {
  position: relative;
}

.picker__list {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  max-height: calc(var(--tap-min) * 5);
  background: var(--color-surface);
  box-shadow: var(--shadow-raised);
}


/* =============================================================================
   CONTACT LIST
   A supplier's people (migration 020): each a name, a phone link and a note
   such as "sales rep", the first one marked main. On the supplier page.
   ============================================================================= */

.contact-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-list__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  color: var(--color-text-muted);
}

.contact-list__item > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.contact-list__name {
  color: var(--color-text);
  font-weight: var(--font-medium);
}


/* =============================================================================
   CHIP AS A LINK
   A small outlined button that goes somewhere: the supplier on a full
   load's bill (U3 on the tablet, 10 October 2026: a plain underlined name
   did not look tappable). A truck, the name, a chevron.
   ============================================================================= */

.chip--link {
  color: var(--color-primary);
  text-decoration: none;
  border-color: var(--color-primary-light);
  white-space: normal;
}

.chip--link:active {
  background: var(--color-primary-faint);
}


/* =============================================================================
   CARDS: WARRANTY ITEMS (RET-03)
   "1 to send", and under it how many are with the supplier waiting for the
   replacement, in blue and bold when there are any, so a replacement still
   to come is not forgotten (U10 on the tablet, 10 October 2026).
   ============================================================================= */

.card[data-awaiting='true'] .card__note {
  color: var(--color-primary);
  font-weight: var(--font-medium);
}
