/* ==========================================================================
   panel.css — پنل اپراتور
   روی دیزاین سیستم Soft UI ساخته شده: مقادیر توکن از
   _ds/soft-ui-design-system-.../tokens/{colors,themes,spacing,typography}.css
   عیناً اینجا آورده شده‌اند، چون این فایل باید مستقل و بدون build در اپ Jinja2 کار کند.
   نام‌های معنایی محلی (--surface, --text, --accent …) فقط نگاشت روی توکن‌های Soft UI‌اند.
   انحراف‌های آگاهانه در panel/notes-soft-ui.md نوشته شده‌اند.
   ========================================================================== */

/* --- فونت خودمیزبان: پیدا (انتخاب کارفرما، جای Vazirmatnِ سیستم) --------- */
@font-face {
  font-family: 'Peyda';
  src: url('fonts/PeydaWebVF.woff2') format('woff2-variations'),
       url('fonts/PeydaWebVF.woff') format('woff-variations');
  font-weight: 100 900;
  font-display: swap;
}

/* ==========================================================================
   لایهٔ ۱ — پالت پایهٔ Soft UI. هیچ کامپوننتی مستقیم از اینجا نمی‌خواند.
   ========================================================================== */
:root {
  /* brand — soft indigo */
  --brand-50:#EEF0FF;
  --brand-100:#E0E4FF;
  --brand-200:#C3CAFF;
  --brand-400:#7B89FF;
  --brand-500:#5B6CFF;
  --brand-600:#4757E6;
  --brand-700:#3542B8;

  /* neutrals — خنک، هرگز مشکی خالص */
  --gray-0:#FFFFFF;
  --gray-50:#F6F7FB;
  --gray-100:#F1F3F8;
  --gray-200:#E4E7EF;
  --gray-300:#CFD4E0;
  --gray-400:#A0A6B8;
  --gray-500:#6C7385;
  --gray-700:#3B4152;
  --gray-900:#1E2235;

  /* canvas — میز خاکستری‌آبی که فریم سفید رویش شناور است */
  --canvas-a:#F2F4F8;
  --canvas-b:#DEE3EC;

  /* status — مستقل از برند */
  --green-500:#17B26A; --green-50:#E7F8F0; --green-700:#0F7A49;
  --red-500:#F04438;   --red-50:#FDECEA;   --red-700:#B42318;
  --coral-500:#FF7A59; --coral-50:#FFE9E3; --coral-700:#B54724;
  --amber-500:#F5A524; --amber-50:#FFF4E0; --amber-700:#8A5A06;

  --navy-900:#1E1B3A;

  /* فاصله — شبکهٔ ۸ */
  --s-1: 4px;   /* فقط درون کنترل‌ها */
  --s-2: 8px;
  --s-3: 12px;  /* فقط درون کنترل‌ها */
  --s-4: 16px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* شعاع — پنج مقدار مجاز Soft UI. ۶ و ۸ و ۲۰ ممنوع‌اند */
  --r-frame: 32px;
  --r-card: 24px;
  --r-tile: 16px;
  --r-control: 12px;
  --r-pill: 999px;
  --r-mini: var(--r-control);

  /* تایپ — مقیاس Soft UI؛ فارسی یک وزن بالاتر و بدون tracking */
  --font-fa: 'Peyda', 'Vazirmatn', 'Tahoma', system-ui, sans-serif;
  --fs-display: 32px;
  --fs-h1: 28px;
  --fs-h2: 24px;
  --fs-h3: 18px;
  --fs-body: 15px;
  --fs-sm: 13px;
  --fs-mono: 14px;
  --lh-tight: 1.3;
  --lh-body: 1.8;
  --w-regular: 400;
  --w-medium: 500;
  --w-semi: 600;
  --w-bold: 700;
  --w-fa-strong: 800;

  --dur-fast: 160ms;
  --dur: 240ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-soft: cubic-bezier(.32, .72, 0, 1);
}

/* ==========================================================================
   لایهٔ ۲ — نقش‌های معنایی · تم روشن
   ========================================================================== */
