/* MEGZ | POS design system: tokens + shared components. RTL, Cairo, keyboard-first.
   ONE token source (spec 018 plan §9). The block below is design/ds/tokens.json of
   specs/018-premium-screens: the DS names first (light on `:root`, dark on `html[data-theme="dark"]`),
   then the app's own tokens that the DS has no word for (the till slab, the 4/8 spacing scale, the
   control heights DS01 rules, the print surface DS02 names), then every older name as an ALIAS of a
   DS token, so the 26 per-screen stylesheets keep working untouched. The shell, the rail and the
   navigation live in theme.css; this file is tokens and the primitives every screen shares. */

*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }

@font-face {
  font-family: 'Cairo';
  src: url('/fonts/Cairo-VF.ttf') format('truetype-variations');
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  --mobile-nav-height: 0px;
  /* ---- DS colour, light ------------------------------------------------------------------- */
  --bg: #f5f5f1; --surface: #ffffff; --surface-2: #f0f0eb; --surface-3: #e8e9e3;
  --line: #e2e3dc; --line-2: #cfd1c8; --line-strong: #93958d;
  --ink: #141f27; --ink-2: #4f5c64; --ink-3: #78838a; --ink-3-text: #606a71;
  --teal: #1c6470; --teal-hover: #154f59; --teal-ink: #17555f; --teal-bg: #e5efee; --teal-line: #b9d3d2;
  --on-teal: #ffffff;
  --amber: #93570f; --amber-bg: #faf0df; --amber-line: #ecd3a8; --amber-tint: rgba(250, 240, 223, .45);
  --on-amber: #ffffff;
  --red: #a8321f; --red-bg: #fae9e5; --red-line: #efc4ba; --on-red: #ffffff;
  --green: #2c6a42; --green-bg: #e6f1e8; --green-line: #bcd9c3; --on-green: #ffffff;
  /* Calm tint pairs for tile groups that are not money (spec 021 T047, Admin.dc.html's PEOPLE/SHOP
     arrays): a group needs only its icon-chip background + ink, so these two colours carry no
     -line/-hover/on- variants the way --teal does. */
  --blue-ink: #3b76b4; --blue-bg: #e8f0f8;
  --violet-ink: #7a5aa8; --violet-bg: #efeaf6;
  --focus: #1c6470;
  --chart-2: #6b8f9a;
  --seg-pressed: var(--surface);
  --scrim: rgba(15, 22, 25, .42);
  --kbd-on-fill-bg: rgba(255, 255, 255, .14); --kbd-on-fill-line: rgba(255, 255, 255, .35);

  /* ---- DS elevation and focus halos --------------------------------------------------------- */
  --shadow-1: 0 1px 0 rgba(20, 31, 39, .04), 0 1px 2px rgba(20, 31, 39, .05);
  --shadow-2: 0 10px 30px -12px rgba(20, 31, 39, .28), 0 2px 6px rgba(20, 31, 39, .06);
  --shadow-seg: 0 1px 0 rgba(20, 31, 39, .04), 0 1px 2px rgba(20, 31, 39, .08);
  --halo: 0 0 0 3px var(--teal-bg);
  --halo-red: 0 0 0 3px var(--red-bg);

  /* ---- DS type ---------------------------------------------------------------------------- */
  --font-stack: Cairo, "Segoe UI", "Noto Sans Arabic", "IBM Plex Sans Arabic", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --t-11: 11.5px; --t-12: 13px; --t-13: 14.5px; --t-15: 15px; --t-18: 18px; --t-22: 22px; --t-28: 28px;
  /* Legacy type steps remain available to dense controls. The shared body follows the 15px
     spec 021 board; controls keep their explicit sizes. */
  --t-12-comfortable: 13px; --t-13-comfortable: 14.5px; --t-12-compact: 12.5px; --t-13-compact: 13.5px;
  --t-kbd: 10.5px; --t-kbd-sm: 9.5px; --t-chart: 10px;

  /* ---- DS spacing, radii, sizes, opacity ---------------------------------------------------- */
  --gap: 14px; --pad: 18px; --gap-comfortable: 14px; --pad-comfortable: 18px;
  --space-2: 2px; --space-4: 4px; --space-5: 5px; --space-6: 6px; --space-7: 7px; --space-8: 8px;
  --space-9: 9px; --space-10: 10px; --space-11: 11px; --space-12: 12px; --space-13: 13px; --space-18: 18px;
  --r-1: 5px; --r-2: 8px; --r-3: 11px; --r-inner: 6px; --r-kbd: 4px; --r-mark: 2px; --pill: 20px;
  --ctl: 40px; --ctl-comfortable: 40px; --ctl-compact: 34px; --ctl-touch: 44px; --ctl-sm: 30px; --ctl-lg: 48px;
  --scan-h: 40px; --tender-h: 54px; --icon-btn: 32px; --icon: 16px; --icon-sm: 14px;
  --card-h: 46px; --top-h: 48px; --nav-h: 58px;
  --opacity-disabled: .48; --opacity-bar: .82; --opacity-acked: .35;
  --motion-fast: 150ms ease; --motion-toast: 180ms ease;

  /* ---- app tokens the DS has no word for (kept as they were) -------------------------------- */
  /* The five money states. Each one carries a WORD and a SHAPE beside the colour (spec §Money
     states, acceptance item 14) — `.chip` below draws the square swatch that is the shape. */
  --pay-paid: var(--green); --pay-credit: var(--amber); --pay-held: #7e6334;
  --pay-late: var(--red); --pay-void: var(--ink-3-text);

  /* The till's customer-facing total slab, and nothing else. */
  --fs-total: 96px;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --r-full: 9999px;

  /* DS01 — 48 px controls keep primary actions comfortable while 40 px is the compact floor for
     dense actions and navigation. Both remain larger than the 40 px touch target minimum. */
  --control-h: 48px; --control-h-dense: 40px; --row-till: 76px;

  --transition: 140ms cubic-bezier(.16, 1, .3, 1);

  /* DS02 — the print surface is NOT a theme. A 203 dpi monochrome thermal head prints black on
     white, so these three do not change under `data-theme` and never take a screen value. */
  --paper: #FFFFFF; --ink-print: #000000; --rule-print: #000000;

  /* ---- older names, now aliases of the DS tokens (plan §9.2) -------------------------------- */
  --primary: var(--teal); --primary-hover: var(--teal-hover); --primary-ink: var(--teal-ink);
  --primary-bg: var(--teal-bg); --on-primary: var(--on-teal);
  --accent: var(--amber); --accent-ink: var(--amber); --amber-ink: var(--amber);
  --accent-bg: var(--amber-bg); --on-accent: var(--on-amber);
  --danger: var(--red); --danger-ink: var(--red); --danger-bg: var(--red-bg); --on-danger: var(--on-red);
  --success: var(--green); --success-ink: var(--green); --success-bg: var(--green-bg); --on-success: var(--on-green);
  --warning: var(--amber);
  --focus-ring: var(--halo);
  --fs-xs: var(--t-11); --fs-sm: var(--t-12); --fs-base: var(--t-13);
  --fs-md: var(--t-18); --fs-lg: var(--t-22); --fs-xl: var(--t-28);
  --r-sm: var(--r-2); --r-md: var(--r-2); --r-lg: var(--r-3); --r-xl: var(--r-3); --radius-md: var(--r-2);
  --muted: var(--ink-3-text);
  --font: var(--font-stack); --font-sans: var(--font-stack); --font-mono: var(--mono);
}

