/* ============================================================
   سکه مجید — استایل موبایل و نوار ناوبری پایین (v3)
   ------------------------------------------------------------
   - نوار ناوبری پایین شناور و مدرن (فقط عرض ≤ ۸۶۰px)
   - شیت حساب کاربری: بخش کاربر هدر در موبایل حذف و به تب
     «حساب من» منتقل شد — باکس شناور انیمیشنی بالای ناوبری
   - فیکس سرریز افقی کل صفحه (گرید نوار پایین)
   - جدول‌های واکنش‌گرا (کارت‌های عمودی با برچسب ستون)
   - بازطراحی کارت سفارش، پنل کاربر و پنل مدیریت در موبایل
   - پشتیبانی از ناحیه امن آیفون (safe-area / ناچ)
   ============================================================ */

/* ============================================================
   ۰) محافظ سرریز افقی — هیچ صفحه‌ای نباید سوای دیپاره شود
   (clip تا position: sticky را خراب نکند؛ مرورگرهای قدیمی hidden)
   ============================================================ */
html { overflow-x: clip; }
@supports not (overflow: clip) { html { overflow-x: hidden; } }

/* ============================================================
   ۱) نوار ناوبری پایین — جزیره شناور شیشه‌ای
   ============================================================ */

/* کارت‌های قیمت موبایل — فقط در موبایل نمایان (پایین‌تر) */
#prices-cards { display: none; }

#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  display: none; /* فقط موبایل — پایین‌تر فعال می‌شود */
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--header-bg, rgba(7, 7, 7, 0.88));
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid var(--border-gold, rgba(212, 175, 55, 0.22));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
  overflow: hidden; /* محتوی پهن هرگز صفحه را نمی‌کِشد */
}

.bn-inner {
  display: grid;
  /* ⚠️ minmax(0,1fr) حیاتی است: بدون آن آیتم‌ها زیر min-content کوچک نمی‌شوند
     و کل صفحه دچار سرریز افقی می‌شد (باگ نسخه قبل) */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  max-width: 560px;
  margin-inline: auto;
}

