/* ===========================================================================
   آکادمی سات CRM — دیزاین‌سیستم متمرکز
   تمام رنگ‌ها، فاصله‌ها، اجزا و استایل‌ها اینجا تعریف می‌شوند تا صفحات سبک بمانند.
   RTL · ریسپانسیو · مدرن
   =========================================================================== */

/* ---------------------------------------------------------------------------
   ۱) متغیرها (Design Tokens)
   --------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------
   فونت ایران‌سنس (IRANSans) — self-host، بدون CDN
   • خانواده‌ی «IRANSans» = نسخه‌ی FaNum → کل رابط کاربری (ارقام فارسی نمایش داده می‌شوند)
   • خانواده‌ی «IRANSansLatin» = نسخه‌ی معمولی → کد/لینک/فیلدهای فنی LTR (ارقام لاتین می‌مانند)
   نگاشت وزن‌ها: 300 نازک · 400 معمولی · 500/600 متوسط · 700/800 ضخیم
   --------------------------------------------------------------------------- */
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/IRANSansWeb_Light_FaNum.woff') format('woff'); }
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/IRANSansWeb_FaNum.woff') format('woff'); }
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/IRANSansWeb_Medium_FaNum.woff') format('woff'); }
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/IRANSansWeb_Medium_FaNum.woff') format('woff'); }
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/IRANSansWeb_Bold_FaNum.woff') format('woff'); }
@font-face { font-family: 'IRANSans'; font-style: normal; font-weight: 800; font-display: swap; src: url('../fonts/IRANSansWeb_Bold_FaNum.woff') format('woff'); }

@font-face { font-family: 'IRANSansLatin'; font-style: normal; font-weight: 300; font-display: swap; src: url('../fonts/IRANSansWeb_Light.woff') format('woff'); }
@font-face { font-family: 'IRANSansLatin'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/IRANSansWeb_Medium.woff') format('woff'); }
@font-face { font-family: 'IRANSansLatin'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/IRANSansWeb_Medium.woff') format('woff'); }
@font-face { font-family: 'IRANSansLatin'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/IRANSansWeb_Bold.woff') format('woff'); }
@font-face { font-family: 'IRANSansLatin'; font-style: normal; font-weight: 800; font-display: swap; src: url('../fonts/IRANSansWeb_Bold.woff') format('woff'); }

:root {
  /* رنگ برند */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --primary-rgb: 79, 70, 229;
  --accent: #0ea5e9;

  /* رنگ‌های وضعیت */
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0284c7;
  --info-light: #e0f2fe;

  /* خاکستری‌ها */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* سطوح و پس‌زمینه */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;

  /* شعاع گردی */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 999px;

  /* سایه */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-md: 0 10px 25px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, .12);

  /* اندازه‌ها */
  --sidebar-w: 270px;
  --topbar-h: 66px;
  --container: 1280px;

  /* فونت */
  --font: 'IRANSans', 'Segoe UI', Tahoma, sans-serif;
  --font-latin: 'IRANSansLatin', 'IRANSans', 'Segoe UI', Tahoma, sans-serif;

  /* انتقال */
  --transition: .2s cubic-bezier(.4, 0, .2, 1);
}

/* تم تیره (اختیاری، با کلاس روی body) */
body.theme-dark {
  --bg: #0b1120;
  --surface: #131b2e;
  --surface-2: #0f1626;
  --border: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary-light: #1e1b4b;
  --gray-50: #131b2e;
  --gray-100: #1a2335;
}

/* ---------------------------------------------------------------------------
   ۲) ریست و پایه
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* کد، کلید، لینک و فیلدهای فنی LTR → نسخه‌ی لاتین ایران‌سنس تا ارقام لاتین (۰-۹) بمانند */
code, kbd, pre, samp { font-family: var(--font-latin); }
input[dir="ltr"], textarea[dir="ltr"], .num-en, .ltr-text, .mono { font-family: var(--font-latin); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* اعداد فارسی با فونت مناسب */
.num, .money { font-variant-numeric: tabular-nums; font-feature-settings: "ss01"; }

/* ---------------------------------------------------------------------------
   ۳) چیدمان اصلی (Shell)
   --------------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

/* ساید‌بار */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition);
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar__brand-logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow);
}
.sidebar__brand-text strong { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar__brand-text span { font-size: 11px; color: var(--text-muted); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar__group-title {
  font-size: 11px; font-weight: 700; color: var(--gray-400);
  padding: 16px 12px 8px; letter-spacing: .04em;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--gray-600); font-weight: 500; font-size: 13.5px;
  transition: all var(--transition); margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--gray-100); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.nav-item.active:hover { color: #fff; }
.nav-item .ic { flex-shrink: 0; opacity: .9; }
.nav-item__badge {
  margin-inline-start: auto; background: var(--danger); color: #fff;
  font-size: 10px; min-width: 18px; height: 18px; border-radius: var(--radius-full);
  display: grid; place-items: center; padding: 0 5px;
}
.nav-item.active .nav-item__badge { background: rgba(255,255,255,.25); }

/* محتوای اصلی */
.main { flex: 1; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* تاپ‌بار */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 40;
}
.topbar__toggle { display: none; background: none; border: none; color: var(--gray-600); padding: 6px; }
.topbar__title { font-size: 16px; font-weight: 700; }
.topbar__spacer { flex: 1; }
.topbar__search {
  position: relative; width: 320px; max-width: 40vw;
}
.topbar__search input {
  width: 100%; padding: 9px 40px 9px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-full);
  background: var(--surface-2); font-size: 13px;
}
.topbar__search .ic { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }
.topbar__action {
  position: relative; width: 40px; height: 40px; border-radius: var(--radius-full);
  display: grid; place-items: center; color: var(--gray-600);
  background: var(--surface-2); border: 1px solid var(--border); transition: all var(--transition);
}
.topbar__action:hover { background: var(--gray-100); color: var(--primary); }
.topbar__action .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }

.content { padding: 26px 24px 48px; max-width: var(--container); width: 100%; margin: 0 auto; }

/* ---------------------------------------------------------------------------
   ۴) سربرگ صفحه
   --------------------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.page-head__text p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.page-head__actions { margin-inline-start: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ---------------------------------------------------------------------------
   ۵) کارت
   --------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card__head h3 { font-size: 15px; font-weight: 700; }
.card__head .card__actions { margin-inline-start: auto; display: flex; gap: 8px; }
.card__body { padding: 20px; }
.card__foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* شبکه */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* چیدمان‌های دوستونی ریسپانسیو (جایگزین style‌های inline) */
.cols { display: grid; gap: 20px; align-items: start; }
.cols-form { grid-template-columns: 1fr 320px; }    /* محتوای اصلی + ستون کناری */
.cols-wide { grid-template-columns: 2fr 1fr; }       /* محتوای پهن + ستون باریک */
.cols-profile { grid-template-columns: 240px 1fr; }  /* منوی عمودی + محتوا */

/* جلوگیری از «grid blowout»: آیتم‌های گرید به‌طور پیش‌فرض min-width:auto دارند و کوچک نمی‌شوند؛
   با min-width:0 اجازه می‌دهیم ستون‌ها جمع شوند و محتوای پهن (جدول‌ها) داخل table-wrap اسکرول شود
   نه اینکه کل ستون را پهن‌تر از صفحه کنند و باعث بیرون‌زدگی/بریدگی در موبایل شوند. */
.grid > *, .cols > *, .form-grid > *, .field-grid > * { min-width: 0; }

