/* ============================================================================
   Shivoli management panel — design system
   Direction: Swiss minimal, dense dashboard, Shivoli's own cream / burgundy /
   gold. Everything below is built from tokens: a colour, a space or a radius
   is never written twice, so the whole panel can be retuned from one place.
   ========================================================================= */

/* ------------------------------------------------------------- 1. tokens */
:root {
  /* -- brand primitives ---------------------------------------------- */
  --brand-900: #571022;
  --brand-800: #6E1B32;
  --brand-700: #8E2B46;
  --brand-tint: rgba(110, 27, 50, 0.08);
  --brand-tint-strong: rgba(110, 27, 50, 0.14);

  --gold-600: #7C5C30;   /* passes 4.5:1 on cream — use for gold *text* */
  --gold-500: #B08B57;   /* decorative gold — rules, dots, edges */
  --gold-tint: rgba(176, 139, 87, 0.14);

  --stone-000: #FFFFFF;   /* kept only for *text* sitting on burgundy */
  --paper:     #FDF8EE;   /* card / panel surface — warm paper, never white */
  --stone-050: #F6EFE1;   /* page background — light cream */
  --stone-100: #F0E7D6;
  --stone-200: #E7DCC7;
  --stone-300: #DBCEB6;
  --stone-600: #6B605A;
  --stone-900: #2B2320;

  /* -- status primitives --------------------------------------------- */
  --green-700: #2A6046;
  --amber-700: #8A5F10;
  --red-700: #99282C;
  --blue-700: #35525F;
  --green-700-deep: #21503A;   /* one step darker: the hover of a face */
  --red-700-deep: #832225;
  --gold-600-deep: #6B4F28;

  /* -- status tints (the same colour, low alpha, behind a chip or a note) -- */
  --success-tint: rgba(42, 96, 70, .12);
  --success-tint-soft: rgba(42, 96, 70, .08);
  --success-line: rgba(42, 96, 70, .26);
  --warning-tint: rgba(138, 95, 16, .13);
  --warning-tint-soft: rgba(138, 95, 16, .08);
  --warning-line: rgba(138, 95, 16, .26);
  --danger-tint: rgba(153, 40, 44, .12);
  --danger-tint-soft: rgba(153, 40, 44, .08);
  --danger-line: rgba(153, 40, 44, .28);
  --danger-edge: rgba(153, 40, 44, .35);
  --info-tint: rgba(53, 82, 95, .12);
  --info-tint-soft: rgba(53, 82, 95, .07);
  --info-line: rgba(53, 82, 95, .26);

  /* -- semantic surface ---------------------------------------------- */
  --cream: var(--stone-050);
  --cream-soft: var(--stone-100);
  --cream-deep: var(--stone-200);
  --line: var(--stone-300);
  --line-soft: var(--stone-200);
  --white: var(--stone-000);
  --surface: var(--paper);
  --surface-sunken: var(--stone-100);
  /* the two bars that float over the page and let it show through */
  --surface-glass: rgba(253, 248, 238, .88);
  --surface-glass-solid: rgba(253, 248, 238, .985);
  --backdrop: rgba(43, 35, 32, .38);
  --row-stripe: rgba(176, 139, 87, .05);
  --placeholder: #7A716A;
  --dot-ring: rgba(0, 0, 0, .06);
  --chart-grid: #EDE3D6;
  --brand-glow: rgba(110, 27, 50, .10);
  --gold-glow: rgba(176, 139, 87, .12);
  --attention-edge: rgba(176, 139, 87, .55);
  --attention-glow: rgba(176, 139, 87, .10);

  /* -- semantic text -------------------------------------------------- */
  --ink: var(--stone-900);
  --ink-soft: var(--stone-600);
  --burgundy: var(--brand-800);
  --burgundy-soft: var(--brand-700);
  --burgundy-tint: var(--brand-tint);
  --gold: var(--gold-500);
  --success: var(--green-700);
  --warning: var(--amber-700);
  --danger: var(--red-700);
  --info: var(--blue-700);
  --ring: var(--brand-700);

  /* -- spacing (density 8/10 — dashboard) ----------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* -- shape ---------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* -- elevation (warm-tinted, never neutral grey) --------------------- */
  --shadow-xs: 0 1px 2px rgba(43, 35, 32, .05);
  --shadow: 0 1px 2px rgba(43, 35, 32, .04), 0 2px 10px rgba(43, 35, 32, .05);
  --shadow-md: 0 6px 18px rgba(43, 35, 32, .09);
  --shadow-lg: 0 14px 44px rgba(43, 35, 32, .13);

  /* -- motion --------------------------------------------------------- */
  --ease: cubic-bezier(.32, .72, .35, 1);
  --t-fast: 120ms;
  --t: 180ms;
  --t-slow: 260ms;

  /* -- type ----------------------------------------------------------- */
  --font: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --text-xs: 11.5px;
  --text-sm: 12.5px;
  --text-base: 13.5px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 21px;

  --sidebar-w: 258px;

  /* native widgets — scrollbars, date pickers, checkboxes — follow the theme */
  color-scheme: light;
}

/* ------------------------------------------------- 1b. حالت تاریک (dark)
   The same panel after dark: warm charcoal instead of cream, the burgundy
   lifted to a rose so it still reads as text on a dark ground, and the gold
   kept as the accent it already is. Nothing here is a new rule — only the
   tokens are restated, so every component follows without being touched.
   The theme is chosen by the person and stored in the browser; the boot
   script in <head> writes it on <html> before the first paint. */
:root[data-theme="dark"] {
  color-scheme: dark;

  /* brand: burgundy becomes a rose, because a dark red on a dark ground
     cannot be read. On-brand text turns dark in exchange. */
  --brand-900: #F6CBD6;
  --brand-800: #E28CA4;
  --brand-700: #F2A5B9;
  --brand-tint: rgba(226, 140, 164, 0.16);
  --brand-tint-strong: rgba(226, 140, 164, 0.26);

  --gold-600: #E0BE8C;   /* gold *text*, light enough to read on charcoal */
  --gold-500: #D6B078;
  --gold-tint: rgba(214, 176, 120, 0.14);

  --stone-000: #1C1512;   /* the ink that sits *on* rose or gold */
  --paper:     #241D1B;   /* card / panel surface */
  --stone-050: #17120F;   /* page background */
  --stone-100: #2B2320;
  --stone-200: #352B27;
  --stone-300: #453832;
  --stone-600: #B4A79B;
  --stone-900: #F2E7D8;

  /* status: the same four meanings, lifted to read on a dark ground */
  --green-700: #6FCF97;
  --amber-700: #E3B45F;
  --red-700: #F0888C;
  --blue-700: #8FBDCF;
  --green-700-deep: #57B57F;
  --red-700-deep: #D96E73;
  --gold-600-deep: #C9A167;

  --success-tint: rgba(111, 207, 151, .15);
  --success-tint-soft: rgba(111, 207, 151, .10);
  --success-line: rgba(111, 207, 151, .34);
  --warning-tint: rgba(227, 180, 95, .15);
  --warning-tint-soft: rgba(227, 180, 95, .10);
  --warning-line: rgba(227, 180, 95, .34);
  --danger-tint: rgba(240, 136, 140, .15);
  --danger-tint-soft: rgba(240, 136, 140, .10);
  --danger-line: rgba(240, 136, 140, .34);
  --danger-edge: rgba(240, 136, 140, .42);
  --info-tint: rgba(143, 189, 207, .15);
  --info-tint-soft: rgba(143, 189, 207, .10);
  --info-line: rgba(143, 189, 207, .34);

  --surface-glass: rgba(36, 29, 27, .88);
  --surface-glass-solid: rgba(36, 29, 27, .985);
  --backdrop: rgba(0, 0, 0, .58);
  --row-stripe: rgba(214, 176, 120, .045);
  --placeholder: #8E8278;
  --dot-ring: rgba(255, 255, 255, .14);
  --chart-grid: #3A2F2A;
  --brand-glow: rgba(226, 140, 164, .12);
  --gold-glow: rgba(214, 176, 120, .10);
  --attention-edge: rgba(214, 176, 120, .5);
  --attention-glow: rgba(214, 176, 120, .12);

  /* a dark page casts a real shadow, not a warm grey one */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow: 0 1px 2px rgba(0, 0, 0, .34), 0 2px 10px rgba(0, 0, 0, .34);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .46);
  --shadow-lg: 0 14px 44px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* The page is never wider than the screen. «clip» (not «hidden») on body keeps
   the sticky top bar working; html's «hidden» goes to the viewport itself. */
html { overflow-x: hidden; }
body { overflow-x: clip; }

a { color: var(--burgundy); text-decoration: none; transition: color var(--t-fast) var(--ease); }
a:hover { color: var(--burgundy-soft); }

::selection { background: var(--brand-tint-strong); color: var(--brand-900); }

/* One focus ring for the whole panel: always visible, never removed. */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Icons are drawn, never typed: one outline family, aligned to the text. */
.ico { flex: none; vertical-align: -.18em; }

/* Straight to the page for anyone arriving by keyboard. */
.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  top: -60px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--burgundy);
  color: var(--white);
  font-size: var(--text-sm);
  transition: top var(--t) var(--ease);
}
.skip-link:focus { top: var(--space-3); color: var(--white); }

/* Nobody is thrown around by motion they did not ask for. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------- 2. layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--cream-soft), var(--cream-deep));
  border-inline-start: 2px solid var(--gold-tint);
  padding: var(--space-5) var(--space-3) var(--space-8);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--stone-300) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: var(--radius-pill); }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.brand {
  text-align: center;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-4);
}
/* The atelier's own mark sits above the wordmark; it is a PNG with a
   transparent ground, so it reads on the cream sidebar and on white paper. */
.brand__logo {
  display: block;
  margin: 0 auto var(--space-2);
  height: 62px;
  width: auto;
  max-width: 100%;
}
.brand__mark {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 5px;
  color: var(--burgundy);
  display: block;
  line-height: 1.25;
}
.brand__name { font-size: var(--text-sm); color: var(--ink-soft); letter-spacing: .6px; }

.nav-group { margin-bottom: var(--space-4); }
.nav-group--fold { margin-bottom: var(--space-1); }
.nav-group__title {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  letter-spacing: .8px;
  padding: 0 var(--space-2) var(--space-1);
  font-weight: 600;
}
button.nav-group__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: start;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
button.nav-group__title:hover { background: var(--cream-soft); color: var(--ink); }
.nav-group__label { flex: 1; }
.nav-group__caret {
  display: inline-flex;
  color: var(--gold-500);
  transition: transform var(--t) var(--ease);
}
body[dir="rtl"] .nav-group__caret { transform: rotate(180deg); }
.nav-group.is-open .nav-group__caret,
body[dir="rtl"] .nav-group.is-open .nav-group__caret { transform: rotate(90deg); }
.nav-group.is-open > button.nav-group__title { color: var(--burgundy); }
/* Closed by default so only one branch of the menu is on screen at a time; the
   sidebar script opens the group that holds the current page. */
.nav-group--fold > .nav-group__body { display: none; }
.nav-group--fold.is-open > .nav-group__body { display: block; padding-bottom: var(--space-1); }

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: var(--text-base);
  margin-bottom: 2px;
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-link:hover { background: var(--cream-soft); color: var(--ink); }
.nav-link.is-active {
  background: var(--burgundy);
  color: var(--white);
  font-weight: 500;
  box-shadow: var(--shadow-xs);
}
.nav-link.is-active:hover { background: var(--burgundy); color: var(--white); }
/* A gold edge marks the page you are on even where colour alone is missed. */
.nav-link.is-active::before {
  content: "";
  position: absolute;
  inset-block: 6px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: var(--radius-pill);
  background: var(--gold-500);
}
.nav-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  color: var(--ink-soft);
  transition: color var(--t-fast) var(--ease);
}
.nav-link:hover .nav-link__icon { color: var(--burgundy); }
.nav-link.is-active .nav-link__icon { color: var(--white); }

/* How many decisions are waiting, next to the two sign-off links. */
.nav-badge {
  margin-inline-start: auto;
  min-width: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--gold-600);
  color: var(--white);
  font-size: var(--text-xs);
  line-height: 19px;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nav-link.is-active .nav-badge { background: var(--surface); color: var(--burgundy); }
.nav-sub { padding-inline-start: var(--space-3); }
.nav-sub .nav-link { font-size: var(--text-sm); padding: var(--space-1) var(--space-3); color: var(--ink-soft); }
.nav-sub .nav-link:hover { color: var(--ink); }
.nav-sub .nav-link.is-active { color: var(--white); }

