/* ─── Vazirmatn — فونت فارسی (لوکال + Google Fonts fallback) ─────── */
@import url('/assets/fonts/fonts.css');

/* ─── Animatable accent color ──────────────────────────────────────── */
@property --accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #14b8a6;
}
@property --accent-light {
  syntax: '<color>';
  inherits: true;
  initial-value: #2dd4bf;
}

@keyframes accentShift {
  0%   { --accent:#14b8a6; --accent-light:#2dd4bf; }
  14%  { --accent:#06b6d4; --accent-light:#22d3ee; }
  28%  { --accent:#6366f1; --accent-light:#a5b4fc; }
  42%  { --accent:#ec4899; --accent-light:#f9a8d4; }
  57%  { --accent:#f97316; --accent-light:#fdba74; }
  71%  { --accent:#10b981; --accent-light:#34d399; }
  85%  { --accent:#8b5cf6; --accent-light:#c4b5fd; }
  100% { --accent:#14b8a6; --accent-light:#2dd4bf; }
}

/* ─── CSS Variables ─────────────────────────────────────────────────── */
:root {
  --bg:           #f4fbfa;
  --surface:      #ffffff;
  --surface-soft: #f1f5f9;
  --fg:           #0f172a;
  --muted:        #64748b;
  --border:       #e2e8f0;
  --border2:      #cbd5e1;
  --accent:       #14b8a6;
  --accent-light: #2dd4bf;
  --accent-bg:    rgba(20,184,166,.09);
  --accent-glow:  rgba(20,184,166,.18);
  --danger:       #ef4444;
  --danger-bg:    rgba(239,68,68,.08);
  --danger-border:rgba(239,68,68,.22);
  --success:      #22c55e;
  --success-bg:   rgba(34,197,94,.08);
  --success-border:rgba(34,197,94,.22);
  --warning:      #f59e0b;
  --warning-bg:   rgba(245,158,11,.08);
  --warning-border:rgba(245,158,11,.22);
  --shadow-xs:    0 2px 8px rgba(15,23,42,.05);
  --shadow:       0 8px 32px rgba(15,23,42,.08);
  --shadow-md:    0 16px 48px rgba(15,23,42,.10);
  --shadow-lg:    0 24px 64px rgba(15,23,42,.13);
  --shadow-accent:0 12px 32px rgba(20,184,166,.3);
  --sw:  260px;
  --th:  62px;
  --r:   24px;
  --rsm: 14px;
  --rlg: 32px;
  animation: accentShift 18s ease-in-out infinite;
}

/* ─── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  direction: rtl;
  height: 100%;
  scroll-behavior: smooth;
  /* جلوگیری از اسکرول افقی: سایدبارِ off-canvas (translateX خارج از صفحه) و هر عنصرِ
     پهن‌تر از صفحه نباید روی موبایل صفحه را کج/زوم‌اوت کند. */
  overflow-x: hidden;
}
body {
  font-family: 'Vazirmatn', 'Tahoma', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg);
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* پس‌زمینه اصلی */
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%, rgba(20,184,166,.13), transparent),
    radial-gradient(ellipse 50% 40% at 95% 100%, rgba(99,102,241,.07), transparent),
    linear-gradient(180deg, #f4fbfa 0%, #edf6f5 60%, #f0f9ff 100%);
}

/* پس‌زمینه متحرک */
@keyframes bgPulse {
  0%,100% { filter: hue-rotate(0deg)   brightness(1);   }
  25%     { filter: hue-rotate(40deg)  brightness(1.02);}
  50%     { filter: hue-rotate(180deg) brightness(1.01);}
  75%     { filter: hue-rotate(300deg) brightness(1.02);}
}
body::before {
  content:'';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(20,184,166,.18), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 110%, rgba(99,102,241,.12), transparent 55%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(236,72,153,.05), transparent 60%);
  animation: bgPulse 18s ease-in-out infinite;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; border: none; }
img { max-width: 100%; }

/* ─── Keyframes ──────────────────────────────────────────────────────── */
@keyframes fadeUp   { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:none} }
@keyframes fadeIn   { from{opacity:0} to{opacity:1} }
@keyframes spin     { to{transform:rotate(360deg)} }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes toastIn  { from{opacity:0;transform:translateX(-60px)} to{opacity:1;transform:none} }
@keyframes toastOut { to{opacity:0;transform:translateX(-60px)} }
@keyframes shimmer  { 0%{background-position:200% 0} 100%{background-position:-200% 0} }
@keyframes countUp  { from{opacity:0;transform:translateY(8px) scale(.88)} to{opacity:1;transform:none} }

/* ─── Layout ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── سایدبار — سمت راست در RTL ── */
.sidebar {
  width: var(--sw);
  background: linear-gradient(180deg, #0c1a2e 0%, #111827 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0; bottom: 0;       /* ← سمت راست */
  z-index: 50;
  border-left: 1px solid rgba(255,255,255,.07);
  box-shadow: -16px 0 40px rgba(0,0,0,.18);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;                  /* ← nav مستقل scroll می‌شود */
}

/* nav مستقل scroll‌پذیر — logo و footer ثابت می‌مانند */
.sidebar nav {
  flex: 1;
  min-height: 0;                     /* ← بدون این flex نمی‌تواند کوچک شود */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;             /* Firefox: نازک */
  scrollbar-color: rgba(255,255,255,.15) transparent;
  /* جلوگیری از wrap شدن text در ویندوز با scrollbar عریض */
  padding-left: 2px;
}
.sidebar nav::-webkit-scrollbar       { width: 4px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ── محتوا — با فاصله از راست برای سایدبار ── */
.main {
  flex: 1;
  margin-right: var(--sw);   /* ← فاصله از راست */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  padding: 28px 32px;
  flex: 1;
  animation: fadeUp .38s cubic-bezier(.22,1,.36,1) both;
}

/* ─── Sidebar — محتوای داخلی ─────────────────────────────────────────── */
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-logo .li {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(20,184,166,.32);
}
.sidebar-logo .lt { font-weight: 800; font-size: 15px; color: #fff; }
.sidebar-logo .ld { color: rgba(255,255,255,.4); font-weight: 400; }

/* nav-section header */
div[style*="rgba(100,116,139,.5)"] {
  font-size: 10px !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 8px;
  border-radius: 12px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .16s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: calc(100% - 16px);
  text-align: right;               /* ← راست‌چین */
  position: relative;
  direction: rtl;
  white-space: nowrap;             /* ← جلوگیری از wrap در ویندوز */
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item svg { flex-shrink: 0; color: rgba(255,255,255,.4); transition: color .16s; }
.nav-item:hover {
  background: rgba(20,184,166,.16);
  color: #fff;
  transform: translateX(3px);      /* ← به سمت چپ در RTL = داخل صفحه */
}
.nav-item:hover svg { color: var(--accent-light); }
.nav-item:active { transform: scale(.97); }
.nav-item.active {
  background: rgba(20,184,166,.2);
  color: #fff;
  font-weight: 700;
}
.nav-item.active svg { color: var(--accent-light); }
.nav-item.active::after {     /* نوار رنگی سمت راست (در RTL) */
  content: '';
  position: absolute;
  right: -8px;                     /* ← سمت راست */
  top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 22px;
  background: var(--accent-light);
  border-radius: 2px 0 0 2px;
}

.sidebar-spacer { display: none; }   /* nav حالا flex:1 دارد */
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 10px 8px 16px;
  flex-shrink: 0;                    /* ← همیشه پایین، فشرده نمی‌شود */
}

/* ─── Topbar (mobile only) ──────────────────────────────────────────── */
.topbar {
  display: none;
  align-items: center;
  padding: 0 16px;
  height: var(--th);
  position: relative;               /* ← برای absolute positioning همبرگر */
  background: rgba(244,251,250,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(20,184,166,.08);
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 16px rgba(15,23,42,.06);
  flex-shrink: 0;
}
/* لوگو همیشه وسط topbar */
.topbar-logo {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 800; font-size: 15px; color: var(--fg);
  direction: rtl;
}
.topbar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(20,184,166,.3);
}

/* همبرگر — همیشه سمت راست (کنار سایدبار راست) با position absolute */
.hamburger {
  position: absolute;
  right: 16px;                       /* ← ثابت سمت راست */
  top: 50%;
  transform: translateY(-50%);
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 6px 18px rgba(20,184,166,.3);
  transition: box-shadow .16s;
  flex-shrink: 0;
  z-index: 1;
}
.hamburger:active {
  transform: translateY(-50%) scale(.9);
}

/* ─── Sidebar overlay ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.55); z-index: 45;
  backdrop-filter: blur(3px);
  animation: fadeIn .18s ease;
  cursor: pointer;
}
.sidebar-overlay.show { display: block; }

/* ─── Page header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px; gap: 14px; flex-wrap: wrap;
  direction: rtl;
}
.page-title {
  font-size: 24px; font-weight: 800;
  letter-spacing: -.02em; color: var(--fg);
}
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: rgba(255,255,255,.94);
  border: 1px solid rgba(226,232,240,.84);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transition: box-shadow .22s, transform .22s;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card-head {
  padding: 16px 22px;
  border-bottom: 1px solid rgba(226,232,240,.6);
  font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  direction: rtl;
}

/* ─── KPI / Stat cards ────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 22px; padding: 20px;
  box-shadow: var(--shadow);
  transition: all .22s; overflow: hidden; position: relative;
  direction: rtl;
}
.stat-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--sc,var(--accent)), var(--sc2,var(--accent-light)));
  border-radius: 0 0 22px 22px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card-blue   { --sc:#6366f1; --sc2:#a5b4fc; }
.stat-card-green  { --sc:#22c55e; --sc2:#4ade80; }
.stat-card-orange { --sc:#f59e0b; --sc2:#fbbf24; }
.stat-card-red    { --sc:#ef4444; --sc2:#f87171; }
.stat-card-teal   { --sc:#14b8a6; --sc2:#2dd4bf; }
.stat-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 10px;
}
.stat-value {
  font-size: 28px; font-weight: 800;
  letter-spacing: -.04em;
  animation: countUp .6s ease both;
}

/* ─── Table ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; direction: rtl; }
thead { background: rgba(248,250,252,.9); }
th {
  padding: 11px 16px;
  text-align: right;                 /* ← راست‌چین */
  font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(226,232,240,.5);
  vertical-align: middle;
  text-align: right;                 /* ← راست‌چین */
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: rgba(20,184,166,.04); }
.cell-mono {
  font-family: 'Fira Code','SF Mono',monospace;
  font-size: 12px;
  color: var(--muted);
  /* محتوای LTR (IP، URL) — ولی cell خودش راست‌چین میمونه تا با header align باشه */
  text-align: right;
}
/* محتوای داخل cell-mono — فقط متن LTR می‌شه */
.cell-mono span,
.cell-mono code,
.cell-mono a {
  direction: ltr;
  display: inline-block;
  unicode-bidi: embed;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 18px;
  border-radius: var(--rsm); border: none;
  font-size: 13.5px; font-weight: 700; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: all .18s ease;
  white-space: nowrap; line-height: 1;
  min-height: 42px;
  direction: rtl;
}
.btn:active:not(:disabled) { transform: scale(.95); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  box-shadow: 0 8px 22px rgba(20,184,166,.28);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
  filter: brightness(1.04);
}

.btn-ghost {
  background: var(--surface); color: var(--fg);
  border: 1.5px solid var(--border2);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(20,184,166,.05);
}

.btn-danger {
  background: var(--danger-bg); color: var(--danger);
  border: 1.5px solid var(--danger-border);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.14); }
.btn-success { background: var(--success-bg); color: var(--success); border: 1.5px solid var(--success-border); }
.btn-warning { background: var(--warning-bg); color: var(--warning); border: 1.5px solid var(--warning-border); }

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: 10px; gap: 5px; min-height: 34px; }
.btn-lg  { padding: 13px 26px; font-size: 15px; border-radius: 18px; min-height: 50px; }
.btn-full{ width: 100%; justify-content: center; }

.btn .sp {
  width: 15px; height: 15px;
  border: 2.5px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
.btn-ghost .sp, .btn-danger .sp { border-color: rgba(20,184,166,.2); border-top-color: var(--accent); }

/* ─── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 5px 11px;
  font-size: 12px; font-weight: 700;
  background: var(--accent-bg); color: #0d9488;
  border: 1px solid rgba(20,184,166,.15);
}
.badge-success { background: var(--success-bg); color: #15803d; border-color: var(--success-border); }
.badge-danger  { background: var(--danger-bg);  color: #dc2626; border-color: var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: #b45309; border-color: var(--warning-border); }
.badge-gray    { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-neutral { background: rgba(100,116,139,.08); color: #475569; border: 1px solid rgba(100,116,139,.15); }
.badge-accent  { background: var(--accent-bg); color: #0d9488; border-color: rgba(20,184,166,.15); }

/* ─── Forms ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
label {
  display: block; font-size: 13.5px; font-weight: 700;
  color: var(--fg); margin-bottom: 7px;
  text-align: right;
}
.lhint { color: var(--muted); font-weight: 400; font-size: 12px; }

input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=range]):not([type=color]),
textarea, select {
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--rsm);
  color: var(--fg);
  padding: 11px 14px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  appearance: none;
  text-align: right;               /* ← راست‌چین */
  direction: rtl;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=range]):not([type=color]):focus,
textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20,184,166,.12);
}
input::placeholder,textarea::placeholder { color: rgba(100,116,139,.55); font-size: 13px; }
input:disabled { background: var(--surface-soft); cursor: not-allowed; color: var(--muted); }
textarea { resize: vertical; line-height: 1.7; min-height: 80px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input-group { display: flex; gap: 8px; direction: rtl; }
.input-group input { flex: 1; }
.helper  { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; text-align: right; }
.required{ color: var(--danger); }

/* ─── Search ──────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input { padding-right: 38px !important; }    /* ← padding از راست */
.search-icon {
  position: absolute; right: 12px; top: 50%;              /* ← آیکون سمت راست */
  transform: translateY(-50%); color: rgba(100,116,139,.5); pointer-events: none;
}

/* ─── Toggle ──────────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.toggle input { display: none; }
.toggle-slider {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 999px;
  transition: background .22s cubic-bezier(.4,0,.2,1);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.1);
}
.toggle-slider::before {
  content:''; position: absolute;
  width: 20px; height: 20px; right: 3px; top: 3px;  /* ← از راست */
  background: #fff; border-radius: 50%;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.toggle input:checked + .toggle-slider { background: linear-gradient(135deg,var(--accent),var(--accent-light)); }
.toggle input:checked + .toggle-slider::before { transform: translateX(-20px); } /* ← به چپ */

/* ─── Toggle row ──────────────────────────────────────────────────────── */
.toggle-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: #fff;
  border: 1.5px solid var(--border); border-radius: var(--rsm);
  margin-bottom: 8px; transition: all .18s; cursor: pointer; direction: rtl;
}
.toggle-row:hover { border-color: rgba(20,184,166,.35); box-shadow: 0 0 0 3px var(--accent-glow); }
.toggle-row.active { border-color: rgba(20,184,166,.3); background: rgba(20,184,166,.04); }
.toggle-row-icon  { font-size: 22px; flex-shrink: 0; width: 32px; text-align: center; }
.toggle-row-body  { flex: 1; min-width: 0; text-align: right; }
.toggle-row-title { font-weight: 700; font-size: 13.5px; }
.toggle-row-desc  { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.toggle-row-key {
  font-family: 'Fira Code',monospace; font-size: 10.5px;
  color: #0d9488; background: var(--accent-bg);
  padding: 2px 8px; border-radius: 6px; border: 1px solid rgba(20,184,166,.15); flex-shrink: 0;
  direction: ltr;
}

/* ─── Section header ──────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; margin-bottom: 4px;
  background: linear-gradient(135deg,rgba(20,184,166,.05),rgba(45,212,191,.02));
  border: 1px solid rgba(20,184,166,.1); border-radius: var(--rsm); direction: rtl;
}
.section-header-icon  { font-size: 22px; }
.section-header-title { font-weight: 800; font-size: 14px; }
.section-header-desc  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.section-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted);
  margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; direction: rtl;
}
.section-label::after { content:''; flex: 1; height: 1.5px; background: var(--border); }

/* ─── Modal ───────────────────────────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.52); backdrop-filter: blur(6px);
  z-index: 100; align-items: center; justify-content: center; padding: 16px;
}
.overlay.open { display: flex; }
.modal {
  background: rgba(255,255,255,.97); border: 1px solid rgba(226,232,240,.8);
  border-radius: var(--rlg); padding: 28px; width: 100%; max-width: 520px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .28s cubic-bezier(.22,1,.36,1);
  direction: rtl;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px;
}
.modal-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.modal-close {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; transition: all .14s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-footer {
  display: flex; justify-content: flex-start; gap: 8px;  /* ← راست = flex-start در RTL */
  margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(226,232,240,.5);
  flex-shrink: 0;
}
/* فرم داخل modal: فاصله کمتر */
.modal .form-group { margin-bottom: 0; }
.modal .form-row   { gap: 10px; }

/* ─── Empty state ─────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 52px 24px; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .6; animation: pulse 2.5s ease infinite; }
.empty p { font-size: 14px; }
.empty a { color: var(--accent); font-weight: 700; }

/* ─── Info boxes ──────────────────────────────────────────────────────── */
.info-box {
  background: rgba(20,184,166,.05); border: 1px solid rgba(20,184,166,.18);
  border-radius: var(--rsm); padding: 14px 18px; font-size: 13px; line-height: 1.7;
  color: #0f766e; direction: rtl;
}
.warn-box {
  background: var(--warning-bg); border: 1px solid var(--warning-border);
  border-radius: var(--rsm); padding: 14px 18px; font-size: 13px; line-height: 1.7;
  color: #92400e; direction: rtl;
}
.success-box {
  background: var(--success-bg); border: 1px solid var(--success-border);
  border-radius: var(--rsm); padding: 14px 18px; font-size: 13px; line-height: 1.7;
  color: #065f46; direction: rtl;
}

/* ─── Toasts ──────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 20px; left: 16px;   /* ← چپ در RTL */
  z-index: 999; display: flex; flex-direction: column; gap: 9px;
  pointer-events: none; max-width: 380px; width: calc(100% - 32px);
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(255,255,255,.97); border: 1px solid var(--border);
  border-radius: var(--rsm); padding: 13px 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .28s cubic-bezier(.22,1,.36,1);
  pointer-events: auto; font-size: 13px; direction: rtl;
}
.toast.exit { animation: toastOut .22s ease forwards; }
.toast-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 800; margin-bottom: 2px; font-size: 13px; }
.toast-msg { color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-word; }
.toast-close { background: none; border: none; cursor: pointer; color: rgba(100,116,139,.5); font-size: 18px; padding: 0; margin-right: 4px; flex-shrink: 0; line-height: 1; align-self: flex-start; transition: color .1s; }
.toast-close:hover { color: var(--fg); }
.toast.success { border-right: 3px solid var(--success); }   /* ← راست در RTL */
.toast.error   { border-right: 3px solid var(--danger); }
.toast.warning { border-right: 3px solid var(--warning); }
.toast.info    { border-right: 3px solid var(--accent); }

