@import url('/css/fonts.css?v=6.1-d1');

:root{
  /* ---------- پالت رنگی نسخه ۳.۶ — «ایندیگو مدرن» ---------- */
  --ink:#181a30;         /* متن اصلی / تیره — سرمه‌ای عمیق مدرن */
  --ink-soft:#5c5f80;
  --paper:#f5f5fb;       /* پس‌زمینه‌ی صفحه — لاواندر خیلی روشن */
  --paper-card:#ffffff;
  --line:#e6e5f3;
  --brass:#6d5ef8;       /* رنگ تأکیدی اصلی: بنفش/ایندیگو زنده */
  --brass-dark:#5541e0;
  --brass-rgb:109,94,248;
  --teal:#0e9f75;        /* موفقیت/تأیید — زمردی */
  --teal-bg:#e3f8ef;
  --red:#e0355b;         /* رد/بدهی — رزی مدرن */
  --red-bg:#fdecf1;
  --amber-bg:#fff4e0;    /* در انتظار */
  --blue-dark:#2563eb;   /* تسویه شده */
  --blue-bg:#eaf1fe;
  --ink-rgb:24,26,48;
  --radius:14px;
  --radius-sm:10px;
  --shadow:0 1px 2px rgba(24,26,48,.05), 0 10px 28px rgba(24,26,48,.09);
  --shadow-lg:0 18px 45px rgba(24,26,48,.16);
  --grad-brand: linear-gradient(135deg, #7d6bff 0%, #5541e0 100%);
  --grad-dark: linear-gradient(160deg, #20223e 0%, #14152a 100%);
}

*{box-sizing:border-box;}
html{direction:rtl;}
body{
  margin:0;
  font-family:'Vazirmatn', sans-serif;
  background:var(--paper);
  color:var(--ink);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 2.4em;
  background-attachment: local;
}
.num{ font-family:'IBM Plex Mono','Vazirmatn',monospace; font-variant-numeric: tabular-nums; direction:ltr; unicode-bidi: plaintext; }

a{color:inherit;}
button{font-family:inherit;}

/* ---------- ساختار کلی ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 28px; background:var(--grad-dark); color:#fff;
  box-shadow:0 2px 16px rgba(24,26,48,.18);
}
.topbar .brand{ display:flex; align-items:center; gap:10px; font-weight:800; letter-spacing:.2px;}
.topbar .brand .mark{
  height:30px; width:auto; max-width:none; display:block; flex:0 0 auto;
  filter:invert(1);              /* لوگوی مشکی روی نوار تیره سفید نمایش داده می‌شود */
}
.topbar .who{ font-size:13px; color:#c3c5e6; display:flex; align-items:center; gap:12px;}
.topbar button.logout, .topbar button.topbar-btn, .topbar .topbar-store-link{
  display:inline-flex; align-items:center; justify-content:center; min-height:38px; line-height:1.6;
}
.topbar button.logout, .topbar button.topbar-btn{
  background:transparent;border:1px solid #3a3c66;color:#fff;padding:6px 14px;border-radius:9px;cursor:pointer;
  transition:background .15s ease, border-color .15s ease; font-family:inherit; font-size:13px; font-weight:700;
}
.topbar button.logout:hover, .topbar button.topbar-btn:hover{background:#2a2c52; border-color:#4a4d80;}
.topbar button.topbar-btn.btn-gold-outline{ border-color:var(--brass); color:#c9c2ff; }
.topbar button.topbar-btn.btn-gold-outline:hover{ background:rgba(109,94,248,.18); }
.topbar .topbar-store-link{
  background:linear-gradient(135deg, #f76707 0%, #e05500 100%); border:1px solid transparent; color:#fff; padding:6px 14px; border-radius:9px;
  cursor:pointer; transition:background .15s ease, border-color .15s ease, color .15s ease;
  font-family:inherit; font-size:13px; font-weight:700; text-decoration:none; white-space:nowrap;
}
.topbar .topbar-store-link:hover{background:linear-gradient(135deg, #e8590c 0%, #d9480f 100%); border-color:transparent; color:#fff;}

/* ---------- مودال ورود/ثبت‌نام روی صفحه‌ی عمومی ---------- */
.modal-head-row{ position:relative; }
.modal-close-btn{
  position:absolute; top:0; left:0; width:32px; height:32px; border-radius:50%;
  border:none; background:#f2f1fa; color:var(--ink-soft); cursor:pointer; padding:0;
  display:flex; align-items:center; justify-content:center;
  transition:background .15s ease, color .15s ease;
}
.modal-close-btn svg{ width:16px; height:16px; display:block; }
.modal-close-btn:hover{ background:#e4e2f6; color:var(--ink); }
.auth-modal-box{ width:100%; }
.auth-modal-box .logo{ text-align:center; margin-bottom:18px; }
.auth-modal-box .logo .mark{ height:64px; width:auto; max-width:70%; display:block; margin:0 auto 10px; }
.auth-modal-box .logo h1{ font-size:16px; margin:0; }
.auth-modal-box .logo p{ margin:4px 0 0; color:var(--ink-soft); font-size:12.5px; }
.guest-order-note{ font-size:11.5px; color:var(--ink-soft); margin-top:4px; }

.container{ max-width:1180px; margin:0 auto; padding:26px 20px 60px; }

.card{ background:var(--paper-card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); transition:box-shadow .2s ease; }
.card + .card{ margin-top:20px; }
.card .card-header{ padding:16px 20px; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
.card .card-header h2{ margin:0; font-size:16px; font-weight:700; }
.card .card-body{ padding:18px 20px; }

/* ---------- ورود / ثبت‌نام (تک ستون وسط‌چین) ---------- */
.auth-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;}
.auth-box{ width:100%; max-width:420px; }
.auth-box .logo{ text-align:center; margin-bottom:22px; }
.auth-box .logo .mark{
  height:clamp(110px, 26vw, 180px); width:auto; max-width:80%; display:block; margin:0 auto 12px;
}
.auth-box .logo h1{ font-size:18px; margin:0; }
.auth-box .logo p{ margin:4px 0 0; color:var(--ink-soft); font-size:13px;}

.tabs{ display:flex; gap:6px; margin-bottom:16px; background:#eeedf9; padding:3px; border-radius:10px; }
.tabs button{
  flex:1; padding:6px 10px; border:none; border-radius:8px; background:transparent; cursor:pointer;
  font-weight:600; color:var(--ink-soft); font-size:13px; transition:background .15s ease, color .15s ease;
}
.tabs button.active{ background:var(--paper-card); color:var(--ink); box-shadow:var(--shadow); }

.field{ margin-bottom:14px; }
.field label{ display:block; font-size:13px; margin-bottom:6px; color:var(--ink-soft); font-weight:600; }
.field input, .field select, .field textarea{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:8px; font-size:14px;
  background:#fff; font-family:inherit;
}
.field input:focus, .field select:focus, .field textarea:focus{ outline:2px solid var(--brass); outline-offset:1px; border-color:var(--brass);}
.field textarea{ resize:vertical; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding:11px 16px; border-radius:10px; border:none; cursor:pointer; font-weight:700; font-size:14px;
  transition:background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:active{ transform:translateY(1px); }
.btn-primary{ background:var(--ink); color:#fff; width:100%; }
.btn-primary:hover{ background:#2a2c52; }
.btn-gold{ background:var(--grad-brand); color:#fff; box-shadow:0 6px 16px rgba(var(--brass-rgb),.32); }
.btn-gold:hover{ background:var(--brass-dark); box-shadow:0 8px 20px rgba(var(--brass-rgb),.4); }
.btn-outline{ background:transparent; border:1px solid var(--line); color:var(--ink); }
.btn-outline:hover{ background:#f2f1fa; }
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn:disabled:hover{ background:transparent; }
.btn-danger{ background:var(--red); color:#fff; }
.btn-sm{ padding:6px 10px; font-size:12.5px; border-radius:6px;}
/* دکمه‌های «تحلیل دوباره» (چه متنی مثل «تحلیل دوباره»، چه آیکونی مثل ↻) هیچ‌وقت کشیده یا
   تمام‌عرض نمی‌شوند؛ در مودال گروهی و در مودال ویرایش کالا، اندازه‌شان فقط به محتوایشان
   بستگی دارد، نه به فضای خالی اطراف — حتی وقتی قانون کلی موبایل برای دکمه‌های داخل
   مودال، آن‌ها را کشیده می‌کند. */
.btn-compact{ flex:0 0 auto !important; width:auto !important; white-space:nowrap; }
.btn-icon{ flex:0 0 auto !important; width:38px !important; height:38px; padding:0; font-size:16px; line-height:1; }

.msg{ font-size:13px; padding:10px 12px; border-radius:8px; margin-bottom:14px; }
.msg.error{ background:var(--red-bg); color:var(--red); }
.msg.ok{ background:var(--teal-bg); color:var(--teal); }

/* ---------- صفحه‌بندی لیست کالاها ---------- */
.pagination{
  display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px;
  margin-top:16px; padding-top:14px; border-top:1px solid var(--line);
}
/* نسخه‌ی بالای جدول: خط جداکننده زیر آن است و وقتی فقط یک صفحه هست هیچ فضایی نمی‌گیرد */
.pagination-top{ margin-top:0; margin-bottom:12px; padding-top:0; padding-bottom:12px; border-top:0; border-bottom:1px solid var(--line); }
.pagination-top:empty{ display:none; }
.pagination-info{ font-size:12.5px; color:var(--ink-soft); }
.pagination-controls{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.pagination-pages{ display:flex; align-items:center; gap:4px; }
.pagination-page{ min-width:34px; padding:6px 8px; }
.pagination-nav{ white-space:nowrap; display:inline-flex; align-items:center; justify-content:center; gap:4px; }
.pagination-nav .ico-chev{ width:14px; height:14px; flex:0 0 auto; }
.pagination-ellipsis{ padding:0 4px; color:var(--ink-soft); font-size:13px; }

/* ---------- بج وضعیت به سبک "مهر" ---------- */
.stamp{
  display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:999px;
  font-size:12px; font-weight:700; border:1.5px dashed currentColor;
}
.stamp.approved{ color:var(--teal); background:var(--teal-bg); }
.stamp.pending{ color:var(--brass-dark); background:var(--amber-bg); }
.stamp.rejected{ color:var(--red); background:var(--red-bg); }
.stamp.settled{ color:var(--blue-dark); background:var(--blue-bg); }

/* ---------- جدول قیمت ---------- */
.toolbar{ display:flex; flex-wrap:wrap; gap:10px; margin-bottom:16px; align-items:center; }
.toolbar input[type=text]{ flex:1; min-width:180px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; font-family:inherit;}
.toolbar select{ padding:10px 12px; border:1px solid var(--line); border-radius:8px; font-family:inherit; background:#fff;}
.products-card-header{ align-items:flex-start !important; }
.products-actions{ display:flex; flex-direction:column; flex:1; gap:10px; width:100%; min-width:0; }
.products-action-group{ display:flex; flex-wrap:wrap; gap:8px; align-items:stretch; width:100%; min-width:0; }
.products-action-group .btn{ flex:1 1 170px; min-width:0; white-space:normal; text-align:center; }
.products-selection-bar{ margin-bottom:14px; padding-bottom:14px; border-bottom:1px dashed var(--line); }
.products-selection-bar .btn{ white-space:nowrap; }
.sales-contact{ max-width:1180px; margin:14px auto -8px; padding:0 20px; display:flex; justify-content:center; }
.price-discount-toggle{ display:flex; align-items:center; gap:6px; margin-top:8px; color:var(--teal); font-size:12px; font-weight:700; cursor:pointer; }
.price-discount-toggle input{ width:16px; height:16px; accent-color:var(--teal); }
.price-discount-input{ width:100%; margin-top:7px; padding:8px 10px; border:1px solid #bfe8d9; border-radius:8px; font-family:inherit; }
.old-price{ display:block; color:var(--ink-soft); font-size:11px; text-decoration:line-through; font-weight:500; }
.discount-badge{ display:inline-block; margin:0 4px 3px; padding:1px 5px; border-radius:5px; background:var(--teal-bg); color:var(--teal); font-size:10px; font-family:inherit; }
.discount-table-legend th{ padding:5px 8px !important; background:#f7faff !important; color:var(--teal) !important; font-size:11px; font-weight:700; text-align:center; }
.discount-card-legend{ display:none; margin:0 0 12px; padding:10px 12px; border:1px solid #c8dfd4; border-radius:9px; background:var(--teal-bg); color:var(--teal); font-size:12px; font-weight:700; line-height:1.9; text-align:center; }
@media (max-width:1024px), (orientation:portrait){
  .discount-card-legend{ display:block; }
  .discount-table-legend{ display:none; }
}
.inline-discount-toggle{ justify-content:center; min-height:25px; }
.sc-card{ display:inline-flex; flex-direction:column; align-items:center; gap:6px; padding:10px 22px; background:var(--teal-bg); border:1px solid #c8dfd4; border-radius:12px; max-width:100%; }
.sc-row{ display:flex; align-items:center; justify-content:center; gap:18px; }
.sc-avatar{ width:44px; height:44px; border-radius:50%; background:#fff; color:var(--teal); border:1px solid #c8dfd4; display:inline-flex; align-items:center; justify-content:center; }
.sc-avatar svg{ width:22px; height:22px; }
.sc-name{ font-size:12.5px; font-weight:700; line-height:1.4; color:var(--ink); text-align:center; }
.sc-call{ width:36px; height:36px; border-radius:50%; background:var(--teal); color:#fff; display:inline-flex; align-items:center; justify-content:center; text-decoration:none; box-shadow:0 2px 6px rgba(14,159,117,.35); }
.sc-call:hover{ filter:brightness(.93); }
.sc-call svg{ width:18px; height:18px; }
/* اقلام فاکتور در مودال ویرایش سفارش: هر قلم یک کارت است؛ نام بالا/کنار، و کنترل‌ها
   (تعداد با + و −، و حذف) هم‌ردیف. وقتی جا کم باشد، کنترل‌ها به ردیف پایین می‌روند. */
.eo-item{
  display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px;
  padding:12px 14px; margin-bottom:8px;
  background:#fff; border:1px solid var(--line); border-radius:12px;
}
.eo-main{ display:flex; align-items:center; gap:10px; flex:1 1 260px; min-width:0; }
.eo-main .order-product-search-details strong{ display:block; overflow:visible; -webkit-line-clamp:unset; overflow-wrap:anywhere; }
.eo-controls{ display:flex; align-items:center; gap:10px; flex:0 0 auto; }
.qty-stepper{ display:inline-flex; align-items:stretch; height:38px; border:1px solid var(--line); border-radius:10px; overflow:hidden; background:#fff; }
.qs-btn{ width:36px; border:0; background:#f4f3fb; color:var(--ink); font-size:18px; line-height:1; font-family:inherit; cursor:pointer; }
.qs-btn:hover{ background:#e9e7fb; }
.qs-btn:active{ background:#dedbf7; }
.qty-stepper .qs-input{
  flex:0 0 56px; width:56px; min-width:0; min-height:0; height:auto; margin:0; padding:0; box-shadow:none;
  border:0; border-inline:1px solid var(--line); border-radius:0; text-align:center;
  font-family:inherit; font-size:14px; font-weight:700; background:#fff; -moz-appearance:textfield; appearance:textfield;
}
.qty-stepper .qs-input::-webkit-outer-spin-button, .qty-stepper .qs-input::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
.qty-stepper .qs-input:focus{ outline:2px solid var(--brass); outline-offset:-2px; }
.qty-stepper .qs-btn{ flex:0 0 40px; }
.eo-remove{
  display:inline-flex; align-items:center; justify-content:center; gap:6px; height:38px; padding:0 12px;
  border:1px solid transparent; border-radius:10px; background:var(--red-bg); color:var(--red);
  font-family:inherit; font-size:12.5px; font-weight:700; cursor:pointer;
}
.eo-remove:hover{ border-color:var(--red); }
.partner-search-row{ padding:14px 20px 0; }
.partner-search{
  display:block; width:100%; padding:10px 12px; box-sizing:border-box;
  border:1px solid var(--line); border-radius:8px; font-family:inherit; font-size:13.5px; background:#fff;
}
@media (max-width:1024px){ .partner-search-row{ padding:12px 14px 0; } }
.eo-search{ display:flex; align-items:stretch; gap:8px; }
.eo-search > input{ flex:1 1 auto; min-width:0; }
.eo-search > select, .eo-search > .combo{ flex:0 0 170px; min-width:0; }
.order-product-search-results, .order-product-all-results{ margin-top:8px; max-height:190px; overflow:auto; border:1px solid var(--line); border-radius:8px; padding:4px; }
.order-product-all-results{ max-height:300px; }
.order-product-search-item{ display:flex; width:100%; align-items:center; justify-content:space-between; gap:10px; padding:9px; border:0; border-bottom:1px solid var(--line); background:#fff; color:var(--ink); font-family:inherit; text-align:right; cursor:pointer; }
.order-product-search-item:last-child{ border-bottom:0; }
.order-product-search-item:hover{ background:#f4f3fb; }
.order-product-search-image{ width:42px; height:42px; flex:0 0 42px; object-fit:cover; border-radius:7px; background:#efeefb; }
.order-product-no-image{ display:flex; align-items:center; justify-content:center; padding:4px; box-sizing:border-box; color:var(--ink-soft); font-size:10px; text-align:center; }
.order-product-search-details{ flex:1; min-width:0; display:flex; flex-direction:column; gap:3px; text-align:right; }
.order-product-search-details strong{ font-size:13px; line-height:1.6; overflow:hidden; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.order-product-search-details small{ color:var(--ink-soft); font-size:11px; }
.order-product-price{ flex:0 0 auto; font-size:12.5px; white-space:nowrap; }
/* نوار پایین لیست کالاها (صفحه‌بندی + «افزودن انتخاب‌شده‌ها»).
   position:sticky یعنی: تا وقتی انتهای جدول دیده نشده به کف صفحه می‌چسبد، و وقتی به انتها
   رسیدیم همان‌جا زیر جدول می‌ماند. چون داخل خودِ کارت است، عرضش همیشه دقیقاً هم‌عرضِ
   جدول است و نه با JS اندازه‌گیری می‌شود و نه روی ردیف‌های آخر می‌افتد. */
.list-dock{
  position:sticky; bottom:12px; z-index:30;
  display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;
  margin-top:14px; padding:10px 14px;
  background:#fff; border:1px solid var(--line); border-radius:12px;
  box-shadow:0 8px 24px rgba(24,26,48,.14);
}
.list-dock[hidden]{ display:none; }
#adminListDock { bottom:calc(12px + env(safe-area-inset-bottom, 0px)); }
#savePricesButton { min-height:44px; flex:0 1 auto; white-space:normal; }
#savePricesButton[hidden] { display:none; }
@media (max-width:600px) {
  #adminListDock { gap:8px; padding:10px; }
  #savePricesButton { width:100%; flex-basis:100%; }
}
.list-dock .pagination{ flex:1 1 auto; min-width:0; margin:0; padding:0; border:0; }
.list-dock .pagination:empty{ display:none; }
.add-selected-btn{ flex:0 0 auto; justify-content:center; white-space:nowrap; min-width:170px; }
.add-selected-btn[hidden]{ display:none; }
.order-product-empty{ padding:9px; font-size:12px; color:var(--ink-soft); }

table{ width:100%; border-collapse:collapse; font-size:13.5px; }
thead th{
  text-align:right; padding:10px 12px; background:#f4f3fb; border-bottom:2px solid var(--line);
  font-weight:700; color:var(--ink-soft); position:sticky; top:0;
}
tbody td{ padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:middle;}
/* هم‌ترازی عنوان ستون با مقدار زیرش: ستون‌های عددی/ورودی وسط‌چین (هم th هم td)، ستون‌های متنی راست‌چین.
   (کلاس .num جهت سلول را LTR می‌کند و مقدار را به چپ سلول می‌چسباند، ولی عنوان‌ها راست‌چین بودند.) */
thead th.ta-c, tbody td.ta-c{ text-align:center; }
tbody tr:hover{ background:#fafaff; }
.price-cash{ color:var(--teal); font-weight:700;}
.price-check{ color:var(--brass-dark); font-weight:700;}
.stock-low{ color:var(--red); font-weight:700;}
.qty-input{ width:56px; padding:6px 6px; border:1px solid var(--line); border-radius:6px; text-align:center; font-family:inherit;}
.price-input{ width:112px; padding:6px 6px; border:1px solid var(--line); border-radius:6px; text-align:center; font-family:'IBM Plex Mono','Vazirmatn',monospace; direction:ltr; }
.price-input:focus{ outline:2px solid var(--brass); outline-offset:1px; border-color: var(--brass); }
.thumb{ width:40px; height:40px; object-fit:cover; border-radius:6px; border:1px solid var(--line); display:block; }
.thumb-lg{ width:90px; height:90px; object-fit:cover; border-radius:8px; border:1px solid var(--line); }
/* تصویر اصلی کالا در پنل همکار: حدود ۳ برابر اندازه‌ی قبلی (۴۰px) تا مشتری کالا را ببیند.
   اندازه با متغیر کنترل می‌شود تا در تبلت/موبایل کوچک‌تر و بدون به‌هم‌ریختن جدول بماند. */
:root{ --product-image-size:120px; }
.product-image-column, .product-image-cell{ width:calc(var(--product-image-size) + 16px); text-align:center; }
.product-image-cell{ padding:6px 8px; }
.product-image, .product-image-placeholder{
  width:var(--product-image-size); height:var(--product-image-size); aspect-ratio:1 / 1; border-radius:7px;
  border:1px solid var(--line); display:inline-flex; align-items:center; justify-content:center;
  max-width:100%;
}
.product-image{ object-fit:contain; background:#fff; padding:4px; cursor:zoom-in; }
.product-image-placeholder{ background:#f4f3fb; color:var(--ink-soft); font-size:11px; line-height:1.4; }
.product-name{ font-weight:600; white-space:normal; word-break:break-word; min-width:170px; }
.product-sku{ max-width:90px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.product-brand{ max-width:100px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.product-action-buttons{ display:flex; flex-direction:row; flex-wrap:nowrap; gap:4px; align-items:stretch; min-width:0; }
.product-action-buttons .btn{ padding:5px 7px; font-size:11px; white-space:nowrap; }
.row-actions{ display:flex; flex-wrap:wrap; gap:6px; }
#secPartners .row-actions{ flex-wrap:nowrap; }
.gallery-admin-preview{ display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
.gallery-admin-item{ position:relative; width:72px; height:72px; }
.gallery-admin-item img{ width:72px; height:72px; object-fit:cover; border:1px solid var(--line); border-radius:7px; }
.gallery-admin-item button{ position:absolute; top:-6px; left:-6px; width:20px; height:20px; padding:0; border-radius:50%; border:none; background:var(--red); color:#fff; cursor:pointer; line-height:20px; }
/* ---------- گالری محصول (پنل همکار): لیست بندانگشتی + پیش‌نمایش بزرگ ----------
   ساختار: ستون راست = تصویر بزرگ (stage)، ستون چپ = لیست عکس‌ها (RTL).
   ارتفاع stage تابع ارتفاع پنجره است تا مودال هرگز از کادر بیرون نزند و
   عکس هم با object-fit:contain هیچ‌وقت بزرگ‌تر از کادر یا بریده نمایش داده نشود. */
.product-gallery{
  --gallery-stage-h: clamp(220px, 52vh, 520px);
  display:grid; grid-template-columns:minmax(0, 1fr) 104px; gap:14px; align-items:start;
}
.gallery-stage{
  position:relative; display:flex; align-items:center; justify-content:center;
  height:var(--gallery-stage-h); min-width:0; padding:10px;
  background:#fff; border:1px solid var(--line); border-radius:12px; overflow:hidden;
}
.gallery-main-image{
  max-width:100%; max-height:100%; width:auto; height:auto;
  object-fit:contain; display:block; border-radius:6px;
}
.gallery-nav{
  position:absolute; top:50%; transform:translateY(-50%);
  width:36px; height:36px; border-radius:50%; border:1px solid var(--line);
  background:rgba(255,255,255,.92); color:var(--ink); font-size:17px; line-height:1;
  cursor:pointer; display:flex; align-items:center; justify-content:center; padding:0;
}
.gallery-nav:hover{ background:#fff; border-color:var(--brass); }
.gallery-nav svg{ width:18px; height:18px; display:block; }
.gallery-nav-prev{ right:8px; }
.gallery-nav-next{ left:8px; }
.gallery-counter{
  position:absolute; bottom:8px; inset-inline-start:8px;
  background:rgba(24,26,48,.72); color:#fff; font-size:11px;
  padding:3px 8px; border-radius:20px; direction:ltr;
}
.gallery-thumbs{
  display:flex; flex-direction:column; gap:8px;
  max-height:var(--gallery-stage-h); overflow:auto; padding:2px;
}
.gallery-thumb{
  flex:0 0 auto; width:92px; height:92px; padding:0; cursor:pointer;
  background:#fff; border:1px solid var(--line); border-radius:9px; overflow:hidden;
}
.gallery-thumb img{ width:100%; height:100%; object-fit:contain; display:block; }
.gallery-thumb.active{ border-color:var(--brass); box-shadow:0 0 0 2px rgba(191,149,63,.28); }
/* حالت‌های «در حال بارگذاری / بدون عکس / خطا» کل عرض گالری را بگیرند */
.product-gallery > .empty, .product-gallery > .msg{ grid-column:1 / -1; }

/* فرم کوچک «ساخت سریع» دسته‌بندی/برند داخل مودال ایمپورت اکسل — بدون window.prompt،
   چون در بعضی مرورگرها/وب‌ویوها prompt() بی‌صدا کار نمی‌کند. */
.excel-quick-add{ display:flex; gap:6px; margin-top:8px; }
.excel-quick-add.hidden{ display:none; }
.excel-quick-add input{ flex:1; min-width:0; padding:8px 10px; border:1px solid var(--line); border-radius:8px; font-size:13px; font-family:inherit; }
.excel-quick-add-msg{ font-size:12px; color:var(--red); margin-top:4px; min-height:1em; }

/* ---------- سبد سفارش ---------- */
.cart-fab{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  position:fixed; left:24px; bottom:24px; background:var(--grad-brand); color:#fff;
  border-radius:999px; padding:14px 20px; font-weight:800; box-shadow:0 12px 28px rgba(var(--brass-rgb),.42);
  border:none; cursor:pointer; font-size:14px; transition:transform .12s ease, box-shadow .15s ease;
}
.cart-fab:hover{ box-shadow:0 14px 32px rgba(var(--brass-rgb),.5); }
.cart-fab:active{ transform:translateY(1px); }
.drawer-close-icon{ background:none; border:none; color:var(--ink-soft); padding:4px; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
/* در صفحه‌ی پهن، «سبد سفارش» کنارِ کارتِ جدول (بیرونش) می‌نشیند. از این عرض به پایین جا
   نیست و روی نوار پایین لیست می‌افتد؛ پس نوار پایین لیست به‌اندازه‌ی ارتفاع این دکمه
   (۴۴ + ۲۴ + ۸) بالاتر می‌چسبد. این‌طوری چون دکمه‌ی سبد همیشه کف صفحه می‌ماند و نوار
   همیشه بالای آن است، در هیچ نقطه‌ی اسکرول (حتی انتهای صفحه) روی هم نمی‌افتند. */
.drawer-backdrop{ position:fixed; inset:0; background:rgba(24,26,48,.4); z-index:40; opacity:0; visibility:hidden; pointer-events:none; transition:opacity .22s ease, visibility .22s; }
.drawer-backdrop.open{ opacity:1; visibility:visible; pointer-events:auto; }
.drawer{
  position:fixed; top:0; bottom:0; left:0; width:380px; max-width:92vw; background:#fff; z-index:41;
  transform:translateX(-100%); transition:transform .25s ease; display:flex; flex-direction:column;
}
.drawer.open{ transform:translateX(0); }
.drawer-head{ padding:16px 18px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center;}
.drawer-body{ flex:1; overflow:auto; padding:14px 18px; }
.drawer-foot{ padding:16px 18px; border-top:1px solid var(--line); }
.cart-row{ display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px 0; border-bottom:1px dashed var(--line);}
.cart-row .name{ font-weight:600; font-size:13.5px; }
.cart-row .meta{ font-size:12px; color:var(--ink-soft); }

/* ---------- تب‌های داشبورد ---------- */
.dtabs{ display:flex; gap:8px; margin-bottom:18px; }
.dtabs button{
  padding:9px 16px; border-radius:8px; border:1px solid var(--line); background:#fff; cursor:pointer; font-weight:700; font-size:13.5px; color:var(--ink-soft);
}
.dtabs button.active{ background:var(--ink); color:#fff; border-color:var(--ink); }

.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:14px; margin-bottom:20px;}
.stat{ background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:14px 16px; }
.stat .label{ font-size:12px; color:var(--ink-soft); margin-bottom:6px;}
.stat .value{ font-size:20px; font-weight:800; }

.empty{ text-align:center; padding:40px 10px; color:var(--ink-soft); }

.hidden{ display:none !important; }
.ai-inline-error{ margin-top:6px; font-size:12.5px; color:#b3261e; display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

.badge-count{
  background:var(--red); color:#fff; border-radius:999px; font-size:11px; padding:1px 7px; margin-inline-start:4px;
}

.modal-backdrop{ position:fixed; inset:0; background:rgba(24,26,48,.45); display:flex; align-items:center; justify-content:center; z-index:50; animation:overlayFadeIn .18s ease both; }
.modal{ position:relative; background:#fff; border-radius:12px; width:100%; max-width:480px; max-height:88vh; overflow:auto; padding:20px; animation:overlayScaleIn .22s cubic-bezier(.4,0,.2,1) both; }
@keyframes overlayFadeIn{ from{ opacity:0; } to{ opacity:1; } }
@keyframes overlayScaleIn{ from{ opacity:0; transform:translateY(10px) scale(.97); } to{ opacity:1; transform:none; } }
@media (prefers-reduced-motion:reduce){ .modal-backdrop, .modal, .partner-cart[open], .partner-cart::backdrop, .drawer-backdrop{ animation:none !important; transition:none !important; } }
.modal h3{ margin-top:0; }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }

footer.note{ text-align:center; color:var(--ink-soft); font-size:12px; padding:24px 0 6px; }
.app-version{ margin-inline-start:8px; padding-inline-start:8px; border-inline-start:1px solid var(--line); white-space:nowrap; }
.site-version{ text-align:center; color:var(--ink-soft); font-size:12px; padding:0 20px 22px; }


/* ============================================================
   ریسپانسیو یکپارچه — دسکتاپ / تبلت / موبایل (نسخه ۲.۲)
   یک سیستم واحد به‌جای چند بلوک پراکنده‌ی قبلی؛ همه‌ی جدول‌های
   داخل کارت‌ها (از جمله سفارش‌ها) و مودال ایمپورت اکسل به‌صورت
   عمومی پوشش داده می‌شوند، نه فقط با شناسه‌ی هر بخش.
   ============================================================ */

html{ min-width:320px; }
body{ min-width:320px; overflow-x:hidden; }
img, svg, video, canvas{ max-width:100%; height:auto; }
input, select, textarea, button{ max-width:100%; }

/* دسکتاپ: فضای خوانا و عرض کنترل‌شده */
.container{ width:min(100%, 1240px); padding-inline:clamp(16px, 3vw, 32px); }
.topbar{ padding-inline:clamp(16px, 3vw, 32px); }
.card .card-header{ gap:12px; flex-wrap:wrap; }
.card .card-header > *{ min-width:0; }
.toolbar > *{ min-width:0; }
.modal-backdrop{ padding:20px; overscroll-behavior:contain; }
.modal{ overscroll-behavior:contain; }
.modal [style*="display:flex"]{ flex-wrap:wrap; }
.modal [style*="display:flex"] > .btn{ min-height:42px; }

/* هر ردیف دکمه/کنترلی که به‌صورت inline با display:flex ساخته شده، چه داخل مودال چه
   داخل بدنه/هدر یک کارت (مثلاً ردیف‌های «ذخیره تنظیمات»، فیلترها، اکسپورت/ایمپورت
   دیتابیس و…)، اگر جا نشود می‌شکند، نه اینکه از عرض کارت بیرون بزند یا دکمه‌ها روی هم بیفتند. */
.card [style*="display:flex"]{ flex-wrap:wrap; }
.card [style*="display:flex"] > .btn{ min-height:40px; }

/* ردیف نام کالا + دکمه‌های پیشنهاد هوش مصنوعی: روی دسکتاپ هم‌ردیف،
   روی موبایل نام کالا در خط اول (تمام‌عرض) و دکمه‌ها زیرش در خط دوم. */
.pname-row{ display:flex; gap:8px; align-items:flex-start; }
.pname-row input{ flex:1 1 auto; min-width:0; }
.pname-actions{ display:flex; gap:8px; flex-shrink:0; }
.pname-actions .btn{ white-space:nowrap; }

/* ---------- تبلت و موبایل مشترک (≤1024px): تبدیل جدول‌ها به کارت ---------- */
@media (max-width:1024px){
  .container{ padding-top:20px; padding-bottom:52px; }
  .card .card-header, .card .card-body{ padding:14px; }
  .products-card-header{ align-items:stretch !important; flex-direction:column; gap:12px; }
  .products-action-group .btn{ flex-basis:140px; min-height:42px; margin:0; }
  .products-actions label{ justify-content:center; padding:7px 8px; }
  .sales-contact{ padding-inline:14px; }
  .dtabs{ display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:8px; }
  .dtabs button{ width:100%; min-height:44px; }

  /* هر جدولی داخل بدنه‌ی یک کارت یا مودال ایمپورت اکسل/پیشنهاد هوش مصنوعی (نام یا معرفی)،
     به کارت تبدیل می‌شود (شامل قیمت، همکاران، کالاها، سفارش‌ها، مدیران، پیش‌نمایش ایمپورت) */
  .card-body table, #excelImportModal table, #normalizeNamesTable, #suggestDescriptionsTable{ min-width:0; font-size:12.5px; }
  .card-body thead, #excelImportModal thead, #normalizeNamesTable thead, #suggestDescriptionsTable thead{ display:none; }
  .card-body tbody, .card-body tr, .card-body td,
  #excelImportModal tbody, #excelImportModal tr, #excelImportModal td,
  #normalizeNamesTable tbody, #normalizeNamesTable tr, #normalizeNamesTable td,
  #suggestDescriptionsTable tbody, #suggestDescriptionsTable tr, #suggestDescriptionsTable td{ display:block; width:100%; }
  .card-body tbody tr, #excelImportModal tbody tr, #normalizeNamesTable tbody tr, #suggestDescriptionsTable tbody tr{
    margin-bottom:12px; border:1px solid var(--line); border-radius:10px; background:#fff; overflow:hidden;
  }
  .card-body tbody td, #excelImportModal tbody td, #normalizeNamesTable tbody td, #suggestDescriptionsTable tbody td{
    min-height:40px; padding:9px 12px; border-bottom:1px dashed var(--line);
    display:flex; align-items:center; justify-content:space-between; gap:10px; text-align:left;
  }
  /* کلاس .num جهت را LTR می‌کند؛ در کارت‌های واکنش‌گرا، چیدمان باید RTL بماند: عنوان راست، مقدار چپ. */
  .card-body tbody td.num{ direction:rtl; unicode-bidi:normal; }
  .card-body tbody td:last-child, #excelImportModal tbody td:last-child,
  #normalizeNamesTable tbody td:last-child, #suggestDescriptionsTable tbody td:last-child{ border-bottom:none; }
  .card-body tbody td::before, #excelImportModal tbody td::before,
  #normalizeNamesTable tbody td::before, #suggestDescriptionsTable tbody td::before{
    content:attr(data-label); color:var(--ink-soft); font-size:11px; font-weight:700; text-align:right; flex-shrink:0;
  }
  .card-body tbody td[data-label="انتخاب"], #excelImportModal tbody td[data-label="انتخاب"],
  #normalizeNamesTable tbody td[data-label="انتخاب"], #suggestDescriptionsTable tbody td[data-label="انتخاب"]{ justify-content:flex-start; }
  #excelImportModal tbody td[data-label="انتخاب"]::before{ margin-inline-end:6px; }
  #excelImportModal .excel-create-select{ width:18px; height:18px; }
  /* ردیف‌هایی که مقدارشان یک ورودی/متن چندخطی است (نام یا معرفی پیشنهادی)، به‌جای هم‌ردیف
     شدن با برچسب، زیر آن قرار می‌گیرند تا فضای کافی برای تایپ/ویرایش داشته باشند. */
  #normalizeNamesTable tbody td:has(input[type="text"]),
  #suggestDescriptionsTable tbody td:has(textarea){ flex-direction:column; align-items:stretch; }
  #normalizeNamesTable tbody td:has(input[type="text"])::before,
  #suggestDescriptionsTable tbody td:has(textarea)::before{ margin-bottom:6px; }
  #suggestDescriptionsTable .suggest-desc-suggested{ min-height:90px; }
  /* دکمه‌ی «تحلیل دوباره» (تکی) کنار ورودی نام/معرفی پیشنهادی یا کنار پیام خطا؛
     روی موبایل زیر ورودی نیفتد و کوچک/فشرده بماند. */
  #normalizeNamesTable .normalize-suggested + .btn-sm,
  #suggestDescriptionsTable .suggest-desc-suggested + .btn-sm{ flex-shrink:0; align-self:flex-start; }

  .product-image-cell{ width:100%; text-align:left; }
  .product-name{ min-width:0; }
  /* در حالت کارتیِ موبایل/تبلت هر فیلد روی یک ردیف جداست، پس نیازی به کوچک/بریده‌شدن کد،
     برند و مدل نیست؛ فقط در نمای جدولیِ دسکتاپ برای جادادن ستون‌ها فشرده می‌شوند. */
  .product-sku, .product-brand{ max-width:none; overflow:visible; text-overflow:clip; white-space:normal; text-align:left; }
  .product-action-buttons{ width:100%; flex-direction:row; min-width:0; }
  .product-action-buttons .btn{ flex:1; min-height:40px; font-size:12px; }
  .row-actions{ width:100%; display:grid; grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); gap:6px; }
  .row-actions .btn{ min-height:40px; }
  #secAdmins tbody td[data-label="عملیات"]{ flex-direction:column; align-items:stretch; gap:8px; }
  #secAdmins tbody td[data-label="عملیات"]::before{ text-align:right; }
  #secAdmins .row-actions{ justify-content:flex-start; }
  #secAdmins .row-actions .btn{ flex:1 1 auto; min-height:38px; }
}

/* ---------- تبلت (641–1024px): کنترل‌ها در شبکه، بدون فشردگی ---------- */
@media (min-width:641px) and (max-width:1024px){
  :root{ --product-image-size:96px; }
  .topbar{ gap:14px; }
  .topbar .who{ flex-wrap:wrap; justify-content:flex-start; }
  .toolbar{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); align-items:stretch; }
  .toolbar input[type=text]{ grid-column:1 / -1; width:100%; }
  .toolbar > .btn, .toolbar > label{ min-height:42px; }
  .modal{ width:min(100%, 680px); }
}

/* ---------- موبایل (≤640px): هر کنترل در دسترس انگشت، بدون اسکرول افقی صفحه ---------- */
@media (max-width:640px){
  :root{ --product-image-size:104px; }
  .topbar{ padding:12px 14px; flex-wrap:wrap; gap:10px; }
  .topbar .brand{ flex:1; min-width:0; font-size:14px; }
  .topbar .who{ width:100%; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:10px; }
  .topbar .who > span{ max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar button.logout{ min-height:40px; padding:6px 10px; font-size:12px; }
  .container{ padding:16px 12px 92px; }
  .card{ border-radius:9px; }
  .card .card-header{ align-items:stretch; }
  .card .card-header > .btn, .card .card-header > div{ width:100%; }

  .toolbar{ display:grid; grid-template-columns:1fr; width:100%; gap:8px; }
  .toolbar > *{ width:100% !important; min-height:42px; }
  .toolbar label{ display:flex; align-items:center; justify-content:flex-start; padding:8px 10px; border:1px solid var(--line); border-radius:8px; background:#fff; }
  .toolbar #addSelectedButton{ flex-basis:100%; }

  .products-action-group .btn{ flex-basis:100%; }
  .products-card-header h2{ font-size:15px; }

  .dtabs{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .dtabs button{ min-height:44px; font-size:12.5px; }

  .stat-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
  .stat{ padding:11px; }
  .stat .value{ font-size:16px; overflow-wrap:anywhere; }

  .sales-contact{ margin:10px 0 0; padding-inline:12px; }

  .modal-backdrop{ padding:10px; align-items:center; }
  .modal{ width:100%; max-height:calc(100dvh - 20px); padding:16px 14px; border-radius:14px 14px 10px 10px; }
  .modal h3{ font-size:16px; }
  .modal [style*="display:flex"] > .btn{ flex:1 1 140px; }
  .card [style*="display:flex"] > .btn{ flex:1 1 140px; }
  .grid-2{ grid-template-columns:1fr; gap:0; }

  .pname-row{ flex-direction:column; align-items:stretch; }
  .pname-row input{ width:100%; }
  .pname-actions{ width:100%; }
  .pname-actions #pNameSuggestBtn{ flex:1 1 auto; min-width:0; }
  .pname-actions .btn-icon{ flex:0 0 44px; }

  .drawer{ width:100%; max-width:100vw; max-height:100dvh; }
  .list-dock{ flex-direction:column; align-items:stretch; gap:8px; padding:10px; }
  .list-dock .pagination-info{ display:none; }
  /* Keep all five page numbers and navigation buttons on one row. */
  .list-dock .pagination-controls{ flex-wrap:nowrap; justify-content:center; gap:4px; }
  .list-dock .pagination-controls .pagination-nav{ flex:0 0 auto; padding:6px; gap:2px; }
  .list-dock .pagination-page{ min-width:30px; padding:6px; }
  .add-selected-btn{ order:-1; width:100%; min-height:44px; }

  /* موبایل: پیش‌نمایش بالا، نوار عکس‌ها به‌صورت افقی زیر آن */
  .product-gallery{ --gallery-stage-h: clamp(190px, 42vh, 330px); grid-template-columns:1fr; gap:10px; }
  .gallery-thumbs{ flex-direction:row; max-height:none; overflow-x:auto; overflow-y:hidden; }
  .gallery-thumb{ width:70px; height:70px; }
  .gallery-nav{ width:34px; height:34px; }
  .gallery-modal{ padding:12px; }

  .card-body table, #excelImportModal table, #normalizeNamesTable, #suggestDescriptionsTable{ font-size:12px; }
  td{ overflow-wrap:anywhere; }
  .product-image-cell{ width:100%; }
  .product-action-buttons .btn{ font-size:11px; min-height:38px; }
  .row-actions{ grid-template-columns:repeat(auto-fit, minmax(120px, 1fr)); }
  .qty-input{ width:84px; min-height:38px; }
  .price-input{ max-width:130px; }
  .card-body tbody td[data-label="سبد"] .btn{ width:100%; min-height:38px; }
  #secAdmins tbody td[data-label="عملیات"] .btn{ width:100%; white-space:normal; }

  .eo-search{ flex-direction:column; }
  .eo-search > select, .eo-search > .combo{ flex:0 0 auto; width:100%; }
  .eo-main{ flex-basis:100%; }
  .eo-controls{ flex:1 1 100%; }
  .eo-controls .qty-stepper{ flex:1 1 0; min-width:0; }
  .qty-stepper .qs-input{ flex:1 1 0; width:0; min-width:0; }
  .eo-remove{ flex:0 0 auto; }
  .order-product-search-results{ max-height:160px; }
  .order-product-all-results{ max-height:240px; }
  .order-actions .btn{ flex:1 1 calc(50% - 6px); min-height:40px; }

  .drawer-head, .drawer-body, .drawer-foot{ padding-inline:14px; }
  footer.note{ padding-bottom:12px; }

  .pagination{ flex-direction:column; align-items:stretch; gap:10px; }
  .pagination-info{ text-align:center; }
  .pagination-controls{ justify-content:center; }
  .pagination-nav{ flex:1 1 auto; min-height:38px; }
  .pagination-page{ min-height:38px; }
  .app-version{ display:inline-block; margin-top:6px; border-inline-start:0; padding-inline-start:0; }
  .site-version{ padding-bottom:16px; }

  .auth-wrap{ align-items:flex-start; padding:28px 14px; }
  .auth-box{ max-width:100%; }
  body{ background-size:100% 2.8em; }
}

/* ============================================================
   نسخه 5.0 - چیدمان یکپارچه برای ۴ فرم‌فکتور
   ============================================================ */
html, body{ max-width:100%; overflow-x:clip; }

/* دسکتاپ افقی: فضای اطلاعاتی بیشتر، بدون کشیدگی بیش از حد خطوط متن */
@media (min-width:1201px){
  .topbar, .container, .sales-contact{ width:min(100%, 1360px); margin-inline:auto; }
  .topbar{ border-radius:0 0 14px 14px; }
  .dtabs{ grid-template-columns:repeat(4, minmax(0, 1fr)); }
  .toolbar{ align-items:end; }
}

/* دسکتاپ عمودی: ابزارها دو ردیف کنترل‌شده و کارت‌ها با فضای تنفسی کافی */
@media (min-width:901px) and (max-width:1200px) and (orientation:portrait){
  .topbar{ flex-wrap:wrap; gap:10px 18px; padding:10px 22px; }
  .topbar .who{ margin-inline-start:auto; flex-wrap:wrap; justify-content:flex-end; }
  .container{ padding-inline:20px; }
  .dtabs{ grid-template-columns:repeat(4, minmax(0, 1fr)); }
  .toolbar{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .toolbar input[type=text]{ grid-column:1 / -1; }
}

/* تبلت: هدر و ابزارها به ردیف‌های قابل لمس تبدیل می‌شوند */
@media (min-width:641px) and (max-width:900px){
  .topbar{ flex-wrap:wrap; gap:10px; padding:12px 18px; }
  .topbar .brand{ flex:1 1 45%; }
  .topbar .who{ flex:1 1 45%; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
  .dtabs{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .card .card-header{ align-items:stretch; }
  .partner-header-actions{ width:100%; }
  .partner-header-actions > .combo, .partner-header-actions .btn{ min-height:42px; }
  .stat-grid{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
}

/* موبایل: هدر دو بخش روشن، دکمه‌های هم‌عرض و محتوای بدون اسکرول افقی */
@media (max-width:640px){
  .topbar{ display:block; padding:12px 14px; }
  .topbar .brand{ min-height:32px; justify-content:center; font-size:14px; }
  .topbar .who{ width:100%; display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:7px; margin-top:10px; }
  .topbar .who > span{ grid-column:1 / -1; max-width:none; text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar button.logout, .topbar button.topbar-btn, .topbar .topbar-store-link{ width:100%; min-width:0; min-height:40px; padding:6px 5px; font-size:11.5px; text-align:center; }
  .container{ padding-inline:12px; }
  .dtabs{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .dtabs button{ min-width:0; padding-inline:8px; }
  .card .card-header h2{ font-size:15px; }
  .stat-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .sales-contact{ padding-inline:12px; }
  .partner-header-actions{ width:100%; }
  .partner-header-actions .btn{ min-width:0; }
}

/* ---------- دسکتاپ باریک / مانیتور عمودی (۱۰۲۵–۱۳۰۰px): هنوز جدول واقعی نشان داده
   می‌شود (نه حالت کارتی موبایل/تبلت)، اما فشرده‌تر می‌شود تا در عرض‌های رایج مانیتور
   عمودی (۱۰۸۰/۱۲۰۰/۱۲۸۰px) بدون اسکرول افقی ناخواسته جا شود ---------- */
@media (min-width:1025px) and (max-width:1300px){
  .container{ padding-inline:18px; }
  table{ font-size:12.5px; }
  thead th, tbody td{ padding:8px 9px; }
  .product-sku{ max-width:70px; }
  .product-brand{ max-width:80px; }
  .toolbar{ gap:8px; }
  .toolbar input[type=text]{ flex:1 1 100%; }
  .products-action-group .btn{ flex:1 1 150px; }
  .pagination-page{ min-width:30px; padding:5px 6px; font-size:12px; }
}

/* ---------- مانیتور/پنجره‌ی عمودی روی دسکتاپ (عرض ≥۷۶۸px ولی ارتفاع بیشتر از عرض):
   محتوا در عرض زیاد نکشد و فاصله‌ی عمودیِ اضافه به هدر و کارت‌ها اضافه نشود ---------- */
@media (min-width:768px) and (max-width:1024px) and (orientation:portrait){
  .container{ width:min(100%, 900px); }
  .stat-grid{ grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); }
  .modal{ max-height:80vh; }
}

/* ---------- دسکتاپ خیلی بزرگ (≥۱۶۰۰px): محتوا در وسط با عرض راحت، نه کشیده تا لبه ---------- */
@media (min-width:1600px){
  .container{ width:min(100%, 1320px); }
  table{ font-size:14px; }
}

/* ---------- ترجیح کاربر برای کاهش انیمیشن ---------- */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.001ms !important; animation-iteration-count:1 !important; transition-duration:0.001ms !important; scroll-behavior:auto !important; }
}

/* ---------- موبایل خیلی کوچک (≤380px) ---------- */
@media (max-width:380px){
  .topbar .brand{ font-size:13px; }
  .topbar .brand .mark{ height:26px; }
  .dtabs{ grid-template-columns:1fr; }
  .stat-grid{ grid-template-columns:1fr; }
  .cart-fab{ font-size:12.5px; }
}


/* ============================================================
   اندازه‌بندی و ریسپانسیو مودال‌ها (نسخه ۳.۶.۱)
   همه‌ی پنجره‌های بازشو (ویرایش کالا، همکار، شرایط، ایمپورت اکسل و…) به‌جای عرض ثابت ۴۸۰px،
   با کلاس‌های اندازه، روی دسکتاپ و رزولوشن‌های مختلف عریض‌تر می‌شوند:
     .modal            پایه (فرم‌های کوچک)          ≈ ۶۲۰px
     .modal.modal-md   فرم‌های متوسط                ≈ ۸۲۰px
     .modal.modal-lg   فرم/جدول‌های بزرگ (کالا…)     ≈ ۱۰۸۰px
   موبایل (≤۶۴۰px) مثل قبل به‌صورت کشوی تمام‌عرض می‌ماند.
   این بلوک عمداً آخر فایل است تا بر قانون‌های قدیمی .modal غلبه کند.
   ============================================================ */

/* پدینگ مودال به‌صورت متغیر، تا نوار دکمه‌ی چسبان دقیقاً همان‌قدر داخل پدینگ کشیده شود */
.modal{ --modal-pad-x:20px; --modal-pad-y:20px; }
.bulk-assign-modal{ max-width:760px; overflow:visible; }
.bulk-assign-modal .combo-trigger{ min-height:52px; }
.bulk-assign-modal .combo-panel{ max-height:280px; }

#pSpecifications, #specsModalBody{
  direction:rtl; unicode-bidi:plaintext; text-align:right; font-variant-numeric:tabular-nums;
  overflow-wrap:anywhere; word-break:break-word; white-space:pre-wrap;
}

/* جدول‌های داخل مودال: ارتفاع اسکرول داخلی تابع ارتفاع پنجره (نه vh ثابت) */
.modal-table-scroll{ max-height:50vh; max-height:max(240px, calc(100dvh - 480px)); overflow:auto; }
.modal-table-scroll.excel-table-box{ max-height:280px; }  /* پیش‌نمایش ایمپورت اکسل: هر جدول اسکرول مستقل دارد */

/* پیش‌نمایش ایمپورت اکسل روی دسکتاپ: دو جدول کنار هم؛ جدول کوچک‌ترِ «بروزرسانی» و جدول بزرگ‌ترِ «کالاهای جدید»،
   هر دو به‌اندازه‌ی ارتفاع صفحه کشیده می‌شوند (اسکرول داخلی). زیر ۱۰۲۵px همان چیدمان زیرهم/کارتی قبلی می‌ماند. */
@media (min-width:1025px){
  #excelImportModal .modal.modal-lg{ max-width:min(1560px, 100%); height:calc(100vh - 48px); height:calc(100dvh - 48px); max-height:none; display:flex; flex-direction:column; }
  #excelImportModal .excel-options{ display:grid; grid-template-columns:minmax(0,2fr) minmax(0,1fr); gap:0 20px; align-items:start; }
  #excelImportModal .excel-panels{ flex:1 1 auto; min-height:280px; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.25fr); gap:18px; }
  #excelImportModal .excel-section{ display:flex; flex-direction:column; min-height:0; min-width:0; margin:0 !important; }
  #excelImportModal .excel-section > .toolbar{ flex:0 0 auto; }
  #excelImportModal .excel-table-box{ flex:1 1 auto; min-height:0; max-height:none; }
  #excelImportModal .excel-table-box thead th{ padding:7px 10px; }
  #excelImportModal .excel-table-box tbody td{ padding:5px 10px; font-size:13px; }
  #excelImportModal #excelWarnings{ flex:0 0 auto; max-height:90px; overflow:auto; }
  #excelImportModal .modal-actions-sticky{ margin-top:12px; }
  /* فشرده‌کردن بالای مودال تا بیشترین ارتفاع به جدول‌ها برسد */
  #excelImportModal h3{ margin:0 0 2px; }
  #excelImportModal .modal > p{ margin:2px 0 4px; }
  #excelImportModal #excelImportSummary{ margin-bottom:6px !important; }
  #excelImportModal .excel-options .field{ margin-bottom:6px; }
  #excelImportModal .excel-options .grid-2{ margin-bottom:0; }
  #excelImportModal .excel-options label[style*="display:flex"]{ margin-bottom:4px !important; }
  #excelImportModal .excel-quick-add-msg{ min-height:0; margin-top:0; }
  #excelImportModal .combo-trigger{ padding:8px 12px; }
  #excelImportModal .excel-section > h4{ margin:2px 0 4px !important; }
  #excelImportModal .excel-section > .toolbar{ margin-bottom:6px !important; }
  #excelImportModal .excel-section .toolbar input[type=text],
  #excelImportModal .excel-section .toolbar select{ padding:7px 10px; }
  /* ستون‌های جدول‌ها: عرض ثابت برای کد/موجودی، بقیه‌ی فضا برای نام (تا دو خط می‌شکند) */
  #excelImportModal .excel-table-box table{ table-layout:fixed; }
  #excelToCreateTable th.col-check{ width:64px; }
  #excelToCreateTable th.col-code{ width:130px; }
  #excelToCreateTable th.col-stock{ width:88px; }
  #excelMatchedTable th.col-code{ width:112px; }
  #excelMatchedTable th.col-stock{ width:150px; }
  #excelMatchedTable thead th, #excelMatchedTable tbody td{ padding-inline:10px; }
  /* بین ۱۰۲۵ تا ۱۲۷۹px عرض هر پنل کم است: ستون‌ها فشرده‌تر و عنوان موجودی دو خطی می‌شود تا نام کالا جا داشته باشد */
  @media (max-width:1279px){
    #excelMatchedTable th.col-code{ width:96px; }
    #excelMatchedTable th.col-stock{ width:104px; }
    #excelImportModal #excelMatchedTable thead th.col-stock{ white-space:normal; line-height:1.4; }
    #excelToCreateTable th.col-code{ width:112px; }
    #excelToCreateTable th.col-stock{ width:76px; }
    #excelMatchedTable thead th, #excelMatchedTable tbody td{ padding-inline:8px; }
  }
}
.modal-table-scroll.tall{ max-height:62vh; max-height:max(240px, calc(100dvh - 290px)); overflow:auto; }

/* ساختار فرم کالا: تک‌ستونه (موبایل/تبلت)؛ روی دسکتاپ دو‌ستونه در بلوک زیر */
.product-modal-layout{ display:block; }

/* نوار دکمه‌های «ذخیره / انصراف» در فرم‌های بلند همیشه پایین مودال در دسترس می‌ماند.
   مودالی که این نوار را دارد (.modal-has-sticky) پدینگ پایین ندارد تا نوار دقیقاً به لبه بچسبد. */
.modal.modal-has-sticky{ padding-bottom:0; }
.modal-actions-sticky{
  position:sticky; bottom:0; z-index:3;
  margin:18px calc(var(--modal-pad-x) * -1) 0;
  padding:12px var(--modal-pad-x) 16px;
  background:#fff; border-top:1px solid var(--line);
}

/* ---------- تبلت و دسکتاپ (≥۶۴۱px) ---------- */
@media (min-width:641px){
  .modal-backdrop{ padding:24px; }
  .modal{
    --modal-pad-x:28px; --modal-pad-y:24px;
    width:100%;
    max-width:620px;
    max-height:calc(100vh - 48px);
    max-height:calc(100dvh - 48px);
    padding:var(--modal-pad-y) var(--modal-pad-x);
  }
  .modal.modal-md{ max-width:820px; }
  .modal.modal-lg{ max-width:1080px; }
  .modal-lg .product-gallery{ grid-template-columns:minmax(0, 1fr) 120px; }
  .modal-lg .gallery-thumb{ width:108px; height:108px; }
  .modal textarea{ min-height:84px; }
  /* فاصله‌ی عمودی بین ردیف‌های فیلد را خود .field می‌دهد؛ فاصله‌ی grid فقط افقی باشد */
  .modal .grid-2{ column-gap:14px; row-gap:0; }
}

/* ---------- لپ‌تاپ/دسکتاپ (≥۹۰۰px): فرم کالا دو‌ستونه؛ اطلاعات سمت راست، عکس‌ها سمت چپ (RTL) ---------- */
@media (min-width:900px){
  .modal-lg .product-modal-layout{
    display:grid; grid-template-columns:minmax(0, 1.75fr) minmax(0, 1fr); align-items:start;
  }
  .modal-lg .product-modal-main{ padding-inline-end:28px; }
  .modal-lg .product-modal-media{ padding-inline-start:28px; border-inline-start:1px solid var(--line); }
  .product-modal-main textarea{ min-height:140px; }
  .product-modal-media .thumb-lg{ width:150px; height:150px; }
  .product-modal-media .gallery-admin-item,
  .product-modal-media .gallery-admin-item img{ width:84px; height:84px; }
}

/* ---------- دسکتاپ عریض (≥۱۱۰۰px): فیلدهای فرم کالا سه‌ستونه ---------- */
@media (min-width:1100px){
  .modal-lg .product-modal-main .grid-2{ grid-template-columns:repeat(3, minmax(0, 1fr)); }
}

/* ---------- مانیتور بزرگ (≥۱۶۰۰px): کمی عریض‌تر ---------- */
@media (min-width:1600px){
  .modal.modal-md{ max-width:900px; }
  .modal.modal-lg{ max-width:1240px; }
}

/* ---------- ارتفاع کم (لپ‌تاپ‌های کوتاه / پنجره‌ی لندسکیپ): فشرده‌تر ---------- */
@media (min-width:641px) and (max-height:700px){
  .modal-backdrop{ padding:12px; }
  .modal{ max-height:calc(100vh - 24px); max-height:calc(100dvh - 24px); --modal-pad-y:16px; }
}

/* ---------- موبایل (≤۶۴۰px): پدینگ کشو و بدون سقف ۴۸۰px قدیمی ---------- */
@media (max-width:640px){
  .modal{ --modal-pad-x:14px; --modal-pad-y:16px; max-width:100%; max-height:calc(100dvh - 20px); }
  .bulk-assign-modal{ max-width:100%; overflow:visible; }
  .bulk-assign-modal .combo-trigger{ min-height:54px; padding:12px 14px; }
  .bulk-assign-modal .combo-panel{ max-height:250px; }
  .modal-backdrop{ padding:10px; align-items:center; }
  .combo-panel{ max-height:240px; }
  .combo-item{ padding:12px 14px; white-space:normal; overflow-wrap:anywhere; line-height:1.6; }
  #pSpecifications, #specsModalBody{ text-align:right; word-break:break-word; }
  .modal .modal-actions-sticky{ padding-top:10px; padding-bottom:12px; }
  .modal .modal-actions-sticky > .btn{ flex:1 1 0; min-height:42px; }
}

/* ============================================================
   کمبوباکس سفارشی (رفع باگ نمایش/ارتفاع نامناسب select بومی مرورگر)
   select بومی (native <select>) در کروم/مرورگرها با CSS قابل کنترل نیست:
   عرض/ارتفاع/فونتِ لیستِ بازشو را مرورگر و سیستم‌عامل تعیین می‌کنند، نه صفحه.
   همین یعنی نمی‌شود مطمئن شد متن گزینه‌ها (مثلاً نام برندها) کامل و با
   ارتفاعِ مناسب نمایش داده می‌شود. به همین دلیل فیلد «برند» در ایمپورت اکسل
   هلو با یک کمبوباکس سبک و کاملاً سفارشی (این فایل + admin.js) جایگزین شد؛
   خودِ select برای نگه‌داشتن مقدار در DOM می‌ماند ولی مخفی است.
   ============================================================ */
.combo-native-hidden{ display:none !important; }

.combo{ position:relative; min-width:0; }
.combo-trigger{
  width:100%; display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:11px 12px; border:1px solid var(--line); border-radius:8px; font-size:14px;
  background:#fff; font-family:inherit; color:var(--ink); cursor:pointer; text-align:right;
}
.combo-trigger:focus, .combo-trigger.open{ outline:2px solid var(--brass); outline-offset:1px; border-color:var(--brass); }
.combo-trigger.combo-trigger-disabled, .combo-trigger:disabled{ opacity:.6; cursor:not-allowed; background:#f5f5fb; }
.combo-trigger-text{ flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:right; }
.combo-arrow{ flex:0 0 auto; color:var(--ink-soft); font-size:11px; transition:transform .15s ease; }
.combo-trigger.open .combo-arrow{ transform:rotate(180deg); }

.combo-panel{
  position:absolute; top:calc(100% + 6px); right:0; left:0; z-index:20;
  background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:var(--shadow-lg);
  max-height:320px; overflow:auto; padding:6px;
  animation:overlayFadeSlideIn .14s ease both;
}
.combo-panel.hidden{ display:none; }
@keyframes overlayFadeSlideIn{ from{ opacity:0; transform:translateY(-4px); } to{ opacity:1; transform:none; } }
@media (prefers-reduced-motion:reduce){ .combo-panel{ animation:none !important; } }
.combo-item{
  padding:10px 12px; border-radius:8px; font-size:14px; line-height:1.5; cursor:pointer;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:right;
}
.combo-item:hover, .combo-item.selected{ background:#f1effe; color:var(--brass-dark); }
.combo-panel.combo-panel-up{ top:auto; bottom:calc(100% + 6px); }  /* وقتی زیر دکمه جا نیست، رو به بالا باز می‌شود */
.toolbar > .combo{ min-width:150px; }  /* عرض ثابت‌تر در نوار فیلتر تا با عوض شدن گزینه، چیدمان نپرد */

/* حالت «در حال پردازش» دکمه/لیبل انتخاب فایل ایمپورت هلو؛ تا زمان پاسخ سرور
   دوباره‌کلیک‌شدن (و در نتیجه باز شدن دوبارهٔ پنجره‌ی انتخاب فایل) را می‌بندد. */
.is-busy{ opacity:.6; pointer-events:none; }

/* ============================================================
   کادر «مسئول فروش» (داشبورد همکار): تمام‌عرض و هم‌تراز با کارت‌ها/آمار زیرش
   در همه‌ی حالت‌ها (دسکتاپ، دسکتاپ عمودی، تبلت، موبایل). عرض و پدینگ دقیقاً مثل .container
   محاسبه می‌شود تا لبه‌ها با بقیه‌ی صفحه یکی باشد. (نسخه ۴.۰.۶)
   ============================================================ */
.sales-contact{ width:min(100%, 1240px); max-width:1180px; margin:16px auto -6px; padding-inline:clamp(16px, 3vw, 32px); display:block; }
.sc-card{
  display:flex; flex-direction:row; align-items:center; justify-content:flex-start; gap:14px;
  width:100%; max-width:none; padding:12px 18px;
}
.sc-row{ display:contents; }
.sc-avatar{ order:1; width:48px; height:48px; flex:0 0 48px; }
.sc-name{ order:2; flex:1 1 auto; min-width:0; text-align:right; font-size:14px; overflow-wrap:anywhere; }
.sc-name::before{ content:"کارشناس فروش شما"; display:block; font-size:11px; font-weight:600; color:var(--ink-soft); margin-bottom:2px; }
.sc-call{ order:3; width:44px; height:44px; flex:0 0 44px; }
.sc-call svg{ width:20px; height:20px; }
@media (min-width:1025px) and (max-width:1300px){ .sales-contact{ padding-inline:18px; } }
@media (min-width:768px) and (max-width:1024px) and (orientation:portrait){ .sales-contact{ width:min(100%, 900px); } }
@media (min-width:1600px){ .sales-contact{ width:min(100%, 1320px); } }
@media (max-width:640px){
  .sales-contact{ margin:12px 0 0; padding-inline:12px; }
  .sc-card{ padding:10px 14px; gap:12px; }
  .sc-avatar{ width:42px; height:42px; flex-basis:42px; }
  .sc-call{ width:42px; height:42px; flex-basis:42px; }
}

/* ============================================================
   نوار بالای موبایل (≤۶۴۰px) — داشبورد همکار: لوگو/عنوان، لینک فروشگاه، دکمه‌ی پروفایل،
   نام مجموعه و دکمه‌ی خروج در «یک خط». نام مجموعه اگر بلند بود با … کوتاه می‌شود.
   چون هم پنل همکار (۴ کنترل: فروشگاه، پروفایل، نام، خروج) و هم پنل مدیریت (۳ کنترل: نام،
   پروفایل، خروج) باید در یک خط جا شوند، هر دو فشرده می‌شوند. (نسخه ۴.۰.۹)
   ============================================================ */
@media (max-width:640px){
  .topbar{ flex-wrap:nowrap; gap:8px; }
  .topbar .brand{ flex:1 1 auto; min-width:0; gap:8px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .topbar .who{ width:auto; flex:0 1 auto; min-width:0; flex-wrap:nowrap; justify-content:flex-end; gap:8px; }
  .topbar .who > span{ flex:0 1 auto; min-width:0; max-width:110px; }
  .topbar button.logout, .topbar button.topbar-btn, .topbar .topbar-store-link{ flex:0 0 auto; white-space:nowrap; padding:6px 10px; font-size:12px; min-height:38px; }
  /* پنل مدیریت: سه کنترل (نام، پروفایل من، خروج) هم در یک خط؛ دکمه‌ها کمی فشرده‌تر */
  .topbar:has(#adminName) .who{ gap:6px; }
  .topbar:has(#adminName) .who > span{ max-width:72px; font-size:12px; }
  .topbar:has(#adminName) button.logout{ padding:6px 8px; font-size:11.5px; min-height:38px; }
  /* پنل همکار: چهار کنترل (فروشگاه، پروفایل، نام مجموعه، خروج) هم در یک خط؛ فشرده‌تر */
  .topbar:has(#companyName) .who{ gap:6px; }
  .topbar:has(#companyName) .who > span{ max-width:70px; font-size:12px; }
  .topbar:has(#companyName) button.logout,
  .topbar:has(#companyName) button.topbar-btn,
  .topbar:has(#companyName) .topbar-store-link{ padding:6px 8px; font-size:11.5px; min-height:38px; }
}
@media (max-width:380px){
  .topbar .who > span{ max-width:64px; }
  .topbar .brand{ font-size:12.5px; }  .topbar:has(#adminName) .who > span{ max-width:44px; }
  .topbar:has(#adminName) .brand .mark{ height:22px; }
  .topbar button.topbar-btn{ padding:6px 8px; font-size:11.5px; }
  .topbar:has(#companyName) .who > span{ max-width:38px; }
  .topbar:has(#companyName) .brand .mark{ height:22px; }
  .topbar:has(#companyName) button.logout,
  .topbar:has(#companyName) button.topbar-btn,
  .topbar:has(#companyName) .topbar-store-link{ padding:5px 7px; font-size:11px; }
}

/* ============================================================
   فیلدهای مدرن‌تر (نسخه ۴.۰.۱۲)
   قبلاً فقط فیلدهای داخل .field استایل داشتند و بقیه (مثل «نام پیشنهادی» و «معرفی پیشنهادی»
   هوش مصنوعی، فیلتر وضعیت همکاران و هر فیلد تازه‌ای که در آینده ساخته شود) ظاهر پیش‌فرض
   مرورگر را داشتند: فونت Arial، متن کوچک، گوشه‌ی تیز. این بلوک یک پایه‌ی سراسری با
   :where (اولویت صفر) می‌گذارد؛ پس هر فیلدی که استایل اختصاصی دارد (.field، .qty-input، …)
   دست‌نخورده می‌ماند و بقیه خودکار فونت وزیر، متن بزرگ‌تر، گوشه‌ی گرد و حالت فوکوس مدرن می‌گیرند.
   ============================================================ */
:where(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=range]):not([type=color]), select, textarea){
  font-family:inherit; font-size:14.5px; line-height:1.6; color:var(--ink);
  padding:10px 14px; background:#fff; border:1px solid #dcdaf0; border-radius:10px;
  transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
:where(input, select, textarea)::placeholder{ color:#9a9cb8; opacity:1; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea):hover:not(:disabled){ border-color:#c4c1e6; }
:where(input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea):focus{
  outline:none; border-color:var(--brass); box-shadow:0 0 0 3px rgba(var(--brass-rgb), .16);
}
:where(input, select, textarea):disabled{ background:#f5f5fb; color:var(--ink-soft); cursor:not-allowed; }
:where(input[type=checkbox], input[type=radio]){ accent-color:var(--brass); cursor:pointer; }

/* فیلدهای قدیمیِ استایل‌دار هم هم‌اندازه و هم‌حال‌وهوا شوند */
.field input, .field select, .field textarea, .toolbar input[type=text], .toolbar select{ font-size:14.5px; border-radius:10px; }
.field input:focus, .field select:focus, .field textarea:focus{ outline:none; box-shadow:0 0 0 3px rgba(var(--brass-rgb), .16); }
.combo-trigger{ font-size:14.5px; border-radius:10px; }
.qty-input{ font-size:14.5px; min-height:38px; border-radius:8px; }
.price-input{ font-size:14px; min-height:38px; border-radius:8px; }

/* فیلدهای ساخته‌شده توسط جاوااسکریپت (پیشنهاد نام / معرفی هوش مصنوعی) */
.normalize-suggested{ font-size:15px; min-height:46px; padding:10px 14px; border-radius:10px; min-width:0; }
.suggest-desc-suggested{ font-size:14.5px; line-height:1.9; min-height:110px; padding:12px 14px; border-radius:10px; min-width:0; resize:vertical; }
#normalizeNamesTable tbody td, #suggestDescriptionsTable tbody td{ font-size:14.5px; }
.normalize-select, .excel-create-select, .product-select{ width:18px; height:18px; }

/* موبایل: متن فیلد حداقل ۱۶px تا مرورگرهای iOS هنگام فوکوس صفحه را بزرگ‌نمایی نکنند */
@media (max-width:640px){
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), select, textarea{ font-size:16px; }
}


/* ============================================================
   پیش‌نمایش ایمپورت اکسل — جدول‌ها (ترازبندی، ستون‌ها، موبایل)
   ============================================================ */
#excelImportModal .excel-table-box{ border:1px solid var(--line); border-radius:12px; background:#fff; }
#excelImportModal .excel-table-box thead th{ white-space:nowrap; font-size:12.5px; }
/* عنوان و مقدار هر ستون هم‌تراز: انتخاب/موجودی وسط، کد و نام راست (شروع خط فارسی) */
#excelImportModal th.col-check, #excelImportModal td.col-check,
#excelImportModal th.col-stock, #excelImportModal td.col-stock{ text-align:center; }
#excelImportModal td.col-code{ text-align:right; color:var(--ink-soft); font-size:12.5px; }
#excelImportModal td.col-name{ line-height:1.7; overflow-wrap:anywhere; }
#excelImportModal td.col-check input{ vertical-align:middle; }

/* موجودی در جدول مطابق: «قبل ← جدید»؛ افزایش سبز، کاهش قرمز، بدون تغییر کم‌رنگ */
#excelImportModal .stock-num{ font-family:'IBM Plex Mono','Vazirmatn',monospace; font-variant-numeric:tabular-nums; direction:ltr; unicode-bidi:isolate; }
#excelImportModal .stock-old, #excelImportModal .stock-same{ color:var(--ink-soft); }
#excelImportModal .stock-arrow{ margin:0 7px; color:#a3a5c2; }
#excelImportModal .stock-new{ font-weight:700; }
#excelImportModal .stock-new.up{ color:var(--teal); }
#excelImportModal .stock-new.down{ color:var(--red); }

@media (max-width:1024px){
  #excelImportModal .modal-table-scroll.excel-table-box{ max-height:min(48vh, 440px); }
  #excelImportModal .excel-table-box tbody tr:last-child{ margin-bottom:0; }
  /* در کارت‌های موبایل، عنوان سمت راست و مقدار سمت چپ باشد (کلاس .num جهت را LTR می‌کند و ترتیب را برعکس می‌کرد) */
  #excelImportModal tbody td.num{ direction:rtl; unicode-bidi:normal; }

  /* جدول مطابق روی موبایل/تبلت: کارت فشرده — نام بالا (تمام‌عرض)، زیرش کد راست و موجودی چپ */
  #excelMatchedTable tbody tr{ display:flex; flex-wrap:wrap; align-items:center; gap:4px 12px; padding:10px 12px; }
  #excelMatchedTable tbody td{ width:auto; min-height:0; padding:0; border-bottom:none; justify-content:flex-start; gap:6px; }
  #excelMatchedTable tbody td.col-name{ order:1; flex:1 0 100%; font-size:13.5px; font-weight:600; }
  #excelMatchedTable tbody td.col-name::before{ display:none; }
  #excelMatchedTable tbody td.col-code{ order:2; margin-inline-end:auto; }
  #excelMatchedTable tbody td.col-stock{ order:3; }
  #excelMatchedTable tbody tr:has(> td[colspan]){ display:block; }
  #excelMatchedTable tbody td[colspan]{ width:100%; padding:6px 0; }
}

/* ============================================================
   نسخه ۴.۱
   ۱) نام کالا و پیام «قیمت صفر / تخفیف» در کارت موبایل و تبلت: هر دو داخل یک بلوک (.product-name-wrap)
      قرار می‌گیرند تا در چیدمان flex کارت، دو آیتم جدا و به‌هم‌ریخته نشوند؛ نام کالا زیر برچسب و
      تمام‌عرض می‌نشیند و پیام قرمز دقیقاً زیر نام می‌آید.
   ۲) فیلتر وضعیت در «مدیریت همکاران»: کشوی گزینه‌ها همعرض خود select باز می‌شود، پس select باید
      به‌اندازه‌ی کافی پهن باشد تا «در انتظار تأیید / تأیید شده / رد شده» کامل دیده شود.
   ۳) کارت پشتیبان در صفحه‌ی ورود/ثبت‌نام.
   ============================================================ */
.product-name-wrap{ min-width:0; }
.product-title{ display:block; }
.zero-price-note, .price-note{ display:block; margin-top:3px; font-size:11px; font-weight:600; line-height:1.6; color:var(--red); }
.price-cell{ display:flex; flex-direction:column; align-items:center; gap:3px; }
.price-input.inline-discount-price::placeholder{ font-family:'Vazirmatn',sans-serif; font-size:11px; }
.cell-value{ min-width:0; overflow-wrap:anywhere; }

.partner-header-actions{ display:flex; gap:8px; align-items:stretch; }
/* select بومی با enhanceCombo مخفی و با یک .combo جایگزین می‌شود؛ پس عرض باید روی .combo تعیین شود
   (لیست بازشو هم‌عرض همین wrapper است و اگر wrapper کوچک باشد گزینه‌ها با «…» بریده می‌شوند). */
.partner-header-actions > .combo{ flex:0 0 150px; width:150px; min-width:0; }
.partner-header-actions .btn{ flex:0 0 auto; white-space:nowrap; }
/* فیلتر وضعیت هم‌اندازه‌ی دکمه‌ی «+ همکار جدید»: ارتفاع، فونت و گردی گوشه یکسان */
.partner-header-actions > .combo .combo-trigger{ min-height:36px; height:100%; padding:6px 10px; font-size:12.5px; border-radius:6px; }
/* متن گزینه‌های کشوی همه‌ی کمبوباکس‌ها: به‌جای بریده‌شدن با «…»، اگر جا نبود در چند خط شکسته شود. */
.combo-item{ white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:anywhere; }

@media (max-width:1024px){
  /* نام کالا مثل بقیه‌ی فیلدهای کارت: برچسب «نام کالا» سمت راست، مقدار (نام + پیام قرمز) سمت چپ؛ فشرده و تک‌ردیفی */
  .card-body tbody td.product-name{ flex-direction:row; align-items:flex-start; justify-content:space-between; gap:10px; }
  .card-body tbody td.product-name::before{ text-align:right; padding-top:2px; }
  .card-body tbody td.product-name .product-name-wrap{ flex:1 1 auto; width:auto; min-width:0; text-align:left; font-size:13px; line-height:1.6; }
  .card-body tbody td.product-name .zero-price-note{ margin-top:1px; font-size:11px; }
  /* هر ستون قیمت در کارت موبایل یک عرض مشخص دارد؛ بنابراین فیلد و تیک تخفیف
     هر دو دقیقاً در مرکز همان ستون قرار می‌گیرند و تیک به لبه‌ی کارت نمی‌چسبد. */
  .card-body tbody td[data-label^="قیمت"] .price-cell{
    width:130px;
    max-width:44vw;
    flex:0 0 auto;
    align-items:center;
  }
  .card-body tbody td[data-label^="قیمت"] .inline-discount-toggle{
    display:flex;
    width:100%;
    min-height:24px;
    margin:0;
    align-items:center;
    justify-content:center;
  }
  .cell-value{ text-align:left; }
}

@media (max-width:640px){
  /* موبایل: فیلتر و دکمه کنار هم در یک ردیف، هم‌ارتفاع و متناسب (فیلتر کمی پهن‌تر، چون متنش بلندتر است) */
  .partner-header-actions{ flex-wrap:nowrap; gap:8px; }
  .partner-header-actions > .combo{ flex:1 1 0; width:auto; min-width:0; }
  .partner-header-actions > .combo .combo-trigger{ min-height:42px; padding:6px 10px; font-size:13px; }
  .partner-header-actions .btn{ flex:0 0 auto; width:auto !important; min-height:42px; padding:6px 12px; font-size:13px; }
}

/* کارت پشتیبانی (صفحه‌ی ورود و ثبت‌نام) */
.support-card{
  display:flex; align-items:center; gap:14px; margin-top:18px; padding:12px 16px;
  background:var(--teal-bg); border:1px solid #c8dfd4; border-radius:12px;
}
.support-avatar{
  width:46px; height:46px; flex:0 0 46px; border-radius:50%; background:#fff; color:var(--teal);
  border:1px solid #c8dfd4; display:inline-flex; align-items:center; justify-content:center;
}
.support-avatar svg{ width:22px; height:22px; }
.support-text{ flex:1 1 auto; min-width:0; display:flex; flex-direction:column; gap:2px; text-align:right; }
.support-label{ font-size:11px; font-weight:600; color:var(--ink-soft); }
.support-name{ font-size:14px; font-weight:700; color:var(--ink); }
.support-number{
  align-self:flex-start; font-size:14px; font-weight:700; letter-spacing:.3px; color:var(--ink);
  text-decoration:none;
}
.support-number:hover{ color:var(--teal); }
.support-call{
  width:44px; height:44px; flex:0 0 44px; border-radius:50%; background:var(--teal); color:#fff;
  display:inline-flex; align-items:center; justify-content:center; text-decoration:none;
  box-shadow:0 2px 6px rgba(14,159,117,.35);
}
.support-call:hover{ filter:brightness(.93); }
.support-call svg{ width:20px; height:20px; }
@media (max-width:640px){
  .support-card{ padding:10px 14px; gap:12px; }
}

/* اولویت نهایی نسخه 5.0 برای پنل مدیریت و همکار */
@media (max-width:640px){
  .topbar{ display:block; padding:12px 14px; }
  .topbar .brand{ display:grid; grid-template-columns:minmax(0, 1fr) auto minmax(0, 1fr); min-height:40px; gap:8px; font-size:clamp(11px, 3vw, 14px); }
  .topbar .brand .brand-title{ grid-column:1; grid-row:1; text-align:right; white-space:normal; }
  .topbar .brand .mark{ grid-column:2; grid-row:1; height:30px; justify-self:center; }
  .topbar .who{ width:100%; display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:7px; margin-top:10px; }
  .topbar .who > span{ grid-column:1 / -1; max-width:none; text-align:center; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar button.logout, .topbar button.topbar-btn, .topbar .topbar-store-link{ width:100%; min-width:0; min-height:40px; padding:6px 5px; font-size:11.5px; text-align:center; }
}

/* Product image cards: phone, tablet, laptop and wide desktop. */
.product-modal-media{ display:grid; gap:16px; min-width:0; }
.media-card{ min-width:0; padding:16px; border:1px solid var(--line); border-radius:16px; background:var(--paper-card); }
.media-card-heading{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:14px; }
.media-card-heading label{ margin:0; color:var(--ink); font-size:13px; font-weight:700; }
.media-badge{ flex-shrink:0; padding:4px 9px; border-radius:8px; background:rgba(var(--brass-rgb),.08); color:var(--brass-dark); font-size:11px; font-weight:700; }
.media-main-preview{ display:flex; align-items:center; justify-content:center; min-height:150px; padding:12px; margin-bottom:12px; border:1px solid var(--line); border-radius:12px; background:var(--paper); }
.media-main-preview img{ display:block; width:100%; height:160px; object-fit:contain; border-radius:8px; }
.media-empty{ display:block; padding:14px 4px; color:var(--ink-soft); font-size:12px; line-height:1.9; text-align:center; }
.media-picker{ position:relative; display:flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:12px 8px; margin:0; border:1px dashed rgba(var(--brass-rgb),.45); border-radius:10px; background:rgba(var(--brass-rgb),.045); color:var(--brass-dark); font-size:12px; font-weight:700; cursor:pointer; transition:background .15s,border-color .15s; }
.media-picker:hover{ background:rgba(var(--brass-rgb),.1); border-color:var(--brass); }
.media-picker:focus-within{ outline:3px solid rgba(var(--brass-rgb),.3); outline-offset:3px; }
.media-picker input[type=file]{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); border:0; }
.media-picker svg{ width:20px; height:20px; flex-shrink:0; }
.media-picker.is-disabled{ background:var(--paper); border-color:var(--line); color:var(--ink-soft); cursor:not-allowed; }
.media-hint{ margin:9px 0 0; color:var(--ink-soft); font-size:10.5px; line-height:1.9; }
.media-error{ margin:8px 0 0; color:var(--red); font-size:12px; line-height:1.8; }
.media-error:empty{ display:none; }
.product-modal-media .gallery-admin-preview{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin:0 0 14px; }
.product-modal-media .gallery-admin-preview > .media-empty{ grid-column:1 / -1; padding:24px 8px; border:1px dashed var(--line); border-radius:10px; }
.product-modal-media .gallery-admin-item{ width:100%; height:auto; aspect-ratio:1; min-width:0; }
.product-modal-media .gallery-admin-item img{ display:block; width:100%; height:100%; object-fit:contain; padding:5px; border-radius:10px; background:var(--paper); }
.product-modal-media .gallery-admin-item button{ display:grid; place-items:center; top:3px; left:3px; width:30px; height:30px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--red); font-size:20px; line-height:1; box-shadow:0 2px 5px rgba(var(--ink-rgb),.08); }
.product-modal-media .gallery-admin-item button:hover{ background:var(--red-bg); border-color:var(--red); }
.product-modal-media .gallery-admin-item button:focus-visible{ outline:3px solid var(--brass); outline-offset:2px; }
.product-modal-media .gallery-admin-item button:disabled{ opacity:.5; cursor:wait; }
.media-pending{ position:absolute; bottom:5px; right:5px; padding:1px 6px; border-radius:5px; background:var(--teal-bg); color:var(--teal); font-size:10px; }
@media (max-width:640px){
  .product-modal-media{ gap:12px; }
  .media-card{ padding:14px; }
  .media-main-preview img{ height:150px; }
  .product-modal-media .gallery-admin-item button{ width:34px; height:34px; }
}
@media (min-width:641px) and (max-width:899px){
  .product-modal-media{ grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
}
@media (min-width:900px) and (max-width:1099px){
  .modal-lg .product-modal-layout{ grid-template-columns:minmax(0,1.55fr) minmax(0,1fr); }
  .modal-lg .product-modal-media{ padding-inline-start:18px; }
  .media-card{ padding:12px; }
  .media-main-preview{ min-height:125px; }
  .media-main-preview img{ height:125px; }
  .product-modal-media .gallery-admin-preview{ grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (min-width:1100px){
  .media-main-preview img{ height:185px; }
  .media-card{ padding:16px; }
}
/* Partner cart shares the storefront item layout in a compact dialog. */
.partner-cart{ position:fixed; inset:0; margin:auto; width:400px; max-width:calc(100vw - 24px); max-height:calc(100dvh - 32px); padding:0; border:1px solid var(--line); border-radius:16px; background:#fff; color:var(--ink); box-shadow:0 20px 60px #181a3033; overflow:hidden; }
.partner-cart[open]{ display:flex; flex-direction:column; animation:overlayScaleIn .22s cubic-bezier(.4,0,.2,1) both; }
.partner-cart::backdrop{ background:rgba(26,29,46,.45); animation:overlayFadeIn .18s ease both; }
.partner-cart .drawer-head,.partner-cart .drawer-foot{ flex-shrink:0; padding:16px 20px; }
.partner-cart .drawer-head strong{ font-size:17px; }
.partner-cart .drawer-body{ min-height:0; padding:16px 20px; overscroll-behavior:contain; }
.partner-cart .drawer-foot[hidden]{ display:none; }
.partner-cart-open{ overflow:hidden; }
.partner-cart-open .cart-fab{ visibility:hidden; }
.partner-cart-empty{ text-align:center; padding:40px 0; color:var(--ink-soft); }
.partner-cart-empty>span{ font-size:40px; }
.partner-cart-empty p{ margin:12px 0 0; font-size:14px; }
.partner-cart-item{ display:flex; gap:12px; padding:12px 0; border-bottom:1px solid var(--line); align-items:flex-start; }
.partner-cart-item:last-child{ border-bottom:0; }
.partner-cart-image{ width:64px; height:64px; flex:0 0 64px; object-fit:contain; padding:4px; border:1px solid var(--line); border-radius:8px; background:#f8f9fc; }
.partner-cart-no-image{ display:flex; align-items:center; justify-content:center; font-size:10px; color:var(--ink-soft); }
.partner-cart-info{ flex:1; min-width:0; }
.partner-cart-name{ font-size:13px; font-weight:600; line-height:1.6; margin-bottom:4px; overflow-wrap:anywhere; }
.partner-cart-price{ font-size:13px; font-weight:700; color:#5541e0; margin-bottom:4px; }
.partner-cart-controls{ display:flex; width:max-content; align-items:center; gap:2px; border:1px solid var(--line); border-radius:8px; overflow:hidden; }
.partner-cart-controls button{ width:26px; height:26px; border:0; background:#f4f5f9; color:var(--ink); font:inherit; font-size:14px; font-weight:700; cursor:pointer; }
.partner-cart-controls span{ min-width:26px; padding-inline:4px; text-align:center; font-size:12px; font-weight:700; }
.partner-cart-remove{ background:none; border:0; color:var(--red); font:inherit; font-size:11.5px; padding:4px 0; margin-top:4px; cursor:pointer; }
.partner-cart .drawer-foot .btn{ padding:9px 14px; font-size:13px; }
@media(max-height:500px){ .partner-cart .drawer-head,.partner-cart .drawer-foot{ padding:8px 14px; } }

/* 5.1: independent catalog visibility controls */
.product-visibility { display:grid; grid-template-columns:minmax(0,1fr); gap:6px; margin-top:10px; font-size:12px; font-weight:normal; direction:rtl; text-align:right; }
.product-visibility label { display:flex; align-items:center; gap:8px; min-height:40px; padding:7px 9px; border:1px solid var(--line); border-radius:8px; background:#fff; line-height:1.6; cursor:pointer; }
.product-visibility label:has(input:checked) { background:var(--teal-bg); border-color:#bbded3; }
.product-visibility label:focus-within { outline:2px solid var(--brass); outline-offset:2px; }
.product-visibility input[type="checkbox"] { width:18px; height:18px; margin:0; flex:0 0 18px; accent-color:var(--teal); }
.visibility-bulk-bar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)) auto; align-items:end; gap:12px; padding:16px; margin:12px 0; border:1px solid var(--line); border-radius:12px; background:var(--paper); }
.visibility-bulk-heading { grid-column:1 / -1; font-size:13px; font-weight:700; text-align:right; }
.visibility-bulk-field { display:flex; flex-direction:column; gap:6px; min-width:0; }
.visibility-bulk-field > label { display:block; margin:0; font-size:12px; text-align:right; }
.visibility-bulk-field > select, .visibility-bulk-field > .combo { width:100%; min-width:0; }
.visibility-bulk-field .combo-trigger { min-height:46px; padding:10px 12px; font-size:13px; }
.visibility-bulk-field .combo-item { min-height:44px; display:flex; align-items:center; }
#bulkVisibilityButton { min-height:46px; margin:0; white-space:normal; }
#bulkVisibilityStatus { grid-column:1 / -1; font-size:12px; line-height:1.7; color:var(--teal); }
#bulkVisibilityStatus:empty { display:none; }
.visibility-help { margin:10px 0 14px; font-size:12px; line-height:1.9; color:var(--ink-soft); }
@media (max-width:1024px) {
  #productsBody td.product-name { display:block; }
  #productsBody td.product-name::before { display:block; margin-bottom:6px; }
  #productsBody td.product-name .product-name-wrap { width:100%; text-align:right; }
  #productsBody .product-title { line-height:1.9; }
  .product-visibility { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .product-visibility label { min-height:46px; font-size:12px; }
}
@media (max-width:640px) {
  .visibility-bulk-bar { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 10px; padding:12px; }
  #bulkVisibilityButton { grid-column:1 / -1; width:100%; }
  .product-visibility { grid-template-columns:minmax(0,1fr); }
  .product-visibility label { justify-content:space-between; flex-direction:row-reverse; padding:10px 12px; }
}

.price-updating { display:inline-block; font-family:inherit; font-size:12px; font-weight:600; line-height:1.9; color:var(--ink-soft); white-space:normal; direction:rtl; }
.product-visibility:has(.product-status-toggle){display:flex}
.product-status-toggle{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-width:92px;min-height:40px;padding:7px 12px;border:1px solid var(--line);border-radius:9px;background:#f5f6fa;color:var(--ink-soft);font:inherit;cursor:pointer}
.product-status-toggle[aria-checked="true"]{background:var(--teal-bg);border-color:#bbded3;color:var(--teal)}
.product-status-dot{width:7px;height:7px;border-radius:50%;background:currentColor}
.product-status-toggle:focus-visible{outline:2px solid var(--brass);outline-offset:2px}
.product-status-toggle:disabled{opacity:.6;cursor:wait}
@media(max-width:1024px){.product-status-toggle{min-height:44px}}