:root,
[data-theme='light'] {
  --canvas: linear-gradient(135deg, var(--canvas-a) 0%, var(--canvas-b) 100%);
  --bg: var(--canvas);
  --bg-sunken: var(--gray-100);
  --surface: var(--gray-0);
  --surface-raised: var(--gray-0);
  --surface-quiet: var(--gray-50);

  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --text-faint: var(--gray-400);     /* جای‌نگه‌دار و غیرفعال، نه متن وضعیت */
  --text-on-accent: #FFFFFF;

  --line: var(--gray-200);           /* فقط خط مویی و خط دور دکمهٔ ثانویه */
  --line-strong: var(--gray-300);

  --accent: var(--brand-500);
  --accent-hover: var(--brand-600);
  --accent-quiet: var(--brand-50);
  --accent-line: var(--brand-200);
  --accent-text: var(--brand-600);

  --danger: var(--red-500);
  --danger-quiet: var(--red-50);
  --danger-text: var(--red-700);
  --warn: var(--coral-500);
  --warn-quiet: var(--coral-50);
  --warn-text: var(--coral-700);
  --ok: var(--green-500);
  --ok-quiet: var(--green-50);
  --ok-text: var(--green-700);
  --info: var(--amber-500);
  --info-quiet: var(--amber-50);
  --info-text: var(--amber-700);

  --focus: var(--brand-200);
  --focus-ring: 0 0 0 3px var(--brand-100);
  --overlay: rgb(30 34 53 / .34);

  /* ارتفاع — نرم، خنک، لایه‌لایه؛ هرگز drop تیره و سفت */
  --sh-1: 0 1px 2px rgb(30 34 53 / .04), 0 12px 32px -12px rgb(30 34 53 / .10);
  --sh-2: 0 4px 12px rgb(30 34 53 / .05), 0 28px 64px -24px rgb(30 34 53 / .22);
  --sh-3: var(--sh-2);
  --sh-frame: 0 40px 100px -40px rgb(30 34 53 / .28);
  --sh-brand: 0 10px 24px -10px rgb(91 108 255 / .55);
  color-scheme: light;
}

/* تم تیره — مقادیر themes.css سیستم. تم پیش‌فرض نیست؛ انتخاب کاربر یا prefers-color-scheme */
[data-theme='dark'] {
  --canvas: linear-gradient(135deg, #12142A 0%, #0B0D1A 100%);
  --bg: var(--canvas);
  --bg-sunken: #1F2338;
  --surface: #171A2C;
  --surface-raised: #1F2338;
  --surface-quiet: #1B1E31;

  --text: #F2F3F8;
  --text-muted: #9AA0B5;
  --text-faint: #6C7385;
  --text-on-accent: #0B0D1A;

  --line: rgb(255 255 255 / .08);
  --line-strong: rgb(255 255 255 / .18);

  --accent: var(--brand-400);
  --accent-hover: var(--brand-500);
  --accent-quiet: rgb(123 137 255 / .14);
  --accent-line: rgb(123 137 255 / .32);
  --accent-text: var(--brand-200);

  --danger: var(--red-500);
  --danger-quiet: rgb(240 68 56 / .16);
  --danger-text: #FFB4AC;
  --warn: var(--coral-500);
  --warn-quiet: rgb(255 122 89 / .16);
  --warn-text: #FFC0AC;
  --ok: var(--green-500);
  --ok-quiet: rgb(23 178 106 / .16);
  --ok-text: #7FE3B4;
  --info: var(--amber-500);
  --info-quiet: rgb(245 165 36 / .16);
  --info-text: #FFD79A;

  --focus: rgb(123 137 255 / .55);
  --focus-ring: 0 0 0 3px rgb(123 137 255 / .35);
  --overlay: rgb(8 9 20 / .62);

  --sh-1: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -12px rgb(0 0 0 / .5);
  --sh-2: 0 4px 12px rgb(0 0 0 / .35), 0 28px 64px -24px rgb(0 0 0 / .7);
  --sh-3: var(--sh-2);
  --sh-frame: 0 40px 100px -40px rgb(0 0 0 / .8);
  --sh-brand: 0 10px 24px -10px rgb(91 108 255 / .45);
  color-scheme: dark;
}

/* ==========================================================================
   لایهٔ ۳ — توکن کامپوننت (component)
   ========================================================================== */
:root {
  --btn-h: 40px;
  --btn-h-sm: 32px;
  --btn-pad: 0 var(--s-4);
  --btn-radius: var(--r-control);
  --btn-font: var(--w-semi) var(--fs-body) / 1 var(--font-fa);

  --card-pad: var(--s-6);
  --card-radius: var(--r-card);

  --field-h: 40px;
  --field-radius: var(--r-control);

  --pill-h: 36px;

  --badge-h: 24px;
  --toast-radius: var(--r-card);
  --dialog-w: 440px;
  --dialog-radius: var(--r-card);
}

/* ==========================================================================
   پایه
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

/* تم روی هر دامنه‌ای که data-theme دارد اعمال می‌شود، نه فقط روی ریشه */
body,
[data-theme] {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  font-family: var(--font-fa);
  font-size: var(--fs-body);
  font-weight: var(--w-regular);
  line-height: var(--lh-body);
  letter-spacing: 0;          /* روی فارسی هرگز letter-spacing */
}

h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); text-wrap: balance; }
h1 { font-size: var(--fs-h1); font-weight: var(--w-bold); }
h2 { font-size: var(--fs-h2); font-weight: var(--w-bold); }
h3 { font-size: var(--fs-h3); font-weight: var(--w-semi); }
p { margin: 0; text-wrap: pretty; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ارقام: لاتین همیشه tabular؛ فارسی در شمارش و تاریخ */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  unicode-bidi: plaintext;
  white-space: nowrap;
}
.num--fa { font-variant-numeric: normal; unicode-bidi: isolate; direction: rtl; }