html[data-theme="dark"] {
  --bg: #0f1619; --surface: #162026; --surface-2: #1c2830; --surface-3: #243139;
  --line: #26343c; --line-2: #34454e; --line-strong: #5a6c75;
  --ink: #edf2f2; --ink-2: #aebcc1; --ink-3: #82939a; --ink-3-text: #8ea0a7;
  --teal: #7cc3cf; --teal-hover: #9dd4dd; --teal-ink: #9ad3dc; --teal-bg: #183a40; --teal-line: #2b5a62;
  --on-teal: #0c1c20;
  --amber: #e7b16b; --amber-bg: #372a19; --amber-line: #5e4724; --amber-tint: rgba(55, 42, 25, .45);
  --on-amber: #0c1c20;
  --red: #f0977f; --red-bg: #3a2019; --red-line: #6a3527; --on-red: #0c1c20;
  --green: #8fcf9f; --green-bg: #183224; --green-line: #2d5a3b; --on-green: #0c1c20;
  --blue-ink: #8fb8e6; --blue-bg: #182a3a;
  --violet-ink: #c3a8e0; --violet-bg: #241c34;
  --focus: #9ad3dc;
  --seg-pressed: var(--surface-3);
  /* the same in both themes, stated again so the dark block names every DS colour */
  --chart-2: #6b8f9a;
  --scrim: rgba(15, 22, 25, .42);
  --kbd-on-fill-bg: rgba(255, 255, 255, .14); --kbd-on-fill-line: rgba(255, 255, 255, .35);

  --pay-held: #D2A85A;

  --shadow-1: none;
  --shadow-seg: none;
  --shadow-2: 0 12px 30px -10px rgba(0, 0, 0, .6);
}

