/* TailorJi web styles — Pavazhi Technologies, Coimbatore.
   The ONE stylesheet for the shop web app (Step 2). Every colour, font, space and
   radius is a variable defined in the two token blocks below; nothing else in this
   file, or in any view, may hold a colour value.

   Light by default; dark follows the device (prefers-color-scheme). There is no
   manual toggle and no data-theme attribute (decision D16).

   Layout of this file:
     0. Fonts            self-hosted, no third-party requests
     1. Tokens           light, then dark
     2. TailorJi components (tj-*)   from the design system, unchanged
     3. App layout       the classes the existing screens use, re-made from the tokens */

/* =========================================================================
   0. FONTS — static instances (SIL OFL) made from the Google Fonts variable
      fonts with fontTools, served from our own origin. unicode-range means a
      browser only downloads a script's file when a page actually contains it.
   ========================================================================= */
@font-face { font-family: "Playfair Display"; font-weight: 800; font-style: normal; font-display: swap;
  src: url("../fonts/PlayfairDisplay-ExtraBold.woff2") format("woff2"); }

@font-face { font-family: "Anek Latin"; font-weight: 400; font-display: swap; src: url("../fonts/AnekLatin-Regular.woff2") format("woff2");
  unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20A0-20CF, U+2100-21FF, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Anek Latin"; font-weight: 600; font-display: swap; src: url("../fonts/AnekLatin-SemiBold.woff2") format("woff2");
  unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20A0-20CF, U+2100-21FF, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Anek Latin"; font-weight: 700; font-display: swap; src: url("../fonts/AnekLatin-Bold.woff2") format("woff2");
  unicode-range: U+0000-024F, U+1E00-1EFF, U+2000-206F, U+20A0-20CF, U+2100-21FF, U+2212, U+2215, U+FEFF, U+FFFD; }

@font-face { font-family: "Anek Tamil"; font-weight: 400; font-display: swap; src: url("../fonts/AnekTamil-Regular.woff2") format("woff2");
  unicode-range: U+0964-0965, U+0B80-0BFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Tamil"; font-weight: 600; font-display: swap; src: url("../fonts/AnekTamil-SemiBold.woff2") format("woff2");
  unicode-range: U+0964-0965, U+0B80-0BFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Tamil"; font-weight: 700; font-display: swap; src: url("../fonts/AnekTamil-Bold.woff2") format("woff2");
  unicode-range: U+0964-0965, U+0B80-0BFF, U+200C-200D, U+25CC; }

@font-face { font-family: "Anek Malayalam"; font-weight: 400; font-display: swap; src: url("../fonts/AnekMalayalam-Regular.woff2") format("woff2");
  unicode-range: U+0D00-0D7F, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Malayalam"; font-weight: 600; font-display: swap; src: url("../fonts/AnekMalayalam-SemiBold.woff2") format("woff2");
  unicode-range: U+0D00-0D7F, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Malayalam"; font-weight: 700; font-display: swap; src: url("../fonts/AnekMalayalam-Bold.woff2") format("woff2");
  unicode-range: U+0D00-0D7F, U+200C-200D, U+25CC; }