/* On a phone the menu slides over the page; the page behind it dims. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--backdrop);
  backdrop-filter: blur(2px);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface-glass);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__title { font-size: var(--text-lg); font-weight: 600; margin: 0; line-height: 1.4; }
.topbar__meta { font-size: var(--text-sm); color: var(--ink-soft); line-height: 1.5; }
.topbar__user { display: flex; align-items: center; gap: var(--space-3); }
.topbar__lead { display: flex; align-items: center; gap: var(--space-3); }
.topbar__who { text-align: start; }
.topbar__who-name { font-size: var(--text-base); font-weight: 500; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--burgundy-tint); color: var(--burgundy);
  display: grid; place-items: center; font-weight: 600;
  border: 1px solid var(--brand-tint-strong);
  flex: none;
}

.content { padding: var(--space-6) var(--space-6) 64px; flex: 1; }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--burgundy);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.menu-toggle:hover { background: var(--cream-soft); border-color: var(--line); }

/* -------------------------------------------------------------- 3. cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--gold-tint);
}
.card__title { font-size: var(--text-md); font-weight: 600; margin: 0; letter-spacing: -.1px; }
.card--flat { box-shadow: none; }

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset-block-start: 0; inset-inline-start: 0;
  width: 3px; height: 100%; background: var(--burgundy);
}
.stat--gold::after { background: var(--gold-500); }
.stat--success::after { background: var(--success); }
.stat--danger::after { background: var(--danger); }
.stat--warning::after { background: var(--warning); }
.stat__label { font-size: var(--text-sm); color: var(--ink-soft); margin-bottom: var(--space-1); }
.stat__value {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -.4px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.stat__unit { font-size: var(--text-sm); color: var(--ink-soft); font-weight: 400; margin-inline-start: var(--space-1); }
.stat__hint { font-size: var(--text-xs); color: var(--ink-soft); margin-top: var(--space-1); }

/* a figure with a page behind it: same card, but it says so on hover */
a.stat--link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease), border-color var(--t) var(--ease);
}
a.stat--link:hover { border-color: var(--gold-500); transform: translateY(-2px); box-shadow: var(--shadow-md); }
a.stat--link .stat__label::after { content: " \203A"; color: var(--ink-soft); }

/* ------------------------------------------------------------- 4. tables */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  scrollbar-width: thin;
}
table.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
table.table th {
  text-align: right;
  font-weight: 600;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: linear-gradient(180deg, var(--cream-soft), var(--cream-deep));
  /* the header stays put while a long list scrolls under it */
  position: sticky;
  top: 0;
  z-index: 1;
}
table.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.table tbody tr { transition: background var(--t-fast) var(--ease); }
table.table tbody tr:nth-child(even) { background: var(--row-stripe); }
table.table tbody tr:hover { background: var(--gold-tint); }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tfoot td {
  font-weight: 700;
  background: var(--surface-sunken);
  border-top: 2px solid var(--line);
}
.table--compact td, .table--compact th { padding: var(--space-1) var(--space-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* -- an amount ------------------------------------------------------------
   Every sum on the panel is printed twice: the figure in tomans, and the same
   figure spelled out under it. The words are what catch a missing or an extra
   zero, so they sit with the number everywhere — in a table cell, in a stat
   tile and under a box that is being typed into. */
.amount { display: inline-block; vertical-align: top; max-width: 100%; }
.amount__num { display: block; }
.amount__words {
  display: block;
  white-space: normal;
  font-size: 0.72em;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-top: 1px;
}
.stat__value .amount__num { display: inline; }
.stat__value .amount__words {
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: normal;
}

/* the live echo written under a money box while it is being filled in */
.amount-echo {
  display: block;
  min-height: 1em;
  margin-top: 3px;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--ink-soft);
}
.amount-echo:empty { min-height: 0; margin-top: 0; }

.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: var(--space-8) var(--space-3);
  font-size: var(--text-base);
}

/* ------------------------------------------------------------- 5. badges */
.badge {
  display: inline-block;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--cream-deep);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge--burgundy { background: var(--brand-tint); color: var(--burgundy); }
.badge--gold { background: var(--gold-tint); color: var(--gold-600); }
.badge--success { background: var(--success-tint); color: var(--success); }
.badge--warning { background: var(--warning-tint); color: var(--warning); }
.badge--danger { background: var(--danger-tint); color: var(--danger); }
.badge--info { background: var(--info-tint); color: var(--info); }
.badge--purple { background: #efe4fb; color: #6b2fb3; }
.badge--dot::before { content: "\2022"; margin-inline-end: var(--space-1); }

/* ------------------------------------------------------------ 6. buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  min-height: 36px;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  background: var(--burgundy);
  color: var(--white);
  box-shadow: var(--shadow-xs);
  transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--burgundy-soft); color: var(--white); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn--ghost { background: var(--surface); color: var(--burgundy); border-color: var(--line); box-shadow: none; }
.btn--ghost:hover { background: var(--cream-soft); color: var(--burgundy); border-color: var(--gold-500); }
.btn--gold { background: var(--gold-600); }
.btn--gold:hover { background: var(--gold-600-deep); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: var(--red-700-deep); }
.btn--success { background: var(--success); }
.btn--success:hover { background: var(--green-700-deep); }
.btn--sm { padding: var(--space-1) var(--space-3); min-height: 30px; font-size: var(--text-sm); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* -------------------------------------------------------------- 7. forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* a hidden field stays hidden even though .field sets its own display */
[hidden] { display: none !important; }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field--full { grid-column: 1 / -1; }
/* Every field says what it is above itself, never a placeholder standing in
   for a label, which disappears the moment anyone types. */
.field label { font-size: var(--text-sm); color: var(--ink-soft); font-weight: 500; }
.field input, .field select, .field textarea, .input {
  font-family: inherit;
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input:hover, .field select:hover, .field textarea:hover, .input:hover { border-color: var(--stone-600); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--burgundy-soft);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.field input::placeholder, .field textarea::placeholder { color: var(--placeholder); }
.field textarea { min-height: 78px; resize: vertical; }
.field__error { color: var(--danger); font-size: var(--text-xs); font-weight: 500; }
.field__hint { color: var(--ink-soft); font-size: var(--text-xs); }
.checkbox { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); }
.checkbox input { width: auto; min-height: 0; accent-color: var(--burgundy); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
}
.filters .field { min-width: 150px; }

/* month strip: every Jalali month of the year, above the date filter */
.month-strip {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: 2px;
  border-bottom: 1px dashed var(--line);
}
.month-strip__label { font-size: var(--text-sm); color: var(--ink-soft); white-space: nowrap; }
.month-strip__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  overflow-x: auto;
  padding-bottom: 2px;
}
.month-strip__list a,
.period-tabs a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  white-space: nowrap;
  background: var(--cream-soft);
  color: var(--ink-soft);
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.month-strip__list a:hover,
.period-tabs a:hover { border-color: var(--gold-500); color: var(--burgundy); }
.month-strip__list a.is-active,
.period-tabs a.is-active { background: var(--burgundy); color: var(--white); border-color: var(--burgundy); }
.month-strip__list a.is-future { opacity: .45; }
.month-strip__list .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold-500); }
.month-strip__list a.is-active .dot { background: var(--surface); }

.period-tabs { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* ------------------------------------------------------------ 8. flashes */
.flashes { margin-bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
/* پیام «ثبت شد» وقتی صفحه سر جای قبلی‌اش برگشته و بالای صفحه دیده نمی‌شود */
.flashes--float {
  position: fixed; inset-inline: var(--space-4); bottom: var(--space-4); z-index: 60;
  margin: 0 auto; max-width: 640px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); transition: opacity .5s;
}
.flashes--float { background: var(--surface); border-radius: var(--radius-sm); }
.flashes--float.is-leaving { opacity: 0; }
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  border: 1px solid transparent;
  border-inline-start-width: 3px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.flash--success { background: var(--success-tint-soft); border-color: var(--success-line); color: var(--success); }
.flash--danger  { background: var(--danger-tint-soft); border-color: var(--danger-line); color: var(--danger); }
.flash--warning { background: var(--warning-tint-soft); border-color: var(--warning-line); color: var(--warning); }
.flash--info    { background: var(--info-tint-soft); border-color: var(--info-line); color: var(--info); }

/* -------------------------------------------------------------- 9. login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 520px at 80% -10%, var(--brand-glow), transparent 60%),
    radial-gradient(800px 400px at 5% 105%, var(--gold-glow), transparent 60%),
    var(--cream);
  padding: var(--space-6);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-8) var(--space-6);
}
.login-card .brand { border: 0; margin-bottom: var(--space-6); }
.login-card .brand__mark { font-size: 36px; }
.login-card .brand__logo { height: 96px; margin-bottom: var(--space-3); }
.login-note { font-size: var(--text-xs); color: var(--ink-soft); text-align: center; margin-top: var(--space-4); }

/* -------------------------------------------------------------- 10. misc */
.section-title { font-size: var(--text-md); font-weight: 600; margin: var(--space-6) 0 var(--space-3); }
.muted { color: var(--ink-soft); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-gold { color: var(--gold-600); }
.text-warning { color: var(--warning); }
.tiny { font-size: var(--text-xs); }
.right { text-align: left; }
.divider { height: 1px; background: var(--line); margin: var(--space-4) 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: var(--space-2) 0; border-bottom: 1px solid var(--line-soft); font-size: var(--text-base); }
.list-plain li:last-child { border: 0; }
/* the value floated to the far side stays inside its own line: a long value
   wraps there instead of spilling over the rows and cards beneath it */
.list-plain li { display: flow-root; overflow-wrap: anywhere; }
.list-plain li > span[style*="float"] { max-width: 65%; text-align: left; }

.progress { height: 6px; background: var(--cream-deep); border-radius: var(--radius-pill); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--burgundy); border-radius: var(--radius-pill); }

.pagination { display: flex; gap: var(--space-1); justify-content: center; margin-top: var(--space-4); flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; min-height: 34px;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.pagination a:hover { border-color: var(--gold-500); background: var(--cream-soft); }
.pagination .is-active { background: var(--burgundy); color: var(--white); border-color: var(--burgundy); }

.chart-box { position: relative; height: 260px; }

/* the colour a sales channel wears on every chart and table that names it */
input[type="color"] {
  width: 64px;
  height: 38px;
  padding: 3px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.channel-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: var(--space-1);
  vertical-align: middle;
  box-shadow: 0 0 0 1px var(--dot-ring);
}

.item-row td { vertical-align: top; }
.item-row input, .item-row select { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); min-height: 32px; }

/* ------------------------------------------- 11. فاکتور مشتری (سند چاپی) */
/* The one page that leaves the atelier and is read by the buyer. What makes
   the owner's own paper invoice look tidy is that everything from the items
   down to the payable line is a single ruled block, and every figure is one
   line — so that is how this is built. */
.bill {
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.bill__bar { height: 14px; background: var(--burgundy); }
.bill__body { padding: var(--space-6) var(--space-6) var(--space-6); }

.bill__title {
  margin: var(--space-1) 0 var(--space-6);
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.3px;
}

/* the two banded headers — the atelier on one, the customer on the next */
.bill__band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  background: var(--cream-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.bill__band + .bill__band {
  margin-top: var(--space-2);
  background: var(--stone-050);
}
.bill__seller { display: flex; align-items: center; gap: var(--space-4); }
.bill__mark {
  flex: none;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--gold-500);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.bill__mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.bill__mark span { font-family: var(--font-display); font-size: 23px; font-weight: 700; color: var(--burgundy); }
.bill__seller-name { font-size: var(--text-lg); font-weight: 700; line-height: 1.6; }
.bill__seller-line { font-size: var(--text-sm); color: var(--ink-soft); line-height: 1.9; }
.bill__facts { text-align: start; font-size: var(--text-base); line-height: 2.1; }
.bill__facts b { font-weight: 600; }

.bill__band--stack { flex-direction: column; align-items: stretch; gap: var(--space-2); }
.bill__band-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.bill__addr { font-size: var(--text-sm); color: var(--ink-soft); }
.bill__who { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-base); }
.bill__who-icon { color: var(--burgundy); }
.bill__who-name { font-weight: 700; }

/* ---- the one ruled block: items, notes and totals share a single frame ---- */
.bill__sheet {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-5);
  table-layout: fixed;
}
.bill__sheet th,
.bill__sheet td {
  border: 1px solid var(--line);
  padding: var(--space-3);
  font-size: var(--text-base);
  vertical-align: middle;
}
.bill__sheet thead th {
  position: static;
  background: var(--brand-tint-strong);
  color: var(--burgundy);
  font-weight: 700;
  text-align: center;
  padding-block: var(--space-2);
}
.bill__sheet thead th:first-child { text-align: start; }
.bill__item td { text-align: center; }
.bill__item .bill__cell-name { text-align: start; line-height: 1.9; }
.bill__num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill__desc { font-size: var(--text-xs); color: var(--ink-soft); margin-top: 2px; }
/* موجود یا سفارشی‌دوزی — said on the line itself, because a customer who takes
   one piece home today and waits for another has to read which is which. */
.bill__tag {
  display: inline-block;
  margin-inline-start: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.bill__tag--stock { background: rgba(42, 96, 70, .12); color: var(--success); }
.bill__tag--custom { background: var(--gold-tint); color: var(--gold-600); }
.bill__empty { text-align: center; color: var(--ink-soft); }

/* توضیحات — sits inside the same frame, so nothing floats loose */
.bill__notes-cell { text-align: start; }
.bill__notes-title { color: var(--gold-600); font-weight: 700; margin-bottom: var(--space-2); }
.bill__notes-body { font-size: var(--text-sm); line-height: 2.1; white-space: pre-line; }
.bill__notes-body + .bill__notes-body { margin-top: var(--space-2); }

/* the closing rows — label on the right, figure on the left, aligned with the
   last column of the table above them */
.bill__sheet tfoot th {
  text-align: start;
  font-weight: 600;
  background: var(--stone-050);
}
.bill__sheet tfoot td { text-align: start; font-weight: 600; }
.bill__sheet tfoot tr.bill__payable th {
  background: var(--burgundy);
  color: var(--white);
  font-size: var(--text-md);
  font-weight: 700;
}
.bill__sheet tfoot tr.bill__payable td {
  background: var(--brand-tint);
  color: var(--burgundy);
  font-size: var(--text-md);
  font-weight: 700;
}
.bill__sheet tfoot tr.bill__words td {
  background: var(--surface);
  color: var(--ink-soft);
  font-size: var(--text-sm);
  font-weight: 500;
}
.bill__words td {
  text-align: start;
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  background: var(--surface);
}
.bill__words b { color: var(--ink); font-weight: 700; }

/* مهر و امضاء، و راه‌های ارتباطی */
.bill__foot-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); table-layout: fixed; }
.bill__foot-table th, .bill__foot-table td { border: 1px solid var(--line); padding: var(--space-3); }
.bill__foot-table th { background: var(--cream-soft); font-weight: 700; font-size: var(--text-base); text-align: center; }
.bill__foot-table td { text-align: center; height: 158px; vertical-align: middle; }
.bill__stamp-img { max-height: 120px; max-width: 175px; object-fit: contain; }
.bill__contact { display: inline-flex; flex-direction: column; gap: var(--space-2); text-align: start; font-size: var(--text-sm); }
.bill__contact a { word-break: break-all; }
/* Each way of reaching the atelier is one line: its own mark, then the id or
   number. The marks are drawn inline so a printed invoice never waits on a
   network image. */