.u-muted { color: var(--text-muted); }
.u-faint { color: var(--text-faint); }
.u-nowrap { white-space: nowrap; }
.u-stack { display: flex; flex-direction: column; gap: var(--s-2); }
.u-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* ==========================================================================
   دکمه
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--btn-h);
  padding: var(--btn-pad);
  border: 1px solid transparent;
  border-radius: var(--btn-radius);
  font: var(--btn-font);
  white-space: nowrap;
  flex: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(.98); }

.btn--primary { background: var(--accent); color: var(--text-on-accent); box-shadow: var(--sh-brand); }
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn--secondary:hover { border-color: var(--accent); color: var(--accent-text); }

.btn--destructive { background: var(--surface); color: var(--danger-text); border-color: var(--line); }
.btn--destructive:hover { background: var(--danger); color: #FFFFFF; border-color: var(--danger); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text); }

.btn--sm { min-height: var(--btn-h-sm); padding: 0 var(--s-3); font-size: var(--fs-sm); }

.btn[disabled], .btn[aria-disabled='true'] {
  opacity: 1;
  cursor: not-allowed;
  background: var(--bg-sunken);
  color: var(--text-faint);
  border-color: var(--line);
  box-shadow: none;
}

.btn__spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--r-pill);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   فیلد
   ========================================================================== */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field__label { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text); }
.field__hint { font-size: var(--fs-sm); color: var(--text-muted); }
.field__error { font-size: var(--fs-sm); font-weight: var(--w-medium); color: var(--danger-text); }

.input, .select, .textarea {
  min-height: var(--field-h);
  padding: 0 var(--s-3);
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--field-radius);
  font: var(--w-regular) var(--fs-body) / var(--field-h) var(--font-fa);
  width: 100%;
  transition: border-color var(--dur) var(--ease);
}
.textarea { line-height: var(--lh-body); padding: var(--s-2) var(--s-3); resize: vertical; min-height: 96px; }
.select { appearance: none; padding-inline-end: var(--s-8); background-image: none; cursor: pointer; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--accent-line); }
.input:focus, .select:focus, .textarea:focus { background: var(--surface); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input[aria-invalid='true'] { border-color: var(--danger); }
.input[disabled] { background: var(--bg-sunken); color: var(--text-faint); }

.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; }
.check__box {
  width: 20px; height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface);
  display: grid; place-items: center;
  flex: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box svg { width: 14px; height: 14px; opacity: 0; color: var(--text-on-accent); }
.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box svg { opacity: 1; }
.check input:focus-visible + .check__box { outline: none; box-shadow: var(--focus-ring); }

/* ==========================================================================
   بج وضعیت
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: var(--w-semi);
  border: 0;
  white-space: nowrap;
}
.badge--neutral { background: var(--bg-sunken); color: var(--text-muted); }
.badge--ok { background: var(--ok-quiet); color: var(--ok-text); }
.badge--warn { background: var(--warn-quiet); color: var(--warn-text); }
.badge--danger { background: var(--danger-quiet); color: var(--danger-text); }
.badge--info { background: var(--info-quiet); color: var(--info-text); }
.badge--accent { background: var(--accent-quiet); color: var(--accent-text); }

/* شدت — رنگ تنها حامل معنا نیست: تعداد تیغه + برچسب متنی */
.sev { display: inline-flex; align-items: center; gap: 6px; }
.sev__bars { display: flex; gap: 3px; align-items: flex-end; }
.sev__bars i {
  display: block;
  width: 3px;
  background: var(--line-strong);
  border-radius: var(--r-pill);
}
.sev__bars i:nth-child(1) { height: 6px; }
.sev__bars i:nth-child(2) { height: 9px; }
.sev__bars i:nth-child(3) { height: 12px; }
.sev__label { font-size: 11.5px; font-weight: var(--w-semi); color: var(--text-muted); }