@font-face { font-family: "Anek Devanagari"; font-weight: 400; font-display: swap; src: url("../fonts/AnekDevanagari-Regular.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+A8E0-A8FF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Devanagari"; font-weight: 600; font-display: swap; src: url("../fonts/AnekDevanagari-SemiBold.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+A8E0-A8FF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Devanagari"; font-weight: 700; font-display: swap; src: url("../fonts/AnekDevanagari-Bold.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CFF, U+A8E0-A8FF, U+200C-200D, U+25CC; }

@font-face { font-family: "Anek Kannada"; font-weight: 400; font-display: swap; src: url("../fonts/AnekKannada-Regular.woff2") format("woff2");
  unicode-range: U+0C80-0CFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Kannada"; font-weight: 600; font-display: swap; src: url("../fonts/AnekKannada-SemiBold.woff2") format("woff2");
  unicode-range: U+0C80-0CFF, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Kannada"; font-weight: 700; font-display: swap; src: url("../fonts/AnekKannada-Bold.woff2") format("woff2");
  unicode-range: U+0C80-0CFF, U+200C-200D, U+25CC; }

@font-face { font-family: "Anek Telugu"; font-weight: 400; font-display: swap; src: url("../fonts/AnekTelugu-Regular.woff2") format("woff2");
  unicode-range: U+0C00-0C7F, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Telugu"; font-weight: 600; font-display: swap; src: url("../fonts/AnekTelugu-SemiBold.woff2") format("woff2");
  unicode-range: U+0C00-0C7F, U+200C-200D, U+25CC; }
@font-face { font-family: "Anek Telugu"; font-weight: 700; font-display: swap; src: url("../fonts/AnekTelugu-Bold.woff2") format("woff2");
  unicode-range: U+0C00-0C7F, U+200C-200D, U+25CC; }

/* =========================================================================
   1. TOKENS
   ========================================================================= */
:root {
  /* Logo Kit v3 palette (D45): plum #660033 on warm ivory #F5F0E8. */
  --bg: #F5F0E8; --surface: #FCF9F3; --surface-sunk: #EFE5DD; --line: #E4D5CF;
  --ink: #261219; --ink-muted: #5F4A53;
  --brand: #660033; --brand-pressed: #4D0026; --brand-tint: #F4DFE9; --on-brand: #F5F0E8;
  /* zari-ink is the kit's #8A6418 deepened (same hue) so it also reads on
     surface-sunk and brand-tint, not only on bg/surface (D45). */
  --zari: #DDB257; --on-zari: #33001A; --zari-ink: #835F17;
  --ready: #2E6B45; --ready-bg: #E3F0E6; --progress: #8A6418; --progress-bg: #F7EDD5;
  --trial: #1F5F8B; --trial-bg: #E2EEF6; --late: #B3261E; --late-bg: #F8E1DE;
  --font-display: "Playfair Display", Georgia, serif;
  --font-sans: "Anek Latin", "Anek Tamil", "Anek Malayalam", "Anek Devanagari", "Anek Kannada", "Anek Telugu", system-ui, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-6: 24px; --space-8: 32px; --tap: 48px;
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px; --radius-pill: 999px;
  --shadow-sheet: 0 -8px 24px rgba(38,18,25,0.12);
  --shadow-fab: 0 6px 16px rgba(38,18,25,0.22);
  --stitch-width: 2px; --stitch-dash: 6px; --stitch-gap: 5px;
  --rail-w: 240px;
  /* The Today band stays the real plum in BOTH themes: it is the one brand
     SURFACE at night (D46), and gold must read on it. */
  --band: #660033; --band-deep: #520029;
  /* Late on the band (D30): text only, never a fill. Same in both themes. */
  --late-on-band: #F2A39C;
  /* Brand when it must be READ (links, outline buttons, the current nav item).
     The same plum by day; at night --brand is a fill colour that text
     cannot sit in (~2:1), so this lightens to a rose that clears AA.
     Logo Kit v3's COLOURS.txt calls this token "brand-readable". */
  --brand-ink: #660033;
  /* Paper: the invoice, the garment tag and the bill picture are black on
     white in BOTH themes (they end up on paper or in a customer's camera roll).
     Deliberately not overridden in the dark block below. */
  --paper: #FFFFFF; --paper-ink: #111111; --paper-muted: #555555; --paper-rule: #C9C9C9; --paper-band: #F2F2F2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
:root {
  /* D46 "professional neutral": at night the surfaces are neutral greys and
     plum is an accent only - the primary/New order button (--brand) and the
     Today band (--band, unchanged). The top bar is --surface at night, see
     .topbar. --brand-tint is a neutral selected tint, not plum. */
  --bg: #141114; --surface: #1E1A1D; --surface-sunk: #272226; --line: #373037;
  --ink: #F2EEF0; --ink-muted: #B9B0B6;
  --brand: #7E2E5B; --brand-pressed: #682046; --brand-tint: #2B2228;
  --brand-ink: #E08FBA;
  --zari-ink: #E6C277;
  --ready: #7FC79A; --ready-bg: #1D2F24; --progress: #E6C277; --progress-bg: #33291A;
  --trial: #9CC7E6; --trial-bg: #182A36; --late: #F2A39C; --late-bg: #3A1D1A;
  --shadow-sheet: 0 -8px 24px rgba(0,0,0,0.5);
  --shadow-fab: 0 6px 16px rgba(0,0,0,0.55);
  color-scheme: dark;
}
}

/* =========================================================================
   2. TAILORJI COMPONENTS (tj-*) — from the design system
   ========================================================================= */

/* Type styles */
.tj-display-lg { font: 800 30px/36px var(--font-display); }
.tj-display-md { font: 800 22px/28px var(--font-display); }
.tj-title { font: 600 19px/24px var(--font-sans); }
.tj-body { font: 400 15px/22px var(--font-sans); }
.tj-label { font: 600 13px/18px var(--font-sans); letter-spacing: .02em; }
.tj-muted { color: var(--ink-muted); }

body { background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 17px; line-height: 25px; }
.tj-num { font-variant-numeric: tabular-nums; }

/* ---------- Stitch line: the signature divider ---------- */
.tj-stitch { height: var(--stitch-width); border: 0; margin: 0;
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }

/* ---------- Button ---------- */
.tj-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius-md); border: 1.5px solid transparent;
  font: 600 16px/20px var(--font-sans); cursor: pointer; text-decoration: none; }
.tj-btn--primary { background: var(--brand); color: var(--on-brand); }
.tj-btn--primary:active { background: var(--brand-pressed); }
.tj-btn--gold { background: var(--zari); color: var(--on-zari); }
.tj-btn--outline { background: transparent; color: var(--brand); border-color: var(--brand); }
.tj-btn--ghost { background: transparent; color: var(--ink); }
.tj-btn--block { width: 100%; }
.tj-btn:focus-visible { outline: 3px solid var(--zari); outline-offset: 2px; }
.tj-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- Status chip ---------- */
.tj-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--radius-pill);
  font: 600 13px/18px var(--font-sans); letter-spacing: .02em; white-space: nowrap; }
