/* ═══════════════════════════════════════════════════════════
   پنل مدیریت امیرکانو
   راست‌به‌چپ، دو حالت روشن/تاریک، بدون هیچ منبع بیرونی.
   ═══════════════════════════════════════════════════════════ */

/* فونت از همان تصویر داکر می‌آید که برای PDF نصب شده */
@font-face {
  font-family: 'Vazirmatn';
  src: url('/fonts/Vazirmatn-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/fonts/Vazirmatn-Medium.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('/fonts/Vazirmatn-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

/* پالت: زمینهٔ استخوانی روشن، لهجه‌های پاستلی.
   دو رنگ جدا برای هر لهجه — یکی برای پُر کردن (accent) و یکی تیره‌تر
   برای متن (accent-ink). رنگ پاستلی روی استخوانی زیباست ولی متنش خوانا
   نیست؛ بدون این تفکیک یا متن محو می‌شود یا پُرها تیره و سنگین.

   حالت روشن پیش‌فرض است و از تنظیم سیستم پیروی نمی‌کند. تاریک فقط با
   زدن دکمه می‌آید. */
:root {
  --bg: #f5f3ed;
  --surface: #fffefb;
  --surface-2: #eeebe2;
  --border: #e2ded2;
  --text: #302d28;
  /* خاکستری‌های روشن‌تر از این زیر حد خوانایی می‌افتند (کنتراست کمتر
     از ۴٫۵) — مخصوصاً برای برچسب‌ها که ریزند */
  --muted: #6d675c;
  --accent: #f0a875;
  --accent-ink: #b96a35;
  --accent-weak: #f0a87526;
  --positive: #4aa583;
  --positive-ink: #2e7d61;
  --negative: #e8836f;
  --negative-ink: #c2543c;
  --warn: #e0ab4f;
  --warn-ink: #9c7118;

  /* رنگ‌های دسته‌ای نمودار — به ترتیب استفاده می‌شوند */
  --c1: #f4b183;
  --c2: #8fd3ba;
  --c3: #9cc6ec;
  --c4: #c6b4e8;
  --c5: #f3d68f;
  --c6: #f2a7b6;

  --radius: 16px;
  --shadow: 0 1px 2px #6b604d0a, 0 10px 28px #6b604d14;
  color-scheme: light;
}

/* تاریکِ خنثی، نه قهوه‌ای — قهوه‌ای تیره سنگین می‌شود */
:root[data-theme='dark'] {
  --bg: #17181a;
  --surface: #202225;
  --surface-2: #292c31;
  --border: #353940;
  --text: #edeff1;
  --muted: #9ba3ab;
  --accent: #f0a875;
  --accent-ink: #f6bf94;
  --accent-weak: #f0a8752e;
  --positive: #6cc7a4;
  --positive-ink: #7fd6b4;
  --negative: #ef9280;
  --negative-ink: #f4a692;
  --warn: #e6b862;
  --warn-ink: #f0c87e;
  --c1: #e8a97c;
  --c2: #82c6ad;
  --c3: #8fb9df;
  --c4: #b8a7db;
  --c5: #e6c983;
  --c6: #e59caa;
  --shadow: 0 1px 2px #0005, 0 10px 28px #0003;
  /* تا نوار اسکرول و کنترل‌های پیش‌فرض مرورگر هم تاریک شوند */
  color-scheme: dark;
}

/* عمداً هیچ قاعدهٔ prefers-color-scheme اینجا نیست: پنل روشن باز
   می‌شود حتی اگر سیستم روی تاریک باشد. تاریک انتخاب کاربر است، نه
   پیش‌فرض تحمیلی. */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ستون کناری سمت راست ثابت است و محتوا کنارش می‌آید. در راست‌به‌چپ،
   inline-start یعنی راست — پس ستون خودبه‌خود سمت درست می‌نشیند. */
:root { --side-w: 232px; }

.shell { margin-inline-start: var(--side-w); min-height: 100vh; }
.wrap {
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 22px;
}
body.no-scroll { overflow: hidden; }

/* ── ستون کناری ──────────────────────────────────────────── */

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px 14px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  overflow-y: auto;
  z-index: 40;
}
.sidebar .brand { margin: 0 8px 18px; }

.mobilebar { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  background: #0006;
  z-index: 35;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-weak);
  font-size: 1rem;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: .92rem;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-weak); color: var(--accent-ink); font-weight: 700; }
.nav-ic { flex: 0 0 20px; text-align: center; font-size: .95em; opacity: .75; }
.nav a.active .nav-ic { opacity: 1; }

/* عنوان دسته — گزارش‌ها و تنظیمات کمتر استفاده می‌شوند و با فاصله از
   کار روزانه جدا می‌شوند، ولی پنهان نیستند: در ستون عمودی جا هست و
   منوی کشویی فقط یک کلیک اضافه می‌کرد. */