.sev--0 .sev__bars i:nth-child(1) { background: var(--text-muted); }
.sev--1 .sev__bars i:nth-child(-n+2) { background: var(--warn); }
.sev--1 .sev__label { color: var(--warn-text); }
.sev--2 .sev__bars i { background: var(--danger); }
.sev--2 .sev__label { color: var(--danger-text); }

/* ==========================================================================
   کارت و پنل
   ========================================================================== */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  box-shadow: var(--sh-1);
}
.card--raised { box-shadow: var(--sh-2); }
.card--raised:hover { transform: translateY(-2px); }
.card--sunken { background: var(--bg-sunken); border: 0; border-radius: var(--r-tile); box-shadow: none; }
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.card__title { font-size: var(--fs-h3); font-weight: var(--w-semi); }
.card__meta { font-size: var(--fs-sm); color: var(--text-muted); }

/* ==========================================================================
   تب raised-pill — زبان انتخاب قفل‌شدهٔ تراز
   هر جا چیزی انتخاب می‌شود، همین زبان تکرار می‌شود.
   ========================================================================== */
.pills {
  display: inline-flex;
  gap: var(--s-1);
  padding: var(--s-1);
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: var(--pill-h);
  padding: 0 var(--s-4);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-pill);
  font: var(--w-semi) var(--fs-body) / 1 var(--font-fa);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pill:hover { color: var(--text); }
.pill[aria-selected='true'], .pill.is-selected {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(30 34 53 / .08), 0 6px 16px -10px rgb(30 34 53 / .35);
}
.pill__count {
  font-size: var(--fs-sm);
  font-weight: var(--w-semi);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.pill[aria-selected='true'] .pill__count { color: var(--accent-text); }

/* ==========================================================================
   جدول عددی
   ========================================================================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: var(--s-3) var(--s-2);
  text-align: start;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
}
.table th { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text-muted); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { font-variant-numeric: tabular-nums; text-align: end; }
.table--rows tbody tr:hover { background: var(--surface-quiet); }

/* ==========================================================================
   توست
   ========================================================================== */
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 0;
  border-radius: var(--toast-radius);
  box-shadow: var(--sh-2);
  font-weight: var(--w-medium);
  max-width: 480px;
}
.toast__mark { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--text-muted); flex: none; }
.toast--ok .toast__mark { background: var(--ok); }
.toast--danger .toast__mark { background: var(--danger); }
.toast--info .toast__mark { background: var(--info); }
.toast__text { flex: 1; }
.toast__action { font-weight: var(--w-semi); color: var(--accent-text); background: none; border: 0; cursor: pointer; font-family: var(--font-fa); font-size: var(--fs-body); }

/* ==========================================================================
   دیالوگ تأیید
   ========================================================================== */
.dialog-scrim {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  display: grid;
  place-items: center;
  border-radius: inherit;
}
.dialog {
  width: min(var(--dialog-w), 100%);
  background: var(--surface);
  border: 0;
  border-radius: var(--dialog-radius);
  box-shadow: var(--sh-3);
  padding: var(--card-pad);
}
.dialog__title { font-size: var(--fs-h3); font-weight: var(--w-bold); margin-bottom: var(--s-2); }
.dialog__body { color: var(--text-muted); margin-bottom: var(--s-6); }
.dialog__actions { display: flex; gap: var(--s-2); justify-content: flex-start; }

/* ==========================================================================
   حالت خالی
   ========================================================================== */
.empty { padding: var(--s-12) var(--s-6); text-align: center; }
.empty__title { font-size: var(--fs-h3); font-weight: var(--w-semi); margin-bottom: var(--s-2); }
.empty__body { color: var(--text-muted); margin-bottom: var(--s-6); }