.tj-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tj-chip--ready { color: var(--ready); background: var(--ready-bg); }
.tj-chip--progress { color: var(--progress); background: var(--progress-bg); }
.tj-chip--trial { color: var(--trial); background: var(--trial-bg); }
.tj-chip--late { color: var(--late); background: var(--late-bg); }
.tj-chip--late::before { border-radius: 1px; transform: rotate(45deg); }

/* ---------- Stage track: stages joined by a stitch line, done stages are gold buttons ---------- */
.tj-stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: relative; }
.tj-stages::before { content: ""; position: absolute; left: 11%; right: 11%; top: 11px; height: var(--stitch-width);
  background-image: linear-gradient(to right, var(--line) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); }
.tj-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font: 600 12px/16px var(--font-sans); color: var(--ink-muted); text-align: center; }
.tj-stage__dot { width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center; }
.tj-stage--done .tj-stage__dot { background: var(--zari); border-color: var(--zari); }
.tj-stage--done .tj-stage__dot::after { content: ""; width: 10px; height: 10px;
  background: linear-gradient(45deg, transparent 40%, var(--on-zari) 40%, var(--on-zari) 60%, transparent 60%),
              linear-gradient(-45deg, transparent 40%, var(--on-zari) 40%, var(--on-zari) 60%, transparent 60%); }
.tj-stage--now { color: var(--ink); }
.tj-stage--now .tj-stage__dot { border-color: var(--brand); border-width: 3px; }
.tj-stage--done { color: var(--ink); }

/* ---------- Card / order card ---------- */
.tj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.tj-order__top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.tj-order__title { font: 600 19px/24px var(--font-sans); margin: 0; }
.tj-order__meta { font: 400 15px/22px var(--font-sans); color: var(--ink-muted); }
.tj-order__foot { display: flex; justify-content: space-between; align-items: baseline; }
.tj-money { font: 600 22px/26px var(--font-sans); font-variant-numeric: tabular-nums; }
.tj-money--due { color: var(--zari-ink); }

/* ---------- Order slip: a tailor's carbon slip with a perforated top ---------- */
.tj-slip { position: relative; background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); padding: 22px var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.tj-slip::before { content: ""; position: absolute; left: -1px; right: -1px; top: -8px; height: 8px;
  background: radial-gradient(circle at 6px 0, transparent 5px, var(--surface) 5.5px) 0 0 / 12px 8px repeat-x; }
.tj-slip__no { font: 800 22px/28px var(--font-display); color: var(--brand); }
.tj-slip__row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: 15px; line-height: 22px; }
.tj-slip__row span:first-child { color: var(--ink-muted); }

/* ---------- Measurement tape ---------- */
.tj-tape { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border-radius: var(--radius-md); background: var(--surface-sunk); }
.tj-tape__name { flex: 1; font: 600 15px/20px var(--font-sans); }
.tj-tape__ticks { width: 72px; height: 14px; background:
  linear-gradient(to right, var(--ink-muted) 1px, transparent 1px) 0 100% / 6px 7px repeat-x,
  linear-gradient(to right, var(--ink) 1.5px, transparent 1.5px) 0 100% / 30px 14px repeat-x; opacity: .55; }
.tj-tape__val { min-width: 64px; text-align: right; font: 600 22px/26px var(--font-sans); font-variant-numeric: tabular-nums; }
.tj-tape__unit { font: 600 13px/18px var(--font-sans); color: var(--ink-muted); }

/* ---------- Text field ---------- */
.tj-field { display: flex; flex-direction: column; gap: 6px; }
.tj-field label { font: 600 13px/18px var(--font-sans); letter-spacing: .02em; color: var(--ink-muted); }
.tj-field input { min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 400 17px/25px var(--font-sans); }
.tj-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.tj-field__hint { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.tj-field--error input { border-color: var(--late); }
.tj-field--error .tj-field__hint { color: var(--late); }

/* ---------- Profile switcher ---------- */
.tj-profiles { display: flex; flex-direction: column; gap: var(--space-2); }
.tj-profile { display: flex; align-items: center; gap: var(--space-3); min-height: 60px; padding: 0 var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.tj-profile[aria-pressed="true"] { background: var(--brand-tint); border-color: var(--brand); }
.tj-profile__badge { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunk); color: var(--brand); font: 700 15px/1 var(--font-sans); flex: none; }
.tj-profile__text { display: flex; flex-direction: column; flex: 1; }
.tj-profile__role { font: 600 13px/18px var(--font-sans); color: var(--ink-muted); }

/* ---------- Bottom nav ---------- */
.tj-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px; }
.tj-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; color: var(--ink-muted); text-decoration: none; font: 600 12px/16px var(--font-sans); }
.tj-nav a[aria-current="page"] { color: var(--brand); }
.tj-nav a[aria-current="page"] svg { background: var(--brand-tint); border-radius: var(--radius-pill); }
.tj-nav svg { width: 52px; height: 28px; padding: 3px 14px; box-sizing: border-box; }

/* ---------- Gallery tile ---------- */
.tj-tile { display: flex; flex-direction: column; gap: 6px; }
.tj-tile__img { aspect-ratio: 3 / 4; border-radius: var(--radius-md); background: var(--surface-sunk); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-muted); font-size: 13px; overflow: hidden; }
.tj-tile__path { font: 600 13px/18px var(--font-sans); color: var(--ink-muted); }
.tj-tile__path b { color: var(--ink); font-weight: 600; }