.bill__contact-row { display: flex; align-items: center; gap: var(--space-2); }
.bill__contact-ico { flex: 0 0 auto; color: var(--ink-soft); }
.bill__contact-ico--wa { color: #25D366; }
.bill__contact-ico--ig { color: #C13584; }
.bill__contact-ico--tg { color: #229ED9; }
.bill__sign-hint { font-size: var(--text-xs); color: var(--ink-soft); margin-top: var(--space-2); }

.bill__foot {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--ink-soft);
  line-height: 2;
}

/* دیجی‌پی و تخفیف نقدی: جملهٔ مشتری‌خوان، پررنگ‌تر از جملهٔ پایانی */
.bill__pay { font-size: var(--text-sm); font-weight: 700; color: var(--ink); line-height: 1.8; }

/* A phone number starts with a zero, and bidi would otherwise throw that zero
   to the far side of the line. Kept as its own left-to-right run. */
.tel { direction: ltr; unicode-bidi: isolate; display: inline-block; }

@media (max-width: 720px) {
  .bill__body { padding: var(--space-4); }
  .bill__title { font-size: 22px; }
  .bill__band { flex-direction: column; align-items: flex-start; }
  .bill__sheet { table-layout: auto; }
  .bill__sheet th, .bill__sheet td { padding: var(--space-2); font-size: var(--text-sm); }
}

/* On a phone the customer opens the invoice from a link, and a five-column
   table does not fit: the amount columns and every closing figure — «قابل
   پرداخت» included — were cut off the side of the page. So on a narrow screen
   each item becomes its own box, one figure per line with its name beside it,
   and each closing row is a label on the right and the amount on the left.
   Screen only: the printed A5 sheet and the PDF keep the ruled table. */
@media screen and (max-width: 720px) {
  .bill__band-row { flex-wrap: wrap; row-gap: var(--space-2); }

  .bill__sheet,
  .bill__sheet tbody,
  .bill__sheet tfoot,
  .bill__sheet tr,
  .bill__sheet th,
  .bill__sheet td { display: block; width: auto; }
  .bill__sheet {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
  }
  .bill__sheet colgroup,
  .bill__sheet thead { display: none; }
  .bill__sheet th,
  .bill__sheet td { border: 0; }

  .bill__item { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
  .bill__item .bill__cell-name { padding: var(--space-1) var(--space-3) var(--space-2); font-weight: 600; }
  .bill__item .bill__cell-name .bill__desc { font-weight: 400; }
  .bill__item td.bill__num {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 3px var(--space-3);
  }
  .bill__item td.bill__num::before {
    content: attr(data-label);
    color: var(--ink-soft);
    font-weight: 400;
  }
  .bill__item td.bill__num--none { display: none; }
  .bill__item td.bill__num--total { font-weight: 700; color: var(--burgundy); }

  .bill__notes-cell { padding: var(--space-3); }

  .bill__sheet tfoot tr { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
  .bill__sheet tfoot tr:first-child { border-top: 0; }
  .bill__sheet tfoot th { flex: 1 1 auto; padding: var(--space-2) var(--space-3); }
  .bill__sheet tfoot td { flex: 0 0 auto; padding: var(--space-2) var(--space-3); }
  .bill__sheet tfoot tr.bill__words td { flex: 1 1 auto; line-height: 1.9; }
}

@media print {
  /* یک برگهٔ A5 — the whole invoice, at a size that still reads on paper. The
     type scale is redefined on .bill itself, so every rule built from these
     tokens comes down with it instead of being overridden one by one. */
  @page { size: A5 portrait; margin: 7mm; }
  .bill {
    --text-xs: 5.6pt;
    --text-sm: 6.4pt;
    --text-base: 7pt;
    --text-md: 8pt;
    --text-lg: 9pt;
    --text-xl: 10.5pt;
    --space-1: 2px;
    --space-2: 4px;
    --space-3: 6px;
    --space-4: 8px;
    --space-5: 10px;
    --space-6: 12px;
    --space-8: 16px;
  }
  .bill__bar { height: 6px; }
  .bill__title { font-size: 13pt; margin: 2px 0 8px; }
  .bill__mark { width: 40px; height: 40px; border-width: 1px; }
  .bill__mark span { font-size: 13pt; }
  .bill__sheet th, .bill__sheet td { padding: 3px 5px; }
  .bill__foot-table th, .bill__foot-table td { padding: 4px; }
  .bill__foot-table td { height: 58px; }
  .bill__stamp-img { max-height: 46px; max-width: 80px; }
  .bill__foot { margin-top: 6px; padding-top: 4px; }
  /* On a narrow page the two halves of a band would wrap under each other and
     the sheet would grow a line taller for nothing; they stay side by side. */
  .bill__band { flex-wrap: nowrap; align-items: flex-start; padding: 6px 8px; }
  .bill__band--stack { flex-wrap: wrap; }
  .bill__seller-name { line-height: 1.4; }
  .bill__seller-line, .bill__facts { line-height: 1.7; }
  .bill__notes-body { line-height: 1.7; }
  .bill__notes-cell { padding-block: 4px; }
  .bill__sheet { margin-top: 6px; }
  .sidebar, .topbar, .no-print, .flashes, .sidebar-backdrop, .skip-link { display: none !important; }
  body { background: #fff; padding: 0 !important; }
  .content { padding: 0; }
  .bill { max-width: none; width: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; }
  .bill__body { padding: 0; }
  .bill__bar,
  .bill__band,
  .bill__sheet thead th,
  .bill__sheet tfoot th,
  .bill__payable th,
  .bill__payable td,
  .bill__foot-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bill__contact-ico { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bill__sheet thead { display: table-header-group; }
  .bill__item, .bill__band, .bill__foot-table { break-inside: avoid; }
  .card { box-shadow: none; border-color: #ccc; }
  table.table th { position: static; }
}

/* ---------------------------------------------- 11b. فرم درشت ثبت سفارش */
/* ثبت سفارش is the screen an admin lives on all day and types a real customer's
   money into. It is set one size up from the rest of the panel — larger fields,
   numbered boxes, and a summary bar that stays under the thumb. */
.form-lg .card { padding: var(--space-5) var(--space-5) var(--space-6); }
.form-lg .form-grid { gap: var(--space-4) var(--space-5); }
.form-lg .field label { font-size: var(--text-base); color: var(--ink); font-weight: 600; }
.form-lg .field__hint { font-size: var(--text-sm); line-height: 1.9; }
.form-lg .field input,
.form-lg .field select,
.form-lg .field textarea {
  font-size: var(--text-md);
  min-height: 46px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}
.form-lg .field textarea { min-height: 92px; }
.form-lg .combo__input { font-size: var(--text-md); min-height: 46px; }
.form-lg .item-row input,
.form-lg .item-row select { font-size: var(--text-base); min-height: 40px; padding: var(--space-1) var(--space-2); }

/* a numbered head, so the form reads as steps rather than as one long page */
.section__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--space-5)) var(--space-4);
  padding: 0 var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--line-soft);
}
.section__num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--burgundy);
  color: var(--white);
  font-size: var(--text-md);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.section__title { margin: 0; font-size: var(--text-lg); font-weight: 700; letter-spacing: -.2px; }
.section__note { font-size: var(--text-sm); color: var(--ink-soft); width: 100%; }
.section__side { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }

/* the boxed group inside a step — delivery details, amounts, and so on */
.box {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--stone-050);
  padding: var(--space-4);
}
.box + .box { margin-top: var(--space-3); }
.box__title { font-size: var(--text-sm); font-weight: 600; color: var(--burgundy); margin-bottom: var(--space-3); }

/* جمع فاکتور — the figure the admin reads back to the customer on the phone */
.total-board { display: flex; flex-direction: column; gap: var(--space-2); }
.total-board__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--stone-050);
  font-size: var(--text-base);
}
.total-board__row--grand {
  background: var(--brand-tint);
  border: 1px solid var(--burgundy);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--burgundy);
}
.total-board__row--grand .total-board__value { font-size: var(--text-xl); }
.total-board__value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* the submit bar — always reachable, never hunted for at the foot of the page */
.form-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-glass-solid);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}
.form-bar__sum { display: flex; flex-direction: column; line-height: 1.5; }
.form-bar__label { font-size: var(--text-sm); color: var(--ink-soft); }
.form-bar__value { font-size: var(--text-xl); font-weight: 700; color: var(--burgundy); font-variant-numeric: tabular-nums; }
.form-bar__actions { margin-inline-start: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.btn--lg { min-height: 50px; padding: var(--space-2) var(--space-8); font-size: var(--text-md); font-weight: 600; }

@media (max-width: 720px) {
  /* on a phone the bar used to stack the sum over four tall buttons and hid a
     third of the screen; now it is one line of sum and one row of buttons */
  .form-bar { flex-direction: row; align-items: center; gap: 6px 10px; padding: 8px 10px; }
  .form-bar__sum { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 0 8px; line-height: 1.3; }
  .form-bar__label { font-size: var(--text-xs); }
  .form-bar__value { font-size: var(--text-lg); }
  .form-bar__value .amount__words { font-size: 10.5px; line-height: 1.3; }
  .form-bar__actions { margin-inline-start: 0; width: 100%; flex-wrap: nowrap; gap: 6px; }
  .form-bar__actions .btn {
    flex: 1 1 0; min-width: 0; min-height: 42px;
    padding: 4px 6px; font-size: var(--text-sm); line-height: 1.25; white-space: normal;
  }
  .form-bar__actions .btn[data-submit-once] { flex-grow: 1.5; }
  .section__head { margin-inline: calc(-1 * var(--space-4)); padding-inline: var(--space-4); }
}

/* -------------------------------------------------------- 12. responsive */
@media (max-width: 1100px) {
  .grid--5, .grid--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* The drawer rests just off the edge it will slide in from: the right in
     Persian, the left in a left-to-right language. */
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    transform: translateX(-100%);
    /* Closed, the drawer is hidden outright, not only pushed off the edge:
       iPad Safari counted the pushed-off drawer as page width, zoomed the page
       out and let it slide sideways under a half-covering backdrop. The
       visibility switch waits for the slide-out to finish. */
    visibility: hidden;
    transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
    z-index: 50;
    box-shadow: var(--shadow-lg);
  }
  body[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.is-open {
    transform: translateX(0) !important;
    visibility: visible;
    transition: transform var(--t-slow) var(--ease), visibility 0s;
  }
  .sidebar-backdrop.is-on { display: block; }
  .menu-toggle { display: inline-flex; }
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .content { padding: var(--space-4) var(--space-3) 56px; }
  .topbar { padding: var(--space-2) var(--space-3); }
  .topbar__who { display: none; }
}
@media (max-width: 560px) {
  .grid--5, .grid--6 { grid-template-columns: 1fr; }
  .grid--4 { grid-template-columns: 1fr; }
  .stat__value { font-size: var(--text-lg); }
}
/* On anything driven by a finger, every target is at least 44px tall. */
@media (hover: none) and (pointer: coarse) {
  .nav-link { min-height: 44px; }
  .btn { min-height: 44px; }
  .btn--sm { min-height: 38px; }
  .pagination a, .pagination span { min-width: 44px; min-height: 44px; }
  .field input, .field select, .field textarea, .input { min-height: 44px; }
}

/* --------------------------------------------- 13. handing an order over */
.ship-form { display: flex; flex-direction: column; gap: var(--space-3); }
.ship-form__methods { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.ship-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  min-height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--cream-soft);
  font-size: var(--text-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.ship-pill:hover { border-color: var(--gold-500); }
.ship-pill:has(input:checked) { background: var(--burgundy); color: var(--white); border-color: var(--burgundy); }
.ship-pill:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.ship-pill input { accent-color: var(--gold-500); margin: 0; }
.ship-form__fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-2); }
.ship-field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 130px; }
.ship-field--grow { flex: 1; min-width: 160px; }
.ship-field span { font-size: var(--text-xs); color: var(--ink-soft); }
.ship-field.is-hidden { display: none; }