/* ─── Auth ────────────────────────────────────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
  background:
    radial-gradient(ellipse 80% 60% at 10% -5%, rgba(20,184,166,.2), transparent 50%),
    radial-gradient(ellipse 60% 50% at 90% 105%, rgba(99,102,241,.14), transparent 50%),
    linear-gradient(180deg, #f4fbfa 0%, #edf6f5 100%);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: rgba(255,255,255,.97); border-radius: var(--rlg);
  padding: 44px 40px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(20,184,166,.08);
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1);
  direction: rtl;
}
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 800; font-size: 17px; }
.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 8px 22px rgba(20,184,166,.35);
}
.auth-title { font-size: 26px; font-weight: 800; letter-spacing: -.04em; margin-bottom: 5px; }
.auth-sub   { color: var(--muted); font-size: 13.5px; margin-bottom: 28px; }
.auth-error {
  background: var(--danger-bg); border: 1.5px solid var(--danger-border);
  color: var(--danger); border-radius: var(--rsm);
  padding: 11px 15px; font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px; animation: fadeUp .2s ease;
}

/* ─── Code ────────────────────────────────────────────────────────────── */
code {
  background: rgba(15,23,42,.06); border: 1px solid rgba(15,23,42,.08);
  border-radius: 8px; padding: 2px 7px;
  font-family: 'Fira Code','SF Mono',monospace; font-size: 12px;
  color: var(--fg); direction: ltr; /* کد همیشه LTR */
}