/* =========================================================================
   3. APP LAYOUT — the classes the existing screens use, re-made from the
      tokens above (Step 2). Only classes some view still uses are here; the old
      stylesheet's dashboard, chart and theme-toggle rules are gone.
   ========================================================================= */

/* ---- Base ---- */
* { box-sizing: border-box; }
html, body { margin: 0; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--font-sans); font-weight: 600; line-height: 1.25; }
p { margin: 0 0 var(--space-3); }
a { color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--zari); outline-offset: 2px; border-radius: var(--radius-sm); }
.num, .money, .measure, [data-numeric] { font-variant-numeric: tabular-nums; }
.money { font-weight: 600; }
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* The stitch line again, under the names the views already use. */
.seam { height: var(--stitch-width); border: 0; margin: var(--space-4) 0;
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }
.seam-x { display: block; height: var(--stitch-width);
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }

/* Outline icons, 1.8px stroke, round caps; they take the text colour. */
.icon { width: 22px; height: 22px; flex: 0 0 auto; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 28px; height: 28px; }

/* ---- Buttons. ONE plum primary per screen; gold only for money. ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius-md); border: 1.5px solid transparent;
  font: 600 16px/20px var(--font-sans); cursor: pointer; text-decoration: none; white-space: nowrap;
  background: transparent; color: var(--ink); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover, .btn-primary:active { background: var(--brand-pressed); }
.btn-money { background: var(--zari); color: var(--on-zari); }
.btn-outline { border-color: var(--brand-ink); color: var(--brand-ink); }
.btn-ghost { border-color: var(--line); color: var(--ink); }
.btn-ghost:hover, .btn-outline:hover { background: var(--brand-tint); }
.btn-ghost[aria-pressed="true"], .btn-ghost.is-on { border-color: var(--brand-ink); background: var(--brand-tint); color: var(--brand-ink); }
/* "Small" keeps the 48px tap target; it is only a narrower button. */
.btn-sm { padding: 0 var(--space-3); }
.btn-block { width: 100%; margin-top: var(--space-4); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
a.btn { text-decoration: none; }

/* ---- Form fields ---- */
.field { font: 400 17px/25px var(--font-sans); width: 100%; min-height: var(--tap); padding: 0 14px;
  border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
textarea.field { padding: var(--space-3) 14px; }
select.field { padding-right: var(--space-8); }
.field::placeholder { color: var(--ink-muted); }
.field:focus { outline: none; border-color: var(--brand-ink); box-shadow: 0 0 0 3px var(--brand-tint); }
.field-sm { min-height: var(--tap); }
.field-inline { width: auto; }
.field-amount { width: 140px; text-align: right; font-variant-numeric: tabular-nums; }
.field-search { width: min(320px, 100%); }
.field-hint { margin: var(--space-1) 0 0; font-size: 15px; line-height: 22px; color: var(--ink-muted); }
.label { display: block; font: 600 15px/22px var(--font-sans); color: var(--ink-muted); margin-bottom: var(--space-1); }
.req { color: var(--zari-ink); margin-left: var(--space-1); }
.code-input { letter-spacing: .4em; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }
.form-span { grid-column: 1 / -1; }
.flash-list { margin: 0; padding-left: var(--space-6); }

/* ---- App shell: a left rail on desks, a bottom tab bar on phones ---- */
.shell { display: flex; min-height: 100vh; }
.shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.page { flex: 1 1 auto; width: 100%; max-width: 1180px; margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-8); }
.page-flush { padding-top: 0; }

.sidebar { flex: 0 0 var(--rail-w); width: var(--rail-w); background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3);
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-4);
  text-decoration: none; color: var(--ink); }
.sidebar-brand::after { content: ""; display: block; height: var(--stitch-width); margin-top: var(--space-2);
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }
.brand-logo { height: 32px; width: auto; display: block; }
.brand-sub { font: 600 15px/22px var(--font-sans); color: var(--ink); overflow-wrap: anywhere; }

.app-nav { display: flex; flex-direction: column; gap: var(--space-1); }
.app-nav a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: 0 var(--space-3);
  border-radius: var(--radius-md); color: var(--ink-muted); text-decoration: none; font: 600 17px/25px var(--font-sans); }