/* ==========================================================================
   پوستهٔ پنل — ریل آیکونی باریک + هدر (فاز B)
   ========================================================================== */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
}
.rail {
  grid-column: 1;
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  box-shadow: var(--sh-1);
  margin: var(--s-6) var(--s-6) var(--s-6) 0;
  padding: var(--s-4) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  position: sticky;
  top: var(--s-6);
  align-self: start;
  height: calc(100dvh - var(--s-12));
}
.rail__mark {
  width: 40px; height: 40px;
  border-radius: var(--r-tile);
  background: var(--accent);
  color: var(--text-on-accent);
  display: grid; place-items: center;
  font-weight: var(--w-bold);
  margin-bottom: var(--s-4);
}
.rail__link {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-tile);
  cursor: pointer;
  position: relative;
  transition: background-color var(--dur) var(--ease);
}
.rail__link:hover { background: var(--bg-sunken); color: var(--text); }.rail__link[data-todo] { color: var(--text-faint); cursor: not-allowed; }
.rail__link[data-todo]:hover { background: transparent; color: var(--text-faint); }
.rail__link[aria-current='page'] { background: var(--accent); color: var(--text-on-accent); box-shadow: var(--sh-brand); }
.rail__link svg { width: 22px; height: 22px; }
.rail__badge {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-start: 4px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: var(--w-bold);
  font-variant-numeric: tabular-nums;
  display: grid; place-items: center;
}
.rail__spacer { flex: 1; }

.main { grid-column: 2; min-width: 0; padding: var(--s-6) var(--s-6) var(--s-12) 0; }
.main__inner {
  max-width: 1240px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-frame);
  box-shadow: var(--sh-frame);
  padding: var(--s-10);
}
@media (max-width: 960px) { .main__inner { padding: var(--s-6); } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  background: transparent;
  border: 0;
  padding: 0 var(--s-2) var(--s-6);
  margin-bottom: 0;
}
.topbar__title { display: flex; align-items: baseline; gap: var(--s-3); }
.topbar__count { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.topbar__tools { display: flex; align-items: center; gap: var(--s-2); }
.iconbtn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  cursor: pointer;
}
.iconbtn:hover { color: var(--text); border-color: var(--accent); }
.iconbtn svg { width: 20px; height: 20px; }

/* ==========================================================================
   صف کار
   ========================================================================== */