.nav-section {
  margin: 16px 12px 5px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--muted);
  opacity: .8;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.side-date { padding: 0 12px; color: var(--muted); font-size: .76rem; }
.side-user {
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  font-size: .82rem;
  min-width: 0; /* بدون این، فرزند فلکس زیر عرض محتوایش کوچک نمی‌شود و
                   ellipsis اسم کار نمی‌کند — کل ردیف از سایدبار بیرون می‌زند */
}
.side-user-name {
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1 1 auto;
}
.side-user .pill,
.side-user .icon-btn,
.side-user form { flex-shrink: 0; }
.side-user form { margin-inline-start: auto; }

.view-as-form {
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
}
.view-as-form select.field { flex: 1 1 auto; font-size: .78rem; padding: 6px 10px; }

.view-as-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 16px; padding: 10px 16px;
  background: var(--warn); color: var(--warn-ink);
  border-radius: 12px; font-size: .88rem; font-weight: 600;
}
.view-as-banner form { margin-inline-start: auto; }

.menu-toggle {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: .84rem;
  color: var(--muted);
  text-align: start;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
/* پیش‌فرض روشن است، پس ماه (برو به تاریک) دیده می‌شود */
.only-light { display: inline; }
.only-dark { display: none; }
:root[data-theme='dark'] .only-light { display: none; }
:root[data-theme='dark'] .only-dark { display: inline; }

/* ── سرصفحهٔ صفحه ────────────────────────────────────────── */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin: 30px 0 20px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -.2px; }
.page-sub { color: var(--muted); font-size: .9rem; }

.range { display: flex; gap: 6px; margin-inline-start: auto; }
.range a {
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
}
/* متن تیرهٔ ثابت روی پُرِ پاستلی — نه رنگ متغیر.
   accent-ink در حالت تاریک روشن می‌شود، و متن روشن روی آن کنتراست
   ۱٫۵ می‌داد یعنی عملاً نامرئی. پُر در هر دو حالت روشن است، پس متن
   باید در هر دو حالت تیره بماند. */
.range a.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #402d1d;
  font-weight: 700;
}

/* ── کارت‌ها ─────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  row-gap: 4px;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-note { color: var(--muted); font-size: .82rem; margin-inline-start: auto; }
.section-sub {
  margin: 18px 0 8px;
  font-size: .86rem;
  font-weight: 700;
  color: var(--muted);
}
.section-sub:first-of-type { margin-top: 0; }
.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.tier-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .82rem;
}
.tier-cell b { font-size: .92rem; }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, 1fr); }
.stats-5 { grid-template-columns: repeat(5, 1fr); }
.split { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.split-3 { grid-template-columns: 1.15fr .85fr; margin-top: 16px; }
.trend-cols { grid-template-columns: repeat(3, 1fr); }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; font-size: .88rem; }

.compare-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.compare-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.compare-table td:first-child { color: var(--muted); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.tag-cloud .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── کارت آماری ──────────────────────────────────────────── */

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: var(--muted); font-size: .84rem; }
.stat-value {
  font-size: 1.62rem;
  font-weight: 700;
  letter-spacing: -.4px;
  line-height: 1.25;
}
.stat-unit { font-size: .8rem; color: var(--muted); font-weight: 400; }
.stat-foot { font-size: .8rem; color: var(--muted); }
.stat-value.pos { color: var(--positive-ink); }
.stat-value.neg { color: var(--negative-ink); }
.compact-toman {
  display: block;
  font-size: .68rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 1px;
  letter-spacing: normal;
}

/* ── نمودارها ────────────────────────────────────────────── */

.chart { width: 100%; height: 210px; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .area { fill: var(--accent); opacity: .22; stroke: none; }
.chart .line { fill: none; stroke: var(--accent-ink); stroke-width: 2.2;
               stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent-ink); stroke: var(--surface); stroke-width: 2.5; }
.chart .tick { fill: var(--muted); font-size: 10px; font-family: inherit; }
.chart-empty { color: var(--muted); font-size: .9rem; padding: 28px 0; text-align: center; }

/* عرض/ارتفاع خودِ svg (نه 100%) — تا هر نقطه فاصلهٔ ثابت و لمس‌پذیر
   داشته باشد؛ روی موبایل با اسکرول افقیِ .tl-scroll دیده می‌شود */