.app-nav a:hover { color: var(--ink); background: var(--surface-sunk); }
.app-nav a[aria-current="page"] { color: var(--brand-ink); background: var(--brand-tint); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.plan-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.plan-kicker { font: 600 13px/18px var(--font-sans); color: var(--ink-muted); }
.plan-name { font: 600 17px/25px var(--font-sans); }
.plan-card a { font-size: 15px; color: var(--brand-ink); }
.user-card { display: flex; align-items: center; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.user-meta { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.user-name { font-size: 15px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 15px; line-height: 22px; color: var(--ink-muted); text-transform: capitalize; }
.signout { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap); padding: 0 var(--space-2);
  color: var(--ink-muted); text-decoration: none; border-radius: var(--radius-md); font-size: 15px; }
.signout:hover { color: var(--late); background: var(--late-bg); }

.avatar { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; background: var(--brand-tint); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; font: 700 15px/1 var(--font-sans); text-transform: uppercase; }
.avatar-sm { width: 36px; height: 36px; }

/* Phone top bar: the one plum thing on a phone screen by day, carrying the logo. */
.topbar { display: none; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4);
  min-height: 56px; background: var(--brand); color: var(--on-brand); position: sticky; top: 0; z-index: 20; }
.brand-mark-img { height: 28px; width: auto; display: block; }
.app-brand { font: 600 15px/22px var(--font-sans); color: var(--on-brand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* At night the bar is a neutral surface, like the bottom bar (D46); the logo
   stays the ivory one. The bottom bar (.sidebar) is --surface in both themes,
   and its current item is --brand-ink on the now-neutral --brand-tint. */
@media (prefers-color-scheme: dark) {
  .topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
  .app-brand { color: var(--ink); }
}

/* ---- Auth shell (login, code, onboarding, billing, 403): no shop yet ---- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; gap: var(--space-6);
  padding: var(--space-8) var(--space-4); }
.auth-shell .app-header { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.auth-logo { width: 220px; max-width: 100%; height: auto; display: block; }
.brand-rule { width: 120px; }
.auth-card { width: 100%; max-width: 420px; padding: var(--space-6); }
.auth-card-wide { max-width: 780px; }
.auth-alt { margin: var(--space-4) 0 0; font-size: 15px; line-height: 22px; }
.auth-or { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; color: var(--ink-muted); font-size: 15px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.app-header { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-4); margin: var(--space-6) 0; }
.plan-tile { text-align: center; align-items: center; }
.plan-tile form { width: 100%; }

/* ---- Cards and panels: 1px line border, no shadow ---- */
.card, .panel, .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.panel + .panel, .panel + .grid, .grid + .panel, .flash + .panel { margin-top: var(--space-4); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4); }
.panel-head + .panel-body, .panel-head + .panel-body-flush, .panel-head + .table-wrap, .panel-head + .filters { border-top: 1px solid var(--line); }
.panel-title { font: 600 19px/24px var(--font-sans); margin: 0; }
.panel-sub { font-size: 15px; line-height: 22px; color: var(--ink-muted); margin: 2px 0 0; }
.panel-body { padding: var(--space-4); }
.panel-body-flush { padding: 0; }
.section-heading { font: 600 17px/25px var(--font-sans); color: var(--ink); margin: 0; }
.section-heading::after { content: ""; display: block; height: var(--stitch-width); margin-top: var(--space-2);
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.page-title { font: 600 26px/32px var(--font-sans); color: var(--ink); margin: 0; }
.page-sub { color: var(--ink-muted); font-size: 17px; line-height: 25px; margin: var(--space-1) 0 0; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---- Grids and stacks ---- */
.grid { display: grid; gap: var(--space-4); }
.grid-split { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.grid-split > .panel + .panel, .grid > .panel + .panel { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.cluster { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cluster-top { margin-top: var(--space-4); }

/* ---- Figure tiles (customer page, billing plans) ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.tile-grid-tight { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); color: var(--ink); text-decoration: none; }
.tile-top { display: flex; align-items: center; gap: var(--space-3); }
.tile-icon { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand-ink); }
.tile-icon-gold { background: var(--progress-bg); color: var(--zari-ink); }
.tile-label { color: var(--ink-muted); font-size: 15px; line-height: 22px; }
.tile-value { font: 600 26px/30px var(--font-sans); font-variant-numeric: tabular-nums; }
.unit { color: var(--ink-muted); margin-right: 1px; }

/* ---- Pills (non-stage labels) and stage dots ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px; border-radius: var(--radius-pill);
  font: 600 13px/18px var(--font-sans); letter-spacing: .02em; white-space: nowrap; background: var(--surface-sunk); color: var(--ink-muted); }
.pill-ok { color: var(--ready); background: var(--ready-bg); }
.pill-warn { color: var(--progress); background: var(--progress-bg); }
.pill-bad { color: var(--late); background: var(--late-bg); }
.pill-neutral { color: var(--ink-muted); background: var(--surface-sunk); }
/* A stage that has been done: a small gold "sewn button" (signature 1). */
.dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--zari); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; container-type: inline-size; }
.table { width: 100%; border-collapse: collapse; font-size: 17px; line-height: 25px; }
.table th { text-align: left; font: 600 15px/22px var(--font-sans); color: var(--ink-muted); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-sunk); }
.right, .table .right { text-align: right; }
.nowrap, .table .nowrap { white-space: nowrap; }
.cell-stack { display: flex; flex-direction: column; line-height: 1.35; }
.cell-meta { font-size: 15px; line-height: 22px; color: var(--ink-muted); }
.cell-id { display: flex; align-items: center; gap: var(--space-3); }
.table a { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a:hover { color: var(--brand-ink); text-decoration: underline; }
.is-retired td { opacity: .62; }

/* ---- Money tables become cards when THEIR AREA is narrow (container query)
   so a total is never cut off on a phone. A card is the same row re-laid:
   every cell shown, none hidden; only the header row is visually hidden.
   The two switch copies below must stay identical (TableCardsTest). ---- */
.tc-id     { grid-area: id; }
.tc-who    { grid-area: who; }
.tc-stage  { grid-area: stage; }
.tc-due    { grid-area: due; justify-self: end; }
.tc-pay    { grid-area: pay; }
.tc-money  { grid-area: money; justify-self: end; }
.tc-no     { grid-area: no; justify-self: end; }
.tc-city   { grid-area: city; }
.tc-count  { grid-area: count; justify-self: end; }
.tc-last   { grid-area: last; }
.tc-work   { grid-area: work; }
.tc-form   { grid-area: form; }
.tc-family { grid-area: family; }
.tc-flag   { grid-area: flag; justify-self: end; }
.tc-action { grid-area: action; justify-self: end; }

.cards-customer-orders tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "id stage money" "id stage due"; }
.cards-orders tr          { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "id who money" ". stage due" ". pay pay"; }
.cards-customers tr       { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who money" "city count" "last no"; }
.cards-garments tr        { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "form form form" "family flag action"; }
.cards-items tr           { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who money" "work count"; }
.cards-payments tr        { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who money"; }

@container (max-width: 520px) {
  .table.table-cards, .table.table-cards > tbody { display: block; }
  .table.table-cards > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .table.table-cards > tbody > tr {
    display: grid; position: relative; column-gap: var(--space-3); row-gap: var(--space-1);
    align-items: baseline; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line);
  }
  .table.table-cards > tbody > tr:last-child { border-bottom: 0; }
  .table-wrap .table.table-cards > tbody > tr > td { display: block; padding: 0; border: 0; min-width: 0; }
  .table-wrap .table.table-cards > tbody > tr > td.tc-who { overflow-wrap: anywhere; }
  .table-wrap .table.table-cards > tbody > tr > td.tc-who .cell-meta { overflow-wrap: normal; white-space: nowrap; }
  .table.table-cards .tc-money { font-weight: 600; }
  .table.table-cards .tc-link::after { content: ""; position: absolute; inset: 0; }
  .table.table-cards [data-label]::before {
    content: attr(data-label) " "; font-size: 15px; color: var(--ink-muted);
  }
}

@container (max-width: 760px) {
  .table.table-cards-wide, .table.table-cards-wide > tbody { display: block; }
  .table.table-cards-wide > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .table.table-cards-wide > tbody > tr {
    display: grid; position: relative; column-gap: var(--space-3); row-gap: var(--space-1);
    align-items: baseline; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line);
  }
  .table.table-cards-wide > tbody > tr:last-child { border-bottom: 0; }
  .table-wrap .table.table-cards-wide > tbody > tr > td { display: block; padding: 0; border: 0; min-width: 0; }
  .table-wrap .table.table-cards-wide > tbody > tr > td.tc-who { overflow-wrap: anywhere; }
  .table-wrap .table.table-cards-wide > tbody > tr > td.tc-who .cell-meta { overflow-wrap: normal; white-space: nowrap; }
  .table.table-cards-wide .tc-money { font-weight: 600; }
  .table.table-cards-wide .tc-link::after { content: ""; position: absolute; inset: 0; }
  .table.table-cards-wide [data-label]::before {
    content: attr(data-label) " "; font-size: 15px; color: var(--ink-muted);
  }

  /* The customers card's second and third lines sit under the NAME, not
     under the avatar: 36px avatar + the cell-id gap. */
  .table-wrap .table.table-cards-wide > tbody > tr > td.tc-city,
  .table-wrap .table.table-cards-wide > tbody > tr > td.tc-last { padding-left: calc(36px + var(--space-3)); }
}

/* Tone for a due date. Late is the only thing allowed to shout. */
.due-overdue { color: var(--late); font-weight: 600; }
.due-soon    { color: var(--zari-ink); }
.due-none    { color: var(--ink-muted); }

/* ---- Definition lists (record detail, money summary) ---- */
.dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--space-3) var(--space-6); margin: 0; }
.dl-cols { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-4); }
.dl-cols > div { display: flex; flex-direction: column; gap: 2px; }
.dl dt { color: var(--ink-muted); font-size: 15px; line-height: 22px; }
.dl dd { margin: 0; }
.dl-money { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-6); margin: 0; }
.dl-money dt { color: var(--ink-muted); }
.dl-money dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
/* The balance line is money still owed: zari ink, above a stitch line. */
.dl-money .total { color: var(--zari-ink); font-weight: 600; font-size: 22px; line-height: 26px; }
.dl-money .total-row { padding-top: var(--space-3);
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; background-position: top left; }

/* ---- Stage history: steps joined by a stitch line ---- */
.timeline { list-style: none; margin: 0; padding: var(--space-4); display: flex; flex-direction: column; }
.timeline-step { display: grid; grid-template-columns: 10px 1fr; align-items: start; gap: var(--space-4); padding-bottom: var(--space-4); position: relative; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before { content: ""; position: absolute; left: 4px; top: 16px; bottom: 0; width: var(--stitch-width);
  background-image: linear-gradient(to bottom, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: var(--stitch-width) calc(var(--stitch-dash) + var(--stitch-gap)); background-repeat: repeat-y; }
.timeline-step:last-child::before { display: none; }
.timeline-step .dot { margin-top: 7px; }

/* ---- Small bar lists (measurement completion) ---- */
.barlist { display: flex; flex-direction: column; }
.barlist-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 56px; align-items: center; gap: var(--space-3);
  min-height: var(--tap); padding: var(--space-2) var(--space-4); color: var(--ink); text-decoration: none; }
.barlist-row + .barlist-row { border-top: 1px solid var(--line); }
.barlist-row:hover { background: var(--surface-sunk); }
.barlist-label { display: flex; align-items: baseline; gap: var(--space-2); min-width: 0; }
.barlist-code { font-weight: 600; }
.barlist-name { color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-track { display: block; height: 8px; border-radius: var(--radius-pill); background: var(--surface-sunk); overflow: hidden; }
.barlist-fill { display: block; height: 100%; border-radius: var(--radius-pill); background: var(--zari); min-width: 2px; }
.barlist-value { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Paid meter on the order list ---- */
.meter { display: flex; gap: 2px; height: 8px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-sunk); }
.meter-seg { display: block; height: 100%; min-width: 2px; }
.meter-seg-accent { background: var(--zari); }

/* ---- Empty states: say what will appear, offer one button ---- */
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-6) var(--space-4); color: var(--ink-muted); }
.empty-mark { width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--progress-bg); color: var(--zari-ink); }
.empty-title { color: var(--ink); font: 600 19px/24px var(--font-sans); }
.empty-body { max-width: 52ch; margin: 0; font-size: 17px; line-height: 25px; color: var(--ink-muted); }