/* Touch and phone: a control is never below 44px (DS «Controls & hit targets»). `--control-h-dense`
   follows so every primitive that sizes from it grows with `--ctl`. */
@media (pointer: coarse), (max-width: 600px) {
  :root { --ctl: 44px; --control-h-dense: 44px; }
}

html {
  font-family: var(--font-stack);
  font-size: 15px;
  line-height: 1.4;
  direction: rtl;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  min-height: 100dvh;
  font-weight: 400;
  overflow-x: hidden;
  max-width: 100vw;
}

/* The ring is `--focus` (the DS teal, 5.8:1 or more on every ground), drawn as a 2 px edge; the
   `--focus-ring` halo under it is decoration, the edge is what carries the focus. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  box-shadow: var(--focus-ring);
}

::selection { background: var(--primary-bg); color: var(--ink); }

/* Paper, not chrome: the scrollbar is a line on the surface it scrolls. */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-2); background-clip: content-box; }

/* Reduced motion drops every transition and animation. 0.01ms rather than `none`: the end events
   still fire, so a script that waits for a toast's exit or a dialog's entry is never stranded. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* utilities */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  direction: ltr;
  unicode-bidi: isolate;
}
.muted { color: var(--ink-2); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.stack { display: grid; gap: var(--sp-3); }
.grow { flex: 1 1 auto; }
.hidden, [hidden] { display: none !important; }

/* buttons — the DS button values on the app's own names (plan §9.4, H3).
   The control height is `--control-h-dense` (40 px, 44 px on touch and phone); `.btn-lg` is the
   48 px `--control-h` for the one action that closes a sale. A control border is `--line-2`: the
   label identifies a button, so its edge only has to separate it. Hover is a change of surface and
   nothing else — acceptance item 3 keeps motion off the scan → line → total path. Sizes read the
   older names (`--fs-base`, `--r-md`) on purpose: they equal the DS steps globally, and the super
   admin's denser scope (admin.css) overrides exactly those names. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-7);
  min-height: var(--control-h-dense);
  padding: 0 var(--space-13);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--line); }
.btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; pointer-events: none; }

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

.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); filter: brightness(1.08); }

/* «ghost» — the tertiary action: no box at all until it is touched, its label in `--ink-2`
   (6.9:1 on surface) and the full ink on hover, as the DS draws it. */
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--ink); }

.btn-lg { min-height: var(--control-h); padding: 0 var(--space-18); font-size: var(--t-15); }
.btn-sm { min-height: var(--control-h-dense); padding: 0 var(--space-9); font-size: var(--fs-sm); }
.btn-block { display: flex; width: 100%; }

/* Spec 021 board helmet: one shared key cap for framed commands and the workflow box. */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-kbd);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--t-kbd);
  font-weight: 400;
  line-height: 1;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}
.kbd-on { background: var(--kbd-on-fill-bg); border-color: var(--kbd-on-fill-line); color: var(--on-teal); }

/* The key cap — the DS `kbd`: mono, a hairline edge with a 2 px foot, the surface under it. It
   stays a flex box so a screen that fixes its height (sell.css) still centres the label. */