.queue {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.queue-item {
  display: grid;
  grid-template-columns: 3px 104px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-6);
  min-height: 104px;
  padding: var(--s-4) var(--s-6) var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.queue-item:last-child { border-bottom: 0; }
.queue-item[hidden] { display: none; }
.queue-item:hover { background: var(--surface-quiet); }
.queue-item__edge { align-self: stretch; border-radius: 2px; background: transparent; }
.queue-item--sev2 .queue-item__edge { background: var(--danger); }
.queue-item--sev1 .queue-item__edge { background: var(--warn); }

.queue-item__sev { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.queue-item__age { font-size: var(--fs-body); font-weight: var(--w-medium); color: var(--text); font-variant-numeric: tabular-nums; }

.queue-item__thumb {
  width: 56px; height: 56px;
  padding: 0;
  border: 0;
  border-radius: var(--r-tile);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: var(--w-semi);
  cursor: zoom-in;
  display: grid; place-items: center;
  flex: none;
}
.queue-item__thumb:hover { background: var(--accent-quiet); color: var(--accent-text); }
.queue-item__thumb--none { width: 56px; visibility: hidden; }

.queue-item__body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.queue-item__kindline { display: flex; align-items: center; gap: var(--s-2); min-height: 20px; }
.queue-item__kindline .badge--neutral {
  background: transparent;
  border: 0;
  padding: 0;
  min-height: 0;
  font-size: 11.5px;
  font-weight: var(--w-semi);
  color: var(--text-faint);
}
.queue-item__kindline .badge--neutral + .badge::before {
  content: '';
  width: 3px; height: 3px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  margin-inline-end: var(--s-2);
}
.queue-item__title { font-size: 16.5px; font-weight: var(--w-semi); line-height: 1.5; letter-spacing: 0; max-width: 62ch; }
.queue-item__meta { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; line-height: 1.6; }
.queue-item__actions { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; }

/* بین ۸۶۰ و ۱۲۴۰: اقدام‌ها زیر متن می‌روند تا عنوان در یک یا دو خط جا شود */
@media (max-width: 1240px) {
  .queue-item {
    grid-template-columns: 3px 104px auto minmax(0, 1fr);
    row-gap: var(--s-3);
  }
  .queue-item__edge { grid-row: 1 / -1; }
  .queue-item__actions { grid-column: 3 / -1; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; width: 100%;
    flex-direction: row; justify-content: flex-start;
    border-inline-end: 0; border-block-end: 1px solid var(--line);
    padding: var(--s-2) var(--s-4); overflow-x: auto;
  }
  .rail__mark { margin-bottom: 0; }
  .rail__spacer { flex: none; }
  .main { padding: var(--s-4); }
  .queue-item {
    grid-template-columns: 4px auto minmax(0, 1fr);
    grid-template-areas: 'edge sev body' 'edge thumb body' 'edge act act';
    padding: var(--s-4);
  }
  .queue-item__edge { grid-area: edge; }
  .queue-item__sev { grid-area: sev; }
  .queue-item__thumb { grid-area: thumb; }
  .queue-item__body { grid-area: body; }
  .queue-item__actions { grid-area: act; margin-top: var(--s-2); }
}

/* دیالوگ عکس رسید */
.sheet {
  border: 0;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-3);
  padding: var(--card-pad);
  max-width: min(720px, 92vw);
  width: 100%;
}
.sheet::backdrop { background: var(--overlay); }
.sheet__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.sheet__well {
  border: 1.5px dashed var(--accent-line);
  border-radius: var(--r-tile);
  background: var(--accent-quiet);
  color: var(--accent-text);
  min-height: 320px;
  display: grid; place-items: center;
  text-align: center;
  padding: var(--s-6);
  margin-bottom: var(--s-4);
}
.sheet__img {
  display: block;
  width: 100%;
  max-height: 60dvh;
  object-fit: contain;
  background: var(--bg-sunken);
  border-radius: var(--r-tile);
  margin-bottom: var(--s-4);
}
.sheet__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.toast-stack {
  position: fixed;
  inset-block-end: var(--s-6);
  inset-inline-start: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  z-index: 40;
}

/* ==========================================================================
   نوار توقف فروش — سراسری، بالای همهٔ صفحه‌ها
   ========================================================================== */
.halt-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-6);
  background: var(--danger-quiet);
  color: var(--danger-text);
  border-bottom: 1px solid var(--danger);
  font-weight: var(--w-semi);
  position: sticky;
  top: 0;
  z-index: 30;
}
.halt-bar[hidden] { display: none; }
.halt-bar__mark {
  width: 24px; height: 24px;
  border-radius: var(--r-mini);
  border: 2px solid currentColor;
  display: grid; place-items: center;
  font-weight: var(--w-bold);
  flex: none;
}
.halt-bar__text { flex: 1; min-width: 0; }
.halt-bar__meta { font-weight: var(--w-regular); font-size: var(--fs-sm); }

/* ==========================================================================
   حالت‌های ردیف صف: در دست بررسی، و سن گذشته از قول
   ========================================================================== */
.queue-item--claimed { background: var(--bg-sunken); }
.queue-item__claim {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: var(--w-medium);
  color: var(--text-muted);
  background: transparent;
  border: 0;
  padding: 0 var(--s-2);
  min-height: var(--btn-h);
  max-width: 22ch;
  text-align: start;
  line-height: 1.5;
}

.queue-item__age--late {
  font-weight: var(--w-bold);
  color: var(--danger-text);
  border: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.queue-item__age--late::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: var(--danger);
  flex: none;
}
.queue-item__sla { font-size: 11.5px; font-weight: var(--w-medium); color: var(--danger-text); line-height: 1.5; max-width: 13ch; }

.toast__count { font-variant-numeric: tabular-nums; font-weight: var(--w-semi); color: var(--text-muted); }