/* ---- Messages ---- */
.flash { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--line); margin-bottom: var(--space-4); font-size: 17px; line-height: 25px; }
.flash-ok  { border-color: var(--ready); background: var(--ready-bg); color: var(--ink); }
.flash-bad { border-color: var(--late); background: var(--late-bg); color: var(--ink); }

/* ---- Filter bar ---- */
.filters { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.filters-foot { border-bottom: 0; border-top: 1px solid var(--line); color: var(--ink-muted); }
.filters-scroll { display: flex; gap: var(--space-2); overflow-x: auto; padding-bottom: var(--space-1); }
.dash-more { margin: 0; font-size: 15px; line-height: 22px; }
.dash-more a { color: var(--brand-ink); }

/* ---- Today (/dashboard) ---- */
.today-band { background: var(--band); color: var(--on-brand); border-radius: var(--radius-lg); padding: var(--space-6); margin-bottom: var(--space-6); }
.today-greet { font: 800 30px/36px var(--font-display); margin: 0; color: var(--on-brand); }
.today-date { margin: var(--space-1) 0 var(--space-4); color: var(--on-brand); opacity: .85; }
.today-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.today-count { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--band-deep); color: var(--on-brand); text-decoration: none; min-height: var(--tap); }
.today-count b { font: 600 30px/34px var(--font-sans); font-variant-numeric: tabular-nums; }
.today-count span { font-size: 15px; line-height: 22px; }
/* D30: the three tiles look the same; Late is carried by its text colour only,
   a late red that reads on the plum band in both themes. */
