body { font-family: 'Vazirmatn', sans-serif; background: #f8fafc; }
.tab, .settings-tab { display: none; }
.tab.active, .settings-tab.active { display: block; }
.pd-popup { position: absolute; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,.15); z-index: 1000; width: 300px; font-family: 'Vazirmatn', sans-serif; direction: rtl; }
.pd-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f3f4f6; }
.pd-header button { background: #f3f4f6; border: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 18px; color: #374151; }
.pd-header button:hover { background: #e5e7eb; }
.pd-title { font-weight: bold; color: #111827; font-size: 15px; }
.pd-weekdays { display: grid; grid-template-columns: repeat(7,1fr); text-align: center; font-size: 12px; color: #9ca3af; margin-bottom: 8px; font-weight: 600; }
.pd-days { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.pd-days button { padding: 8px 4px; border: none; background: transparent; border-radius: 8px; cursor: pointer; font-size: 14px; color: #374151; transition: all .2s; }
.pd-days button:hover { background: #dbeafe; color: #1d4ed8; }
.pd-days button.today { border: 1px solid #3b82f6; color: #3b82f6; font-weight: bold; }
.pd-days button.selected { background: #3b82f6; color: #fff; font-weight: bold; }
.pd-footer { margin-top: 12px; padding-top: 8px; border-top: 1px solid #f3f4f6; display: flex; justify-content: space-between; }
.pd-footer button { background: none; border: none; color: #3b82f6; cursor: pointer; font-size: 13px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: #3b82f6; }
.login-bg { background: linear-gradient(135deg,#1e3a5f 0%,#3b82f6 100%); }
.nav-btn.on { background: #eff6ff; color: #1d4ed8; }
.st-btn.on { background: #eff6ff; color: #1d4ed8; }
.inp { width: 100%; border: 1px solid #d1d5db; border-radius: .5rem; padding: .625rem .75rem; font-size: .875rem; }
th { white-space: nowrap; }

/* ============================================================
   کشوی ناوبری موبایل و تبلت — از لبهٔ راست به چپ

   z-index کشو بالاتر از نوار چسبان (۴۰) و پایین‌تر از پنجره‌ها (۵۰)
   است تا اگر کاربر از داخل کشو کاری را باز کرد، پنجره روی آن بنشیند.

   بستن با visibility انجام می‌شود نه display، وگرنه انیمیشن اجرا
   نمی‌شود؛ و بدون visibility، کشوی بسته همچنان با Tab قابل فوکوس
   می‌ماند و صفحه را افقی می‌کشد.
   ============================================================ */
.drawer-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(15,23,42,.5);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease; }
.drawer-backdrop.open { opacity: 1; visibility: visible; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 46;
  width: 284px; max-width: 82vw; background: #fff;
  display: flex; flex-direction: column; overflow-y: auto;
  box-shadow: -10px 0 30px rgba(15,23,42,.15);
  transform: translateX(100%); visibility: hidden;
  transition: transform .25s ease, visibility .25s ease;
  padding-bottom: env(safe-area-inset-bottom); }
.drawer.open { transform: translateX(0); visibility: visible; }

.drawer-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px; padding: 14px 14px 12px; border-bottom: 1px solid #f3f4f6; }
.drawer-x { width: 34px; height: 34px; border-radius: 9px; background: #f3f4f6;
  color: #4b5563; font-size: 15px; line-height: 1; flex: 0 0 auto; }
.drawer-x:hover { background: #e5e7eb; }

.drawer-nav { flex: 1 1 auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.drawer-item { display: block; width: 100%; text-align: right; padding: 12px;
  border-radius: 10px; font-size: 14px; font-weight: 500; color: #374151; transition: background .15s; }
.drawer-item:hover { background: #f3f4f6; }

/* آیکون همبرگر — سه خط با CSS، بدون تصویر و بدون اموجی
   تا در همهٔ دستگاه‌ها یک شکل دیده شود */
.burger { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; transition: background .15s; }
.burger:hover { background: #f3f4f6; }
.burger span { display: block; width: 19px; height: 2px; border-radius: 2px; background: #374151; }

/* از ۱۰۲۴ به بالا کشو اصلاً وجود ندارد و نوار دسکتاپ سر جای قبلی‌اش است */
@media (min-width: 1024px) {
  .drawer, .drawer-backdrop, .burger { display: none !important; }
}

/* ============================================================
   پنجره‌ها — روی موبایل «کشوی پایین»، از تبلت به بالا وسط صفحه
   دلیل: پنجرهٔ وسط‌چین روی صفحهٔ کوچک زیر کیبورد گم می‌شود و
   دکمه‌های ذخیره/انصراف از دسترس شست خارج می‌مانند.
   ============================================================ */
.modal { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.5);
  align-items: flex-end; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: #fff; width: 100%; max-width: 560px; padding: 20px;
  border-radius: 16px 16px 0 0; max-height: 88vh; overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-content { width: 92%; padding: 24px; padding-bottom: 24px; border-radius: 16px; max-height: 90vh; }
}

/* ============================================================
   نوار ناوبری افقی بدون نوار اسکرول دیده‌شده
   ============================================================ */
.noscrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.noscrollbar::-webkit-scrollbar { display: none; }

/* ============================================================
   جلوگیری از بزرگ‌نمایی خودکار سافاری آی‌اواس
   سافاری هر فیلد متنی با فونت کوچک‌تر از ۱۶ پیکسل را که فوکوس بگیرد
   زوم می‌کند و کاربر در صفحهٔ بزرگ‌شده گیر می‌افتد. تنها راه قطعی،
   بردن فونت به ۱۶ پیکسل است — و چون کلاس‌های Tailwind مثل text-sm
   وزن یکسانی دارند، اینجا ناچار از important هستیم.
   ============================================================ */
@media (max-width: 767px) {
  .inp, .share-inp, input[type="text"], input[type="password"],
  input[type="number"], textarea { font-size: 16px !important; }
}

/* ============================================================
   تبدیل جدول به کارت روی صفحهٔ کوچک

   دو گروه با دو نقطهٔ شکست:
     .rt        جدول‌های تا شش ستون  → زیر ۷۶۸ پیکسل کارت می‌شوند
     .rt-wide   جدول‌های هفت-هشت ستون → زیر ۱۰۲۴ پیکسل کارت می‌شوند
   جدول هشت‌ستونی حتی روی تبلت عمودی هم جا نمی‌شود، ولی جدول
   چهارستونی روی تبلت کاملاً خواناست و کارت‌کردنش فقط صفحه را دراز می‌کند.

   نام ستون از data-label روی خودِ td خوانده می‌شود؛ پس هر td تازه‌ای
   که به این جدول‌ها اضافه شود باید data-label بگیرد وگرنه در نمای
   کارت بدون برچسب می‌ماند. سلولِ دکمه‌ها data-label خالی می‌گیرد.

   قواعد عیناً برای دو گروه تکرار شده‌اند چون CSS راهی برای
   به‌اشتراک‌گذاری یک بلوک بین دو media query ندارد.
   ============================================================ */
@media (max-width: 1023px) {
  .rt-wide, .rt-wide thead, .rt-wide tbody, .rt-wide tr, .rt-wide td { display: block; }
  .rt-wide thead { display: none; }
  .rt-wide { background: #f8fafc; }
  .rt-wide tr { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    margin: 10px; overflow: hidden; }
  .rt-wide tr.bg-gray-50 { background: #f9fafb; }
  .rt-wide td { display: flex; align-items: baseline; justify-content: flex-start;
    gap: 10px; padding: 9px 14px; overflow-wrap: anywhere;
    border-bottom: 1px solid #f3f4f6; white-space: normal; }
  .rt-wide tr td:last-child { border-bottom: 0; }
  /* ستون برچسب عرض ثابت دارد تا مقدارها زیر هم تراز شوند؛ با
     space-between روی تبلت یک فاصلهٔ خالی ۵۰۰ پیکسلی وسط کارت می‌افتاد */
  .rt-wide td::before { content: attr(data-label); color: #6b7280; font-size: 12px;
    flex: 0 0 5.5rem; text-align: right; }
  .rt-wide td:empty { display: none; }
  .rt-wide td[data-label=""] { gap: 8px; background: #fafafa; }
  .rt-wide td[data-label=""]::before { content: none; }
  .rt-wide td[data-label=""] button { padding: 7px 12px; border-radius: 8px;
    background: #fff; border: 1px solid #e5e7eb; margin: 0; }
  .rt-wide td[colspan] { display: block; text-align: center; }
  .rt-wide td[colspan]::before { content: none; }
}
@media (max-width: 767px) {
  .rt, .rt thead, .rt tbody, .rt tr, .rt td { display: block; }
  .rt thead { display: none; }
  .rt { background: #f8fafc; }
  .rt tr { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    margin: 10px; overflow: hidden; }
  .rt tr.bg-gray-50 { background: #f9fafb; }
  .rt td { display: flex; align-items: baseline; justify-content: flex-start;
    gap: 10px; padding: 9px 14px; overflow-wrap: anywhere;
    border-bottom: 1px solid #f3f4f6; white-space: normal; }
  .rt tr td:last-child { border-bottom: 0; }
  /* ستون برچسب عرض ثابت دارد تا مقدارها زیر هم تراز شوند؛ با
     space-between روی تبلت یک فاصلهٔ خالی ۵۰۰ پیکسلی وسط کارت می‌افتاد */
  .rt td::before { content: attr(data-label); color: #6b7280; font-size: 12px;
    flex: 0 0 5.5rem; text-align: right; }
  .rt td:empty { display: none; }
  .rt td[data-label=""] { gap: 8px; background: #fafafa; }
  .rt td[data-label=""]::before { content: none; }
  .rt td[data-label=""] button { padding: 7px 12px; border-radius: 8px;
    background: #fff; border: 1px solid #e5e7eb; margin: 0; }
  .rt td[colspan] { display: block; text-align: center; }
  .rt td[colspan]::before { content: none; }
}

/* ============================================================
   تقویم شمسی روی موبایل — کشوی پایین به‌جای پاپ‌آپ شناور
   مقدار top/right را جاوااسکریپت به‌صورت inline می‌نویسد، پس تنها
   راه خنثی‌کردنش در این نقطهٔ شکست، important است.
   ============================================================ */
@media (max-width: 639px) {
  .pd-popup { position: fixed !important; width: auto !important;
    top: auto !important; bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    right: 12px !important; left: 12px !important; }
  .pd-days button { padding: 12px 4px; font-size: 15px; }
  .pd-header button { width: 38px; height: 38px; }
  .pd-footer button { padding: 6px 4px; }
}