.chart-timeline { width: auto; height: auto; display: block; }
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-timeline .tl-axis { stroke: var(--border); stroke-width: 2; }
.chart-timeline .tl-today { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-timeline .tl-today-label { fill: var(--muted); font-size: 11px; font-family: inherit; font-weight: 600; }
.chart-timeline .tl-tick { fill: var(--muted); font-size: 10px; font-family: inherit; }
/* pointer-events: all لازم است چون نقاط حل‌شده fill="none" دارند
   (فقط حلقهٔ توخالی) — بدون این، کلیک/تاچ روی وسطِ خالیِ دایره از آن رد
   می‌شود و به عنصر زیرش (مثلاً خط محور) می‌رسد، نه به خودِ دایره */
.chart-timeline .tl-pt { stroke: var(--surface); stroke-width: 1.5; cursor: pointer; transition: opacity .15s; pointer-events: all; }
.chart-timeline .tl-pt.resolved { stroke-width: 2; }
.chart-timeline .tl-pt:hover, .chart-timeline .tl-pt:focus { opacity: 1 !important; }
.chart-timeline .tl-stem { stroke-width: 1.5; }
.tl-legend { display: flex; gap: 18px; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.tl-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tl-legend .swatch-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
/* جعبهٔ اطلاعات نقطهٔ کلیک‌شده روی خط زمانی — چون <title> فقط با هاور
   دیده می‌شود و روی موبایل که تاچ است، بی‌فایده است. عملیاتِ همان
   ردیف (تسویه/ویرایش/...) هم همین‌جا کنارش می‌آید — نه با اسکرول به
   جدول، همان‌طور که خواسته شده بود. */
.tl-info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.tl-info { font-size: .84rem; }
.tl-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* عنوان‌های قابل‌سورتِ جدول — کلیک روی عنوان مرتب می‌کند، فلش کوچک
   نشان می‌دهد کدام ستون و کدام جهت فعال است */
.pending-table th[data-sort], .sortable th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.pending-table th[data-sort]::after, .sortable th[data-sort]::after { content: '↕'; opacity: .35; margin-inline-start: 4px; font-size: .8em; }
.pending-table th[data-sort].sort-asc::after, .sortable th[data-sort].sort-asc::after { content: '↑'; opacity: 1; }
.pending-table th[data-sort].sort-desc::after, .sortable th[data-sort].sort-desc::after { content: '↓'; opacity: 1; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(70px, 1.1fr) 2.4fr auto;
  align-items: center;
  gap: 11px;
  font-size: .88rem;
}
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--bar-color, var(--accent));
}

/* هر ردیف رنگ پاستلی خودش را می‌گیرد. یک‌رنگ بودن همهٔ میله‌ها صفحه را
   یکنواخت می‌کرد و چشم نمی‌توانست ردیف‌ها را از هم جدا دنبال کند. */
.bar-row:nth-child(6n + 1) { --bar-color: var(--c1); }
.bar-row:nth-child(6n + 2) { --bar-color: var(--c2); }
.bar-row:nth-child(6n + 3) { --bar-color: var(--c3); }
.bar-row:nth-child(6n + 4) { --bar-color: var(--c4); }
.bar-row:nth-child(6n + 5) { --bar-color: var(--c5); }
.bar-row:nth-child(6n + 6) { --bar-color: var(--c6); }
.bar-value { color: var(--muted); font-size: .83rem; white-space: nowrap; }

/* ── جدول ────────────────────────────────────────────────── */

.table-scroll { overflow-x: auto; }

/* فضای کاری کالا و قیمت‌گذاری: دو کارِ مرتبط، یک تبِ اصلی و انتخاب روشن. */
.workspace-tabs {
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  margin: 4px 0 8px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.workspace-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .86rem;
  text-decoration: none;
}
.workspace-tabs a:hover { color: var(--text); background: var(--surface); }
.workspace-tabs a.on { color: var(--accent-ink); background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .08); font-weight: 700; }

/* زیرگروه‌های محصول در لیست قیمت — گروه قیمت (نقدی/چکی/...) در تب بالا
   می‌ماند و این نوار فقط برای پرش بین خانواده‌های کالا است. */
.price-list-category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 4px;
}
.price-list-category-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: .8rem;
  text-decoration: none;
}
.price-list-category-tabs a:hover { color: var(--accent-ink); border-color: var(--accent); }
.price-list-category-tabs a span {
  min-width: 1.35em;
  padding: 1px 4px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent-weak);
  text-align: center;
  font-size: .75rem;
}

.price-list-category {
  scroll-margin-top: 16px;
  margin-top: 26px;
}
.price-list-category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
  padding: 0 3px;
  border-inline-start: 4px solid var(--accent);
  padding-inline-start: 11px;
}
.price-list-category-head h2 {
  margin: 0 0 3px;
  font-size: 1.05rem;
}
.price-list-top-link {
  white-space: nowrap;
  font-size: .78rem;
  text-decoration: none;
}
.price-list-top-link:hover { color: var(--accent-ink); }