.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;          /* اجازه کوچک‌شدن در گرید */
  min-height: 54px;
  padding: 6px 2px 4px;
  border-radius: 14px;
  color: var(--text-3, #8a8a8a);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  transition: color 0.18s, background 0.18s, transform 0.18s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.bn-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.bn-item:active { transform: scale(0.94); }

.bn-item.active {
  color: var(--gold-2, #f2c94c);
  background: var(--gold-soft, rgba(212, 175, 55, 0.12));
}

.bn-item.active svg {
  transform: translateY(-1px);
  filter: drop-shadow(0 2px 8px rgba(212, 175, 55, 0.35));
}

/* نشانگر خط طلایی بالای آیتم فعال */
.bn-item.active::before {
  content: "";
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--gold-grad, linear-gradient(135deg, #f2c94c, #d4af37));
  margin-bottom: 1px;
}

.bn-item:not(.active)::before {
  content: "";
  width: 18px;
  height: 3px;
  margin-bottom: 1px;
}

/* انیمیشن ورود */
@keyframes bnUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============================================================
   ۱-ب) شیت حساب کاربری — بالای نوار پایین (فقط موبایل)
   ------------------------------------------------------------
   در موبایل بخش کاربر هدر مخفی است؛ تب «حساب من» این شیت
   شناور را با انیمیشن fade-up تدریجی باز می‌کند.
   ============================================================ */

/* پس‌زمینه تیره‌کننده صفحه — زیر نوار پایین می‌ماند تا ناوبری دسترس‌پذیر بماند */
.as-backdrop {
  position: fixed;
  inset: 0;
  z-index: 790; /* زیر نوار پایین (۸۰۰) */
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: asFadeIn 0.25s ease;
}
.as-backdrop.closing { opacity: 0; transition: opacity 0.22s ease; }

/* شیت شناور */
.account-sheet {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  inset-inline: 10px;
  max-width: 560px;
  margin-inline: auto;
  z-index: 810; /* بالای نوار پایین */
  background: var(--panel-2, #181818);
  border: 1px solid var(--border-gold, rgba(212, 175, 55, 0.22));
  border-radius: 22px;
  box-shadow: 0 -14px 52px rgba(0, 0, 0, 0.5), var(--shadow-gold, none);
  padding: 6px 12px 12px;
  animation: sheetUp 0.34s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100vh - 160px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.account-sheet.closing {
  animation: sheetDown 0.24s ease forwards;
}

@keyframes sheetUp {
  from { transform: translateY(26px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes sheetDown {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to { transform: translateY(22px) scale(0.96); opacity: 0; }
}
@keyframes asFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* دستگیره بالای شیت */
.as-grip {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: var(--border-gold, rgba(212, 175, 55, 0.35));
  margin: 6px auto 10px;
}

/* هدر شیت — آواتار + نام + دکمه بستن */
.as-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 14px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  margin-bottom: 8px;
  min-width: 0;
}
.as-head-info { min-width: 0; flex: 1; }
.as-name {
  font-weight: 800;
  font-size: 15.5px;
  color: var(--text, #f2f2f2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-mail {
  font-size: 12px;
  color: var(--text-3, #8a8a8a);
  direction: ltr;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.as-sub {
  font-size: 12px;
  color: var(--text-3, #8a8a8a);
  line-height: 1.8;
}
.as-avatar { width: 46px; height: 46px; font-size: 20px; }
.as-avatar-guest {
  display: grid;
  place-items: center;
  background: var(--gold-soft, rgba(212, 175, 55, 0.12));
  border: 1px solid var(--border-gold, rgba(212, 175, 55, 0.22));
  color: var(--gold-2, #f2c94c);
}
.as-avatar-guest svg { width: 22px; height: 22px; }
.as-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  color: var(--text-3, #8a8a8a);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.18s;
}
.as-close:active { transform: scale(0.9); color: var(--text, #f2f2f2); }
.as-close svg { width: 16px; height: 16px; }

/* ردیف‌های منو */
.as-items { display: flex; flex-direction: column; gap: 2px; }
.as-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 10px 12px;
  border-radius: 14px;
  background: none;
  border: 0;
  color: var(--text, #f2f2f2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s, transform 0.16s;
}
.as-item:active { background: var(--gold-soft, rgba(212, 175, 55, 0.12)); transform: scale(0.98); }
.as-item > svg {
  width: 20px;
  height: 20px;
  color: var(--gold-2, #f2c94c);
  flex-shrink: 0;
}
.as-item > span:first-child:not(.as-end):not(.as-switch) { min-width: 0; }

/* انتهای ردیف — بج + فلش */
.as-end {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3, #8a8a8a);
  flex-shrink: 0;
}
.as-end svg { width: 15px; height: 15px; }

/* بج اعلان‌های خوانده‌نشده داخل شیت */
.as-badge {
  display: none;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: linear-gradient(135deg, #f2c94c, #d4af37);
  color: #241a04;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(212, 175, 55, 0.45);
}
.as-badge.show { display: inline-block; }

/* ردیف تم — سوییچ CSS خالص همگام با data-theme */
.as-theme-ic {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--gold-2, #f2c94c);
  flex-shrink: 0;
}
.as-theme-ic svg { width: 20px; height: 20px; }
.as-theme-ic .icon-sun { display: none; }
:root[data-theme="light"] .as-theme-ic .icon-sun { display: block; }
:root[data-theme="light"] .as-theme-ic .icon-moon { display: none; }

.as-switch {
  margin-inline-start: auto;
  width: 44px;
  height: 26px;
  border-radius: 99px;
  background: var(--panel-3, #1f1f1f);
  border: 1px solid var(--border, #2a2a2a);
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}
.as-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold-grad, linear-gradient(135deg, #f2c94c, #d4af37));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
:root[data-theme="light"] .as-switch {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--border-gold, rgba(212, 175, 55, 0.35));
}
:root[data-theme="light"] .as-switch::after { transform: translateX(-18px); }

/* دکمه‌های ورود/ثبت‌نام مهمان */
.as-auth-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 4px 4px;
}
.as-auth-btns .btn { min-height: 46px; }
.as-sep {
  height: 1px;
  background: var(--border, #2a2a2a);
  margin: 12px 4px 8px;
}

/* دکمه خروج */
.as-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px solid rgba(229, 83, 75, 0.4);
  background: var(--red-soft, rgba(229, 83, 75, 0.14));
  color: var(--red, #e5534b);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.16s;
}
.as-logout:active { transform: scale(0.97); }
.as-logout svg { width: 18px; height: 18px; }

/* زیرنمای اعلان‌ها */
.as-sub-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 12px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  margin-bottom: 4px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text, #f2f2f2);
}
.as-sub-head > span { flex: 1; }
.as-back {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border, #2a2a2a);
  background: transparent;
  color: var(--text-3, #8a8a8a);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.as-back:active { transform: scale(0.9); color: var(--text, #f2f2f2); }
.as-back svg { width: 17px; height: 17px; }
.as-notif-list { max-height: 46vh; overflow-y: auto; }

/* ورود تدریجی ردیف‌ها — هر ردیف با تأخیر کوتاه (استاگر افکت) */
.account-sheet .as-head,
.account-sheet .as-item,
.account-sheet .as-logout,
.account-sheet .as-auth-btns {
  animation: asItemIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.account-sheet .as-item:nth-child(1), .account-sheet .as-head { animation-delay: 0.05s; }
.account-sheet .as-item:nth-child(2) { animation-delay: 0.09s; }
.account-sheet .as-item:nth-child(3) { animation-delay: 0.13s; }
.account-sheet .as-item:nth-child(4) { animation-delay: 0.17s; }
.account-sheet .as-item:nth-child(5) { animation-delay: 0.21s; }
.account-sheet .as-logout, .account-sheet .as-auth-btns { animation-delay: 0.24s; }

@keyframes asItemIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* آواتار کاربر داخل تب «حساب من» نوار پایین */
.bn-ic { display: grid; place-items: center; }
.bn-ic svg { width: 22px; height: 22px; }
.bn-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold-grad, linear-gradient(135deg, #f2c94c, #d4af37));
  color: #1a1405;
  font-size: 11.5px;
  font-weight: 800;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* حالت باز شیت روی تب حساب */
button.bn-item {
  background: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}
.bn-item.sheet-open {
  color: var(--gold-2, #f2c94c);
  background: var(--gold-soft, rgba(212, 175, 55, 0.12));
}

/* شیت فقط در موبایل معنی دارد — در دسکتاپ هرگز نمایش داده نشود */
@media (min-width: 861px) {
  .account-sheet, .as-backdrop { display: none !important; }
}

/* تبلت — ترک گرید مدیریت هم قبل از ۸۶۰ ایمن شود */
@media (max-width: 1080px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-grid > div { min-width: 0; }
}

/* ============================================================
   ۲) فعال‌سازی موبایل — عرض ≤ ۸۶۰px
   ============================================================ */
@media (max-width: 860px) {

  /* نمایش ناوبری پایین و حذف همبرگری */
  #bottom-nav { display: block; animation: bnUp 0.3s ease; }
  .nav-toggle { display: none !important; }
  .main-nav { display: none !important; }

  /* بخش کاربر هدر (چیپ مدیر سامانه، زنگ، تم) در موبایل حذف می‌شود —
     همه در شیت «حساب من» بالای نوار پایین در دسترس است */
  .header-side { display: none !important; }

  /* سوییچ پنل — تصویر هیرو در کل بازه موبایل/تبلت (≤860) حذف می‌شود
     (v19: قبلاً فقط ≤640 اعمال می‌شد و در عرض‌های میانی کار نمی‌کرد) */
  .hero-visual.hero-mobile-off { display: none; }

  /* جا باز کردن برای نوار پایین — فقط صفحات سایت (پنل مدیریت نوار پایین ندارد) */
  body:not(.adm-body) { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }

  /* توست بالای نوار پایین قرار بگیرد */
  body:not(.adm-body) #toast-root { bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }

  /* هدر جمع‌وجورتر — min-height هم بازنویسی می‌شود چون در CSS بر height
     اولویت دارد؛ بدون این، هدر ۷۸px می‌ماند و لوگو ۸px پایین‌تر از وسط
     دیده می‌شد (رفع «لوگو وسط عمودی نیست» — پاسخ کارفرما v19) */
  .site-header { height: 62px; }
  .header-inner { height: 62px; min-height: 62px; gap: 10px; }
  .brand-logo { width: 38px; height: 38px; }
  /* لوگوی تصویری در موبایل (v19) — جعبه ۴۰px با عرض آزاد؛ کادر دقیقاً
     وسط عمودی هدر می‌نشیند و تصویر کامل و بدون برش دیده می‌شود */
  .brand-logo.has-img { height: 40px; }
  .brand-logo.has-img img { max-width: 150px; }
  .brand-name { font-size: 16px; }

  /* برند در سمت راست (ابتدای RTL) و عمودی وسط هدر — تصویر و متن هم‌راستا
     (پاسخ کارفرما v18: وسط‌چین قبلی حذف شد؛ برند به ابتدای خط برمی‌گردد) */
  .header-inner { position: relative; justify-content: flex-start; }
  .nav-toggle {
    position: absolute;
    inset-inline-end: 2px;
    top: 50%;
    transform: translateY(-50%);
  }

  /* عبارت «مرجع قیمت لحظه‌ای طلا و سکه» در موبایل حذف می‌شود (پاسخ کارفرما) */
  .hero-kicker { display: none; }

  /* کارت‌های جدید v18 — نمای کیف پول پروفایل و آدرس‌ها */
  .wallet-overview { padding: 14px 16px; gap: 12px 20px; }
  .wallet-overview .wo-value { font-size: 16.5px; }
  .wallet-overview .wo-cta { margin-inline-start: 0; width: 100%; }
  .wallet-overview .wo-cta .btn { flex: 1; }
  .address-grid { grid-template-columns: 1fr; }

  /* کارت‌های قیمت موبایل (صفحه قیمت‌ها) */
  #prices-cards { display: grid; gap: 12px; }
  .table-wrap.has-mobile-cards { display: none; }

  /* ردیف‌های قیمت صفحه اصلی — جمع‌تر */
  .price-row-card { padding: 14px 16px; gap: 10px; }
  .pr-num { font-size: 14.5px; }
  .pr-name { font-size: 14px; }

  /* قرص‌های فیلتر — ردیف اسکرول افقی به‌جای شکستن
     ⚠️ flex-wrap: nowrap حیاتی است: ترکیب column + wrap در کروم
     اندازه stretch آیتم‌ها را تا ۲ برابر والد باد می‌کند (سرریز کل صفحه) */
  .filter-bar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 12px; }
  .filter-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-inline: -18px;
    padding-inline: 18px;
    scroll-snap-type: x proximity;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .filter-pill { white-space: nowrap; flex-shrink: 0; scroll-snap-align: end; }

  /* تب‌های پروفایل — اسکرول نرم */
  .ptabs {
    flex-wrap: nowrap;
    scrollbar-width: none;
    margin-inline: -18px;
    padding-inline: 18px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .ptabs::-webkit-scrollbar { display: none; }
  .ptab { flex: 0 0 auto; white-space: nowrap; scroll-snap-align: end; }

  /* ⚠️ حیاتی: ترک ۱fr بدون minmax(0,1fr) در گرید، به min-content
     تب‌های nowrap باد می‌کند و کل صفحه را دچار سرریز افقی می‌کند */
  .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-grid > div { min-width: 0; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-grid > div { min-width: 0; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .contact-grid { grid-template-columns: minmax(0, 1fr); }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }

  /* جدول‌ها — لمس نرم */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  /* سرصفحه بخش زنده */
  .live-section-head { flex-wrap: wrap; gap: 8px; }
}

/* ============================================================
   ۳) جدول‌های واکنش‌گرا — کارت‌های عمودی (≤ ۷۰۰px)
   ------------------------------------------------------------
   جدول‌هایی که کلاس rt دارند (به‌طور خودکار توسط ui.js از روی
   وجود thead اضافه می‌شود) به کارت تبدیل می‌شوند؛ برچسب هر
   سلول از data-label خوانده می‌شود.
   ============================================================ */
@media (max-width: 700px) {
  .table-wrap { border: 0; background: transparent; border-radius: 0; }

  table.data-table.rt { min-width: 0 !important; font-size: 13px; }
  table.data-table.rt thead { display: none; }

  table.data-table.rt tbody {
    display: grid;
    gap: 10px;
  }

  table.data-table.rt tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    background: var(--panel, #141414);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: 16px;
    padding: 4px 16px 8px;
  }

  table.data-table.rt tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    /* خط جداکننده با توکن تم — در دارک و لایت هر دو درست دیده شود */
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.07));
    text-align: start;
    /* ⚠️ بازنشانی nowrap پایه جدول — بدون این، نام‌های طولانی
       از کارت بیرون می‌زنند و چیدمان کلا به‌هم می‌ریزد */
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
  }

  table.data-table.rt tbody tr td:last-child { border-bottom: 0; }

  /* برچسب ستون — سمت راست، مقدار سمت چپ */
  table.data-table.rt tbody td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-3, #8a8a8a);
  }

  /* مقدار — خواناتر از برچسب */
  table.data-table.rt tbody td > :first-child { min-width: 0; }
  table.data-table.rt tbody td .fw-7 { font-size: 13.5px; }

  /* سلول‌های colspan (اسکلتون / حالت خالی) عادی دیده شوند */
  table.data-table.rt tbody td[colspan] {
    display: block;
    padding: 14px 0;
  }

  /* ---------- سلول‌های عملیاتی/فرمی — برچسب بالا، محتوا تمام‌عرض ----------
     مرورگرهای مدرن :has دارند؛ در قدیمی‌ها fallback پایین‌تر فعال است */
  table.data-table.rt tbody td:has(> .row-actions),
  table.data-table.rt tbody td:has(> .flex.gap-2),
  table.data-table.rt tbody td:has(> .select.status-select) {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-top: 12px;
  }

  /* ردیف‌های عملیات — دکمه‌ها هم‌عرض در گرید لمسی */
  table.data-table.rt tbody td .row-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 8px;
  }
  table.data-table.rt tbody td .row-actions .btn {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    font-size: 13px;
    border-radius: 11px;
  }

  /* فیلدهای داخل کارت (قیمت‌گذاری) — ورودی‌ها زیر هم و تمام‌عرض */
  table.data-table.rt tbody td .flex.gap-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
  }
  table.data-table.rt tbody td .flex.gap-2 .input,
  table.data-table.rt tbody td .flex.gap-2 .btn { width: 100%; }
  table.data-table.rt tbody td .flex.gap-2 .btn { min-height: 42px; }

  /* سلکت تغییر وضعیت سفارش — تمام‌عرض و لمسی */
  table.data-table.rt tbody td .select.status-select {
    width: 100%;
    min-height: 44px;
  }

  /* سلول کاربر (آواتار + نام) فشرده‌تر */
  table.data-table.rt tbody td .ucell { min-width: 0; }
  table.data-table.rt tbody td .ucell-name { font-size: 12.5px; }

  /* بج‌ها و اعداد داخل کارت */
  table.data-table.rt tbody td .badge { font-size: 11px; }

  /* ================= کارت محصول (تب مدیریت محصولات) =================
     ردیف اول کارت = هدر: تصویر بندانگشتی + نام محصول کنار هم؛
     به‌جای اتلاف دو ردیف کامل برای «تصویر» و «نام» تنها */
  #tab-products table.data-table.rt tbody tr {
    grid-template-columns: 56px minmax(0, 1fr);
    column-gap: 13px;
    padding: 14px 16px 8px;
  }
  #tab-products table.data-table.rt tbody td:first-child {
    grid-column: 1;
    grid-row: 1;
    display: block;
    padding: 0;
    border-bottom: 0;
  }
  #tab-products table.data-table.rt tbody td:first-child::before { display: none; }
  #tab-products table.data-table.rt tbody td:first-child .pthumb {
    width: 56px;
    height: 56px;
    border-radius: 13px;
  }
  #tab-products table.data-table.rt tbody td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    display: block;
    padding: 0;
    border-bottom: 0;
    min-width: 0;
  }
  #tab-products table.data-table.rt tbody td:nth-child(2)::before { display: none; }
  #tab-products table.data-table.rt tbody td:nth-child(2) .fw-7 {
    font-size: 14.5px;
    line-height: 1.55;
    padding-top: 3px;
  }
  #tab-products table.data-table.rt tbody td:nth-child(n+3) {
    grid-column: 1 / -1;
  }
  /* ردیف‌های حالت خالی/اسکلتون (colspan) — تمام‌عرض، نه ستون ۵۶px */
  #tab-products table.data-table.rt tbody td[colspan] {
    grid-column: 1 / -1;
  }
}

/* ============================================================
   ۴) موبایل کوچک — عرض ≤ ۶۴۰px
   ============================================================ */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .container { padding-inline: 16px; }

  /* هم‌ترازی لبه قرص‌ها/تب‌ها با پدینگ ۱۶ پیکسلی کانتینر */
  .filter-pills, .ptabs { margin-inline: -16px; padding-inline: 16px; }

  /* ---------- هیرو ---------- */
  .hero { padding: 16px 0 20px; }
  .hero-grid { gap: 14px; }
  /* تصویر هیرو در موبایل — دایره ماسک‌شده مثل دسکتاپ (بازگشت به حالت اول —
     پاسخ کارفرما: کارت تمام‌عرض ۱۶:۱۱ سکه را بیضی نشان می‌داد).
     سوییچ پنل: hero-mobile-off → تصویر هیرو در موبایل حذف می‌شود (v18) */
  .hero-visual { max-width: 220px; margin-inline: auto; }
  .hero-visual.hero-mobile-off { display: none; }
  .hero-visual .coin-wrap { animation: none; max-width: 100%; }
  .hero-visual::after { display: none; }
  .hero-title { font-size: 25px; line-height: 1.45; }
  .hero-kicker { font-size: 12px; padding: 7px 14px; }
  .hero-tags { gap: 6px; flex-wrap: wrap; margin: 12px 0 14px; }
  .hero-tags span { font-size: 12px; padding: 6px 14px; }
  .hero-trust { gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 16px; }
  .trust-item { font-size: 12px; gap: 5px; }
  .hero-cta { flex-direction: column; flex-wrap: nowrap; gap: 10px; }
  .hero-cta .btn { width: 100%; }

  /* ---------- محصولات — دو ستونه فشرده ---------- */
  .product-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .product-card { border-radius: 14px; }
  .pc-body { padding: 12px 13px 14px; gap: 8px; }
  .pc-title-row h3 { font-size: 13.5px; line-height: 1.45; }
  .pc-spec { font-size: 10.5px; padding: 2px 8px; }
  .pc-prices { gap: 7px; }
  .pc-price-box { padding: 8px 6px; border-radius: 10px; }
  .pc-price-box .v { font-size: 12.5px; }
  .pc-price-box .l { font-size: 10px; }
  .pc-img { aspect-ratio: 4/3; }              /* تصویر مربع‌تر برای گرید دو ستونه */
  .pc-img img { background: var(--panel-2, #141414); }
  .pc-img .pc-badge { top: 8px; inset-inline-start: 8px; }
  .pc-img .pc-badge .filter-pill { padding: 5px 11px; font-size: 11px; min-height: 0; }

  /* ---------- کارت‌های قیمت ---------- */
  .price-row-card { flex-wrap: wrap; row-gap: 10px; }
  .price-row-card > div:first-child { flex: 1 1 100%; }
  .pr-nums { flex: 1; }

  /* ---------- فرم‌ها — جلوگیری از زوم iOS ---------- */
  .input, input[type="text"], input[type="email"], input[type="tel"],
  input[type="password"], input[type="search"], input[type="number"],
  select, textarea {
    font-size: 16px !important;
  }

  /* خبرنامه فوتر — عمودی */
  .newsletter { flex-direction: column; gap: 10px; }
  .newsletter .btn { width: 100%; }

  /* ---------- فوتر — جمع‌وجورتر ---------- */
  .footer-grid { gap: 26px; padding: 34px 0 24px; }
  .footer-col h4 { font-size: 15px; }
  .footer-links a { font-size: 14px; padding: 6px 0; }
  .social-row a { width: 42px; height: 42px; }
  .copyright-bar .container {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    text-align: center;
    font-size: 12px;
  }

  /* ---------- صفحه قیمت موبایل ---------- */
  #prices-cards .price-row-card { padding: 14px; }
  .pc-mobile-time { font-size: 11px; color: var(--text-3); }

  /* ---------- دکمه‌ها و اهداف لمسی ---------- */
  .filter-pill { padding: 9px 16px; min-height: 42px; }
  .tab-btn { padding: 12px 12px; min-height: 46px; }
  .icon-btn { width: 42px; height: 42px; }

  /* ---------- بردکرامب و تیتر صفحات ---------- */
  .crumbs { font-size: 12px; flex-wrap: wrap; }
  .page-hero h1 { font-size: 26px; }
  .page-hero .lead { font-size: 14px; }

  /* ---------- بخش‌ها ---------- */
  .section { padding: 40px 0; }
  /* تیتر بخش‌ها همیشه یک خط — خطوط تزئینی کوتاه‌تر (پاسخ کارفرما:
     «قیمت لحظه‌ای بازار» در دو خط نمی‌گنجد) */
  .section-head { gap: 12px; }
  .section-head::before, .section-head::after { width: 34px; }
  .section-head h2 { font-size: 18.5px; white-space: nowrap; }
  .section-head .lead { font-size: 13.5px; }

  /* ---------- درباره / تماس ---------- */
  .about-stats { gap: 10px; }
  .about-stat .v { font-size: 26px; }
  .about-stat { padding: 18px 10px; }

  /* ======================= سفارش‌های من — کارت موبایل ======================= */
  .order-item {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 6px 12px;
    align-items: center;
    padding: 15px 14px;
    border-radius: 14px;
  }
  .oi-icon { width: 46px; height: 46px; border-radius: 12px; }
  .oi-icon svg { width: 21px; height: 21px; }
  .oi-main { min-width: 0; }
  .oi-title { font-size: 14.5px; gap: 8px; }
  .oi-title .badge { font-size: 10.5px; }
  .oi-sub { font-size: 11.5px; line-height: 1.8; }
  .oi-amount {
    grid-column: 2;
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 4px;
    text-align: start;
  }
  .oi-amount .v { font-size: 16px; }
  .oi-amount .l { font-size: 11px; }
  .order-item > .btn { grid-column: 1 / -1; width: 100%; }

  /* ======================= پروفایل — پنل کاربر ======================= */
  .profile-grid { gap: 16px; }
  .profile-side { padding: 22px 16px 18px; }
  .profile-avatar { width: 82px; height: 82px; font-size: 30px; margin-bottom: 12px; }
  .avatar-edit { width: 32px; height: 32px; bottom: 4px; left: 4px; }
  .profile-stats { gap: 8px; margin-top: 16px; }
  .stat-box { padding: 12px 8px; border-radius: 11px; }
  .stat-box .v { font-size: 17px; }
  .stat-box .l { font-size: 11px; }

  /* پنل‌ها — پدینگ کمتر، گوشه نرم‌تر */
  .panel { padding: 18px 14px; border-radius: 14px; }
  .panel h3 { font-size: 15px; }
  .panel h3 svg { width: 19px; height: 19px; margin-inline-end: 7px; }

  /* فرم‌ها — ردیف‌ها همیشه تک‌ستونه */
  .form-row, .form-row-3 { display: grid; grid-template-columns: 1fr; gap: 0; }
  .form-field label { font-size: 12.5px; }

  /* ---------- مقیاس یکدست دکمه‌ها در موبایل ----------
     نکته: main.css در ≤720px همه دکمه‌ها (حتی btn-sm) را با
     padding 11px 20px می‌پوشاند → دکمه‌های ریز ۴۶px بل می‌شوند.
     اینجا سلسله‌مراتب درست بازسازی می‌شود (mobile.css بعد از
     main.css لود می‌شود، پس قواعد هم‌ارزش اینجا برنده‌اند) */
  .btn {
    padding: 12px 22px;
    font-size: 14.5px;
    border-radius: 12px;
    min-height: 46px; /* هدف لمسی */
  }
  .btn-sm {
    padding: 9px 14px;
    font-size: 13px;
    border-radius: 10px;
    min-height: 0;
  }
  .btn-lg { padding: 14px 26px; font-size: 15.5px; min-height: 52px; }
  .btn.btn-xs { padding: 5px 10px; font-size: 11px; min-height: 0; }

  /* بازخورد لمسی — فشرده‌شدن ملایم دکمه هنگام لمس */
  .btn:not(:disabled):active { transform: scale(0.96); }
  .btn-gold:not(:disabled):active { transform: scale(0.96); box-shadow: 0 6px 18px rgba(212, 175, 55, 0.25); }

  /* کیف پول — دو ستونه فشرده */
  .wallet-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .wcard { padding: 13px 12px; border-radius: 13px; gap: 5px; }
  .wcard .wc-l { font-size: 11px; }
  .wcard .wc-v { font-size: 15.5px; }
  .wcard .wc-v small { font-size: 9.5px; }
  .wcard .wc-s { font-size: 10px; }

  /* KYC — کارت‌های آپلود افقی و جمع */
  .kyc-uploads { gap: 9px; margin: 12px 0; }
  .kyc-drop {
    flex-direction: row;
    align-items: center;
    text-align: start;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 12px;
  }
  .kyc-drop-ic svg { width: 26px; height: 26px; }
  .kyc-drop-t { font-size: 12.5px; }
  .kyc-drop-s { font-size: 10.5px; }

  /* حساب‌های بانکی */
  .bank-item { padding: 12px 13px; border-radius: 12px; }
  .bank-sheba { font-size: 12.5px; word-break: break-all; }

  /* واریز سریع — قرص‌های مبلغ سه‌تایی */
  .dep-quick { gap: 6px; }
  .dep-quick button { flex: 1 1 30%; padding: 9px 6px; font-size: 11.5px; min-height: 40px; }

  /* جعبه شماره حساب */
  .acct-number-box { padding: 12px 14px; border-radius: 12px; }
  .acct-number-box .acct-number { font-size: 15.5px; letter-spacing: 1px; }
  .acct-number-box .btn { padding: 8px 14px; }

  /* بنرها */
  .kyc-banner, .info-banner { padding: 13px 14px; border-radius: 12px; gap: 10px; }
  .kyc-banner svg { width: 24px; height: 24px; }
  .kyc-banner p { font-size: 12px; }

  /* ---------- مودال‌ها — تمام‌عرض ---------- */
  .modal-backdrop { padding: 12px; }
  .modal-box {
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    border-radius: 16px;
  }
  .modal-head { padding: 14px 16px; }
  .modal-head h3 { font-size: 15.5px; }
  .modal-body { padding: 16px 14px; }
  .modal-foot { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .modal-foot .btn { flex: 1 1 auto; }
}

/* ============================================================
   ۵) پنل مدیریت — موبایل (≤ ۹۰۰px)
   ============================================================ */
@media (max-width: 900px) {
  /* ناچ آیفون — تاپ‌بار زیر ناچ نرود */
  .adm-top { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }

  .adm-content { padding: 14px 12px calc(40px + env(safe-area-inset-bottom, 0px)); }

  /* تاپ‌بار — تیتر کوتاه، دکمه‌ها لمسی */
  .adm-top { padding-inline: 12px; gap: 8px; }
  .adm-title { min-width: 0; }
  .adm-title h1 {
    font-size: 15.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .adm-top-actions { gap: 7px; }
  .adm-top-actions .icon-btn { width: 38px; height: 38px; }

  /* پنل هشدارها — تمام‌عرض زیر تاپ‌بار */
  .adm-alerts-panel {
    position: fixed;
    top: calc(64px + env(safe-area-inset-top, 0px));
    inset-inline: 10px;
    width: auto;
    max-width: none;
  }

  /* سایدبار کشویی — باریک‌تر و نرم */
  .adm-side { width: min(84vw, 300px); }

  /* کارت‌های آمار — دو ستونه تا حد امکان */
  .astat-grid { gap: 10px; }
  .astat { padding: 14px; gap: 11px; border-radius: 14px; }
  .astat-ic { width: 40px; height: 40px; border-radius: 12px; }
  .astat-ic svg { width: 19px; height: 19px; }
  .astat-v { font-size: 18px; }
  .astat-l { font-size: 11.5px; }
  .astat-s { font-size: 10.5px; }

  /* کارت‌ها */
  .adm-card-head { padding: 13px 14px; }
  .adm-card-head h3 { font-size: 14px; }
  .adm-card-head h3 svg { width: 17px; height: 17px; }
  .adm-card-body { padding: 14px; }
  .dash-grid { gap: 12px; margin-top: 12px; }

  /* نوار ابزار — جستجو تمام‌عرض
     ⚠️ flex: 1 0 100% حیاتی است: فقط width:100% کافی نیست چون
     flex-shrink پیش‌فرض اجازه می‌دهد جستجو در کنار سلکت و دکمه
     تا ۵۹px هم جمع شود (باگ به‌هم‌ریختگی نوار ابزار محصولات) */
  .adm-toolbar { gap: 8px; }
  .adm-toolbar .adm-search { flex: 1 0 100%; min-width: 0; max-width: none; order: -1; }
  .adm-toolbar .select { flex: 1 1 auto; min-width: 125px; width: auto; }
  .adm-toolbar .adm-toolbar-end { margin-inline-start: 0; flex: 1 1 auto; display: flex; }
  .adm-toolbar .adm-toolbar-end .btn { flex: 1; min-height: 46px; }

  /* قرص‌های فیلتر پنل */
  .apills { gap: 6px; }
  .apill { padding: 7px 13px; font-size: 12px; }

  /* بندانگشتی محصول */
  .pthumb { width: 40px; height: 40px; border-radius: 10px; }

  /* فرم‌های داخل مودال */
  .field label { font-size: 12px; }
}

@media (max-width: 560px) {
  .astat-grid { grid-template-columns: 1fr 1fr; }
  .astat { padding: 12px; }
  .astat-v { font-size: 16.5px; }
  .astat-s { display: none; }
}

/* ============================================================
   ۶) موبایل خیلی کوچک — عرض ≤ ۳۸۰px
   ============================================================ */
@media (max-width: 380px) {
  .brand-name { display: none; }
  .header-actions .btn-sm { padding: 8px 12px; font-size: 12.5px; }
  .bn-item { font-size: 9.5px; }
  .bn-item svg { width: 20px; height: 20px; }
  .product-grid { gap: 10px; }
  .wallet-cards { gap: 8px; }
  .wcard { padding: 11px 10px; }
  .wcard .wc-v { font-size: 14px; }
}

/* ============================================================
   ۷) لمس — حذف هاور چسبنده
   ============================================================ */
@media (hover: none) {
  .price-row-card:hover,
  .cat-card:hover,
  .product-card:hover { transform: none; }
  .data-table tbody tr:hover { background: transparent; }
  .astat:hover { transform: none; border-color: var(--border); }
  .kyc-docs figure:hover { transform: none; }
}

/* چاپ — نوار پایین و شیت حساب مخفی */
@media print { #bottom-nav, .account-sheet, .as-backdrop { display: none !important; } }

/* احترام به کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
  #bottom-nav { animation: none; }
  .bn-item, .bn-item svg { transition: none; }
  .account-sheet { animation: none; }
  .as-backdrop { animation: none; }
  .account-sheet .as-head,
  .account-sheet .as-item,
  .account-sheet .as-logout,
  .account-sheet .as-auth-btns { animation: none; }
  .as-switch::after { transition: none; }
}