/* ─── Drop zone ───────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border2); border-radius: var(--r);
  padding: 36px 20px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--surface-soft);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: rgba(20,184,166,.05); }
.drop-zone-icon { font-size: 38px; margin-bottom: 12px; opacity: .7; }
.drop-zone p { font-size: 13.5px; color: var(--muted); }
.drop-zone strong { color: var(--accent); }

/* ─── Card loading ────────────────────────────────────────────────────── */
.card-loading { position: relative; pointer-events: none; }
.card-loading::after {
  content:''; position: absolute; inset: 0;
  background: rgba(255,255,255,.8); border-radius: inherit; z-index: 5;
  animation: pulse 1.2s ease infinite;
}

/* ─── Skeleton ────────────────────────────────────────────────────────── */
.skeleton-card {
  min-height: 120px; border-radius: var(--r);
  background: linear-gradient(90deg,rgba(255,255,255,.75),rgba(226,232,240,.65),rgba(255,255,255,.75));
  background-size: 220% 100%;
  animation: shimmer 1.25s ease-in-out infinite;
  border: 1px solid rgba(226,232,240,.9);
}

/* ─── Drag rows ───────────────────────────────────────────────────────── */
.drag-row {
  background: #fff; border: 1.5px solid var(--border);
  border-radius: var(--rsm); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 8px; transition: all .18s; direction: rtl;
}
.drag-row:hover { box-shadow: var(--shadow-xs); border-color: rgba(20,184,166,.25); }
.drag-row.disabled { opacity: .45; }
.order-btn {
  width: 30px; height: 30px; border-radius: 10px;
  background: var(--surface-soft); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all .14s; flex-shrink: 0;
}
.order-btn:hover { background: var(--accent-bg); border-color: rgba(20,184,166,.3); color: #0d9488; }

/* ─── User cards ──────────────────────────────────────────────────────── */
.user-card {
  background: #fff; border-bottom: 1px solid rgba(226,232,240,.55);
  padding: 12px 16px; cursor: pointer; transition: background .12s;
  display: flex; align-items: center; gap: 12px; direction: rtl;
}
.user-card:last-child { border-bottom: none; }
.user-card:hover { background: rgba(20,184,166,.04); }
.user-card.selected { background: rgba(20,184,166,.08); border-right: 3px solid var(--accent); }
.user-card-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.user-card-name { font-weight: 700; font-size: 13.5px; }
.user-card-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ─── Tablet (769–1024) ───────────────────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
  :root { --sw: 220px; }
  .page-content { padding: 22px 24px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ─── Mobile (≤768) ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* سایدبار از راست می‌آید — عرض کافی تا منو ناقص/تنگ نباشد */
  .sidebar {
    transform: translateX(100%);
    width: 244px;
    max-width: 86vw;                 /* هرگز از عرض صفحه بیرون نزند */
    height: 100dvh;                  /* ارتفاعِ واقعیِ موبایل (نه 100vh که با toolbar خطا دارد) */
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -12px 0 40px rgba(15,23,42,.28);
  }
  /* nav حتماً اسکرول‌پذیر باشد تا همهٔ آیتم‌ها (حتی روی گوشیِ کوتاه) کامل دیده شوند */
  .sidebar nav { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .nav-item { white-space: normal; }   /* متنِ بلند بریده نشود، در صورت نیاز به خط بعد برود */
  .main { margin-right: 0; min-width: 0; }
  .topbar { display: flex; }

  /* topbar ارتفاع با safe-area notch آیفون */
  .topbar {
    padding-right: env(safe-area-inset-right, 0px);
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--th) + env(safe-area-inset-top, 0px));
  }
  .sidebar-logo {
    padding-top: max(22px, calc(16px + env(safe-area-inset-top, 0px)));
  }

  /* محتوا */
  .page-content {
    padding: 16px 16px 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  }
  .page-title { font-size: 20px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* فرم */
  .form-row { grid-template-columns: 1fr; }

  /* iOS zoom prevention — font-size زیر 16px زوم میکنه */
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]):not([type=range]):not([type=color]),
  textarea, select { font-size: 16px !important; }

  /* آمار */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px 12px; border-radius: 16px; }

  /* modal — bottom-sheet */
  .overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    padding: 22px 18px 22px;
    padding-bottom: max(22px, env(safe-area-inset-bottom, 22px));
    border-radius: var(--r) var(--r) 0 0;
    max-height: 92dvh;
    width: 100%;
    max-width: 100%;
    animation: slideUp .3s cubic-bezier(.22,1,.36,1);
    -webkit-overflow-scrolling: touch;
  }

  /* جدول */
  .card { border-radius: 18px; }
  th, td { padding: 9px 10px; font-size: 12.5px; }
  .hide-mobile { display: none !important; }
  .table-wrap { border-radius: 18px; }

  /* Auth */
  .auth-card { padding: 24px 18px; border-radius: var(--r); }
  .auth-title { font-size: 22px; }

  /* toast — safe-area */
  .toast-wrap {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    left: max(12px, env(safe-area-inset-left, 12px));
    width: calc(100% - max(24px, calc(env(safe-area-inset-left, 0px) + env(safe-area-inset-right, 0px) + 24px)));
  }

  /* touch targets حداقل ۴۴px (Apple HIG) */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 8px 12px; font-size: 12.5px; }
  .nav-item { padding: 10px 10px; min-height: 44px; font-size: 12.5px; gap: 7px; }
  .nav-item svg { width: 14px; height: 14px; }
  .modal-close { width: 40px; height: 40px; }
  /* modal — padding کمتر + فرم compact */
  .modal { padding: 18px 16px 16px; }
  .modal-header { margin-bottom: 14px; }
  .modal-title { font-size: 15px; }
  .modal-footer { margin-top: 14px; padding-top: 12px; }
  .modal .form-row { gap: 8px; }
}