table { width: 100%; border-collapse: collapse; font-size: .89rem; }
th {
  text-align: right;
  font-weight: 500;
  color: var(--muted);
  font-size: .82rem;
  padding: 0 8px 9px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.strong { font-weight: 500; }

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: .76rem;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.warn { background: color-mix(in srgb, var(--warn) 26%, transparent); color: var(--warn-ink); }
.pill.bad  { background: color-mix(in srgb, var(--negative) 24%, transparent); color: var(--negative-ink); }
.pill.good { background: color-mix(in srgb, var(--positive) 24%, transparent); color: var(--positive-ink); }

.empty { color: var(--muted); font-size: .88rem; padding: 18px 0; text-align: center; }
.dim { color: var(--muted); }
.owed { color: var(--negative-ink); font-weight: 500; }
.row-link { color: var(--accent-ink); text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.row-actions { white-space: nowrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; margin-inline-start: 2px;
  border-radius: 8px; text-decoration: none; font-size: .95rem;
  background: var(--surface-2, rgba(127,127,127,.08));
  transition: background .15s;
}
.icon-btn:hover { background: var(--surface-3, rgba(127,127,127,.18)); }
button.icon-btn { border: none; cursor: pointer; font: inherit; color: inherit; }
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  margin-bottom: 2px;
}
.back:hover { color: var(--accent-ink); }

/* ── فرم و دکمه ──────────────────────────────────────────── */

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field {
  flex: 1 1 200px;
  min-width: 0;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
}
.field:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
select.field { flex: 0 0 auto; }

.btn {
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #402d1d;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.96); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 400;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); filter: none; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  font-size: .86rem;
}

/* ── برچسب مرحلهٔ قیف فروش ───────────────────────────────── */

.pill.stage-lead            { background: color-mix(in srgb, var(--c3) 30%, transparent); color: var(--text); }
.pill.stage-contacted       { background: color-mix(in srgb, var(--c4) 30%, transparent); color: var(--text); }
.pill.stage-sample_sent     { background: color-mix(in srgb, var(--c5) 34%, transparent); color: var(--text); }
.pill.stage-negotiating     { background: color-mix(in srgb, var(--c1) 32%, transparent); color: var(--text); }
.pill.stage-active_customer { background: color-mix(in srgb, var(--c2) 34%, transparent); color: var(--text); }
.pill.stage-inactive        { background: var(--surface-2); color: var(--muted); }

/* ── برچسب رنگی ثبت‌کننده — کدام فروشنده/کاربر این ردیف را ثبت کرده ── */
.pill.user-c1 { background: color-mix(in srgb, var(--c1) 32%, transparent); color: var(--text); }
.pill.user-c2 { background: color-mix(in srgb, var(--c2) 32%, transparent); color: var(--text); }
.pill.user-c3 { background: color-mix(in srgb, var(--c3) 32%, transparent); color: var(--text); }
.pill.user-c4 { background: color-mix(in srgb, var(--c4) 32%, transparent); color: var(--text); }
.pill.user-c5 { background: color-mix(in srgb, var(--c5) 32%, transparent); color: var(--text); }
.pill.user-c6 { background: color-mix(in srgb, var(--c6) 32%, transparent); color: var(--text); }

/* ── فهرست مشخصات ───────────────────────────────────────── */

.facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: .89rem; }
.facts dt { color: var(--muted); white-space: nowrap; }
.facts dd { margin: 0; }
.note-box {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: .87rem;
  white-space: pre-wrap;
}