/* راهنمای تاشو (details/summary) — شورت‌لینک و سایر راهنماها */
.sl-guide { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.sl-guide > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 13px; background: var(--surface-2); display: flex; align-items: center; gap: 8px; user-select: none; list-style: none; }
.sl-guide > summary::-webkit-details-marker { display: none; }
.sl-guide[open] > summary { border-bottom: 1px solid var(--border); }
.sl-guide__body { padding: 14px 16px; font-size: 13px; line-height: 2.05; }
.sl-guide__body ol { padding-inline-start: 20px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.sl-guide__body code { direction: ltr; display: inline-block; }

/* ردیف ویرایش فیلد (عنوان + نوع + دکمه حذف) */
.field-grid { display: grid; grid-template-columns: 2fr 1.5fr auto; gap: 12px; align-items: end; }
@media (max-width: 600px) { .field-grid { grid-template-columns: 1fr 1fr auto; } }

/* ---------------------------------------------------------------------------
   ۶) کارت آمار (KPI)
   --------------------------------------------------------------------------- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat__icon { width: 48px; height: 48px; border-radius: var(--radius); display: grid; place-items: center; color: #fff; }
.stat__icon.indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat__icon.sky { background: linear-gradient(135deg, #38bdf8, #0ea5e9); }
.stat__icon.green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.stat__icon.amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat__icon.rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.stat__icon.violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.stat__value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat__label { font-size: 13px; color: var(--text-muted); }
.stat__trend { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.stat__trend.up { color: var(--success); }
.stat__trend.down { color: var(--danger); }

/* ---------------------------------------------------------------------------
   ۷) دکمه‌ها
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13.5px; border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-light { background: var(--surface); color: var(--gray-700); border-color: var(--border); }
.btn-light:hover { background: var(--gray-50); color: var(--text); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger-light); }
.btn-outline-danger:hover { background: var(--danger-light); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-lg { padding: 13px 26px; font-size: 15px; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-group { display: inline-flex; gap: 6px; }

/* ---------------------------------------------------------------------------
   ۸) نشان‌ها (Badges)
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 700; line-height: 1.6;
}
.badge.gray { background: var(--gray-100); color: var(--gray-600); }
.badge.green { background: var(--success-light); color: var(--success); }
.badge.amber { background: var(--warning-light); color: var(--warning); }
.badge.red { background: var(--danger-light); color: var(--danger); }
.badge.blue { background: var(--info-light); color: var(--info); }
.badge.indigo { background: var(--primary-light); color: var(--primary); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }

/* ---------------------------------------------------------------------------
   ۹) جداول
   --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  text-align: right; padding: 13px 16px; font-weight: 700; font-size: 12.5px;
  color: var(--gray-500); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .cell-actions { display: flex; gap: 6px; justify-content: flex-start; }
.table-empty { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.table-empty .ic { color: var(--gray-300); margin-bottom: 12px; }

/* آواتار */
.avatar { width: 38px; height: 38px; border-radius: var(--radius-full); object-fit: cover; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.user-cell { display: flex; align-items: center; gap: 11px; }
.user-cell__name { font-weight: 600; color: var(--text); }
.user-cell__sub { font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   ۱۰) فرم‌ها
   --------------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
.label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.label .req { color: var(--danger); }
.hint { font-size: 11.5px; color: var(--text-muted); }
.input, .select, .textarea {
  width: 100%; padding: 11px 14px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: all var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12);
}
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.textarea { resize: vertical; min-height: 100px; line-height: 1.8; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); }
.input-group { display: flex; }
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.input-group > :last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.input-group__addon { display: grid; place-items: center; padding: 0 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

/* چک‌باکس و رادیو و سوییچ */
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; width: 44px; height: 25px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider { position: absolute; inset: 0; background: var(--gray-300); border-radius: var(--radius-full); transition: var(--transition); }
.switch__slider::before { content: ''; position: absolute; width: 19px; height: 19px; inset-inline-end: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: var(--shadow-sm); }
.switch input:checked + .switch__slider { background: var(--primary); }
.switch input:checked + .switch__slider::before { transform: translateX(-19px); }

/* فیلدست */
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.fieldset legend { padding: 0 10px; font-weight: 700; font-size: 13px; color: var(--primary); }

/* ---------------------------------------------------------------------------
   ۱۱) هشدارها (Alerts) و Flash
   --------------------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--radius); font-size: 13.5px; border: 1px solid; margin-bottom: 16px; }
.alert.success { background: var(--success-light); color: #166534; border-color: #bbf7d0; }
.alert.error { background: var(--danger-light); color: #991b1b; border-color: #fecaca; }
.alert.warning { background: var(--warning-light); color: #92400e; border-color: #fde68a; }
.alert.info { background: var(--info-light); color: #075985; border-color: #bae6fd; }

#flash-stack { position: fixed; top: 18px; inset-inline-start: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: 360px; max-width: 90vw; }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); border-inline-start: 4px solid var(--gray-400); animation: toastIn .3s ease; font-size: 13.5px; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast.info { border-color: var(--info); }
.toast__close { margin-inline-start: auto; color: var(--gray-400); background: none; border: none; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------------------------------------------------------------------------
   ۱۲) مودال
   --------------------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); z-index: 100; display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: modalIn .25s ease; }
.modal.lg { max-width: 820px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h3 { font-size: 16px; font-weight: 700; }
.modal__close { margin-inline-start: auto; color: var(--gray-400); background: none; border: none; padding: 4px; }
.modal__body { padding: 22px; }
.modal__foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-start; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------------------------------------------------------------------------
   ۱۳) دراپ‌داون
   --------------------------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 200px; padding: 6px; z-index: 60;
  display: none; animation: ddIn .15s ease;
}
.dropdown__menu.open { display: block; }
.dropdown__item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--gray-700); font-size: 13px; transition: background var(--transition); width: 100%; background: none; border: none; text-align: right; }
.dropdown__item:hover { background: var(--gray-100); color: var(--text); }
.dropdown__item.danger { color: var(--danger); }
.dropdown__item.danger:hover { background: var(--danger-light); }
.dropdown__divider { height: 1px; background: var(--border); margin: 6px 0; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------------
   ۱۴) تب‌ها
   --------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab { padding: 12px 18px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; transition: all var(--transition); display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-color: var(--primary); }
.tab__count { background: var(--gray-100); color: var(--gray-500); font-size: 11px; padding: 1px 8px; border-radius: var(--radius-full); }
.tab.active .tab__count { background: var(--primary-light); color: var(--primary); }

/* تب‌های عمودی (پروفایل مشتری) */
.vtabs { display: flex; flex-direction: column; gap: 3px; }
.vtab { display: flex; align-items: center; gap: 11px; padding: 11px 14px; border-radius: var(--radius-sm); color: var(--gray-600); font-weight: 500; font-size: 13.5px; transition: all var(--transition); }
.vtab:hover { background: var(--gray-100); color: var(--text); }
.vtab.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.vtab__count { margin-inline-start: auto; font-size: 11px; color: var(--gray-400); }

/* ---------------------------------------------------------------------------
   ۱۵) صفحه‌بندی
   --------------------------------------------------------------------------- */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--gray-600); background: var(--surface); padding: 0 10px; }
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .45; pointer-events: none; }