/* ─── کوچک‌ترین گوشی‌ها (≤400 — iPhone SE, Galaxy A) ──────────────────── */
@media (max-width: 400px) {
  :root { --r: 18px; --rsm: 12px; --rlg: 22px; }
  .page-content { padding: 12px 12px 20px; padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)); }
  .stat-grid { gap: 8px; }
  .stat-card { padding: 12px 10px; border-radius: 14px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }
  .modal { padding: 16px 14px 20px; padding-bottom: max(20px, env(safe-area-inset-bottom, 20px)); }
  .page-title { font-size: 18px; }
  td { padding: 7px 8px; font-size: 12px; }
  th { padding: 7px 8px; font-size: 10px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; }
  .toast { padding: 10px 12px; }
  .badge { padding: 4px 8px; font-size: 11px; }
}

/* ─── Desktop بزرگ (≥1400) ────────────────────────────────────────────────── */
@media (min-width: 1400px) {
  :root { --sw: 280px; }
  .page-content { padding: 32px 40px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
}

/* ─── انیمیشن bottom-sheet ────────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(60px); opacity: .7; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── اسکرول لیست‌ها روی iOS ──────────────────────────────────────────────── */
.table-wrap,
.sidebar {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ─── select بدون ظاهر پیش‌فرض iOS/Android ─────────────────────────────── */
select {
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 34px;
}

/* ─── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* فاز ۲۰: آیکون راهنما ؟ — دکمهٔ کلیکی (با کلیک، توضیح زیرش باز می‌شود) */
.help-q{
  display:inline-flex;align-items:center;justify-content:center;
  width:18px;height:18px;border-radius:50%;
  background:var(--accent-bg);color:var(--accent);
  font-size:11px;font-weight:800;cursor:pointer;margin-right:4px;
  border:1px solid var(--accent);vertical-align:middle;
  transition:.15s;user-select:none;
}
.help-q:hover{background:var(--accent);color:#fff;transform:scale(1.12)}
.help-q.active{background:var(--accent);color:#fff}
/* کادر توضیح بازشونده */
.help-pop{
  background:var(--accent-bg);
  border:1px solid var(--accent);
  border-radius:var(--rsm);
  color:var(--text);font-size:12.5px;line-height:1.75;
  max-height:0;opacity:0;overflow:hidden;padding:0 14px;margin:0;
  transition:max-height .25s ease, opacity .2s ease, padding .25s ease, margin .25s ease;
}
.help-pop.open{max-height:300px;opacity:1;padding:11px 14px;margin:8px 0}
.help-pop b{color:var(--accent)}

/* فاز ۲۰: ورودی‌های انگلیسی چپ‌چین (host/path/user/pass/...) — !important چون قانون سراسری input
   به‌خاطر زنجیرهٔ :not() specificity بسیار بالایی دارد و direction:rtl را تحمیل می‌کند. */
input[dir="ltr"], textarea[dir="ltr"]{ direction:ltr !important; text-align:left !important; }
/* placeholder فارسی راست‌چین بماند (فقط متن تایپ‌شدهٔ انگلیسی چپ‌چین است) */
input[dir="ltr"]::placeholder, textarea[dir="ltr"]::placeholder{ direction:rtl; text-align:right; }