.row-actions summary { list-style: none; cursor: pointer; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions__body {
  position: relative;
  z-index: 2;
  margin-top: var(--space-2);
  padding: var(--space-3);
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
tr.is-highlighted > td { background: var(--gold-tint); }

/* -- the month's orders board ---------------------------------------------
   Two hundred orders a month must be read without sliding the page sideways:
   the columns are few enough to fit, and every order's buttons sit in a
   full-width strip right under it instead of in a far-off last column. */
.table-wrap--fit { overflow-x: visible; }
.table--orders td { vertical-align: top; }
.table--orders .cell-address { max-width: 260px; }
/* an address or note typed without spaces must break inside its cell, not push
   the whole board sideways off a phone screen */
.table--orders td { overflow-wrap: anywhere; }
table.table--orders tbody tr:nth-child(even) { background: transparent; }
table.table--orders tbody tr.order-main > td { border-bottom: 0; padding-bottom: var(--space-2); }
table.table--orders tbody tr.order-actions > td {
  padding-top: 0;
  border-bottom: 2px solid var(--line);
}
table.table--orders tbody tr.order-main:hover,
table.table--orders tbody tr.order-main:hover + tr.order-actions { background: var(--gold-tint); }
.order-actions__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.order-actions__bar form { margin: 0; }
.order-actions__label { align-self: center; font-size: var(--text-xs); color: var(--ink-soft); }
.order-actions .row-actions { flex-basis: auto; }
.order-actions .row-actions[open] { flex-basis: 100%; }
.order-actions .row-actions__body { min-width: 0; }
/* a folded «ثبت ارسال» form must take up no room at all while it is shut */
.row-actions:not([open]) > .row-actions__body { display: none; }

/* the order's invoice, folded open under its buttons */
.order-bill {
  margin-top: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.order-bill__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  list-style: none;
}
.order-bill__summary::-webkit-details-marker { display: none; }
.order-bill__summary::before { content: "▸"; color: var(--gold-500); }
.order-bill[open] > .order-bill__summary::before { content: "▾"; }
.order-bill[open] > .order-bill__summary { border-bottom: 1px solid var(--line-soft); }
.order-bill__title { font-weight: 700; color: var(--burgundy); }
.order-bill__glance { font-size: var(--text-xs); color: var(--ink-soft); }
.order-bill__body { display: grid; gap: var(--space-3); padding: var(--space-3); }
.order-bill__facts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.order-bill__items { margin: 0; padding-inline-start: var(--space-5); display: grid; gap: var(--space-2); }
.order-bill__item { padding-bottom: var(--space-2); border-bottom: 1px dashed var(--line-soft); }
.order-bill__name { overflow-wrap: anywhere; }
.order-bill__calc { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin-top: var(--space-1); }
.order-bill__totals { margin: 0; display: grid; gap: var(--space-1); max-width: 420px; }
.order-bill__totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }
.order-bill__totals dt { color: var(--ink-soft); font-size: var(--text-sm); }
.order-bill__totals dd { margin: 0; text-align: left; }
.order-bill__total { padding-top: var(--space-1); border-top: 1px solid var(--line-soft); font-weight: 700; }

/* on a phone every order becomes a card: label on one side, value on the other */
@media (max-width: 760px) {
  .table--orders, .table--orders tbody, .table--orders tr, .table--orders td { display: block; width: 100%; }
  .table--orders thead { display: none; }
  table.table--orders tbody tr.order-main > td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    column-gap: var(--space-3);
    align-items: start;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px dashed var(--line-soft);
    text-align: right;
  }
  table.table--orders tbody tr.order-main > td > * { grid-column: 2; justify-self: start; }
  table.table--orders tbody tr.order-main > td::before {
    content: attr(data-label);
    grid-column: 1;
    grid-row: 1 / span 20;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--ink-soft);
    text-align: right;
  }
  table.table--orders tbody tr.order-main > td:first-child { background: var(--cream-deep); }
  table.table--orders tbody tr.order-actions > td { padding: var(--space-2) var(--space-3) var(--space-4); }
  .table--orders .cell-address { max-width: none; }
  .table--orders .num { white-space: normal; }
}

/* the edit/delete pair that sits beside every row that can be added */
.crud-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.crud-actions form { margin: 0; }

/* whether this order is allowed to be sent, and why */
.permission-line {
  margin: var(--space-3) 0 var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.permission-line.is-granted { background: var(--success-tint-soft); color: var(--success); }
.permission-line.is-blocked { background: var(--danger-tint-soft); color: var(--danger); }
.permission-line form { margin: 0; }

/* the approve / send-back pair on the sign-off screen */
.decision-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.decision-row form { margin: 0; }
/* «ویرایش» of a کار موجود: once open, its form takes the whole row */
.stock-edit[open] { flex-basis: 100%; }

/* what an order was for, tucked under the customer on the deposit-approval list */
.order-lines {
  list-style: none;
  margin: var(--space-1) 0 0;
  padding: var(--space-1) var(--space-2);
  border-inline-start: 2px solid var(--gold-500);
  background: var(--gold-tint);
  border-radius: 6px;
  font-size: var(--text-xs);
  line-height: 1.7;
}

/* the two sign-offs of one order, shown together */
.ticks { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.tick {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.tick--on { background: var(--success-tint); color: var(--success); }
.tick--off { background: var(--danger-tint); color: var(--danger); }
.tick--wait { background: var(--warning-tint); color: var(--warning); }

/* سفارشی که رفته: همهٔ نوشته‌هایش سبز و مُهر درشت «ارسال شده» روی خودش، تا
   کسی آن را به اشتباه دوباره نفرستد. دکمه‌ها رنگ خودشان را نگه می‌دارند تا
   خوانا بمانند. */
.is-shipped,
.is-shipped *:not(.btn) { color: var(--success) !important; }
.is-shipped .badge { background: var(--success-tint); }
tr.is-shipped > td,
table.table--orders tbody tr.is-shipped > td:first-child { background: var(--success-tint-soft); }
table.table--orders tbody tr.order-main.is-shipped > td:first-child { box-shadow: inset -4px 0 0 var(--success); }
table.table--orders tbody tr.order-main.is-shipped > td::before { color: var(--success); }
.card.is-shipped, .order-card.is-shipped { border: 2px solid var(--success); background: var(--success-tint-soft); }
.shipped-stamp {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 3px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--success-tint);
  color: var(--success);
  line-height: 1.35;
}
.shipped-stamp__title { font-size: 19px; font-weight: 800; white-space: nowrap; }
.shipped-stamp__how { font-size: var(--text-xs); font-weight: 600; }
.shipped-stamp--big { display: flex; margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); }
.shipped-stamp--big .shipped-stamp__title { font-size: 26px; }
.shipped-stamp--big .shipped-stamp__how { font-size: var(--text-sm); }

/* پنج کارت در یک ردیف باریک‌ترند: مبلغ میلیاردی ماه اگر جا نشد، «تومان» به خط بعد می‌رود
   و هیچ رقمی زیر لبهٔ کارت پنهان نمی‌شود */
.grid--5 .stat { padding-inline: var(--space-3); }
.grid--5 .stat__value { font-size: var(--text-lg); }
.grid--5 .stat__value,
.grid--5 .stat__value .amount__num { white-space: normal; }

/* «مانده‌ها پیش هر خیاط» بالای فهرست سفارش‌های ارسال‌نشده */
.remaining-tailors { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin-bottom: var(--space-3); }

/* a finished order held back by nothing but an unapproved deposit slip */
.row--alert > td { background: var(--danger-tint-soft); }
/* سرِ ماه در فهرست‌هایی که ماه به ماه چیده شده‌اند — «مهر ۱۴۰۵ — ۳ تحویلی، مزد …» */
.row--month > td { background: var(--gold-tint); font-weight: 700; }
.row--alert > td:first-child { box-shadow: inset -3px 0 0 var(--danger); }

.approval-banner {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--danger-tint-soft);
  border: 1px solid var(--danger-line);
  border-inline-start-width: 3px;
  color: var(--danger);
  font-size: var(--text-base);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.approval-banner__order {
  background: var(--surface);
  color: var(--danger);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* ---------------------- the customer's details on the order form */
.contact-box {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream-soft);
}
.contact-box__name { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.contact-box .field { margin: 0; min-width: 150px; }
.contact-box__address { flex: 1; min-width: 240px; }
.contact-box textarea { min-height: 54px; }
@media (max-width: 560px) {
  .contact-box { flex-direction: column; align-items: stretch; }
}

.delivery-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--cream-soft);
  font-size: var(--text-base);
}
.delivery-details__address { flex: 1 1 100%; }
.cell-address { max-width: 220px; white-space: normal; line-height: 1.6; }

/* fabric prices are never shown in one unit alone */
.dual-price { display: flex; flex-direction: column; gap: 2px; line-height: 1.55; }
.dual-price__row { display: flex; gap: var(--space-1); justify-content: space-between; white-space: nowrap; }
.dual-price__unit { color: var(--ink-soft); font-size: var(--text-xs); }
.unit-echo { display: block; margin-top: var(--space-1); font-size: var(--text-xs); color: var(--ink-soft); }
.unit-echo strong { font-weight: 600; color: var(--burgundy); }

/* reading the slip queue against the bank statement */
.hidden-form { display: none; }
.card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
}
.card--danger { border-color: var(--danger-edge); }
.card--danger .card__title { color: var(--danger); }