/* ==========================================================================
   بچ‌ها و موجودی (فاز C)
   ========================================================================== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin: var(--s-8) 0 var(--s-4);
}
.section-head h2 { display: flex; align-items: baseline; gap: var(--s-3); }
.section-head__meta { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.batch-list {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--sh-1);
}
.batch-row {
  display: grid;
  grid-template-columns: 3px minmax(210px, 1fr) 150px minmax(200px, 1.1fr) auto;
  align-items: start;
  gap: var(--s-6);
  padding: var(--s-6);
  border-bottom: 1px solid var(--line);
}
.batch-row:last-child { border-bottom: 0; }
.batch-row:hover { background: var(--surface-quiet); }
.batch-row__edge { align-self: stretch; border-radius: 2px; background: transparent; }
.batch-row--blocked { background: var(--danger-quiet); }
.batch-row--blocked .batch-row__edge { background: var(--danger); }
.batch-row--watch .batch-row__edge { background: var(--warn); }

.batch-row__id { font-size: var(--fs-h3); font-weight: var(--w-semi); line-height: 1.4; }

/* متادیتا: قلم‌های جدا با جداکنندهٔ چسبیده به آیتم بعدی، پس «·» هرگز ته خط آویزان نمی‌ماند */
.batch-row__meta {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.7;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-3);
  margin-top: 2px;
}
.batch-row__meta > span { display: inline-flex; align-items: baseline; gap: var(--s-3); white-space: nowrap; }
.batch-row__meta > span + span::before {
  content: '';
  width: 3px; height: 3px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  flex: none;
  align-self: center;
}
.batch-row__note { font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.7; margin-top: var(--s-1); max-width: 34ch; }

/* نرخ ریوُک — مهم‌ترین عدد این صفحه. از دو متری خوانده می‌شود. */
.batch-rate { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.batch-rate__num {
  font-size: 34px;
  line-height: 1;
  font-weight: var(--w-bold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.batch-rate--blocked .batch-rate__num { color: var(--danger-text); }
.batch-rate--watch .batch-rate__num { color: var(--warn-text); }
.batch-rate__cap { font-size: 11.5px; font-weight: var(--w-medium); color: var(--text-muted); white-space: nowrap; margin-top: 2px; }
.batch-rate__bar {
  position: relative;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--bg-sunken);
  overflow: hidden;
  margin-top: 2px;
}
.batch-rate__bar { width: 100%; min-width: 112px; margin-top: 6px; }
.batch-rate__bar i { display: block; height: 100%; background: var(--text-muted); border-radius: var(--r-pill); }
.batch-rate__bar[data-over] i {
  background: repeating-linear-gradient(115deg, var(--danger) 0 6px, color-mix(in oklab, var(--danger) 72%, #fff) 6px 12px);
}
.batch-rate__over { font-size: 11px; font-weight: var(--w-semi); color: var(--danger-text); margin-top: 3px; white-space: nowrap; }
.batch-rate__bar b {
  position: absolute;
  inset-block: -3px;
  inset-inline-start: 50%;
  width: 2px;
  border-radius: var(--r-pill);
  background: var(--text);
  opacity: .45;
}
.batch-rate--blocked .batch-rate__bar i { background: var(--danger); }
.batch-rate--watch .batch-rate__bar i { background: var(--warn); }

.batch-row__status { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); text-align: start; }
.batch-row__status .batch-row__meta { display: block; max-width: 30ch; margin-top: 0; }
.batch-row__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }

/* قاعدهٔ مسدودسازی — از settings خوانده می‌شود، نه ثابت در کد */
.rule-box {
  background: var(--surface);
  border: 0;
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--r-card);
  box-shadow: var(--sh-1);
  padding: var(--s-4) var(--s-6);
  margin-bottom: var(--s-4);
}
.rule-box__title { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text-muted); margin-bottom: var(--s-2); }
.rule-box__list { display: flex; flex-direction: column; gap: var(--s-1); font-size: var(--fs-body); }
.rule-box__list span { display: flex; gap: var(--s-2); align-items: baseline; }
.rule-box__no {
  min-width: 22px; height: 22px;
  border-radius: var(--r-pill);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 11px; font-weight: var(--w-bold);
  display: grid; place-items: center;
  flex: none;
}

/* صف انتظار تعویض — واحدهایی که موجودی سالم برایشان نیست */
.wait-strip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  background: var(--bg-sunken);
  border: 0;
  border-radius: var(--r-tile);
  padding: var(--s-3) var(--s-6);
  margin-top: var(--s-4);
  font-size: var(--fs-sm);
}
.wait-strip__num { font-size: var(--fs-h2); font-weight: var(--w-bold); font-variant-numeric: tabular-nums; }
.wait-strip__text { color: var(--text-muted); flex: 1; min-width: 200px; }

/* دسترسی ادمین */
.role-lock {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: 0;
  border-radius: var(--r-control);
  padding: 0 var(--s-3);
  min-height: var(--btn-h);
}