/* ---------------------------------------------------------------------------
   ۱۶) تقویم و تایم‌لاین
   --------------------------------------------------------------------------- */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding-bottom: 22px; }
.timeline__dot { position: absolute; inset-inline-start: -26px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline__item.green .timeline__dot { border-color: var(--success); }
.timeline__item.amber .timeline__dot { border-color: var(--warning); }
.timeline__time { font-size: 11.5px; color: var(--text-muted); }
.timeline__title { font-weight: 600; font-size: 13.5px; margin: 2px 0; }

/* ---------------------------------------------------------------------------
   ۱۷) متفرقه و کمکی
   --------------------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.fw-700 { font-weight: 700; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; background: var(--gray-100); border-radius: var(--radius-full); font-size: 12px; font-weight: 600; color: var(--gray-600); }

.empty-state { text-align: center; padding: 60px 24px; }
.empty-state__icon { width: 72px; height: 72px; border-radius: var(--radius-lg); background: var(--primary-light); color: var(--primary); display: grid; place-items: center; margin: 0 auto 18px; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); margin-bottom: 18px; }

.progress { height: 8px; background: var(--gray-100); border-radius: var(--radius-full); overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: var(--radius-full); transition: width .4s ease; }

/* اسپینر */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   ۱۸) ریسپانسیو
   --------------------------------------------------------------------------- */
/* تبلت بزرگ: شبکه‌های ۴ و ۳ ستونه دو‌به‌دو، چیدمان فرم/پروفایل پشته می‌شود */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .cols-form, .cols-wide, .cols-profile { grid-template-columns: 1fr; }
}

/* تبلت/موبایل: ساید‌بار کشویی، باکس‌ها دو‌به‌دو می‌مانند */
@media (max-width: 768px) {
  /* درایور کشویی ساید‌بار خارج از کادر است؛ سرریز افقی را می‌بندیم تا اسکرول افقی ناخواسته نداشته باشیم.
     از overflow-x:clip استفاده می‌کنیم تا (برخلاف hidden) overflow-y را به auto تبدیل نکند و چسبندگی topbar حفظ شود.
     hidden به‌عنوان fallback برای مرورگرهای قدیمی که clip را پشتیبانی نمی‌کنند. */
  html, body { overflow-x: hidden; overflow-x: clip; }
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-inline-start: 0; }
  .topbar__toggle { display: grid; place-items: center; }
  .topbar__search { display: none; }
  /* تاپ‌بار موبایل: عنوان صفحه تک‌خطی با سه‌نقطه (نه چندخطی)، و مخفی‌کردن نام/سمت کاربر برای فضای بیشتر */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar__title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
  .topbar__user-meta { display: none; }
  .topbar__action { width: 38px; height: 38px; }
  /* باکس‌های KPI و کارت‌ها دو‌به‌دو (طبق درخواست) */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 18px 14px 40px; }
  .page-head__actions { width: 100%; }
  /* ستون‌های کناری چسبان روی موبایل غیرچسبان شوند */
  .cols-form > div[style*="sticky"], .cols-profile > div[style*="sticky"],
  [style*="position:sticky"] { position: static !important; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; display: none; }
  .sidebar-backdrop.open { display: block; }
}

/* موبایل کوچک — باکس‌ها همچنان دو‌به‌دو می‌مانند (طبق درخواست) */
@media (max-width: 420px) {
  .stat { padding: 16px; gap: 10px; }
  .stat__icon { width: 40px; height: 40px; }
  .stat__value { font-size: 20px; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
  .page-head__actions { flex-direction: column; }
  .page-head__actions .btn { width: 100%; }
  .content { padding: 14px 10px 36px; }
}

/* ---------------------------------------------------------------------------
   ۱۹) چاپ (برای فاکتور/قرارداد)
   --------------------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .page-head__actions, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
}