/* the one badge every screen reads before a parcel is handed over */
.settle {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.settle--success { background: var(--success-tint); color: var(--success); }
.settle--warning { background: var(--warning-tint); color: var(--warning); }
.settle--danger { background: var(--danger-tint); color: var(--danger); }

/* a reason dropdown that sits beside a small button without towering over it */
.input--sm { font-size: var(--text-sm); padding: var(--space-1) var(--space-2); min-height: 30px; height: auto; max-width: 150px; }

/* Picking tailors, and tailors picking their own pieces: big tap targets,
   because both are done in a hurry, often on a phone. */
.pick-grid { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pick {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.pick:hover { border-color: var(--gold-500); }
.pick:has(input:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; }
.pick.is-on {
  border-color: var(--burgundy);
  background: var(--burgundy-tint);
  box-shadow: inset 0 0 0 1px var(--burgundy);
}
.pick.is-off { opacity: .45; cursor: not-allowed; }
.pick input { accent-color: var(--burgundy); width: 18px; height: 18px; min-height: 0; }
.pick__name { font-weight: 600; }
.pick__meta { color: var(--ink-soft); font-size: var(--text-sm); font-weight: 400; }
.pick--wide { flex: 1 1 260px; justify-content: space-between; }
/* «هر کار را کدام خیاط می‌زند؟» — one row per sewing piece, the names wrap on a phone */
.split-tailors__row { display: grid; gap: var(--space-2); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.split-tailors__row:first-child { border-top: 0; padding-top: 0; }
.split-tailors__piece { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.pick--taken { background: var(--cream-soft); border-style: dashed; }

/* a card that is asking the person for something, not just showing them something */
.card--attention {
  border-color: var(--attention-edge);
  box-shadow: 0 0 0 3px var(--attention-glow), var(--shadow);
}
.card--attention .card__title { color: var(--burgundy); }

/* A dropdown that can be searched. The list is drawn on top of the page (not
   inside the scrolling items table), so it is never cut off at the table edge. */
.combo { position: relative; display: block; }
.combo--wide { max-width: 420px; }
.combo--ready .combo__select { display: none; }
/* the customer dropdown holds one or two names only; the search box stands in for it from the start */
.combo--customer .combo__select { display: none; }
.combo__input { width: 100%; padding-left: 28px; }
.combo__clear {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: var(--text-sm);
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.combo__clear:hover { color: var(--danger); background: var(--cream-soft); }
.combo__list {
  position: fixed;
  z-index: 200;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg, 0 12px 28px rgba(43,35,32,.16));
  scrollbar-width: thin;
}
.combo__option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 40px;
  justify-content: center;
}
.combo__option.is-active { background: var(--burgundy-tint, var(--cream-soft)); }
.combo__name { font-weight: 600; }
.combo__hint { color: var(--ink-soft); font-size: var(--text-xs); }
.combo__empty { padding: var(--space-3); color: var(--ink-soft); font-size: var(--text-sm); }

/* ---- عکس‌های سفارش ---- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
.photo-grid__item { margin: 0; background: var(--cream-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.photo-grid__item img { display: block; width: 100%; height: 190px; object-fit: cover; background: var(--surface); }
.photo-grid__item figcaption { padding: var(--space-2); display: grid; gap: 4px; }
@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); }
  .photo-grid__item img { height: 150px; }
}

/* متن ثبت سفارش — the order as it was first written down */
.order-note { white-space: pre-wrap; line-height: 2; font-size: var(--text-sm); color: var(--ink);
  background: var(--cream-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: var(--space-3); max-height: 420px; overflow: auto; }

/* ------------------------------------------- 14. کلید حالت روشن / تاریک */
/* One button, in the top bar and on the login page. It shows the mode it will
   switch *to*, so the moon means "make it dark" and the sun means "bring the
   light back". The choice is kept in the browser, per person and per device. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--burgundy);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.theme-toggle:hover { background: var(--cream-soft); border-color: var(--gold-500); }
.theme-toggle__dark { display: none; }
:root[data-theme="dark"] .theme-toggle__dark { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle__light { display: none; }

/* on the login page it sits in the corner of the page, not of a card */
.theme-toggle--corner {
  position: fixed;
  top: var(--space-4);
  inset-inline-end: var(--space-4);
  z-index: 10;
}

@media (hover: none) and (pointer: coarse) {
  .theme-toggle { width: 44px; height: 44px; }
}

/* The mark is one solid burgundy shape on a transparent ground; on charcoal it
   would sink into the page, so after dark it is lifted to the same rose the
   rest of the brand takes. The invoice keeps the original ink. */
:root[data-theme="dark"] .sidebar .brand__logo,
:root[data-theme="dark"] .login-card .brand__logo { filter: brightness(1.85) saturate(1.05); }

/* ---- the date picker is a third-party widget: it is told the theme too ----
   Its own stylesheet paints a white card with grey bars, which after dark is
   a torch in the face; the same tokens the panel uses are put over it. */
:root[data-theme="dark"] .datepicker-container,
:root[data-theme="dark"] .datepicker-plot-area {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-lg);
}
:root[data-theme="dark"] .datepicker-navigator,
:root[data-theme="dark"] .datepicker-day-view .header,
:root[data-theme="dark"] .datepicker-grid-view .header,
:root[data-theme="dark"] .datepicker-plot-area .toolbox {
  background: var(--surface-sunken);
  border-color: var(--line-soft);
  color: var(--ink);
}
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn-next,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn-prev,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn-switch,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn-today,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn-submit,
:root[data-theme="dark"] .datepicker-plot-area .title,
:root[data-theme="dark"] .datepicker-plot-area .header-row,
:root[data-theme="dark"] .datepicker-plot-area .header-row-cell {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-soft);
}
:root[data-theme="dark"] .datepicker-plot-area .header-row-cell { color: var(--ink-soft); }
:root[data-theme="dark"] .datepicker-plot-area .table-days td,
:root[data-theme="dark"] .datepicker-plot-area .month-grid-box td,
:root[data-theme="dark"] .datepicker-plot-area .month-grid-box div {
  background: transparent;
  color: var(--ink);
}
:root[data-theme="dark"] .datepicker-plot-area .table-days td:hover,
:root[data-theme="dark"] .datepicker-plot-area .pwt-btn:hover,
:root[data-theme="dark"] .datepicker-plot-area .month-grid-box div:hover { background: var(--cream-soft); }
/* The plugin marks the picked day with a blue chip on a bare <span> inside
   the cell, which is the one colour in the panel that belongs to nobody; it
   is repainted in the panel's own burgundy. */
:root[data-theme="dark"] .datepicker-plot-area .table-days td.selected,
:root[data-theme="dark"] .datepicker-plot-area .month-grid-box div.selected {
  background: var(--burgundy) !important;
  color: var(--white) !important;
}
:root[data-theme="dark"] .datepicker-plot-area .table-days td.selected span,
:root[data-theme="dark"] .datepicker-plot-area .table-days td.today span,
:root[data-theme="dark"] .datepicker-plot-area .month-grid-box div.selected span {
  background: var(--burgundy) !important;
  color: var(--white) !important;
}
:root[data-theme="dark"] .datepicker-plot-area .table-days td.today,
:root[data-theme="dark"] .datepicker-day-view .table-days td.today {
  background: var(--gold-tint);
  color: var(--gold-600);
  box-shadow: inset 0 0 0 1px var(--gold-500);
}
:root[data-theme="dark"] .datepicker-plot-area .table-days td.other-month,
:root[data-theme="dark"] .datepicker-plot-area .table-days td.disabled { color: var(--ink-soft); opacity: .45; }

/* ---- فاکتور: کاغذ، در هر حالتی ----------------------------------------
   The invoice is the one page that leaves the atelier and gets printed. It
   stays on paper colours even after dark, so what is on the screen is what
   comes out of the printer. Only the tokens are restated; no rule of the
   invoice itself changes. */
:root[data-theme="dark"] .bill {
  color-scheme: light;
  /* The semantic tokens are written out in full here, not built from the
     primitives: a var() is resolved where it is declared, so restating
     --paper alone would leave --surface holding the dark value it took at
     the root. */
  --surface: #FDF8EE;
  --surface-sunken: #F0E7D6;
  --cream: #F6EFE1;
  --cream-soft: #F0E7D6;
  --cream-deep: #E7DCC7;
  --stone-050: #F6EFE1;
  --line: #DBCEB6;
  --line-soft: #E7DCC7;
  --white: #FFFFFF;
  --ink: #2B2320;
  --ink-soft: #6B605A;
  --burgundy: #6E1B32;
  --burgundy-soft: #8E2B46;
  --burgundy-tint: rgba(110, 27, 50, 0.08);
  --brand-tint: rgba(110, 27, 50, 0.08);
  --brand-tint-strong: rgba(110, 27, 50, 0.14);
  --gold: #B08B57;
  --gold-500: #B08B57;
  --gold-600: #7C5C30;
  --gold-tint: rgba(176, 139, 87, 0.14);
  --success: #2A6046;
  --warning: #8A5F10;
  --danger: #99282C;
  --info: #35525F;
  --success-tint: rgba(42, 96, 70, .12);
  --warning-tint: rgba(138, 95, 16, .13);
  --danger-tint: rgba(153, 40, 44, .12);
  --info-tint: rgba(53, 82, 95, .12);
  --row-stripe: rgba(176, 139, 87, .05);
  --placeholder: #7A716A;
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .5);
  color: var(--ink);
}

@media print {
  /* Paper has no dark mode: whatever the screen is set to, the page prints
     on white with the panel's own ink. */
  :root[data-theme="dark"] {
    color-scheme: light;
    --surface: #FFFFFF;
    --surface-sunken: #F0E7D6;
    --cream: #FFFFFF;
    --cream-soft: #F0E7D6;
    --cream-deep: #E7DCC7;
    --stone-050: #F6EFE1;
    --line: #DBCEB6;
    --line-soft: #E7DCC7;
    --white: #FFFFFF;
    --ink: #2B2320;
    --ink-soft: #6B605A;
    --burgundy: #6E1B32;
    --burgundy-soft: #8E2B46;
    --burgundy-tint: rgba(110, 27, 50, 0.08);
    --brand-tint: rgba(110, 27, 50, 0.08);
    --brand-tint-strong: rgba(110, 27, 50, 0.14);
    --gold: #B08B57;
    --gold-500: #B08B57;
    --gold-600: #7C5C30;
    --gold-tint: rgba(176, 139, 87, 0.14);
    --success: #2A6046;
    --warning: #8A5F10;
    --danger: #99282C;
    --info: #35525F;
    --success-tint: rgba(42, 96, 70, .12);
    --warning-tint: rgba(138, 95, 16, .13);
    --danger-tint: rgba(153, 40, 44, .12);
    --info-tint: rgba(53, 82, 95, .12);
    --row-stripe: transparent;
    --placeholder: #7A716A;
  }

  :root[data-theme="dark"] .sidebar .brand__logo,
  :root[data-theme="dark"] .login-card .brand__logo { filter: none; }
  .theme-toggle { display: none !important; }
}

/* ---------------------------------------------------------------------------
   جست‌وجو و مرتب‌سازی داخل جدول‌های بلند
   فهرست سفارش‌های یک ماه یا کارت مشتری‌ها ده‌ها ردیف دارد؛ پیدا کردن یک ردیف
   نباید به رفتن به صفحهٔ دیگری نیاز داشته باشد.
   ------------------------------------------------------------------------ */
.table-search {
  display: flex;
  align-items: center;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-3, 12px);
}
.table-search input {
  flex: 1 1 auto;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--line, #e3d7da);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
}
.table-search input:focus {
  outline: 2px solid var(--burgundy, #6E1B32);
  outline-offset: 1px;
}
.table-search__count { white-space: nowrap; }

th.is-sortable { cursor: pointer; user-select: none; }
th.is-sortable:hover { color: var(--burgundy, #6E1B32); }
th.is-sorted-asc::after  { content: " ▲"; font-size: .7em; }
th.is-sorted-desc::after { content: " ▼"; font-size: .7em; }

/* QR گوشهٔ فاکتور مشتری — در خانهٔ مهر و امضا، کنار مهر، نه در ردیفی جدا */
.bill__stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-4, 16px);
}
.bill__qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bill__qr img { display: block; }
.bill__qr .bill__sign-hint { margin-top: 0; }
@media print {
  /* فاکتور باید روی یک برگهٔ A5 تمام شود، جملهٔ تشکر پایانی هم */
  /* برگهٔ A5 از ۷۲۰ پیکسل باریک‌تر است و قاعدهٔ گوشی نوار مزون را زیر هم
     می‌چید؛ روی کاغذ نام مزون و تاریخ کنار هم می‌مانند. */
  .bill__band:not(.bill__band--stack) { flex-direction: row; justify-content: space-between; }
  .bill__stamp { flex-wrap: nowrap; gap: 8px; }
  .bill__qr img { width: 56px; height: 56px; }
  .bill__qr { gap: 1px; }
  .bill__contact { gap: 1px; }
  .bill__contact-ico { width: 12px; height: 12px; }
  .bill__item .bill__cell-name { line-height: 1.55; }
  .bill__desc { margin-top: 0; }
  .bill__notes-body { line-height: 1.55; }
  .bill__foot { break-before: avoid; }

  /* فاکتور بلند هم یک برگه است. قالب از روی طول فاکتور (bill_fit در
     invoices/print.html) یکی از سه درجه را می‌گذارد؛ هر درجه فاصله‌ها را
     تنگ‌تر و حروف را ریزتر می‌کند. قبلاً کادر مهر و امضا که نمی‌شکند، از
     سه قلم به بالا کامل به صفحهٔ دوم می‌پرید. */
  .bill--fit1 .bill__title { font-size: 11pt; margin: 0 0 4px; }
  .bill--fit1 .bill__bar { height: 4px; }
  .bill--fit1 .bill__band { padding: 3px 6px; }
  .bill--fit1 .bill__mark { width: 30px; height: 30px; }
  .bill--fit1 .bill__seller-name { line-height: 1.3; }
  .bill--fit1 .bill__seller-line,
  .bill--fit1 .bill__facts { line-height: 1.45; }
  .bill--fit1 .bill__band--stack { gap: 1px; }
  .bill--fit1 .bill__sheet { margin-top: 4px; }
  .bill--fit1 .bill__sheet th,
  .bill--fit1 .bill__sheet td { padding: 1px 4px; }
  .bill--fit1 .bill__item .bill__cell-name { line-height: 1.4; }
  .bill--fit1 .bill__tag { padding: 0 3px; }
  /* رنگ و توضیح هر قلم دنبال همان سطر می‌آید، نه در سطری جدا */
  .bill--fit1 .bill__desc { display: inline; }
  .bill--fit1 .bill__desc::before { content: " · "; }
  .bill--fit1 .bill__notes-cell { padding-block: 2px; }
  .bill--fit1 .bill__notes-title { margin-bottom: 0; }
  .bill--fit1 .bill__notes-body { line-height: 1.4; }
  .bill--fit1 .bill__notes-body + .bill__notes-body { margin-top: 1px; }
  .bill--fit1 .bill__foot-table { margin-top: 4px; }
  .bill--fit1 .bill__foot-table th,
  .bill--fit1 .bill__foot-table td { padding: 2px 4px; height: auto; }
  .bill--fit1 .bill__stamp-img { max-height: 34px; max-width: 64px; }
  .bill--fit1 .bill__qr img { width: 44px; height: 44px; }
  .bill--fit1 .bill__sign-hint { margin-top: 0; }
  .bill--fit1 .bill__foot { margin-top: 3px; padding-top: 2px; line-height: 1.5; }

  /* درجهٔ دوم: حروف یک پله ریزتر، راه‌های ارتباطی کنار هم */
  .bill.bill--fit2 {
    --text-xs: 5pt;
    --text-sm: 5.8pt;
    --text-base: 6.3pt;
    --text-md: 7.2pt;
    --text-lg: 8pt;
  }
  .bill--fit2 .bill__contact { flex-direction: row; flex-wrap: wrap; gap: 1px 8px; }
  .bill--fit2 .bill__qr img { width: 38px; height: 38px; }
  .bill--fit2 .bill__stamp-img { max-height: 30px; }
  .bill--fit2 .bill__item .bill__cell-name { line-height: 1.3; }
  .bill--fit2 .bill__notes-body,
  .bill--fit2 .bill__seller-line,
  .bill--fit2 .bill__facts { line-height: 1.3; }

  /* درجهٔ سوم: کوچک‌ترین اندازه‌ای که روی کاغذ هنوز خوانده می‌شود */
  .bill.bill--fit3 {
    --text-xs: 4.6pt;
    --text-sm: 5.2pt;
    --text-base: 5.6pt;
    --text-md: 6.4pt;
    --text-lg: 7pt;
    /* فقط فاکتورهای خیلی بلند --bill-zoom می‌گیرند (قالب حسابش می‌کند) */
    zoom: var(--bill-zoom, 1);
  }
  .bill--fit3 .bill__title { font-size: 9pt; margin-bottom: 2px; }
  .bill--fit3 .bill__item .bill__cell-name { line-height: 1.2; }
  .bill--fit3 .bill__notes-body { font-size: var(--text-xs); line-height: 1.25; }
  .bill--fit3 .bill__qr img { width: 32px; height: 32px; }
  .bill--fit3 .bill__stamp-img { max-height: 26px; }
  .bill--fit3 .bill__mark { width: 24px; height: 24px; }
}

/* نوار عکس سفارش در فهرست‌ها — کوچک، مربعی، کنار هم */
.thumb-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.thumb { display: block; width: 52px; height: 52px; border-radius: var(--radius-sm);
         overflow: hidden; border: 1px solid var(--line); background: var(--cream-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb--more { display: flex; align-items: center; justify-content: center;
               font-size: 12px; color: var(--muted); }
@media print { .thumb-row { display: none; } }

/* ------------------------------------------- 15. دکمه‌های درشت کار خیاط */
/* خیاط‌ها پنل را با گوشی باز می‌کنند و وسط کار فقط یک نگاه به آن می‌اندازند.
   «شروع کردم»، «کار تمام شد» و «تحویل مزون / ارسال» پس دکمهٔ کوچک ته جدول
   نیستند: درشت، رنگی، تمام‌عرض روی گوشی، هر رنگ برای یک قدم. */
.big-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
.big-actions > .field { flex: 1 1 100%; margin: 0; }
.big-actions--stack { flex-direction: column; }
.big-actions__title { font-size: var(--text-md); font-weight: 700; color: var(--burgundy); margin-bottom: var(--space-2); }
.big-action {
  flex: 1 1 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px var(--space-3);
  min-height: 64px;
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-radius: var(--radius);
  background: var(--burgundy);
  color: var(--white);
  font-family: inherit;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .22), var(--shadow-md);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.big-action:hover { filter: brightness(1.08); color: var(--white); }
.big-action:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .22); }
.big-action:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 3px; }
.big-action__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  font-size: 20px; line-height: 1;
}
.big-action__label { white-space: normal; }
.big-action__hint { flex-basis: 100%; font-size: var(--text-sm); font-weight: 500; opacity: .9; }
.big-action--in_progress { background: var(--blue-700); }
.big-action--finished { background: var(--success); }
.big-action--atelier { background: var(--gold-600); }
.big-action--ready { background: #2d6a5f; }
.waiting-note {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; line-height: 1.9;
  background: rgba(45, 106, 95, .10); border: 1px solid rgba(45, 106, 95, .35);
}
/* توضیحی که خیاط با «تحویل / ارسال» نوشته — کنار وضعیت سفارش، جدا از متن خاکستری اطرافش */
.tailor-note {
  margin-top: 4px; padding: 4px 8px; border-radius: 8px; line-height: 1.8;
  background: rgba(196, 154, 60, .12); border-right: 3px solid var(--gold-600);
  overflow-wrap: anywhere;
}
.big-action--courier, .big-action--tipax { background: var(--burgundy); }
.big-action--ghost { background: var(--surface); color: var(--burgundy); border: 2px solid var(--line); box-shadow: none; }
.big-action--ghost:hover { color: var(--burgundy); border-color: var(--gold-500); }
/* «اشتباه زدم — هنوز شروع نکردم»: a quiet way back, never mistaken for the next step */
.big-action--waiting, .big-action--unfinish { background: var(--surface); color: var(--ink-soft); border: 2px dashed var(--line); box-shadow: none; font-weight: 600; }
/* smaller than the steps forward, on the card and on a phone alike */
.big-actions > .big-action.big-action--waiting, .big-actions > .big-action.big-action--unfinish { min-height: 44px; font-size: 15px; }
.big-action--waiting:hover, .big-action--unfinish:hover { color: var(--burgundy); border-color: var(--gold-500); }
.big-action--waiting .big-action__icon, .big-action--unfinish .big-action__icon { background: rgba(0, 0, 0, .05); }
.big-action[disabled] {
  background: var(--cream-deep); color: var(--ink-soft);
  box-shadow: none; cursor: not-allowed; filter: none; transform: none;
}
.big-action[disabled] .big-action__icon { background: rgba(0, 0, 0, .06); filter: grayscale(1); }

/* کادر کد رهگیری تیپاکس — درشت و جدا، با دکمهٔ ثبت خودش زیر همان کادر */
.tracking-box { display: flex; flex-direction: column; gap: var(--space-3);
  margin-top: var(--space-3); padding: var(--space-4); border-radius: var(--radius);
  background: var(--warning-tint-soft); border: 2px solid var(--warning-line); }
.tracking-box[hidden] { display: none; }
.tracking-box__label { font-size: var(--text-md); font-weight: 700; color: var(--ink); }
.tracking-box__input { width: 100%; min-height: 60px; font-size: 26px; font-weight: 700;
  letter-spacing: 2px; text-align: center; font-family: inherit; }
.tracking-box__send { flex: 0 0 auto; width: 100%; }
.handover-form__extra { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }
.handover-form__extra .field { margin: 0; }

/* the card that holds the step waiting to be taken */
.card--send.is-ready {
  border: 2px solid var(--gold-500);
  box-shadow: 0 0 0 4px var(--attention-glow), var(--shadow-md);
}
.card--send.is-ready > .card__head .card__title { font-size: var(--text-lg); color: var(--burgundy); font-weight: 800; }

/* کِی به مزون می‌رسد؟ — چهار دکمهٔ درشت روز، و یک تقویم برای روزی دیگر */
.card--arrival { border: 2px solid var(--gold-500); }
.arrival-now { margin-bottom: var(--space-3); padding: var(--space-3); border-radius: var(--radius-sm);
  background: var(--success-tint-soft); border: 1px solid var(--success-line); font-size: var(--text-md); }
.arrival-now--late { background: var(--danger-tint-soft); border-color: var(--danger-line); }
.arrival-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.arrival-quick__btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 64px; padding: var(--space-2); border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--surface); color: var(--burgundy);
  font-family: inherit; cursor: pointer;
}
.arrival-quick__btn:hover { border-color: var(--gold-500); }
.arrival-quick__btn.is-on { background: var(--gold-600); border-color: var(--gold-600); color: #fff; }
.arrival-quick__label { font-size: var(--text-md); font-weight: 800; }
.arrival-quick__date { font-size: var(--text-sm); opacity: .85; }
.arrival-other { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }
.arrival-other input { flex: 1 1 150px; min-width: 0; }
@media (max-width: 720px) {
  .arrival-quick { grid-template-columns: repeat(2, 1fr); }
}

/* ---- یک کارت برای هر کار داخل سفارش ---- */
.job-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-3); }
.job-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--cream-soft);
}
.job-card--todo { border: 2px solid var(--gold-500); background: var(--surface); }
.job-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.job-card__title { font-size: var(--text-lg); font-weight: 800; line-height: 1.5; }
.job-card__meta { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); color: var(--ink-soft); font-size: var(--text-base); }
/* پارچهٔ اضافهٔ سایز روی کارت کار خیاط — دکمه‌های درشت، یک ضربه */
.extra-fabric { margin-top: var(--space-2); }
.extra-fabric__label { font-size: var(--text-base); margin-bottom: 6px; }
.extra-fabric__row { display: flex; flex-wrap: wrap; gap: 6px; }
.extra-fabric__typed { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.extra-fabric__typed input { flex: 1; min-width: 0; max-width: 220px; }
.job-card .big-actions { margin-top: var(--space-1); }
.job-card__next {
  padding: var(--space-3); border-radius: var(--radius-sm);
  background: var(--success-tint); color: var(--success); font-weight: 700; text-align: center;
}
.job-card__more { align-self: flex-start; font-size: var(--text-sm); color: var(--ink-soft); padding: var(--space-1) 0; }

/* ---- یک کارت برای هر سفارش باز خیاط ---- */
.order-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); }
.order-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.order-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.order-card__number { font-size: var(--text-xl); font-weight: 800; color: var(--burgundy); }
.order-card__meta { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); color: var(--ink-soft); }
.order-card__jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.order-card__jobs li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-2); border-radius: var(--radius-xs); background: var(--cream-soft); }
.order-card .big-actions { margin-top: auto; padding-top: var(--space-2); }
.order-card .big-action { min-height: 56px; font-size: 17px; }
/* «شروع کردم» / «کار تمام شد» و «تحویل / ارسال» روی خود کارت سفارش در «کارهای من» */
.order-card__jobs li { flex-wrap: wrap; }
.order-card__jobs li > .big-actions { flex-basis: 100%; margin-top: 0; padding-top: 2px; }
.order-card__jobs .big-action { flex: 1 1 140px; min-height: 50px; font-size: 16px; }
.card-handover { flex: 1 1 100%; }
.card-handover > summary { list-style: none; width: 100%; }
.card-handover > summary::-webkit-details-marker { display: none; }
.card-handover__body { margin-top: var(--space-3); padding: var(--space-3); border: 1px dashed var(--line);
  border-radius: var(--radius-sm); background: var(--cream-soft); }