.today-count--late { color: var(--late-on-band); }
.today-collect { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2) var(--space-4); align-items: baseline;
  margin-top: var(--space-4); padding-top: var(--space-4); color: var(--zari);
  background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; background-position: top left; }
.today-collect .tj-money { color: var(--zari); }
.today-section { margin-bottom: var(--space-6); }
.today-section h2 { font: 600 19px/24px var(--font-sans); margin: 0 0 var(--space-3); display: flex; gap: var(--space-2); align-items: baseline; }
.today-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-3); }
.today-list a.tj-card { color: var(--ink); text-decoration: none; }
.today-list a.tj-card:hover { border-color: var(--brand-ink); }
.today-empty { color: var(--ink-muted); margin: 0; }
/* The floating New order button: plum, the one place (with sheets) a shadow
   is allowed. */
.fab { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 30; box-shadow: var(--shadow-fab); border-radius: var(--radius-pill); padding: 0 var(--space-6); }

/* ---- "More" page ---- */
.more-list { list-style: none; margin: 0; padding: 0; }
.more-list li + li { border-top: 1px solid var(--line); }
.more-list a { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: 0 var(--space-4); color: var(--ink); text-decoration: none; font-size: 17px; }
.more-list a:hover { background: var(--surface-sunk); }

/* ---------- Team (Step 3, W3): people rows joined by the stitch line ---------- */
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li + li { background-image: linear-gradient(to right, var(--zari) var(--stitch-dash), transparent var(--stitch-dash));
  background-size: calc(var(--stitch-dash) + var(--stitch-gap)) var(--stitch-width); background-repeat: repeat-x; }
.team-list a, .team-list .team-row { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-2) var(--space-4); color: var(--ink); text-decoration: none; }
.team-list a:hover { background: var(--surface-sunk); }
.team-row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.team-row-name { font-size: 17px; line-height: 25px; overflow-wrap: anywhere; }