.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: var(--r-kbd);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: var(--t-kbd);
  font-weight: 400;
  line-height: 1;
  direction: ltr;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* On a filled button the cap is a wash of the fill (`--kbd-on-fill-*`) and wears the label's own
   colour: 4.9:1 on teal, 5.1:1 on red. Amber is the exception — a white wash takes it to 4.4:1 —
   so there the cap is only its edge. On every other button the cap is the plain DS cap. */
.btn .key { background: var(--kbd-on-fill-bg); border-color: var(--kbd-on-fill-line); color: inherit; }
.btn-accent .key { background: transparent; }
.btn:not(.btn-primary):not(.btn-danger):not(.btn-accent) .key { background: var(--surface); border-color: var(--line-2); color: var(--ink-3-text); }

/* fields */
.field { display: grid; gap: var(--sp-2); }
.field label { font-weight: 700; font-size: var(--fs-sm); color: var(--ink-2); }

.field > .input,
.field > select.input,
.field > textarea.input {
  width: 100%;
  min-width: 0;
}

.input, select.input, textarea.input {
  min-height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-md);
  font-weight: 700;
  touch-action: manipulation;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea.input { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-base); }
.input::placeholder { color: var(--ink-3-text); opacity: 1; font-weight: 500; }
/* Text entry focuses as the DS draws it: a teal border and the 3 px halo, no outline. Invalid is a
   red border and the red halo — and stays red while focused (declared after, same specificity).
   The outline is transparent, not `none`: forced-colours mode drops box-shadow and repaints borders,
   and a transparent outline is the one mark it turns visible, so a focused field still shows. */
.input:focus, .input:focus-visible { outline: 2px solid transparent; border-color: var(--teal); box-shadow: var(--halo); }
.input-num { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
/* Spec 025 A2: a date, month or time control inherits the page's RTL, and iOS then lays its digits
   out reversed (`032026/10/` for 2026/10/03). Its digits read left to right. Alignment stays where
   it already was: a field that was RTL sat on the right edge, which is `end` once it is LTR; a `.num`
   or `.input-num` field was LTR already and keeps its own. Zero specificity, so a screen that sets
   its own direction or alignment keeps it. */
:where(input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"]) { direction: ltr; }
:where(input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"]):where(:not(.num, .input-num)) { text-align: end; }
.input[aria-invalid="true"], .input.is-invalid { border-color: var(--red); box-shadow: var(--halo-red); }
.help { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; }
.error { display: flex; align-items: center; gap: var(--sp-2); color: var(--danger-ink); font-size: var(--fs-sm); font-weight: 700; }
.error svg { flex: none; }

/* the segmented control / filter chips above a table — the DS `seg` (H4). The track is a sunk
   `--surface-2` strip one control high; the pressed segment is RAISED onto `--seg-pressed` with
   the soft lift, and its label goes to full ink at 700 — a weight cue, not only a fill shift (F9).
   It is never a teal fill. */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.segmented > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  min-height: calc(var(--control-h-dense) - 6px);
  padding: 0 var(--space-11);
  border: 0;
  border-radius: var(--r-inner);
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}

.segmented > .is-active, .segmented > [aria-pressed="true"], .segmented > [aria-selected="true"] {
  background: var(--seg-pressed);
  color: var(--ink);
  box-shadow: var(--shadow-1);
  font-weight: 700;
}

/* card / section header / list / table */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: var(--pad);
}

/* The strip the artboards put across the top of every card: the title at the start edge, the meta
   at the end, on the surface's own shade. Used as `.card > .section-head` with a flush card. */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 48px;
  padding: 0 var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  font-size: var(--fs-md);
  font-weight: 800;
}

.section-head .meta { margin-inline-start: auto; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }

/* A disclosure — a card section the screen opens closed.

   Two screens carry a back-office block on an operational screen: the expense chart of accounts on
   «الوردية» and the employee-sales report on «مرتجعات». Both are correct and both are wanted; what
   was wrong is that they filled the first screenful of a screen a cashier opens to WORK. Closed by
   default they cost one click and give the operational controls the fold back (audit P1-4, P1-5).

   `<summary>` keeps the keyboard and the screen reader for free: it is focusable, it toggles on
   Enter and Space, and it carries its own expanded state — which a div with a click handler does
   not. The marker is dropped and drawn with a rotating chevron so it sits on the RIGHT edge of an
   RTL header instead of the browser's own LTR triangle on the left. */