.card-handover--inline { flex: 0 0 auto; }
.card-handover--inline[open] { flex-basis: 100%; }

/* نواری که روی گوشی پایین صفحه می‌ماند تا تحویل سفارش آماده فراموش نشود */
.action-dock { display: none; }

/* ------------------------------------------------ 16. همهٔ پنل روی گوشی */
@media (max-width: 640px) {
  /* نوشته‌ها روی گوشی یک پله درشت‌تر */
  :root { --text-xs: 12.5px; --text-sm: 13.5px; --text-base: 15px; --text-md: 16px; --text-lg: 18px; }
  /* کادر کمتر از ۱۶ پیکسل، آیفون را وادار به بزرگ‌نمایی ناخواسته می‌کند */
  .field input, .field select, .field textarea, .input, .table-search input { font-size: 16px; min-height: 46px; }
  .card { padding: var(--space-4) var(--space-3); border-radius: var(--radius-sm); }
  .card__head { flex-wrap: wrap; }
  .btn { min-height: 44px; font-size: var(--text-base); }
  .btn--sm { min-height: 40px; }
  .card .btn-row > .btn { flex: 1 1 auto; }

  .big-action { flex-basis: 100%; min-height: 68px; font-size: 20px; }
  .order-card__jobs .big-action { min-height: 56px; font-size: 18px; }
  .handover-form__extra { grid-template-columns: 1fr; }
  .job-cards, .order-cards { grid-template-columns: 1fr; }

  .action-dock {
    display: flex; align-items: center; justify-content: center;
    position: fixed; z-index: 40;
    inset-inline: var(--space-3); bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    min-height: 58px; padding: var(--space-2) var(--space-4);
    border-radius: var(--radius);
    background: var(--gold-600); color: var(--white);
    font-size: 17px; font-weight: 800; text-decoration: none; text-align: center;
    box-shadow: var(--shadow-lg);
  }
  .action-dock:hover { color: var(--white); }
  body:has(.action-dock) .content { padding-bottom: 110px; }

}

/* ------------------------------------------ 17. مشخصات مشتری و سفارش */
/* برچسب در یک سو، مقدار در سوی دیگر؛ مقدار بلند (نشانی، توضیح سفارش) زیر
   برچسبش در یک کادر تمام‌عرض. هیچ مقداری از خط خودش بیرون نمی‌زند. */