/* تحویل‌های در گارانتی از یک بچ — تصمیم تعویض پیشگیرانه */
.deliv-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 124px 140px 132px auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6);
  border-bottom: 1px solid var(--line);
}
.deliv-row:last-child { border-bottom: 0; }
.deliv-row:hover { background: var(--surface-quiet); }
.deliv-row__head { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text-muted); background: var(--bg-sunken); }
.deliv-row .num, .deliv-row__head .num { text-align: start; direction: rtl; }
.deliv-row__actions { display: flex; gap: var(--s-2); justify-content: flex-end; }

.deliv-row__prio { font-variant-numeric: tabular-nums; font-weight: var(--w-bold); color: var(--text-muted); }
.deliv-row__prio--now { color: var(--text); }

@media (max-width: 980px) {
  .deliv-row { grid-template-columns: 56px minmax(0, 1fr) 96px; row-gap: var(--s-2); }
  .deliv-row > :nth-child(4),
  .deliv-row > :nth-child(5),
  .deliv-row > :nth-child(6) { grid-column: 1 / -1; }
  .deliv-row__actions { justify-content: flex-start; }
  .deliv-row__head > :nth-child(4),
  .deliv-row__head > :nth-child(5),
  .deliv-row__head > :nth-child(6) { display: none; }
}

.sku-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 120px 160px auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6);
  border-bottom: 1px solid var(--line);
}
.sku-row:last-child { border-bottom: 0; }
.sku-row:hover { background: var(--surface-quiet); }
.sku-row__head { font-size: var(--fs-sm); font-weight: var(--w-semi); color: var(--text-muted); background: var(--bg-sunken); }
.sku-row__actions { display: flex; align-items: center; gap: var(--s-2); justify-content: flex-end; }
.sku-row .num, .sku-row__head .num { text-align: start; direction: rtl; }

/* ایمپورت CSV */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-tile);
  background: var(--surface-quiet);
  padding: var(--s-10) var(--s-6);
  text-align: center;
}
.dropzone--invalid { border-color: var(--danger); background: var(--danger-quiet); }
.dropzone__title { font-size: var(--fs-h3); font-weight: var(--w-semi); margin-bottom: var(--s-2); }
.dropzone__body { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--s-4); }

.progress {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--bg-sunken);
  overflow: hidden;
  max-width: 320px;
  margin: 0 auto var(--s-3);
}
.progress i { display: block; height: 100%; background: var(--accent); }

.import-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 132px;
  align-items: start;
  gap: var(--s-4);
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.import-row:last-child { border-bottom: 0; }
.import-row__no { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.import-row__code { font-variant-numeric: tabular-nums; unicode-bidi: plaintext; word-break: break-all; }
.import-row--error { background: var(--danger-quiet); }
.import-row--error .import-row__code { text-decoration: line-through; text-decoration-color: var(--danger); }
.import-row__err { color: var(--danger-text); font-weight: var(--w-semi); }
.import-scroll { max-height: 296px; overflow-y: auto; background: var(--bg-sunken); border-radius: var(--r-tile); }

@media (max-width: 980px) {
  /* جای هر فرزند صریح است، پس اضافه شدن یک فرزند ردیف را به هم نمی‌ریزد */
  .batch-row { grid-template-columns: 3px minmax(0, 1fr) auto; row-gap: var(--s-3); column-gap: var(--s-4); }
  .batch-row__edge { grid-row: 1 / -1; grid-column: 1; }
  .batch-row > :nth-child(2) { grid-column: 2; grid-row: 1; }      /* شناسه و متادیتا */
  .batch-rate { grid-column: 3; grid-row: 1; align-items: flex-end; }
  .batch-rate__bar { width: 132px; min-width: 0; }
  .batch-row__status { grid-column: 2 / -1; grid-row: 2; }
  .batch-row__status .batch-row__note { max-width: none; }
  .batch-row__actions { grid-column: 2 / -1; grid-row: 3; justify-content: flex-start; }

  /* سرستون و ردیف داده همین سه track را مشترک دارند؛ دو ستون آخر تمام‌عرض می‌شوند */
  .sku-row { grid-template-columns: minmax(0, 1fr) 64px 64px; row-gap: var(--s-2); }
  .sku-row > :nth-child(4),
  .sku-row > :nth-child(5) { grid-column: 1 / -1; }
  .sku-row__actions { justify-content: flex-start; }
  .sku-row__head > :nth-child(4),
  .sku-row__head > :nth-child(5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