.disclosure > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.disclosure > summary::-webkit-details-marker { display: none; }

.disclosure > summary::after {
  content: 'A';
  margin-inline-start: auto;
  font-size: var(--fs-lg);
  color: var(--ink-2);
  transform: rotate(90deg);
  transition: transform 120ms ease;
}

.disclosure[open] > summary::after { transform: rotate(-90deg); }

.disclosure > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.disclosure:not([open]) > summary {
  border-bottom: 0;
  border-radius: var(--r-lg);
}

@media (prefers-reduced-motion: reduce) {
  .disclosure > summary::after { transition: none; }
}
.card-flush { padding: 0; overflow: hidden; }

/* The DS card parts, for a flush card (H5): a head on the plain surface — the title at the start,
   `.end` holds its controls at the far edge — and a padded body. */
.card-h {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  min-height: var(--card-h);
  padding: var(--space-11) var(--pad);
  border-bottom: 1px solid var(--line);
}

.card-h h2, .card-h h3 { font-size: var(--t-15); font-weight: 650; letter-spacing: 0; }
.card-h .end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-8); }
.card-b { padding: var(--pad); }

.list { display: grid; gap: var(--sp-2); }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--transition), border-color var(--transition);
}

.list-row:hover { background: var(--surface-2); }
.list-row.is-selected { background: var(--primary-bg); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

.table { width: 100%; border-collapse: collapse; }

/* The DS table: the header is a small label (`--t-11`, third-tier ink) on the plain surface, the
   rows are hairlines with no zebra. */
.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: start;
  font-weight: 600;
  font-size: var(--t-11);
  color: var(--ink-3-text);
  padding: var(--space-7) var(--space-10);
  border-bottom: 1px solid var(--line);
}