.info-list { margin: 0 0 var(--space-3); display: grid; }
.info-list__row {
  display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: var(--space-3);
  align-items: baseline;
  padding: var(--space-2) 0; border-bottom: 1px solid var(--line-soft);
}
.info-list__row:last-child { border-bottom: 0; }
.info-list dt { color: var(--ink-soft); font-size: var(--text-sm); font-weight: 600; }
.info-list dd { margin: 0; text-align: end; font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.info-list__row--long { grid-template-columns: 1fr; gap: var(--space-1); }
.info-list__row--long dd {
  text-align: start; font-weight: 500; line-height: 1.9; white-space: pre-line;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); background: var(--cream-soft);
}
.job-card__title { min-width: 0; overflow-wrap: anywhere; }
.job-card__title .tiny { font-weight: 500; margin-top: 2px; }

/* چاپ / پیلیسه در سطر خرید پارچه */
.finishing { display: flex; flex-direction: column; gap: 4px; }
.finishing__job { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.finishing__btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--burgundy); border-radius: 999px;
  color: var(--burgundy); font-size: var(--text-base); user-select: none;
}
.finishing__btn input { position: absolute; opacity: 0; pointer-events: none; }
.finishing__btn::before { content: "+"; font-weight: bold; }
.finishing__btn:has(input:checked) { background: var(--burgundy); color: #fff; }
.finishing__btn:has(input:checked)::before { content: "✓"; }
.finishing__btn:has(input:focus-visible) { outline: 2px solid var(--burgundy); outline-offset: 2px; }
/* نرخ فقط وقتی دیده می‌شود که کار انتخاب شده باشد */
.finishing__job:not(:has(input[type=checkbox]:checked)) .finishing__rate { display: none; }
.finishing__rate { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; }
.finishing__sum { flex-basis: 100%; color: var(--burgundy); white-space: nowrap; line-height: 1.6; }
.finishing__final { color: var(--burgundy); white-space: nowrap; line-height: 1.7; }
.finishing__final:empty { display: none; }
.finishing__sum:empty { display: none; }

/* ------------------------------------------- 17. صفحهٔ اول خیاط، ساده‌تر */
/* سلام و فهرست کوتاه «امروز چه منتظر شماست» — اولین چیزی که خیاط می‌بیند */
.tailor-hello {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.tailor-hello__name { font-size: var(--text-xl); font-weight: 800; color: var(--burgundy); margin-bottom: var(--space-2); }
.tailor-hello__todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tailor-hello__todo li {
  padding: 8px var(--space-3); border-radius: var(--radius-sm);
  background: var(--cream-soft); font-size: var(--text-md); font-weight: 600;
}
.tailor-hello__todo li.is-danger { background: var(--danger-tint); color: var(--danger); }
.tailor-hello__todo li.is-warning { background: var(--warning-tint); color: var(--warning); }
.tailor-hello__todo li.is-success { background: var(--success-tint); color: var(--success); }

.order-card--late { border: 2px solid var(--danger); }
.order-card__wage { color: var(--ink-soft); }
.order-card__jobs li .tiny { font-weight: 400; }

/* تاریخچه‌ای که جمع می‌ماند تا خیاط بخواهد بازش کند */
.card.fold { margin-top: 18px; }
.fold__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  cursor: pointer; list-style: none; min-height: 44px;
}
.fold__head::-webkit-details-marker { display: none; }
.fold__head::after { content: "▾ باز کردن"; font-size: var(--text-sm); color: var(--ink-soft); white-space: nowrap; }
.fold[open] > .fold__head::after { content: "▴ بستن"; }
.fold__head .card__title { flex: 1; }

/* مهلت و مزد سفارش، بالای صفحهٔ سفارش خیاط */
.order-sum {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-2); padding: var(--space-3);
  border-radius: var(--radius-sm); background: var(--cream-soft); font-size: var(--text-md);
}

/* -- a table too wide for its box becomes cards ----------------------------
   Nobody on the panel slides a list sideways, on a laptop or on a phone.
   tables.js puts each column's name on its cells and, when a table is wider
   than its box, gives it is-cards: every row a card, every value under its
   column's name, and the row's own buttons in a full-width strip at the foot
   of that same card. */
.table-wrap.is-cards-wrap { border: 0; overflow: visible; border-radius: 0; }
table.table.is-cards,
table.table.is-cards > tbody,
table.table.is-cards > tfoot { display: block; width: 100%; }
table.table.is-cards > thead { display: none; }
table.table.is-cards > tbody > tr,
table.table.is-cards > tfoot > tr {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  gap: 0 var(--space-3);
  width: 100%;
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
table.table.is-cards > tbody > tr[hidden] { display: none; }
table.table.is-cards > tbody > tr:nth-child(even) { background: var(--surface); }
table.table.is-cards > tbody > tr:hover { background: var(--surface); border-color: var(--gold-500); }
table.table.is-cards > tbody > tr.row--alert { border-color: var(--danger-edge); }
table.table.is-cards > tbody > tr.is-highlighted { background: var(--gold-tint); }
table.table.is-cards > tbody > tr > td,
table.table.is-cards > tfoot > tr > td {
  display: block;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  text-align: start;
  white-space: normal;
  overflow-wrap: anywhere;
}
table.table.is-cards td[data-label]::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
}
table.table.is-cards td:empty { display: none; }
table.table.is-cards td.is-full,
table.table.is-cards td.is-wide,
table.table.is-cards td.is-actions {
  grid-column: 1 / -1;
}
table.table.is-cards td.is-wide .badge { margin: 2px 0 2px 4px; }
table.table.is-cards td.is-full { text-align: center; }
table.table.is-cards td.is-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--line-soft);
}
table.table.is-cards td.is-actions > *,
table.table.is-cards td.is-actions .btn-row,
table.table.is-cards td.is-actions .crud-actions { justify-content: flex-start; }
table.table.is-cards td .btn-row { justify-content: flex-start; }
table.table.is-cards td input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
table.table.is-cards td select,
table.table.is-cards td textarea { width: 100%; max-width: 100%; min-width: 0; }
table.table.is-cards td .num,
table.table.is-cards td.num { white-space: normal; }
@media (max-width: 640px) {
  table.table.is-cards > tbody > tr,
  table.table.is-cards > tfoot > tr { grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); }
}

/* a card never grows wider than the screen: grid cells may shrink below their
   content, and a card's heading wraps its buttons onto a second line */
.grid > * { min-width: 0; }
.card { min-width: 0; max-width: 100%; }
.card__head { flex-wrap: wrap; }
.card__head > * { min-width: 0; }
.table-search { flex-wrap: wrap; max-width: 100%; }
.table-search input { min-width: 0; max-width: 100%; }
table.table.is-cards .badge { white-space: normal; max-width: 100%; }

/* a page that sets its own column split (2fr 1fr…) still becomes one column
   on a phone, like every other grid */
@media (max-width: 900px) {
  .grid[style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
}
/* a row under a cell that spans several rows (one fabric, many colours)
   repeats that cell's value at the top of its own card */
table.table.is-cards > tbody > tr[data-carry]::before {
  content: attr(data-carry);
  grid-column: 1 / -1;
  padding: 4px 0 6px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px dashed var(--line-soft);
  margin-bottom: 4px;
}

/* ------------------------------------------------- اقلام سفارش (مثل کسب)
   The order's lines as cards, and the product window that writes them: a
   search box over the catalogue drawn as cards, then a short form — colour and
   size as buttons, a −/+ for how many, the price already filled in. On a phone
   the window is a sheet from the bottom of the screen; on a computer it is a
   box in the middle. Nothing here scrolls sideways. */
.lines { margin-top: var(--space-2); }
.lines__list { display: flex; flex-direction: column; gap: var(--space-2); }
.lines__empty {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}
.lines__add {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-3);
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--burgundy);
  color: var(--white);
  font: inherit; font-size: var(--text-md); font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.lines__add:hover { background: var(--burgundy-soft); }
.lines__add:active { transform: translateY(1px); }
.lines__add:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.lines__add-plus { font-size: 22px; line-height: 1; }
@media (min-width: 720px) { .lines__add { width: auto; min-width: 280px; margin-inline: auto; padding: 0 var(--space-8); } }
.lines__sum {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-weight: 700;
}
.lines__sum .amount__words { display: block; font-weight: 400; }

.line {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-slow) var(--ease), border-color var(--t-slow) var(--ease);
}
.line.is-new { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.line__view { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3); }
.line__mark, .pcard__mark {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--brand-tint);
  color: var(--burgundy);
  font-weight: 800; font-size: var(--text-lg);
}
.line__main { flex: 1 1 auto; min-width: 0; }
.line__title { font-weight: 700; font-size: var(--text-md); overflow-wrap: anywhere; }
.line__code { margin-inline-start: var(--space-2); font-weight: 400; font-size: var(--text-xs); color: var(--ink-soft); }
.line__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.line__tag {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}
.line__tag--stock { background: var(--success-tint); color: var(--success); }
.line__tag--warn { background: var(--danger-tint); color: var(--danger); }
.picker__no-model {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--danger-tint);
  color: var(--danger);
}
.line__figures {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-2);
}
.line__calc { color: var(--ink-soft); font-size: var(--text-sm); }
.line__sum { font-weight: 700; color: var(--burgundy); text-align: end; }
.line__sum .amount__words { display: block; font-weight: 400; color: var(--ink-soft); }
.line__actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.line__remove { color: var(--danger); }
@media (max-width: 520px) {
  .line__view { flex-wrap: wrap; }
  .line__main { flex-basis: calc(100% - 56px); }
  .line__actions { flex-direction: row; width: 100%; }
  .line__actions .btn { flex: 1; min-height: 40px; }
}

/* the window */
.picker { position: fixed; inset: 0; z-index: 1200; display: flex; align-items: center; justify-content: center; }
.picker[hidden] { display: none; }
.has-picker, .has-picker body { overflow: hidden; }
.picker__backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.picker__panel {
  position: relative;
  display: flex; flex-direction: column;
  width: min(560px, calc(100% - 32px));
  height: min(760px, calc(100% - 48px));
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: picker-in var(--t-slow) var(--ease);
}
@keyframes picker-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .picker { align-items: flex-end; }
  .picker__panel {
    width: 100%;
    height: calc(100% - 24px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}
@media (prefers-reduced-motion: reduce) { .picker__panel { animation: none; } }

.picker__step { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.picker__step[hidden] { display: none; }
.picker__head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}
.picker__title { flex: 1 1 auto; margin: 0; font-size: var(--text-lg); font-weight: 700; }
.picker__icon {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink);
  font-size: 20px; cursor: pointer;
}
.picker__icon:hover { background: var(--surface-sunken); }

.picker__search {
  flex: 0 0 auto;
  position: relative;
  margin: var(--space-4) var(--space-4) var(--space-3);
}
#product-picker .picker__search input {
  width: 100%;
  min-height: 50px;
  padding: 0 46px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit; font-size: 16px;
  color: var(--ink);
}
#product-picker .picker__search input:focus { outline: none; border-color: var(--burgundy); box-shadow: 0 0 0 3px var(--brand-glow); }
.picker__search input::-webkit-search-cancel-button { display: none; }
.picker__search-icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); display: flex; }
.picker__clear {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 16px;
}
.picker__chips {
  flex: 0 0 auto;
  display: flex; gap: var(--space-2);
  padding: 0 var(--space-4) var(--space-3);
  overflow-x: auto; scrollbar-width: none;
}
.picker__chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 38px; padding: 0 var(--space-4);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--text-sm); cursor: pointer; white-space: nowrap;
}
.chip.is-on { background: var(--burgundy); border-color: var(--burgundy); color: var(--white); }
/* شیوهٔ خرید در فرم سفارش: نقدی (۱۰٪ تخفیف) یا دیجی‌پی */
.purchase-mode { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.purchase-mode .chip { display: inline-flex; align-items: center; gap: var(--space-2); white-space: normal; }
.purchase-mode .chip:has(input:checked) { background: var(--burgundy); border-color: var(--burgundy); color: var(--white); }

.picker__list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-1) var(--space-4) var(--space-4);
}
.pcard {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: inherit; text-align: start; cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.pcard:hover, .pcard:focus-visible { border-color: var(--gold); background: var(--gold-glow); outline: none; }
.pcard__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pcard__name { font-weight: 700; font-size: var(--text-md); overflow-wrap: anywhere; }
.pcard__code { font-size: var(--text-xs); color: var(--ink-soft); }
.pcard__price { color: var(--gold-600); font-weight: 700; }
.pcard__cash { color: #2a6046; font-size: .85rem; font-weight: 600; }
.pcard__stock {
  flex: 0 0 auto; max-width: 38%;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-sunken); color: var(--ink-soft);
  font-size: var(--text-xs); text-align: center;
}
.pcard__stock.is-in { background: var(--success-tint); color: var(--success); }
.picker__empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  color: var(--ink-soft); text-align: center;
}