/* ── خط زمانی تعاملات ────────────────────────────────────── */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding-bottom: 15px; }
.timeline li::before {
  content: '';
  position: absolute;
  inset-inline-start: 5px;
  top: 15px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.tl-dot {
  flex: 0 0 11px;
  width: 11px; height: 11px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--c3);
  z-index: 1;
}
.tl-dot.kind-call    { background: var(--c2); }
.tl-dot.kind-visit   { background: var(--c1); }
.tl-dot.kind-sample  { background: var(--c5); }
.tl-dot.kind-message { background: var(--c4); }
.tl-dot.kind-other   { background: var(--border); }
.tl-dot.kind-invoice        { background: var(--c3); }
.tl-dot.kind-invoice_voided { background: var(--border); }
.tl-dot.kind-payment        { background: var(--c2); }
.tl-dot.kind-return         { background: var(--c6); }
.tl-amount { font-weight: 600; }
.tl-amount.in  { color: var(--positive-ink, #3a9d5f); }
.tl-amount.out { color: var(--negative-ink); }
.tl-balance { font-size: .78rem; color: var(--muted); }
.tl-body { font-size: .89rem; min-width: 0; }
.tl-top { font-size: .8rem; color: var(--muted); }
.tl-date { font-variant-numeric: tabular-nums; }

/* ── کلید مبلغ/مقدار ─────────────────────────────────────── */

.toggle {
  display: flex;
  gap: 2px;
  margin-inline-start: auto;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 9px;
}
.toggle a {
  padding: 3px 12px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: .8rem;
}
.toggle a.on { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }

/* ── کلید نمایش کالاهای زیر آستانهٔ موجودی ─────────────── */

.price-list-availability-control { margin: 0; }
.ios-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .82rem;
  cursor: pointer;
  user-select: none;
}
.ios-switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ios-switch {
  position: relative;
  display: inline-flex;
  width: 38px;
  height: 22px;
  flex: 0 0 38px;
  border-radius: 999px;
  background: var(--border);
  transition: background .18s ease;
}
.ios-switch span {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s ease;
}
.ios-switch-input:checked + .ios-switch { background: var(--positive, #36a269); }
.ios-switch-input:checked + .ios-switch span { transform: translateX(-16px); }
.ios-switch-input:focus-visible + .ios-switch { outline: 2px solid var(--accent, #5f8cff); outline-offset: 2px; }
.price-list-unavailable { border-color: var(--negative, #d46a6a); }
.price-list-unavailable-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--negative, #d46a6a) 10%, var(--surface));
  color: var(--negative-ink, var(--text));
  font-size: .82rem;
}

/* ── نمودار دایره‌ای ─────────────────────────────────────── */

.donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; }
.donut { flex: 0 0 200px; width: 200px; height: 200px; }
.donut .slice { transition: opacity .15s; }
.donut:hover .slice { opacity: .45; }
.donut .slice:hover { opacity: 1; }
.donut-value {
  fill: var(--text);
  font-size: 19px;
  font-weight: 700;
  font-family: inherit;
}
.donut-label { fill: var(--muted); font-size: 11px; font-family: inherit; }

.legend { flex: 1 1 220px; list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend-row {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  font-size: .85rem;
}
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-val { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ── سهم درون جدول ──────────────────────────────────────── */

.share-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.share-bar {
  display: inline-block;
  width: 54px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.share-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ── نگاه کلی ────────────────────────────────────────────── */

.insight-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insight-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: .92rem;
  padding-inline-start: 15px;
  position: relative;
  line-height: 1.75;
}
.insight-list li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: .72em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.ins-num {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.foot {
  display: flex; gap: 8px; justify-content: center;
  color: var(--muted); font-size: .82rem;
  padding: 34px 20px 44px;
}
.foot-sep { opacity: .5; }

/* ── تایم‌لاین سفارش ─────────────────────────────────────── */

.tl-group { margin-top: 26px; }
.tl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 9px;
  margin-bottom: 13px;
  border-bottom: 2px solid var(--border);
}
.tl-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.tl-count {
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}
.tl-hint { color: var(--muted); font-size: .82rem; }
.tl-sum { margin-inline-start: auto; color: var(--muted); font-size: .85rem; }

/* دستهٔ عقب‌افتاده باید در یک نگاه از بقیه جدا باشد */
.tl-overdue .tl-head { border-bottom-color: var(--negative); }
.tl-overdue .tl-head h2 { color: var(--negative-ink); }
.tl-today .tl-head { border-bottom-color: var(--accent); }

.tl-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 13px;
}
.tl-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tl-overdue .tl-card { border-inline-start: 3px solid var(--negative); }
.tl-today .tl-card { border-inline-start: 3px solid var(--accent); }
/* خیلی عقب‌افتاده: احتمالاً دیگر نمی‌آید، ولی حذفش با کاربر است */
.tl-card.is-stale { opacity: .62; }

.tl-card-top { display: flex; align-items: center; gap: 8px; }
.tl-customer {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-customer:hover { color: var(--accent-ink); }
.conf {
  margin-inline-start: auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 700;
  white-space: nowrap;
}
.conf-high { background: color-mix(in srgb, var(--positive) 24%, transparent); color: var(--positive-ink); }
.conf-mid  { background: color-mix(in srgb, var(--warn) 26%, transparent); color: var(--warn-ink); }
.conf-low  { background: var(--surface-2); color: var(--muted); }

.tl-product { font-size: .93rem; }
.tl-meta { color: var(--muted); font-size: .84rem; display: flex; gap: 6px; }
.tl-meta .sep { opacity: .5; }
.tl-when { display: flex; align-items: center; gap: 8px; font-size: .84rem; }
.tl-when .tl-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-basis {
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
}
.tl-actions { display: flex; gap: 7px; margin-top: 3px; }
.tl-actions form { flex: 1 1 auto; display: flex; }
.tl-actions form:last-child { flex: 0 0 auto; }
.btn-sm { width: 100%; padding: 7px 12px; font-size: .84rem; }

/* تایم‌لاین بدهی/طلب: فرم تسویهٔ درون‌خطیِ قسط — .field/.btn-sm معمولی
   تمام‌عرض‌اند (فرم‌های عمودی صفحه)، این‌جا داخل یک ردیف جدول باید
   کوچک و هم‌قد بقیهٔ آیکون‌های عملیات بماند، وگرنه هر ردیف قسط چند
   برابر ردیف‌های دیگر بلند می‌شود. */
.inline-pay-form { display: inline-flex; gap: 4px; align-items: center; vertical-align: middle; }
.inline-pay-form select {
  width: 92px; padding: 3px 6px; font-size: .78rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-family: inherit;
}
.inline-pay-form button {
  width: auto; padding: 4px 10px; font-size: .78rem;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: #402d1d; font-family: inherit;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* همان جدول تایم‌لاین: دکمه‌های عملیات چک (سپردن/خرج‌کردن/وصول/برگشت)
   هم همین مشکل را داشتند — هر «form» پیش‌فرض بلوکی است و .btn-sm
   تمام‌عرض، پس چهار دکمه به‌جای هم‌ردیف، چهار بلوکِ بزرگ زیر هم
   می‌شدند. اینجا هم همان دو فیکس: فرم هم‌ردیف + دکمهٔ کوچک.
   .tl-actions هم همین قاعده را می‌خواهد — عملیاتِ همان ردیف، کپی‌شده
   با جاوااسکریپت کنار متنِ کلیکِ روی دایره (بدون اسکرول به جدول). */
.pending-table .row-actions form, .tl-actions form { display: inline-block; }
.pending-table .row-actions .btn-sm, .tl-actions .btn-sm {
  width: auto; padding: 4px 10px; font-size: .78rem;
}

.dismiss { flex: 0 0 auto; }
.dismiss > summary {
  list-style: none;
  display: inline-block;
  width: auto;
  user-select: none;
}
.dismiss > summary::-webkit-details-marker { display: none; }
.dismiss-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 9px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}
.dismiss-label { font-size: .8rem; color: var(--muted); }
.dismiss-form .field { flex: 1 1 auto; font-size: .84rem; padding: 7px 10px; }

.tl-note {
  margin-top: 26px;
  color: var(--muted);
  font-size: .84rem;
  text-align: center;
  line-height: 1.9;
}

/* ── تحلیلگر ─────────────────────────────────────────────── */

.notice { margin-top: 16px; border-inline-start: 3px solid var(--accent); }
.notice p { margin: 6px 0 0; font-size: .88rem; }
.notice code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: .85em;
}
.bad-notice { border-inline-start-color: var(--negative); }

.ask { margin-top: 16px; display: flex; flex-direction: column; gap: 11px; }
.ask-box {
  width: 100%;
  resize: vertical;
  line-height: 1.8;
  font-size: .95rem;
}
.ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ask-hint { flex: 1 1 240px; font-size: .82rem; }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.chip {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: .84rem;
  cursor: pointer;
}
.chip:hover { background: var(--accent-weak); color: var(--accent-ink); border-color: var(--accent); }

.section-title { margin: 30px 0 13px; font-size: 1.05rem; font-weight: 700; }

.run { margin-bottom: 13px; }
.run-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 11px;
  border-bottom: 1px solid var(--border);
}
.run-q { font-weight: 700; font-size: .96rem; }
.run-when { margin-inline-start: auto; font-size: .8rem; white-space: nowrap; }
.run-answer { white-space: pre-wrap; line-height: 1.95; font-size: .93rem; }
.run-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
  font-size: .8rem;
}
/* نام ابزارها انگلیسی است و در متن راست‌به‌چپ به هم می‌ریزد */
.tool-pill { direction: ltr; font-size: .73rem; }
.run-cost { margin-inline-start: auto; white-space: nowrap; }

/* ── راهنمای صفحه ────────────────────────────────────────── */

.help {
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.help-summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: .87rem;
  user-select: none;
}
.help-summary::-webkit-details-marker { display: none; }
.help-summary:hover { color: var(--text); }
.help-icon {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--accent-weak);
  color: var(--accent-ink);
  font-size: .78rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.help[open] .help-summary { border-bottom: 1px solid var(--border); }
.help-list {
  margin: 0;
  padding: 13px 42px 15px 18px;
  display: grid;
  gap: 8px;
  font-size: .88rem;
  line-height: 1.85;
}
.help-list li::marker { color: var(--accent); }

/* ── ردیف باطل‌شده ───────────────────────────────────────── */

/* خط روی متن نه: عدد را ناخوانا می‌کند. کم‌رنگی کافی است و برچسب
   «باطل» تکلیف را روشن می‌کند. */
.is-voided td { opacity: .5; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .87rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.check input { accent-color: var(--accent-ink); width: 15px; height: 15px; }

.danger-card { border-inline-start: 3px solid var(--negative); }
.danger-card .editor-summary { color: var(--negative-ink); }

/* ── فرم ویرایش ──────────────────────────────────────────── */

.tag-pill { background: var(--accent-weak); color: var(--accent-ink); }

/* کارت هشدار — باید در اسکرول سریع هم دیده شود */
.alert-card { border-inline-start: 3px solid var(--negative); }
.alert-card .card-head h2 { color: var(--negative-ink); }

.editor { margin-top: 16px; }
.editor-summary {
  cursor: pointer;
  font-weight: 700;
  font-size: .95rem;
  list-style: none;
  user-select: none;
}
.editor-summary::-webkit-details-marker { display: none; }
.editor[open] .editor-summary {
  padding-bottom: 13px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.edit-form { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  width: 100%;
}
.edit-grid label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.edit-grid label > span { font-size: .85rem; color: var(--muted); }
.edit-grid small { font-size: .77rem; line-height: 1.6; }
.edit-grid .span-2 { grid-column: 1 / -1; }
/* label اینجا flex-column است، پس محور اصلی flex عمودی می‌شود — بدون این
   بازنشانی، «flex: 1 1 200px» عمومی .field (که برای ردیف افقی فیلترهاست)
   ۲۰۰px را به‌عنوان ارتفاع پایه می‌خواند و اینپوت/textarea را به یک کادر
   غول‌آسا تبدیل می‌کند. select از قبل با «select.field { flex: 0 0 auto }»
   مصون بود، ولی input/textarea نبودند. */
.edit-grid .field { flex: 1 1 auto; }
.edit-grid textarea.field { resize: vertical; line-height: 1.8; }

/* ردیف‌های فاکتور در دسکتاپ ستون‌بندی‌شده‌اند و در موبایل زیر هم می‌آیند. */
.invoice-lines { width: 100%; display: flex; flex-direction: column; gap: 9px; }
.invoice-line {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) minmax(160px, 1fr) 42px;
  gap: 9px;
  /* پایین‌تراز، نه وسط‌تراز: وقتی select جست‌وجوپذیر جعبهٔ جست‌وجو را
     بالای خودش اضافه می‌کند، آن ستون بلندتر از بقیه می‌شود — پایین‌تراز
     کردن یعنی خودِ select همچنان با مقدار/قیمت/دکمهٔ حذف هم‌ردیف بماند،
     بدون حدس‌زدن ارتفاع دقیق جعبهٔ جست‌وجو با px */
  align-items: end;
}
.invoice-line .field { width: 100%; }
.invoice-line .btn { padding-inline: 10px; }
.invoice-line-head { color: var(--muted); font-size: .78rem; padding-inline: 3px; align-items: center; }
/* ردیف دوستونه — مثلاً مادهٔ مصرفی تولید که برخلاف قلم فاکتور قیمت ندارد */
.invoice-line-2col { grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) 42px; }

/* ردیف‌های صفحهٔ یک‌جای فرمول قیمت‌گذاری — هر فیلد لیبل خودش را دارد
   (برخلاف .invoice-line که به سرستون بالای جدول تکیه می‌کند)، چون در
   موبایل ستون‌ها به یک ستون تک می‌افتند و باید هرکدام مستقل خوانا
   بمانند، نه فقط با placeholder. */
.formula-row {
  display: grid;
  gap: 9px;
  align-items: end;
  margin-bottom: 9px;
}
.formula-row label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.formula-row label > span { font-size: .78rem; color: var(--muted); }
/* بدون این، «flex: 1 1 200px» عمومی .field که برای ردیف افقی فیلترهاست،
   چون label اینجا هم flex-column است، ۲۰۰px را ارتفاع پایه می‌خواند و
   input را به یک کادر غول‌آسا تبدیل می‌کند — همان مشکلی که برای
   .edit-grid .field بالاتر رفع شده */
.formula-row .field { width: 100%; flex: 1 1 auto; }
.formula-row .remove-line { justify-self: end; }
/* ماده/محصول + مقدار + حذف */
.formula-row-materials { grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) 42px; }
/* متغیر + حالت + مقدار دستی + به‌ازای هر واحد + حذف */
.formula-row-variable {
  grid-template-columns: minmax(170px, 1.4fr) minmax(110px, .9fr) minmax(110px, .9fr) minmax(90px, .7fr) 42px;
}
/* عنوان ثابت (مثلاً «افت وزن رست») + حالت + مقدار دستی، بدون دکمهٔ حذف */
.formula-row-adjust {
  grid-template-columns: minmax(140px, 1fr) minmax(120px, .8fr) minmax(120px, .8fr);
}
.formula-row-adjust > span { align-self: center; }

.cheque-fields[hidden] { display: none; }

.danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-form .field { flex: 0 1 260px; }
.stage-form { gap: 6px; }
.stage-form .field { flex: 0 1 160px; padding: 5px 10px; font-size: .84rem; }
.stage-form .btn-sm { width: auto; padding: 5px 12px; }

@media (max-width: 700px) {
  .edit-grid { grid-template-columns: 1fr; }
  .invoice-line { grid-template-columns: 1fr 1fr 38px; }
  .invoice-line select { grid-column: 1 / -1; }
  .invoice-line-2col { grid-template-columns: 1fr 38px; }
  .invoice-line-head { display: none; }
  /* هر فیلد لیبل خودش را دارد، پس هر کدام روی یک ستون تک می‌ایستد —
     بدون شکستن implicit به ردیف‌های نامرتب مثل حالت قبلی */
  .formula-row-materials, .formula-row-variable, .formula-row-adjust { grid-template-columns: 1fr; }
  .formula-row .remove-line { justify-self: stretch; }

  /* جدول‌هایی با ستون زیاد یا متن آزاد بلند (مثل فهرست مواد مصرفی)
     در موبایل به‌جای اسکرول کنارِ ناخوانا، به کارت زیرهم تبدیل
     می‌شوند — با data-label روی هر td که با محتوای thead جفت است. */
  table.stack-table thead { display: none; }
  table.stack-table, table.stack-table tbody,
  table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr {
    margin-bottom: 10px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  table.stack-table tbody tr:last-child { margin-bottom: 0; }
  table.stack-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
  }
  table.stack-table td:last-child { border-bottom: none; padding-bottom: 0; }
  table.stack-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: .78rem;
  }
  /* ردیف اول کارت — عنوانِ آن (اسم محصول یا تاریخ)، بدون برچسب و بولد */
  table.stack-table tr > td:first-child {
    font-weight: 700;
    font-size: .92rem;
    padding-top: 0;
  }
  table.stack-table tr > td:first-child::before { content: none; }
  /* ستون‌های متن آزاد (فهرست مواد مصرفی) زیر برچسب می‌آیند، نه کنارش */
  table.stack-table td.full { flex-direction: column; align-items: stretch; gap: 4px; }
  /* ردیف دکمه‌های عملیات — بدون برچسب، چسبیده به انتها */
  table.stack-table td.actions { justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
  table.stack-table td.actions::before { content: none; }
}

/* ── جدول متغیرهای قیمت ──────────────────────────────────── */

.var-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}
.var-row { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.var-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: .87rem;
}
.unit {
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
}
/* عدد همیشه چپ‌چین است، حتی در صفحهٔ راست‌به‌چپ — وگرنه رقم‌ها
   هنگام تایپ می‌پرند */
.var-input { text-align: left; font-variant-numeric: tabular-nums; }
.var-row small { font-size: .76rem; line-height: 1.6; }

/* دکمه‌های چک کنار هم و بدون کشیده شدن — ستون جدول باریک است */
.cheque-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.cheque-actions form { display: inline-flex; }
.cheque-actions .btn-sm { width: auto; padding: 5px 10px; font-size: .78rem; }

/* ── جدول قابل ویرایش ────────────────────────────────────── */

.edit-table td { vertical-align: middle; }
.cell-input {
  width: 100%;
  min-width: 110px;
  padding: 6px 10px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: .87rem;
}

/* نوار ذخیره چسبیده به پایین می‌ماند: جدول بلند است و کاربر نباید
   برای ذخیره تا ته صفحه اسکرول کند */
.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.save-bar .dim { flex: 1 1 240px; font-size: .82rem; }

/* ── واکنش‌گرا ───────────────────────────────────────────── */

/* زیر ۱۰۲۴ پیکسل ستون کناری جای زیادی از محتوا می‌گیرد، پس پنهان
   می‌شود و با دکمهٔ همبرگری از سمت راست می‌آید. */
@media (max-width: 1024px) {
  .shell { margin-inline-start: 0; }

  .mobilebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 16px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .brand-mobile { font-size: 1rem; }

  .sidebar {
    transform: translateX(100%);
    transition: transform .22s ease;
    box-shadow: none;
    width: min(280px, 84vw);
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: -8px 0 30px #00000026; }

  /* در چپ‌به‌راست جهت لغزش برعکس است */
  html[dir='ltr'] .sidebar { transform: translateX(-100%); }
  html[dir='ltr'] .sidebar.is-open { transform: translateX(0); }
}

/* روی دسکتاپ نه پرده لازم است نه دکمهٔ همبرگر */
@media (min-width: 1025px) {
  .scrim { display: none !important; }
  .mobilebar { display: none !important; }
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .split, .split-3, .trend-cols { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .wrap { padding-inline: 14px; }
  body { font-size: 14px; }
  .stats { gap: 12px; }
  .stat-value { font-size: 1.35rem; }
  .card { padding: 15px 16px; }
  .page-head { margin: 22px 0 16px; }
  .range { margin-inline-start: 0; width: 100%; }
  .range a { flex: 1; padding-inline: 0; text-align: center; }
  .brand-text { display: none; }
  .bar-row { grid-template-columns: minmax(60px, 1fr) 1.6fr auto; font-size: .83rem; }
  /* ستون‌های کم‌اهمیت‌تر جدول‌های چگال (مثل گزارش محصولات) — دادهٔ
     همین ستون‌ها جای دیگری از همان صفحه هم هست، فقط این‌جا شلوغ می‌کرد */
  .hide-mobile { display: none; }
}