.table td { padding: var(--space-8) var(--space-10); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.num, .table th.num { text-align: end; }
.table td.n, .table th.n { text-align: end; white-space: nowrap; }

/* chips — the status vocabulary, drawn as the DS badge (H2): a word on a tint, fill + border + text
   from one family. The swatch is the SHAPE that has to travel with the colour (acceptance item 14):
   square for money, round for health and waiting; a chip with no state is plain grey, no swatch.
   The board's 28px height and flex alignment centre its Cairo label. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-5);
  height: 28px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.chip-paid::before, .chip-credit::before, .chip-held::before, .chip-late::before,
.chip-void::before, .chip-wait::before, .chip-ok::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-mark);
  background: currentColor;
}

.chip-ok::before, .chip-wait::before { border-radius: 50%; }

.chip-paid { background: var(--green-bg); border-color: var(--green-line); color: var(--pay-paid); }
.chip-credit { background: var(--amber-bg); border-color: var(--amber-line); color: var(--pay-credit); }
.chip-held { background: var(--surface-2); border-color: var(--line); color: var(--pay-held); }
.chip-late { background: var(--red-bg); border-color: var(--red-line); color: var(--pay-late); }
.chip-void { background: var(--surface-2); border-color: var(--line); color: var(--pay-void); }
/* Health is green and waiting is amber; neither borrows a money ink (spec §Status vocabulary —
   three token families, three jobs). */
.chip-ok { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.chip-wait { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }

/* the count pill — the DS `count`: things waiting, amber on its tint. Figures only, and Latin
   digits sit on the middle of a 1.5 line box, so the padding is even. */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: var(--pill);
  background: var(--amber-bg);
  color: var(--amber);
  font-size: var(--t-kbd);
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* empty state — the «فاضي» column of every state matrix: a sentence, never a blank box */
.empty {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--sp-2);
  min-height: 160px;
  padding: var(--sp-6);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  color: var(--ink-2);
  font-weight: 700;
  text-align: center;
}

.empty .empty-title { font-size: var(--fs-md); font-weight: 800; color: var(--ink); }

/* total.
   `--fs-total` is 96 px and it belongs to ONE element — the till's total slab, which sell.css asks
   for by name. Anything else that shows a total takes the display step below it, because a 96 px
   figure inside a back-office card is a figure that does not fit its card. */
.total { display: grid; gap: var(--sp-1); justify-items: end; }
.total .total-label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.total .total-value { font-size: var(--fs-xl); font-weight: 900; direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; line-height: 1.05; }

/* dialog / scrim */
.scrim { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: var(--sp-5); z-index: 100; }

.dialog {
  width: 100%;
  max-width: 560px;
  max-height: min(720px, calc(100dvh - 40px));
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  animation: dialog-enter 160ms ease-out;
}

/* The heading is the dialog's own header line: 21 px / 800, ruled off from the body exactly as the
   artboards' «دؤر على صنف» and «كمية الصنف» are. (dialog.js writes it as the first child — the
   XSS test asserts that shape, so it is styled here and never re-wrapped there.) */
.dialog .dialog-title {
  margin: calc(var(--sp-6) * -1) calc(var(--sp-6) * -1) 0;
  padding: var(--sp-3) var(--sp-6);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-radius: calc(var(--r-xl) - 1px) calc(var(--r-xl) - 1px) 0 0;
  font-size: var(--fs-md);
  font-weight: 800;
}

/* `padding-block-end`: Cairo's glyphs stand ~2.7px taller than a 1.4 line box, and a scroll box counts
   them — the كاش dialog's last line («الباقي») scrolled its body by 2px for nothing (T057). */
.dialog .dialog-body { display: grid; flex: 1 1 auto; gap: var(--sp-4); min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding-block-end: var(--sp-1); }
.dialog .dialog-title, .dialog .dialog-error, .dialog .dialog-actions { flex: none; }
.dialog .dialog-body > * { min-width: 0; }
.dialog .dialog-error {
  margin: 0;
  padding-block: var(--sp-2);
  padding-inline: var(--sp-3);
  flex: none;
  background: var(--red-bg);
  border: 1px solid var(--red-line);
  border-radius: var(--r-sm);
  color: var(--red);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.dialog .dialog-error[hidden] { display: none; }
.dialog.is-busy,
.dialog[aria-busy="true"] { cursor: progress; }
.dialog.is-busy .dialog-actions .btn:disabled,
.dialog[aria-busy="true"] .dialog-actions .btn:disabled {
  opacity: var(--opacity-disabled);
  cursor: progress;
}
/* Inline field guidance works with hover, focus, touch and native Enter/Space disclosure. */
.field-help { position: relative; display: inline-block; vertical-align: middle; margin-inline-start: 6px; font-weight: 400; }
.field-help > summary { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; min-height: 28px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink-2); background: var(--surface-2); cursor: help; list-style: none; }
.field-help > summary::-webkit-details-marker { display: none; }
.field-help > span { position: absolute; z-index: 10; inset-inline-start: 0; top: 100%; width: max-content; max-width: min(260px, 70vw); padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font-size: var(--fs-sm); box-shadow: var(--shadow-2); white-space: normal; }
.field-help:not([open]) > span { display: none; }
.field-help:hover > span, .field-help:focus-within > span { display: block; }
.field-help:hover::details-content, .field-help:focus-within::details-content { content-visibility: visible; }
@media (max-width: 600px) {
  .scrim { padding: var(--sp-2); }
  .dialog { padding: var(--sp-4); gap: var(--sp-3); max-height: calc(100dvh - 16px); }
  .dialog .dialog-title { margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) 0; padding: var(--sp-3) var(--sp-4); }
  .dialog .field-help { display: block; width: 100%; margin-inline-start: 0; }
  .dialog .field-help > span { position: static; display: block; width: 100%; max-width: 100%; margin-block-start: var(--sp-2); box-shadow: none; }
}
/* «إلغاء Esc» first, «تأكيد Enter» at the end — the footer order on every artboard dialog, and the
   order dialog.js already writes. The confirm carries the weight. */