/* Role chips: a radio group that looks like chips. 48px taps, words only. */
.tj-choices { display: flex; flex-wrap: wrap; gap: var(--space-2); border: 0; padding: 0; margin: 0; min-width: 0; }
.tj-choices legend { padding: 0; }
.tj-choice { position: relative; }
.tj-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tj-choice span { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-4); border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 17px; cursor: pointer; }
.tj-choice input:checked + span { border-color: var(--brand-ink); background: var(--brand-tint); color: var(--brand-ink); font-weight: 600; }
.tj-choice input:focus-visible + span { outline: 3px solid var(--zari); outline-offset: 2px; }

/* ---- Breakpoints ---- */
@media (max-width: 1080px) {
  .grid-split { grid-template-columns: minmax(0, 1fr); }
}

/* Phone and small tablet: the rail becomes a bottom tab bar with the same four
   items (word under icon); the shop name and logo move to a plum top bar. */
@media (max-width: 860px) {
  .topbar { display: flex; }
  .shell { display: block; }
  /* Room under the last line for the tab bar AND the floating New order button. */
  .page { padding: var(--space-4) var(--space-4) calc(var(--tap) * 3 + var(--space-6)); }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 25; width: auto; height: auto;
    flex-direction: row; padding: var(--space-1); gap: 0; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .app-nav { flex-direction: row; width: 100%; gap: 0; }
  .app-nav a { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; min-height: 56px; padding: var(--space-1);
    font-size: 15px; line-height: 20px; text-align: center; }
  .page-title { font-size: 22px; line-height: 28px; }
  .table th, .table td { padding: var(--space-2) var(--space-3); }
  .fab { bottom: calc(56px + var(--space-6)); right: var(--space-4); }
  .today-band { padding: var(--space-4); border-radius: var(--radius-md); }
  .today-greet { font-size: 26px; line-height: 32px; }
}

@media (max-width: 420px) {
  .today-counts { gap: var(--space-2); }
  .today-count { padding: var(--space-2); }
  .today-count b { font-size: 26px; line-height: 30px; }
  .barlist-row { grid-template-columns: minmax(0, 1fr) 80px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =========================================================================
   PRINT DOCUMENTS — invoice, garment tag, bill picture page (body.doc)
   Paper in both themes: inside .doc the theme tokens are re-pointed at the
   paper ones and the always-plum band, so buttons and text never follow the
   device into dark. Screen-only furniture carries .noprint.
   ========================================================================= */
.doc { --bg: var(--paper); --surface: var(--paper); --surface-sunk: var(--paper-band); --line: var(--paper-rule);
  --ink: var(--paper-ink); --ink-muted: var(--paper-muted);
  --brand: var(--band); --brand-pressed: var(--band-deep); --brand-ink: var(--band);
  color-scheme: light; margin: 0; padding: var(--space-6) var(--space-4);
  background: var(--paper); color: var(--paper-ink); font-size: 15px; line-height: 22px; }
.doc-sheet { max-width: 720px; margin: 0 auto; }
.doc-narrow { max-width: 680px; margin: 0 auto; }
.doc h1 { margin: 0 0 var(--space-1); font: 700 24px/30px var(--font-sans); }
.doc .muted { color: var(--paper-muted); }
.doc .num { font-variant-numeric: tabular-nums; }
.doc table { width: 100%; border-collapse: collapse; margin-top: var(--space-4); }
.doc th, .doc td { padding: var(--space-2); text-align: left; border-bottom: 1px solid var(--paper-rule); }
.doc td.r, .doc th.r { text-align: right; }
.doc-right { text-align: right; }
.doc-billto { margin-top: var(--space-4); }
.doc .row { display: flex; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.doc .totals { width: 280px; max-width: 100%; margin-left: auto; margin-top: var(--space-3); }
.doc .totals td { border: 0; padding: var(--space-1) var(--space-2); }
.doc .totals .grand { font-weight: 700; border-top: 2px solid var(--paper-ink); }
/* Small, muted, and ruled off from the money above it: a note about the
   stationery, never a second sender competing with the shop's name. */
.doc .attrib { margin: var(--space-8) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--paper-rule);
  text-align: center; font-size: 13px; line-height: 18px; color: var(--paper-muted); }
.doc-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin: 0 0 var(--space-4); }
.doc-hint { color: var(--paper-muted); margin: var(--space-2) 0 0; }
/* The garment tag: a cut-out card, dashed like a tailor's chalk line. */
.doc-tag { width: 300px; max-width: 100%; border: 2px dashed var(--paper-ink); border-radius: var(--radius-sm); padding: var(--space-4); }
.doc-tag__no { font: 800 28px/34px var(--font-display); font-variant-numeric: lining-nums tabular-nums; }
.doc-tag__k { color: var(--paper-muted); font: 600 13px/18px var(--font-sans); text-transform: uppercase; letter-spacing: .04em; }
.doc-tag__v { margin-bottom: var(--space-2); }
/* The bill picture scales down on a narrow phone but never blurs: it is
   vectors, and the picture that gets SAVED is rendered from the source. */
.doc #bill-svg { width: 100%; height: auto; display: block; }

@media print {
  .sidebar, .topbar, .page-actions, .filters, .btn, .fab, .noprint { display: none !important; }
  .page { max-width: none; padding: 0; }
  .doc { padding: 0; }
}