.picker__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--space-2) var(--space-4) var(--space-4); }
.picker__product {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}
.picker__product-name { font-size: var(--text-xl); font-weight: 800; overflow-wrap: anywhere; }
.picker__product-code { color: var(--ink-soft); font-size: var(--text-sm); }
.picker__stock { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.picker__stock b { font-size: var(--text-lg); }
.picker__stock-label { font-size: var(--text-xs); color: var(--ink-soft); }
.picker__row {
  display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.picker__row[hidden] { display: none; }
.picker__row--stack { grid-template-columns: 1fr; gap: var(--space-2); }
.picker__row > label, .picker__label { font-weight: 600; font-size: var(--text-md); }
.picker__row input[type="text"] {
  width: 100%; min-height: 48px; padding: 0 var(--space-3);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--surface-sunken); color: var(--ink);
  font: inherit; font-size: 16px;
}
.picker__row input[type="text"]:focus { outline: none; border-color: var(--burgundy); background: var(--surface); }
.picker__row input.is-invalid { border-color: var(--danger); background: var(--danger-tint-soft); }
.picker__money { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.picker__money .amount-echo { font-size: var(--text-xs); color: var(--ink-soft); }
.chip-price {
  align-self: flex-start;
  padding: 4px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--gold-600);
  font: inherit; font-size: var(--text-sm); cursor: pointer;
}
.picker__options { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.opt {
  min-height: 42px; min-width: 52px; padding: 0 var(--space-4);
  border: 1.5px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--text-base); cursor: pointer;
}
.opt.is-on { border-color: var(--burgundy); background: var(--burgundy); color: var(--white); font-weight: 700; }
/* «رنگ دیگر»: the colour written by hand when the list does not have it */
.opt--own { border-style: dashed; }
.stepper { display: flex; align-items: center; gap: var(--space-2); justify-self: start; }
.stepper__btn {
  width: 48px; height: 48px;
  border: 1.5px solid var(--line); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--burgundy);
  font-size: 22px; font-weight: 700; cursor: pointer;
}
#product-picker .picker__row input.stepper__input { width: 80px; flex: 0 0 80px; text-align: center; font-weight: 700; }
.segmented { display: flex; border: 1.5px solid var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.segmented__opt {
  flex: 1 1 50%; min-height: 46px;
  border: 0; background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--text-base); cursor: pointer;
}
.segmented__opt + .segmented__opt { border-inline-start: 1.5px solid var(--line); }
.segmented__opt.is-on { background: var(--gold-tint); color: var(--gold-600-deep); font-weight: 700; }
.segmented__opt.is-on::before { content: "✓ "; }
.picker__note { font-size: var(--text-sm); color: var(--ink-soft); }
/* what is on the rail: beside each colour and size, and line by line under «نوع تهیه» */
.opt__shelf {
  display: inline-block; margin-inline-start: 6px; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--success-tint); color: var(--success); font-size: var(--text-xs); font-weight: 700;
}
.opt.is-on .opt__shelf { background: rgba(255, 255, 255, .22); color: inherit; }
.picker__shelf { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.picker__shelf-line { padding: 2px 8px; border-radius: var(--radius-pill); background: var(--success-tint-soft); color: var(--ink); }
.picker__shelf-match { margin-top: 4px; font-weight: 700; color: var(--success); }
.picker__costs { margin-top: var(--space-3); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 0 var(--space-3); }
.picker__costs summary { padding: var(--space-3) 0; cursor: pointer; font-weight: 600; }
.picker__costs .picker__row:last-child { border-bottom: 0; }
.picker__foot {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.picker__sum { flex: 1 1 auto; display: flex; flex-direction: column; font-size: var(--text-sm); color: var(--ink-soft); }
.picker__sum b { color: var(--ink); font-size: var(--text-md); }
.picker__sum .amount__words { display: none; }
.picker__confirm { flex: 1 1 55%; min-height: 52px; border-radius: var(--radius-pill); font-size: var(--text-md); }
.is-blogger .picker__confirm { flex-basis: 100%; }
@media (max-width: 400px) { .picker__row { grid-template-columns: 1fr; gap: var(--space-2); } }
.pcard[hidden], .picker__empty[hidden], .lines__empty[hidden], .chip-price[hidden] { display: none; }
/* one model in several fabrics: its card opens the fabrics under it */
.pcard[aria-expanded="true"] { border-color: var(--gold); }
.pcard-fabrics {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-top: calc(-1 * var(--space-1));
  padding: var(--space-3);
  border: 1px dashed var(--gold); border-radius: var(--radius);
  background: var(--gold-glow);
}
.pcard-fabrics[hidden] { display: none; }
.pcard-fabrics__label { flex: 1 0 100%; font-size: var(--text-sm); color: var(--ink-soft); }
.pcard-fabrics .opt { white-space: normal; text-align: start; }

/* فرمی که فرستاده شده و منتظر جواب سرور است؛ زدن دوباره اثری ندارد */
form.is-sending [type="submit"],
form.is-sending button:not([type]) {
  opacity: .55;
  cursor: progress;
}

/* پیش‌نویس سفارش — each waiting draft on one row, «ادامه» and «حذف» beside it;
   on a phone the buttons drop under the name instead of pushing the page sideways */
.drafts__list { display: flex; flex-direction: column; gap: var(--space-2); }
.drafts__row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2) var(--space-3); padding: var(--space-3);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.drafts__row.is-open { border-color: var(--gold, #b8924a); background: var(--gold-tint); }
.drafts__main { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.drafts__name { font-weight: 700; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.drafts__actions { display: flex; gap: var(--space-2); align-items: center; }
.drafts__actions form { margin: 0; }

/* حساب خیاط: کار سفارش مشتری (آبی) و کار موجودی مزون (نارنجی) با یک نگاه از هم جدا */
:root {
  --kind-order: #1f5f99; --kind-order-tint: rgba(46, 116, 184, .14); --kind-order-chip: rgba(46, 116, 184, .22);
  --kind-stock: #9a5410; --kind-stock-tint: rgba(214, 130, 40, .16); --kind-stock-chip: rgba(214, 130, 40, .26);
  --kind-spent: #2a6046; --kind-spent-tint: rgba(42, 120, 80, .13); --kind-spent-chip: rgba(42, 120, 80, .22);
}
:root[data-theme="dark"] {
  --kind-order: #8cc2f2; --kind-order-tint: rgba(110, 170, 230, .14); --kind-order-chip: rgba(110, 170, 230, .24);
  --kind-stock: #f2b872; --kind-stock-tint: rgba(240, 160, 80, .14); --kind-stock-chip: rgba(240, 160, 80, .24);
  --kind-spent: #8fd4ad; --kind-spent-tint: rgba(110, 200, 150, .12); --kind-spent-chip: rgba(110, 200, 150, .22);
}
.job-kind-legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.job-kind {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-weight: 700;
  white-space: nowrap;
}
.job-kind--order { background: var(--kind-order-chip); color: var(--kind-order); }
.job-kind--stock { background: var(--kind-stock-chip); color: var(--kind-stock); }
.row--order > td { background: var(--kind-order-tint); }
.row--order > td:first-child { box-shadow: inset -4px 0 0 var(--kind-order); }
.row--stock > td { background: var(--kind-stock-tint); }
.row--stock > td:first-child { box-shadow: inset -4px 0 0 var(--kind-stock); }
.row--order > td:nth-child(2) b { color: var(--kind-order); }
.row--stock > td:nth-child(2) b { color: var(--kind-stock); }
/* هزینه‌ای که خیاط برای مزون داده (سبز) — طلب او کنار دستمزدها */
.job-kind--spent { background: var(--kind-spent-chip); color: var(--kind-spent); }
.row--spent > td { background: var(--kind-spent-tint); }
.row--spent > td:first-child { box-shadow: inset -4px 0 0 var(--kind-spent); }
.row--spent > td:last-child b { color: var(--kind-spent); }
table.table.is-cards > tbody > tr.row--spent { background: var(--kind-spent-tint); border-inline-start: 4px solid var(--kind-spent); }
tfoot tr.tfoot__total > td { border-top: 2px solid var(--line); }
table.table.is-cards > tbody > tr.row--order { background: var(--kind-order-tint); border-inline-start: 4px solid var(--kind-order); }
table.table.is-cards > tbody > tr.row--stock { background: var(--kind-stock-tint); border-inline-start: 4px solid var(--kind-stock); }
table.table.is-cards > tbody > tr.row--order > td,
table.table.is-cards > tbody > tr.row--stock > td { box-shadow: none; background: transparent; }

/* ---- «کارهای من»: پیدا کردن سفارش، و برگشتن روی همان کارت بعد از هر دکمه ---- */
.tailor-search {
  margin-top: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.tailor-search__label { display: block; font-size: var(--text-md); font-weight: 700; margin-bottom: var(--space-2); }
.tailor-search__row { display: flex; gap: var(--space-2); }
.tailor-search__row input { flex: 1 1 auto; min-width: 0; min-height: 48px; font-size: 17px; }
.tailor-search__row .btn { min-height: 48px; flex: 0 0 auto; }
.tailor-search__result {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2); margin-top: var(--space-3); color: var(--ink-soft);
}
/* the same box on top of «تأیید کارها», above its tabs */
.approval-search { margin: 0 0 var(--space-3); }
/* the sticky top bar must not cover the card the page lands on */
.order-card, .job-card { scroll-margin-top: 84px; }
.order-card .flashes, .job-card .flashes { margin-bottom: 0; }
.is-just-done { animation: just-done 2.4s ease-out 1; }
@keyframes just-done {
  0%, 35% { box-shadow: 0 0 0 4px var(--success); }
  100% { box-shadow: var(--shadow); }
}
@media (prefers-reduced-motion: reduce) { .is-just-done { animation: none; outline: 3px solid var(--success); } }

/* «موجودی مزون» in the tailor's panel: one card per model, its colours and sizes
   as short rows — fits a phone with nothing to slide sideways */
.watch-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.watch-model { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.watch-model--lacking { border-color: var(--danger); background: var(--danger-tint-soft); }
.watch-model__head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.watch-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.watch-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 0; border-top: 1px dashed var(--line-soft); }
.watch-line:first-child { border-top: 0; }
.watch-line__count { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* درآمد ماهانهٔ خیاط — هر ماه یک ردیف تاشو؛ روی گوشی عددها زیر نام ماه می‌روند */
.income-months { display: flex; flex-direction: column; gap: var(--space-2); }
.income-month { border: 1px solid var(--line-soft); border-radius: var(--radius, 10px); }
.income-month > summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: var(--space-2); padding: var(--space-2) var(--space-3); cursor: pointer;
}
.income-month__name { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.income-month__figs { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.income-month[open] > summary { border-bottom: 1px solid var(--line-soft); }
.income-month .table-wrap { padding: 0 var(--space-2) var(--space-2); }

/* تاریخچهٔ تغییرات سفارش — فهرست، نه جدول، تا روی گوشی کنار نرود */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-group { padding: 10px 0; border-bottom: 1px solid var(--line, #eee); }
.history-group:last-child { border-bottom: 0; }
.history-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 4px; }
.history-changes { margin: 0; padding-inline-start: 18px; }
.history-changes li { margin: 2px 0; overflow-wrap: anywhere; }
.history-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.history-long summary { cursor: pointer; display: inline; }

/* --------------------------------------------- خرید پارچه: هر پارچه یک کارت */
.buy-rows { display: flex; flex-direction: column; gap: var(--space-3); align-items: stretch; }
.buy-rows > [data-add-row] { align-self: flex-start; }
.buy-row { border: 1px solid var(--line); border-radius: var(--radius, 12px); padding: var(--space-3); background: var(--cream-soft); display: flex; flex-direction: column; gap: var(--space-2); }
.buy-row[hidden] { display: none; }
.buy-row__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.buy-row__total { font-size: var(--text-sm); }
.buy-row__total .tiny { display: block; }
.buy-row__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-2); }
.buy-row__fields .field { margin: 0; min-width: 0; }
.buy-row__more summary { cursor: pointer; color: var(--muted, #777); }

/* «📦 بسته‌بندی شده» — packed, waiting for the deposit or to be sent: purple until it ships */
.btn--purple { background: #7b3fc4; border-color: #7b3fc4; color: #fff; }
.btn--purple:hover { background: #6b2fb3; border-color: #6b2fb3; color: #fff; }
tr.is-packed > td { background: #f5eefd; }
table.table--orders tbody tr.order-main.is-packed > td:first-child { box-shadow: inset -4px 0 0 #7b3fc4; }
table.table.is-cards > tbody > tr.is-packed { border-color: #b48be6; }
.packed-note { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* سفارش دیجی‌پی — آبی دیجی‌پی، تا در صف تأیید واریزی از فیش‌های بانکی جدا دیده شود */
.badge--digipay { background: #E8F0FE; color: #1A56DB; border: 1px solid #A4C3F7; font-weight: 700; white-space: nowrap; margin-inline-start: 4px; }