.dialog .dialog-actions { justify-content: flex-end; flex-wrap: wrap; }
.dialog .dialog-actions .btn { min-height: var(--control-h-dense); }
/* dialog.js draws «إلغاء» as a quiet button; the artboards draw it with its own edge, because in a
   footer of two the quiet one still has to look like something you can press. */
.dialog .dialog-actions .btn-ghost { border-color: var(--line); background: var(--surface); }
.dialog .dialog-actions .btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }

/* T041 — the quick add's «تفاصيل أكتر» (sell, receiving and the stock count all open that dialog, so
   it lives here). A quiet button at the start edge that names what the fold holds («قطعة · بدون فئة»)
   and one small motion: its chevron turns when the fold opens. Physical borders on purpose — the
   chevron is a drawn down-arrow, not a reading direction. The folded fields sit under a hairline so
   they read as extras, not as more of the same form. */
.qa-more-toggle { justify-self: start; gap: var(--sp-2); padding-inline: var(--sp-2); }
.qa-more-toggle .qa-more-sum { color: var(--ink-3-text); font-weight: 500; }
.qa-more-toggle::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform var(--motion-fast);
}
.qa-more-toggle[aria-expanded="true"]::after { transform: translateY(2px) rotate(-135deg); }
.qa-more { padding-block-start: var(--sp-3); border-block-start: 1px solid var(--line); }
/* The refusal's code line is the body's last box; Cairo's glyphs overhang a 1.4 line by ~3px, which
   the dialog body (overflow: auto) would otherwise answer with a scrollbar. */
.qa-denied .row { padding-block: var(--sp-1); }

@keyframes dialog-enter {
  0% { transform: scale(0.98); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* banners / toast */
.banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--control-h);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  border: 1px solid var(--line);
}

.banner-warn { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-line); }
.banner-danger { background: var(--red-bg); color: var(--red); border-color: var(--red-line); }
.banner-success { background: var(--green-bg); color: var(--green); border-color: var(--green-line); }

.toast { position: fixed; bottom: var(--sp-6); inset-inline: 0; margin-inline: auto; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); z-index: 200; width: max-content; max-width: min(90vw, 480px); pointer-events: none; }
.toast-item { pointer-events: auto; min-height: 48px; display: flex; align-items: center; justify-content: center; padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md); background: var(--ink); color: var(--bg); font-weight: 800; font-size: var(--fs-base); box-shadow: var(--shadow-2); animation: toast-slide-up var(--motion-toast); }
/* `kind` is whatever the caller passed, and the callers pass five words, not two: `danger`,
   `success`, `warn`, `error` and `info`. Only the first two had a rule, so twenty-three «تعذر …»
   toasts on the refunds, receiving, shift and stock-count screens and twenty-eight warnings were
   painted in the neutral style — a failure that looks exactly like a confirmation. `error` is an
   alias of `danger`; `warn` is the accent the banners already use. `info` stays neutral by design. */
.toast-item.kind-danger,
.toast-item.kind-error { background: var(--danger); color: var(--on-danger); }
.toast-item.kind-success { background: var(--success); color: var(--on-success); }
.toast-item.kind-warn { background: var(--accent); color: var(--on-accent); }

/* The one motion the DS keeps: a toast fades in and rises 20px over 180ms, and leaves the same way
   back. `.is-leaving` is the exit; the script that owns the toast adds it and removes the item on
   `animationend` (reduced motion keeps that event, see above). */
.toast-item.is-leaving { animation: toast-sink var(--motion-toast) forwards; pointer-events: none; }

@keyframes toast-slide-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes toast-sink {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(20px); opacity: 0; }
}

/* ---------------------------------------------------------------- the door: PIN pad + password
   `Login` and `PinSwitch` in the artboards. The panel is one block of paper on the scrim: a round
   lock mark, the question, the dots, and the way through. The dots are `--primary` when filled,
   which is the mint in dark and the deep green in light. */
.pin { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: var(--sp-5); z-index: 300; }

.pin-panel {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  padding: var(--sp-7);
  display: grid;
  gap: var(--sp-5);
  text-align: center;
}

/* The lock mark above the question (PinSwitch draws it as a round green plate). */
.pin-mark {
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--primary-bg);
  color: var(--primary-ink);
}

/* Cairo is tall (ascent 1.30em): Arabic text never sits below line-height 1.3 (plan §9.5). */
.pin-title { font-size: var(--fs-lg); font-weight: 900; line-height: 1.3; }
.pin-dots { height: 44px; display: flex; align-items: center; justify-content: center; gap: var(--sp-3); }
.pin-dots .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface-2); transition: background-color var(--transition), border-color var(--transition), transform var(--transition); }
.pin-dots .dot.is-filled { background: var(--primary); border-color: var(--primary); transform: scale(1.12); }
.pin-dots.is-shake { animation: pin-shake 200ms ease-out; }

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.pin-hint { color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700; }
.pin-error { color: var(--danger-ink); font-weight: 800; min-height: 24px; font-size: var(--fs-base); }
.pin-error:not(:empty) {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--danger-bg);
}

/* The owner's and the manager's door beside the till's: phone + password (FR-003). The panel
   centres its own text for the PIN pad; a labelled field is read from the start edge. */
.pin-password { text-align: start; gap: var(--sp-4); }
/* The other door. Quiet, but it keeps its edge: on a panel whose only other control is the pad
   itself, a borderless label is not read as a way through. */
.pin-swap {
  justify-self: center;
  min-height: var(--control-h-dense);
  font-size: var(--fs-sm);
  border-color: var(--line);
  background: var(--surface);
  padding: 0 var(--sp-5);
}

.pin-swap:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
/* «اختار اسمك» — one big button per name (pin.js §showCandidates). */
.pin-choose { gap: var(--sp-2); }
.pin-choose .btn { justify-content: space-between; font-size: var(--fs-md); }
/* Spec 025 A3: the touch pad (pin.js §onPadKey). A phone opens no keyboard for a panel with no
   field, so a touch device gets ten Western digits, «مسح» and «دخول» in the phone's own order — 1 2 3
   left to right, «دخول» on the right. A desktop till never draws it and keeps its F10/Esc hint; a
   touch device has neither key, so the hint goes. `[hidden]` (password, «اختار اسمك») still wins. */
.pin-keypad { display: none; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); direction: ltr; }
/* Two classes deep: mobile-workflows.css sets every phone `.btn` to 44px after this file loads. */
.pin-cancel { display: none; }
.pin-keypad .pin-key { min-height: 56px; padding: 0; font-size: var(--fs-lg); font-weight: 800; }
@media (hover: none) and (pointer: coarse) {
  .pin-keypad { display: grid; }
  .pin-hint { display: none; }
  .pin-cancel:not([hidden]) { display: inline-flex; }
  /* With the pad the panel is ~610px tall: on a short phone it scrolls inside the scrim instead of
     losing its top edge (auto margins still centre it whenever it fits). */
  .pin { align-items: flex-start; overflow-y: auto; }
  .pin-panel { margin-block: auto; }
}

/* receipt designer — switches on one side, the server's own render on the other (US1) */
/* items stretch on purpose: the preview column needs the row's full height for position:sticky */
.designer { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(300px, 440px); gap: var(--sp-5); }
.designer-controls { display: grid; gap: var(--sp-5); }
.designer-group { display: grid; gap: var(--sp-4); }
.designer-group h2 { font-size: var(--fs-md); font-weight: 800; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--control-h);
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--transition), border-color var(--transition);
}

.switch:hover { background: var(--surface-2); }
.switch input { flex: none; width: 26px; height: 26px; accent-color: var(--primary); cursor: pointer; }
.switch:has(input:checked) { border-color: var(--primary); background: var(--primary-bg); }

/* the column stretches to the row height; the card inside it is what sticks */
.designer-preview > .card { position: sticky; top: var(--sp-4); }
.designer-paper { width: 100%; height: 60vh; min-height: 320px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); }
.designer-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.designer-actions .btn { flex: 1 1 auto; }
.designer .error:empty { display: none; }

@media (max-width: 900px) {
  .designer { grid-template-columns: 1fr; }
  .designer-preview > .card { position: static; }
}

@media (max-width: 760px) {
  :root { --mobile-nav-height: calc(56px + env(safe-area-inset-bottom, 0px)); }
}
