@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   پنل کاربری صفر تی‌اس – RTL / مدرن / رسپانسیو
   ============================================ */
:root {
  --bg: #0b1220;
  --bg-soft: #111827;
  --card: #151c2c;
  --card-hover: #1a2336;
  --border: rgba(255,255,255,0.08);
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-w: 280px;
  --header-h: 64px;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,0.25);
  --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { direction: rtl; height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* Layout */
.app {
  min-height: 100vh;
  overflow: visible;
  position: relative;
}


.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}
.nav-section {
  font-size: .72rem;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  transition: .15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-size: .95rem;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: rgba(37,99,235,0.15);
  color: #93c5fd;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; opacity: .9; }
.nav-badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-muted);
}

/* Main — در جریان صفحه؛ اسکرول روی body؛ هدر همراه محتوا حرکت می‌کند */
.main {
  position: relative;
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  overflow: visible;
  z-index: 1;
  background: var(--bg);
}


.header {
  height: var(--header-h);
  background: var(--bg-soft, rgba(17,24,39,0.95));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: var(--sidebar-w);
  z-index: 50;
  width: auto;
  box-sizing: border-box;
}
.app.sidebar-collapsed .header {
  right: 78px;
}
.content {
  padding-top: var(--header-h);
}
.header-title { font-size: 1.1rem; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  transition: .15s;
}
.icon-btn:hover { background: var(--card-hover); }
.icon-btn .dot {
  position: absolute;
  top: 8px; left: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 700;
}
.user-meta { line-height: 1.2; }
.user-meta strong { display: block; font-size: .85rem; }
.user-meta span { font-size: .72rem; color: var(--text-muted); }

.content {
  display: block;
  min-height: 100%;
  padding: 0;
  padding-top: var(--header-h);
  overflow: visible;
}

/* Cards & grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .label { color: var(--text-muted); font-size: .85rem; margin-bottom: 6px; }
.stat-card .value { font-size: 1.45rem; font-weight: 700; }
.stat-card .hint { font-size: .75rem; color: var(--text-muted); margin-top: 6px; }
.stat-card-link {
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.stat-card-link:hover {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 4px 14px rgba(59, 130, 246, .12);
}
.stat-card-link:focus-visible {
  outline: 2px solid var(--primary, #3b82f6);
  outline-offset: 2px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title { font-size: 1.05rem; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); }
.btn-danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
}
.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}
html.theme-light .btn-danger, body.theme-light .btn-danger {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
}
html.theme-light .btn-danger:hover, body.theme-light .btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 14px; }
.field-hint {
  margin-top: 6px;
  font-size: .82rem;
  line-height: 1.4;
  min-height: 1.2em;
}
.field-hint.ok { color: #34d399; }
.field-hint.err { color: #f87171; }
.field-hint.muted { color: var(--text-muted, #94a3b8); }

/* Password field + eye toggle + strength */
.pass-field {
  position: relative;
  display: block;
}
.pass-field .form-control {
  padding-left: 44px;
}
.pass-eye {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color .15s, background .15s;
}
.pass-eye:hover {
  color: var(--text, #e5e7eb);
  background: rgba(148, 163, 184, 0.12);
}
.pass-eye svg { display: block; pointer-events: none; }
.pass-strength {
  margin-top: 10px;
}
.pass-strength-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}
.pass-strength-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width .25s ease, background-color .25s ease;
  background: #ef4444;
}
.pass-strength-bar span.s1 { width: 25%; background: #ef4444; }
.pass-strength-bar span.s2 { width: 50%; background: #f59e0b; }
.pass-strength-bar span.s3 { width: 75%; background: #3b82f6; }
.pass-strength-bar span.s4 { width: 100%; background: #10b981; }
.pass-strength-label {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--text-muted, #94a3b8);
}
.pass-strength-label.s1 { color: #f87171; }
.pass-strength-label.s2 { color: #fbbf24; }
.pass-strength-label.s3 { color: #60a5fa; }
.pass-strength-label.s4 { color: #34d399; }

/* چیدمان باکس تغییر رمز */
.pass-change-layout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.pass-change-current {
  max-width: 420px;
  width: 100%;
}
.pass-change-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.pass-change-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  padding-top: 4px;
}
.pass-change-actions .btn {
  min-width: 140px;
}
@media (max-width: 700px) {
  .pass-change-pair {
    grid-template-columns: 1fr;
  }
  .pass-change-current {
    max-width: 100%;
  }
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  color: var(--text-muted);
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  transition: .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }
.form-control[dir="ltr"] { text-align: left; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: .8rem; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fcd34d; }
.badge-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-info { background: rgba(37,99,235,0.15); color: #93c5fd; }
.badge-muted { background: rgba(156,163,175,0.15); color: #d1d5db; }

/* Empty / loading */
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.5;
}
.alert a { color: var(--primary); font-weight: 600; }

.empty, .loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
/* صف toast عمودی — قدیمی‌تر بالا، جدیدتر پایین؛ قدیمی زودتر محو */
.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: min(420px, 92vw);
  width: max-content;
  pointer-events: none;
}
.toast,
.toast-item {
  position: relative;
  left: auto;
  bottom: auto;
  transform: translateY(12px);
  background: #1f2937;
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  border: 1px solid var(--border);
  max-width: min(420px, 92vw);
  width: max-content;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.toast.show,
.toast-item.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.toast-out,
.toast-item.toast-out {
  opacity: 0;
  transform: translateY(8px);
}
.toast.success,
.toast-item.success {
  border-color: rgba(16, 185, 129, 0.45);
  background: linear-gradient(145deg, #0f2e24, #1f2937);
}
.toast.error,
.toast-item.error {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(145deg, #3a1515, #1f2937);
}

/* Mobile */
.menu-toggle { display: none; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(105%);
  }
  .sidebar.open { transform: translateX(0); }
  .main { right: 0; margin-right: 0; }
  .menu-toggle { display: grid; }
  .sidebar-overlay.show { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .user-meta { display: none; }
}

/* Page sections (SPA-like) */
.page {
  display: none;
  /* کاهش کار رندر برای صفحات مخفی — بدون تغییر ظاهر */
  content-visibility: hidden;
  contain-intrinsic-size: 1px 800px;
}
.page.active {
  display: block;
  content-visibility: visible;
}


/* آواتار دایره‌ای با رینگ استوری */
.avatar-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af, #515bd4);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}
.avatar-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-soft);
  padding: 3px;
  display: grid;
  place-items: center;
}
.avatar-ring img, .avatar-ring .avatar-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.avatar-ring .avatar-fallback {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.4rem;
  color: #fff;
}
.avatar-ring-sm {
  width: 40px;
  height: 40px;
  padding: 2px;
}
.avatar-ring-sm .avatar-ring-inner { padding: 2px; }
.avatar-upload-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.uuid-locked-box {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: .9rem;
}
.uuid-locked-box code {
  direction: ltr;
  display: inline-block;
  margin-top: 4px;
  color: #93c5fd;
  word-break: break-all;
}


/* ===== Theme Light ===== */
html.theme-light, body.theme-light {
  --bg: #f3f4f6;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --card-hover: #f9fafb;
  --border: rgba(0,0,0,0.08);
  --text: #111827;
  --text-muted: #6b7280;
  --shadow: 0 8px 30px rgba(0,0,0,0.06);
}
html.theme-light .sidebar, body.theme-light .sidebar { background: #fff; border-left-color: rgba(0,0,0,0.08); }
html.theme-light .header, body.theme-light .header { background: var(--bg-soft, #ffffff); }

/* Sidebar collapse – فقط وقتی هاور نیست مخفی شود */
.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 78px;
}
.app.sidebar-collapsed .main {
  right: 78px;
  margin-right: 0;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand .brand-text,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand span:not(.brand-logo),
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-badge,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-meta {
  display: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand {
  justify-content: center;
  padding: 0;
  gap: 0;
}
.app.sidebar-collapsed .sidebar.hover-expand {
  width: var(--sidebar-w) !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-item .label,
.app.sidebar-collapsed .sidebar.hover-expand .nav-section,
.app.sidebar-collapsed .sidebar.hover-expand .brand-text,
.app.sidebar-collapsed .sidebar.hover-expand .sb-user-meta,
.app.sidebar-collapsed .sidebar.hover-expand .nav-badge {
  display: inline !important;
  opacity: 1 !important;
  max-width: 200px !important;
  visibility: visible !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-section {
  display: block !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .sb-user-meta {
  display: block !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-item {
  justify-content: flex-start !important;
  padding: 11px 14px !important;
  gap: 12px !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .sidebar-brand {
  justify-content: flex-start !important;
  padding: 0 16px !important;
  gap: 12px !important;
}

/* Avatar fix - never overflow */
.avatar-ring img,
.avatar-ring .avatar-fallback {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  overflow: hidden;
}
.avatar-ring-inner {
  overflow: hidden;
  border-radius: 50%;
  width: 100%;
  height: 100%;
}

/* Profile dropdown */
.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 200;
  display: none;
}
.profile-dropdown.open { display: block; }
.profile-dropdown .pd-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.profile-dropdown .pd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-size: .9rem;
}
.profile-dropdown .pd-item:hover { background: rgba(37,99,235,0.1); }
.profile-dropdown .pd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.profile-dropdown .pd-grid .pd-item {
  flex-direction: column;
  gap: 6px;
  padding: 14px 8px;
  background: rgba(255,255,255,0.03);
}

/* Support dropdown (header) */
.support-wrap { position: relative; }
.support-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 200;
  display: none;
}
.support-dropdown.open { display: block; }
.support-dropdown .sd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-size: .9rem;
  font-family: inherit;
}
.support-dropdown .sd-item:hover { background: rgba(37,99,235,0.1); }
.support-dropdown .sd-item svg { flex-shrink: 0; opacity: .9; }
html.theme-light .support-dropdown .sd-item:hover,
body.theme-light .support-dropdown .sd-item:hover { background: rgba(37,99,235,0.08); }

/* Crop modal */
.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  padding: 16px;
}
.crop-modal.open { display: flex; }
.crop-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(420px, 100%);
  padding: 20px;
  box-shadow: var(--shadow);
}
.crop-stage {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 16px auto;
  overflow: hidden;
  border-radius: 50%;
  background: #000;
  touch-action: none;
  cursor: grab;
}
.crop-stage img {
  position: absolute;
  max-width: none;
  user-select: none;
  pointer-events: none;
}
.crop-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.crop-zoom {
  width: 100%;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .app.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  .app.sidebar-collapsed .main { right: 0; margin-right: 0; }
}


/* ===== Sidebar advanced ===== */
.sidebar {
  transition: width .28s cubic-bezier(.4,0,.2,1), transform .28s ease;
  overflow: hidden;
}
.sidebar-brand {
  position: relative;
  justify-content: space-between;
}
.sidebar-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .28s ease, background .15s;
}
.sidebar-toggle-btn:hover { background: var(--card-hover); }
.app.sidebar-collapsed .sidebar-toggle-btn {
  transform: rotate(180deg);
}
/* In RTL, open state arrow points left (to collapse toward edge), collapsed points right */
.app:not(.sidebar-collapsed) .sidebar-toggle-btn svg {
  transform: rotate(0deg);
}

.sidebar-nav .nav-item {
  white-space: nowrap;
  overflow: hidden;
}
.nav-item .label {
  opacity: 1;
  transition: opacity .2s;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-badge,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand > span,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-meta,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-mini-btn span {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 78px;
}
.app.sidebar-collapsed .main {
  margin-right: 78px;
  transition: margin-right .28s cubic-bezier(.4,0,.2,1);
}
.app.sidebar-collapsed .sidebar.hover-expand {
  width: var(--sidebar-w);
  box-shadow: -8px 0 30px rgba(0,0,0,0.25);
  z-index: 120;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: center;
  padding-left: 12px;
  padding-right: 12px;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand {
  justify-content: center;
  gap: 0;
  padding: 0 8px;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand img {
  margin: 0 auto;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-toggle-btn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
  bottom: -40px; /* will reposition via brand layout */
}

/* Footer user block */
.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  position: relative;
}
.sb-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-user-meta {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
  transition: opacity .2s;
}
.sb-user-meta strong {
  display: block;
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-meta span {
  font-size: .72rem;
  color: var(--text-muted);
}
.sb-mini-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.sb-mini-btn:hover { background: var(--card-hover); }

.sb-mini-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px;
  right: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 130;
}
.sb-mini-menu.open { display: block; }
.sb-mini-menu .pd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sb-mini-menu .pd-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 10px;
  border: none;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  font-size: .8rem;
}
.sb-mini-menu .pd-item:hover { background: rgba(37,99,235,0.12); }
html.theme-light .sb-mini-menu .pd-item, body.theme-light .sb-mini-menu .pd-item { background: rgba(0,0,0,0.03); }

.sidebar .avatar-ring {
  width: 42px;
  height: 42px;
  padding: 2px;
  flex-shrink: 0;
}
.sidebar .avatar-ring-inner { padding: 2px; }

@media (max-width: 768px) {
  .app.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  .app.sidebar-collapsed .main { right: 0; margin-right: 0; }
  .app.sidebar-collapsed .sidebar.hover-expand { width: var(--sidebar-w); }
}


/* وقتی هاور موقت است، مثل حالت باز کامل */
.app.sidebar-collapsed .sidebar.hover-expand .nav-item .label,
.app.sidebar-collapsed .sidebar.hover-expand .nav-section,
.app.sidebar-collapsed .sidebar.hover-expand .nav-badge,
.app.sidebar-collapsed .sidebar.hover-expand .sidebar-brand span,
.app.sidebar-collapsed .sidebar.hover-expand .sb-user-meta {
  opacity: 1 !important;
  width: auto !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-item {
  justify-content: flex-start !important;
  padding: 11px 14px !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .sidebar-brand {
  justify-content: space-between !important;
  padding: 0 20px !important;
}



/* ===== Sidebar icons fixed (no jump) ===== */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.sidebar-brand img.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
}
.sidebar-brand .brand-text {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s ease, width .2s ease, margin .2s ease;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  width: 100%;
  text-align: right;
  position: relative;
}
.sidebar-nav .nav-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  min-width: 22px;
}
.sidebar-nav .nav-item .label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .18s ease, max-width .22s ease, margin .22s ease;
  max-width: 180px;
  opacity: 1;
}

/* Collapsed: keep icon column centered, hide labels */
.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 78px;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .brand-text,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-badge,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-meta {
  opacity: 0 !important;
  max-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  border: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: center;
  padding: 12px 0;
  gap: 0;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand {
  justify-content: center;
  padding: 0;
  gap: 0;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-row {
  justify-content: center;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-mini-btn {
  display: none;
}

/* Hover expand OR not collapsed: full labels */
.app.sidebar-collapsed .sidebar.hover-expand,
.app:not(.sidebar-collapsed) .sidebar {
  width: var(--sidebar-w);
}
.app.sidebar-collapsed .sidebar.hover-expand .brand-text,
.app.sidebar-collapsed .sidebar.hover-expand .nav-section,
.app.sidebar-collapsed .sidebar.hover-expand .nav-item .label,
.app.sidebar-collapsed .sidebar.hover-expand .sb-user-meta {
  opacity: 1 !important;
  max-width: 200px !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-item {
  justify-content: flex-start !important;
  padding: 11px 14px !important;
  gap: 12px !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .sidebar-brand {
  justify-content: flex-start !important;
  padding: 0 16px !important;
  gap: 12px !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .sb-mini-btn {
  display: grid;
}
.app.sidebar-collapsed .sidebar.hover-expand {
  box-shadow: -10px 0 28px rgba(0,0,0,.22);
  z-index: 130;
}



/* =====================================================
   Sidebar icons LOCKED to the right edge (RTL)
   ===================================================== */
.sidebar-nav .nav-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  padding: 12px 18px !important;
  box-sizing: border-box !important;
}
.sidebar-nav .nav-item svg {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  flex: 0 0 22px !important;
}
.sidebar-nav .nav-item .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  max-width: 200px;
  transition: opacity .2s ease, max-width .25s ease;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 72px !important;
}
/* IMPORTANT: same padding + flex-start so icons do not jump */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: flex-start !important;
  padding: 12px 18px !important;
  gap: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-badge,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .brand-text,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-meta {
  opacity: 0 !important;
  max-width: 0 !important;
  width: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  visibility: hidden !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section {
  height: 0 !important;
  min-height: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-brand {
  justify-content: flex-start !important;
  padding: 0 18px !important;
  gap: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-row {
  justify-content: flex-start !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-mini-btn {
  display: none !important;
}
.app.sidebar-collapsed .main { right: 72px; margin-right: 0; }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; overflow: hidden;
  flex-shrink: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  font-size: .8rem; font-weight: 700; position: relative;
}
.user-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}



/* Toggle switch (dark mode) */
.pd-toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  cursor: default !important;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,0.15);
  border-radius: 999px;
  transition: .2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  right: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .slider {
  background: var(--primary);
}
.switch input:checked + .slider:before {
  transform: translateX(-20px);
}
html.theme-light .slider, body.theme-light .slider { background: rgba(0,0,0,0.15); }

/* Chip avatar: single image, no double layer */
#chipAvatar, #ddAvatar {
  background: linear-gradient(135deg, var(--primary), #7c3aed) !important;
  background-image: none !important;
}
#chipAvatar img, #ddAvatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
#chipAvatarFb, #ddAvatarFb {
  position: relative;
  z-index: 0;
}

/* Final icon lock: fixed right column */
.sidebar-nav {
  padding-left: 8px;
  padding-right: 8px;
}
.sidebar-nav .nav-item {
  position: relative !important;
  min-height: 44px !important;
  padding: 11px 14px 11px 14px !important;
}
.sidebar-nav .nav-item svg {
  position: relative !important;
  /* stay in flow at start (RTL = right) */
  margin: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 68px !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  padding: 11px 14px !important;
}
.app.sidebar-collapsed .main {
  margin-right: 68px !important;
}



/* =========================================================
   CRITICAL: section headers keep HEIGHT when collapsed
   so icons never shift vertically
   ========================================================= */
.sidebar-nav .nav-section {
  font-size: .72rem;
  color: var(--text-muted);
  padding: 14px 14px 6px !important;
  letter-spacing: .04em;
  line-height: 1.2;
  min-height: 32px;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
}

/* Collapsed: hide text but KEEP the vertical space */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section {
  opacity: 0 !important;
  visibility: hidden !important;
  color: transparent !important;
  /* DO NOT collapse height */
  height: auto !important;
  min-height: 32px !important;
  max-height: none !important;
  padding: 14px 14px 6px !important;
  margin: 0 !important;
  width: 100% !important;
  max-width: none !important;
  display: block !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Labels: hide without affecting icon row height */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label {
  opacity: 0 !important;
  visibility: hidden !important;
  max-width: 0 !important;
  width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  display: inline-block !important;
}

/* Icon rows: identical metrics open/closed */
.sidebar-nav .nav-item {
  min-height: 44px !important;
  height: 44px !important;
  padding: 0 16px !important;
  margin-bottom: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  min-height: 44px !important;
  height: 44px !important;
  padding: 0 16px !important;
  margin-bottom: 4px !important;
  gap: 0 !important;
  justify-content: flex-start !important;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 68px !important;
}
.app.sidebar-collapsed .main {
  margin-right: 68px !important;
}

/* Hover open: show section titles again */
.app.sidebar-collapsed .sidebar.hover-expand .nav-section {
  opacity: 1 !important;
  visibility: visible !important;
  color: var(--text-muted) !important;
  min-height: 32px !important;
  padding: 14px 14px 6px !important;
}


.rk-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 4px;
}
.rk-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg-soft);
  font-size: .85rem;
}
.rk-group-item:hover { border-color: var(--primary); }
.rk-group-item.active {
  border-color: var(--primary);
  background: rgba(37,99,235,0.12);
}
.rk-group-item img {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.rk-editor-head {
  display: grid;
  grid-template-columns: 1fr 2fr 90px 40px;
  gap: 8px;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 4px;
}
.rk-row {
  display: grid;
  grid-template-columns: 1fr 2fr 90px 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.rk-row select, .rk-row input {
  width: 100%;
}
.rk-sg-option {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rk-search-box { margin-bottom: 10px; }
.rk-group-grid { max-height: 240px; }
.rk-combo { position: relative; }
.rk-combo-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}
.rk-combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  max-height: 260px;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  z-index: 50;
  display: none;
  box-shadow: var(--shadow);
}
.rk-combo-list.open { display: block; }
.rk-combo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: .88rem;
}
.rk-combo-item:hover { background: rgba(37,99,235,0.12); }
.rk-combo-item img { width: 16px; height: 16px; }
.rk-combo-item .meta { color: var(--text-muted); font-size: .72rem; margin-right: auto; }

.nav-tree { margin: 0; }
.nav-tree-toggle { width: 100%; position: relative; }
.nav-tree-toggle .tree-chevron {
  margin-right: auto;
  transition: transform .32s cubic-bezier(.4,0,.2,1), opacity .25s ease;
  opacity: .7;
  flex-shrink: 0;
}
.nav-tree.open .tree-chevron,
.nav-tree.nav-details[open] .tree-chevron { transform: rotate(180deg); opacity: .9; }

/* انیمیشن نرم باز/بسته زیرشاخه‌ها */
.nav-tree-children {
  display: block;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  border-right: 2px solid transparent;
  transition:
    max-height .38s cubic-bezier(.4,0,.2,1),
    opacity .28s ease,
    transform .28s ease,
    padding .28s ease,
    border-color .28s ease;
  pointer-events: none;
}
.nav-tree.open > .nav-tree-children,
.nav-tree.nav-details[open] > .nav-tree-children {
  max-height: 480px;
  opacity: 1;
  transform: translateY(0);
  padding-top: 4px;
  padding-bottom: 6px;
  margin: 2px 0 8px;
  border-right-color: rgba(37,99,235,0.25);
  padding-right: 18px;
  pointer-events: auto;
}
.nav-item.nav-sub {
  font-size: .82rem !important;
  min-height: 36px !important;
  height: auto !important;
  padding: 8px 12px !important;
  opacity: .9;
  transition: background .18s ease, color .18s ease, opacity .18s ease;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-children {
  max-height: 0 !important;
  opacity: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .tree-chevron { display: none !important; }

.rk-assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.rk-assign-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--bg-soft);
}
.rk-assign-card .rk-ms {
  margin-top: 6px;
}
.rk-ms {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
}
.rk-ms-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
}
.rk-ms-list {
  max-height: 160px;
  overflow: auto;
}
.rk-ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: .82rem;
}
.rk-ms-item:hover { background: rgba(37,99,235,0.1); }
.rk-ms-item.active { background: rgba(37,99,235,0.18); }
.rk-ms-item img { width: 16px; height: 16px; }
.rk-ms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  min-height: 28px;
}
.rk-ms-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(37,99,235,0.15);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .72rem;
}



/* ===== Admin tree: stable parent + dots ===== */
.nav-tree {
  width: 100%;
}
.nav-tree-toggle {
  width: 100% !important;
}
.nav-tree-toggle .nav-ico {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-tree-toggle .nav-ico svg {
  width: 20px;
  height: 20px;
}
.nav-tree-toggle .tree-chevron {
  margin-right: auto;
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  opacity: .55;
  transition: transform .2s ease, opacity .2s;
  flex-shrink: 0;
}
.nav-tree.open > .nav-tree-toggle .tree-chevron {
  transform: rotate(180deg);
  opacity: .9;
}

/* Parent stays; children expand under it — انیمیشن در بلوک بالاتر */
.nav-tree-children {
  position: relative;
}

/* Vertical guide line */
.nav-tree-children::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 8px;
  right: 26px;
  width: 2px;
  background: rgba(148, 163, 184, 0.22);
  border-radius: 2px;
  pointer-events: none;
}

.nav-item.nav-sub {
  position: relative;
  width: 100% !important;
  min-height: 36px !important;
  height: auto !important;
  padding: 8px 14px 8px 14px !important;
  gap: 10px !important;
  justify-content: flex-start !important;
  font-size: .82rem !important;
  opacity: .92;
  background: transparent !important;
}

.nav-item.nav-sub .nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 0;
  margin-left: 4px;
  /* hollow ring - RTL: sits near guide */
  box-sizing: border-box;
  border: 1.5px solid rgba(148, 163, 184, 0.55);
  background: transparent;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.nav-item.nav-sub:hover .nav-dot,
.nav-item.nav-sub.active .nav-dot {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
  transform: scale(1.15);
}

.nav-item.nav-sub:hover,
.nav-item.nav-sub.active {
  color: var(--text);
  background: rgba(37, 99, 235, 0.08) !important;
}

/* collapsed: only parent icon, same column as others */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-children {
  display: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .tree-chevron,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .label {
  display: none !important;
  opacity: 0 !important;
  max-width: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle {
  justify-content: flex-start !important;
  padding: 0 16px !important;
  gap: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .nav-ico {
  margin: 0 !important;
}

/* unify all nav icons width so they align */
.sidebar-nav .nav-item > svg,
.sidebar-nav .nav-item .nav-ico svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.sidebar-nav .nav-item {
  justify-content: flex-start !important;
}

#page-admin-rank .admin-rank-section { display: none; }
#page-admin-rank .admin-rank-section.is-active { display: block; }

.money-hint {
  margin-top: 6px;
  font-size: .85rem;
  color: var(--text-muted);
}

.su-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ادمین: فقط با JS برای role=admin باز می‌شود */
.admin-only[hidden],
[hidden].admin-only {
  display: none !important;
}
.admin-only:not([hidden]) {
  /* allow normal display rules */
}


/* مخفی‌سازی ادمین برای کاربر عادی — مهم‌تر از display:flex آیتم‌ها */
.admin-only[hidden],
[hidden].admin-only,
.nav-item[hidden],
.nav-section[hidden],
.nav-tree[hidden] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: none !important;
}


/* بخش ادمین برای کاربر عادی — هیچ فاصله و سرتیتری نماند */
.nav-section.admin-only[hidden],
.nav-tree.admin-only[hidden],
button.admin-only[hidden],
#adminNavSection[hidden],
#navAdminRankTree[hidden],
#navAdminShopUsers[hidden] {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  line-height: 0 !important;
  font-size: 0 !important;
}

body:not(.is-admin) .admin-only {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.ag-list { display: flex; flex-direction: column; gap: 6px; }
.ag-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--bg-soft);
}
.ag-item.active {
  border-color: var(--primary);
  background: rgba(37,99,235,0.1);
}
.ag-item input { accent-color: var(--primary); }

/* درخت مدیریت رنک — باز شدن مطمئن */
body.is-admin #navAdminRankTree:not([hidden]) {
  display: block !important;
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
body.is-admin #navAdminRankTree .nav-tree-children {
  height: auto !important;
  overflow: hidden !important;
  visibility: visible !important;
  line-height: normal !important;
  font-size: inherit !important;
}
body.is-admin #navAdminRankTree:not(.open) .nav-tree-children {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
}
body.is-admin #navAdminRankTree.open .nav-tree-children {
  max-height: 480px !important;
  opacity: 1 !important;
  padding-top: 4px !important;
  padding-bottom: 6px !important;
  margin: 2px 0 8px !important;
  pointer-events: auto !important;
}
body.is-admin #navAdminRankTree .nav-item.nav-sub {
  display: flex !important;
  height: auto !important;
  min-height: 36px !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  font-size: .82rem !important;
  line-height: 1.3 !important;
}

/* درخت سرویس‌ها با details/summary — باز شدن native بدون وابستگی به JS */
#navServicesTree.nav-details {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  overflow: visible !important;
}
#navServicesTree.nav-details > summary.nav-tree-toggle {
  list-style: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
#navServicesTree.nav-details > summary.nav-tree-toggle::-webkit-details-marker {
  display: none !important;
}
#navServicesTree.nav-details > summary.nav-tree-toggle::marker {
  display: none !important;
  content: "" !important;
}
#navServicesTree.nav-details > .nav-tree-children,
#navServicesTree.nav-details #navServicesChildren {
  display: block !important;
  height: auto !important;
  overflow: hidden !important;
  visibility: visible !important;
  line-height: normal !important;
  font-size: inherit !important;
  transition:
    max-height .38s cubic-bezier(.4,0,.2,1),
    opacity .28s ease,
    transform .28s ease,
    padding .28s ease,
    margin .28s ease !important;
}
/* حالت بسته / میانی: حتی اگر open باشد تا کلاس open نیاید جمع بماند */
#navServicesTree.nav-details:not(.open) > .nav-tree-children,
#navServicesTree.nav-details:not(.open) #navServicesChildren {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
  transform: translateY(-6px);
}
#navServicesTree.nav-details.open > .nav-tree-children,
#navServicesTree.nav-details.open #navServicesChildren {
  max-height: 480px !important;
  opacity: 1 !important;
  padding-top: 4px !important;
  padding-bottom: 6px !important;
  margin: 2px 0 8px !important;
  padding-right: 18px !important;
  pointer-events: auto !important;
  transform: translateY(0);
}
#navServicesTree.nav-details.open > summary .tree-chevron {
  transform: rotate(180deg) !important;
  opacity: .9 !important;
}
#navServicesTree.nav-details .nav-item.nav-sub {
  display: flex !important;
  height: auto !important;
  min-height: 36px !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  font-size: .82rem !important;
  line-height: 1.3 !important;
}

/* درخت دانلودها و آموزش — همان انیمیشن سرویس‌ها */
#navResourcesTree.nav-details {
  display: block !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  overflow: visible !important;
}
#navResourcesTree.nav-details > summary.nav-tree-toggle {
  list-style: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
#navResourcesTree.nav-details > summary.nav-tree-toggle::-webkit-details-marker {
  display: none !important;
}
#navResourcesTree.nav-details > summary.nav-tree-toggle::marker {
  display: none !important;
  content: "" !important;
}
#navResourcesTree.nav-details > .nav-tree-children,
#navResourcesTree.nav-details #navResourcesChildren {
  display: block !important;
  height: auto !important;
  overflow: hidden !important;
  visibility: visible !important;
  line-height: normal !important;
  font-size: inherit !important;
  transition:
    max-height .38s cubic-bezier(.4,0,.2,1),
    opacity .28s ease,
    transform .28s ease,
    padding .28s ease,
    margin .28s ease !important;
}
#navResourcesTree.nav-details:not(.open) > .nav-tree-children,
#navResourcesTree.nav-details:not(.open) #navResourcesChildren {
  max-height: 0 !important;
  opacity: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
  transform: translateY(-6px);
}
#navResourcesTree.nav-details.open > .nav-tree-children,
#navResourcesTree.nav-details.open #navResourcesChildren {
  max-height: 480px !important;
  opacity: 1 !important;
  padding-top: 4px !important;
  padding-bottom: 6px !important;
  margin: 2px 0 8px !important;
  padding-right: 18px !important;
  pointer-events: auto !important;
  transform: translateY(0);
}
#navResourcesTree.nav-details.open > summary .tree-chevron {
  transform: rotate(180deg) !important;
  opacity: .9 !important;
}
#navResourcesTree.nav-details .nav-item.nav-sub {
  display: flex !important;
  height: auto !important;
  min-height: 36px !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  font-size: .82rem !important;
  line-height: 1.3 !important;
}

/* حالت جمع‌شده سایدبار: درخت‌های باز کاملاً جمع شوند (specificity بالاتر از قوانین open) */
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details.open > .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details.open #navServicesChildren,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details > .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree #navServicesChildren,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree.nav-details.open > .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree.nav-details.open #navResourcesChildren,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree.nav-details > .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree #navResourcesChildren,
body.is-admin .app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree.open .nav-tree-children,
body.is-admin .app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree.open .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree .nav-tree-children {
  display: none !important;
  max-height: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  opacity: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-right: none !important;
  overflow: hidden !important;
  pointer-events: none !important;
  transform: none !important;
  visibility: hidden !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree.nav-details,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree {
  overflow: hidden !important;
  max-height: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details > summary.nav-tree-toggle,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navResourcesTree.nav-details > summary.nav-tree-toggle,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree > .nav-tree-toggle,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle {
  min-height: 44px !important;
  height: 44px !important;
  max-height: 44px !important;
  overflow: hidden !important;
  justify-content: flex-start !important;
  padding: 0 16px !important;
  gap: 0 !important;
  margin-bottom: 4px !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .tree-chevron,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree .tree-chevron,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree .tree-chevron {
  display: none !important;
  opacity: 0 !important;
  width: 0 !important;
  max-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle.active,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navServicesTree.nav-details.open > summary,
.app.sidebar-collapsed .sidebar:not(.hover-expand) #navAdminRankTree.open > .nav-tree-toggle {
  background: rgba(37, 99, 235, 0.12) !important;
  box-shadow: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-children::before {
  display: none !important;
  content: none !important;
}

#btnNotifMute.is-muted {
  opacity: .55;
  color: var(--text-muted);
}


/* ===== سایدبار جمع‌شده: اسکرول بدون جابه‌جایی آیکن‌ها ===== */
.sidebar-nav {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 8px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

/* در حالت بسته: اسکرول‌بار فضا نگیرد تا آیکن‌ها وسط بمانند */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-nav {
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  scrollbar-gutter: auto;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-nav::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 72px !important;
  overflow: hidden;
}
.app.sidebar-collapsed .main {
  right: 72px !important;
  margin-right: 0 !important;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: center !important;
  align-items: center !important;
  padding: 12px 0 !important;
  margin: 0 8px 4px !important;
  width: auto !important;
  gap: 0 !important;
  min-height: 44px;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item > svg,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .nav-ico,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .nav-ico svg {
  margin: 0 auto !important;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: block;
}

/* سرتیترها و زیرمنو در حالت بسته هیچ ارتفاعی نگیرند */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-children,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .tree-chevron,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-dot {
  display: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle {
  justify-content: center !important;
  padding: 12px 0 !important;
  gap: 0 !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .nav-ico {
  margin: 0 auto !important;
}

.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-user {
  padding: 10px 0 !important;
  display: flex;
  justify-content: center;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-row {
  justify-content: center;
  gap: 0;
}


/* =========================================================
   سایدبار بسته = همان چیدمان باز، فقط نوشته‌ها نامرئی
   سرتیترها فضا نگه می‌دارند تا آیکن‌ها جابه‌جا نشوند
   ========================================================= */

/* عرض ثابت باریک؛ آیکن‌ها از راست مثل حالت باز */
.app.sidebar-collapsed .sidebar:not(.hover-expand) {
  width: 78px !important;
}
.app.sidebar-collapsed .main {
  right: 78px !important;
  margin-right: 0 !important;
}

/* ناوبری: همان padding حالت باز */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-nav {
  padding: 16px 12px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-width: none !important;
  scrollbar-gutter: auto !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-nav::-webkit-scrollbar {
  width: 0 !important;
  display: none !important;
}

/* آیتم‌ها: همان padding و justify راست — آیکن جابه‌جا نشود */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item {
  justify-content: flex-start !important;
  align-items: center !important;
  padding: 11px 14px !important;
  margin-bottom: 4px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 0 !important;
}

/* نوشته‌ها نامرئی ولی ساختار flex حفظ */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .label,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-badge,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .tree-chevron {
  opacity: 0 !important;
  color: transparent !important;
  pointer-events: none !important;
  /* عرض واقعی متن را صفر نکن تا layout نپرد — فقط نامرئی */
  visibility: hidden !important;
  max-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
  flex: 0 0 0 !important;
}

/* آیکن در همان ستون راست */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item > svg,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-item .nav-ico {
  margin: 0 !important;
  flex: 0 0 20px !important;
  width: 20px !important;
  height: 20px !important;
  display: block !important;
}

/* سرتیتر: فضا بماند، متن دیده نشود */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-section {
  display: block !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: auto !important;
  min-height: 1.6em !important;
  padding: 12px 12px 6px !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
  font-size: .72rem !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

/* زیرمنوی درخت در حالت بسته جمع شود ولی toggle همان جای آیکن بماند */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-children {
  display: none !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle {
  justify-content: flex-start !important;
  padding: 11px 14px !important;
  gap: 12px !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-tree-toggle .tree-chevron {
  display: none !important;
}

/* فوتر کاربر: آواتار در همان راست */
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sidebar-user {
  padding: 12px !important;
  justify-content: flex-start !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-row {
  justify-content: flex-start !important;
  gap: 10px !important;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-user-meta,
.app.sidebar-collapsed .sidebar:not(.hover-expand) .sb-mini-btn {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  max-width: 0 !important;
  overflow: hidden !important;
  flex: 0 0 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

/* هاور موقت (داینامیک): مثل باز کامل */
.app.sidebar-collapsed .sidebar.hover-expand .nav-section {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.app.sidebar-collapsed .sidebar.hover-expand .nav-item .label {
  opacity: 1 !important;
  visibility: visible !important;
  max-width: none !important;
  flex: initial !important;
  color: inherit !important;
}


/* داشبورد — نمودارها و نقشه (کاملاً رسپانسیو) */
.dash-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.dash-charts-grid > .card,
.dash-charts-grid > .dash-bottom-row {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.dash-charts-grid .card.dash-chart-full {
  grid-column: 1 / -1;
}
.dash-chart-box {
  position: relative;
  width: 100%;
  height: 240px;
  max-width: 100%;
  direction: ltr;
  box-sizing: border-box;
}
.dash-chart-box.doughnut {
  height: 240px;
  max-width: 360px;
  margin: 0 auto;
  direction: rtl;
}
.dash-chart-box canvas {
  max-width: 100% !important;
}
.dash-country-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  max-height: 100px;
  overflow-y: auto;
}
.dash-country-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(37,99,235,.08);
  border: 1px solid var(--border);
  font-size: .8rem;
  cursor: default;
}
.dash-country-chip strong { font-variant-numeric: tabular-nums; }
.jvm-hover { cursor: pointer; }

.dash-bottom-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
}
.dash-visitors-card {
  min-width: 0;
}
.dash-visitors-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.dash-visitors-pct {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary, #2563eb);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}
html:not(.theme-light) .dash-visitors-pct, body:not(.theme-light) .dash-visitors-pct {
  background: rgba(249, 115, 22, 0.18);
  color: #fb923c;
}
.dash-visitors-sub {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--text-muted);
}

/* نقشه تم شب: کشور دارای کاربر قرمز — هاور نارنجی */
html:not(.theme-light) #dashWorldMap path[data-has-users="1"], body:not(.theme-light) #dashWorldMap path[data-has-users="1"] {
  fill: #dc2626 !important;
}
html:not(.theme-light) #dashWorldMap path[data-has-users="1"]:hover, body:not(.theme-light) #dashWorldMap path[data-has-users="1"]:hover,
html:not(.theme-light) #dashWorldMap path[data-has-users="1"].jvm-hover, body:not(.theme-light) #dashWorldMap path[data-has-users="1"].jvm-hover {
  fill: #f97316 !important;
  cursor: pointer;
}
/* نقشه تم روز: آبی — هاور آبی پررنگ */
html.theme-light #dashWorldMap path[data-has-users="1"], body.theme-light #dashWorldMap path[data-has-users="1"] {
  fill: #2563eb !important;
}
html.theme-light #dashWorldMap path[data-has-users="1"]:hover, body.theme-light #dashWorldMap path[data-has-users="1"]:hover,
html.theme-light #dashWorldMap path[data-has-users="1"].jvm-hover, body.theme-light #dashWorldMap path[data-has-users="1"].jvm-hover {
  fill: #1d4ed8 !important;
  cursor: pointer;
}

@media (max-width: 1100px) {
  .dash-charts-grid {
    grid-template-columns: 1fr;
  }
  .dash-bottom-row {
    grid-template-columns: 1fr;
  }
  .dash-chart-box {
    height: 220px;
  }
  #dashWorldMap {
    height: 280px !important;
  }
}
@media (max-width: 768px) {
  .dash-chart-box {
    height: 200px;
  }
  .dash-chart-box.doughnut {
    max-width: 100%;
  }
  #dashWorldMap {
    height: 240px !important;
  }
}


/* panel overflow guard */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
.main-content, .page, #page-dashboard {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.page.active {
  width: 100%;
  max-width: 100%;
}


/* ========== قوانین ========== */
.rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  padding: 20px 22px;
}
.rules-header-main {
  display: flex;
  align-items: center;
  gap: 14px;
}
.rules-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}
.rules-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.rules-sub {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 2px 0 0;
}
.rules-updated {
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(37,99,235,.1);
  color: var(--primary, #2563eb);
}
.rules-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.rules-cat {
  background: var(--card, var(--bg-card, #fff));
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow .2s;
}
.rules-cat:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.rules-cat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.rules-cat-header:hover {
  background: rgba(37,99,235,.04);
}
html:not(.theme-light) .rules-cat-header:hover, body:not(.theme-light) .rules-cat-header:hover {
  background: rgba(255,255,255,.03);
}
.rules-cat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.rules-cat-icon.blue { background: #eff6ff; }
.rules-cat-icon.purple { background: #f5f3ff; }
.rules-cat-icon.red { background: #fef2f2; }
.rules-cat-icon.orange { background: #fff7ed; }
.rules-cat-icon.teal { background: #f0fdfa; }
.rules-cat-icon.green { background: #ecfdf5; }
.rules-cat-icon.cyan { background: #ecfeff; }
.rules-cat-icon.indigo { background: #eef2ff; }
.rules-cat-icon.pink { background: #fdf2f8; }
html:not(.theme-light) .rules-cat-icon.blue, body:not(.theme-light) .rules-cat-icon.blue { background: rgba(59,130,246,.2); }
html:not(.theme-light) .rules-cat-icon.purple, body:not(.theme-light) .rules-cat-icon.purple { background: rgba(139,92,246,.2); }
html:not(.theme-light) .rules-cat-icon.red, body:not(.theme-light) .rules-cat-icon.red { background: rgba(239,68,68,.2); }
html:not(.theme-light) .rules-cat-icon.orange, body:not(.theme-light) .rules-cat-icon.orange { background: rgba(249,115,22,.2); }
html:not(.theme-light) .rules-cat-icon.teal, body:not(.theme-light) .rules-cat-icon.teal { background: rgba(20,184,166,.2); }
html:not(.theme-light) .rules-cat-icon.green, body:not(.theme-light) .rules-cat-icon.green { background: rgba(16,185,129,.2); }
html:not(.theme-light) .rules-cat-icon.cyan, body:not(.theme-light) .rules-cat-icon.cyan { background: rgba(6,182,212,.2); }
html:not(.theme-light) .rules-cat-icon.indigo, body:not(.theme-light) .rules-cat-icon.indigo { background: rgba(99,102,241,.2); }
html:not(.theme-light) .rules-cat-icon.pink, body:not(.theme-light) .rules-cat-icon.pink { background: rgba(236,72,153,.2); }
.rules-cat-title {
  flex: 1;
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
}
.rules-cat-count {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(37,99,235,.1);
  color: var(--primary, #2563eb);
}
.rules-cat-toggle {
  color: var(--text-muted);
  transition: transform .2s;
  font-size: .75rem;
}
.rules-cat.open .rules-cat-toggle {
  transform: rotate(180deg);
}
.rules-cat-body {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}
.rules-cat.open .rules-cat-body {
  display: block;
}
.rules-item {
  display: flex;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.rules-item:last-child { border-bottom: none; }
.rules-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(37,99,235,.12);
  color: var(--primary, #2563eb);
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rules-text {
  flex: 1;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--text);
}
.rules-note {
  display: flex;
  gap: 10px;
  padding: 12px;
  margin-top: 6px;
  border-radius: 10px;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: var(--text);
  font-size: .88rem;
  line-height: 1.65;
}
.admin-rule-row, .admin-cat-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.admin-rule-row .body, .admin-cat-row .body {
  flex: 1;
  min-width: 160px;
  font-size: .88rem;
}
.admin-rule-row .acts, .admin-cat-row .acts {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .rules-header { padding: 16px; }
  .rules-cat-header { padding: 12px; }
}





/* =========================================================
   LAYOUT LOCK — اسکرول روی صفحه (body) | هدر با محتوا حرکت می‌کند
   سایدبار ثابت می‌ماند | هدر position ثابت/sticky ندارد
   این بلوک باید آخرین قانون layout باشد
   ========================================================= */
html {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
body {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  margin: 0 !important;
}
.app {
  height: auto !important;
  min-height: 100vh !important;
  overflow: visible !important;
  position: relative !important;
}
.sidebar {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  z-index: 100 !important;
}
.main {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  margin-right: var(--sidebar-w) !important;
  width: auto !important;
  height: auto !important;
  max-height: none !important;
  min-height: 100vh !important;
  overflow: visible !important;
  z-index: 1 !important;
  background: var(--bg) !important;
}
.app.sidebar-collapsed .main {
  margin-right: 78px !important;
  right: auto !important;
}
header.header,
.header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: var(--sidebar-w) !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 50 !important;
  width: auto !important;
}
.app.sidebar-collapsed .header {
  right: 78px !important;
}
.content {
  display: block !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  padding: 0 !important;
  padding-top: var(--header-h) !important;
}
.content > .page {
  padding: 24px;
}
@media (max-width: 768px) {
  .main {
    margin-right: 0 !important;
    right: auto !important;
  }
  header.header,
  .header {
    right: 0 !important;
  }
  .content > .page {
    padding: 16px;
  }
}

/* ========== Shop category layout ========== */
/* بالاهای دو باکس همیشه هم‌تراز؛ گسترش فقط از پایین */
.shop-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}
.shop-layout > .shop-main.card,
.shop-layout > .shop-sidebar.card {
  margin-bottom: 0;
  box-sizing: border-box;
  vertical-align: top;
}
.shop-main.card {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  align-self: start;
}
.shop-sidebar.card {
  /* بدون sticky تا هنگام باز شدن آکاردئون از بالا جابه‌جا نشود */
  position: relative;
  align-self: start;
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
  top: auto !important;
}
.shop-sidebar > .card-header {
  margin-bottom: 16px;
}
.shop-cat-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  margin: 0;
  overflow: visible;
  height: auto;
}
.shop-cat-group {
  display: block;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.shop-cat-item {
  border: none;
  background: transparent;
  color: var(--text, #e5e7eb);
  text-align: right;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background .2s ease, color .2s ease;
  box-sizing: border-box;
  line-height: 1.35;
}
.shop-cat-item:hover {
  background: rgba(148, 163, 184, 0.12);
}
.shop-cat-item.active {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  font-weight: 600;
}
.shop-cat-item.root {
  font-weight: 600;
}
.shop-cat-item .shop-cat-label {
  flex: 1;
  min-width: 0;
}
.shop-cat-item .chev {
  opacity: .7;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
  font-size: .85rem;
  display: inline-block;
  flex-shrink: 0;
  width: 1em;
  text-align: center;
  will-change: transform;
}
.shop-cat-item .chev.chev-empty {
  opacity: 0;
  pointer-events: none;
}
.shop-cat-item.root.open .chev:not(.chev-empty) {
  transform: rotate(-90deg);
}
/* آکاردئون نرم — باز/بسته شدن زیردسته */
.shop-cat-children {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  padding-right: 10px;
  margin: 0;
  overflow: hidden;
  transition:
    grid-template-rows .48s cubic-bezier(.22, 1, .36, 1),
    opacity .38s cubic-bezier(.22, 1, .36, 1);
  will-change: grid-template-rows, opacity;
}
.shop-cat-children.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.shop-cat-children-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0;
  transform: translateY(-6px);
  transition:
    transform .42s cubic-bezier(.22, 1, .36, 1),
    padding .42s cubic-bezier(.22, 1, .36, 1);
}
.shop-cat-children.open .shop-cat-children-inner {
  padding: 4px 0 8px;
  transform: translateY(0);
}
.shop-cat-item.child {
  padding: 8px 12px 8px 18px;
  font-size: .92rem;
  color: var(--text-muted, #94a3b8);
  opacity: 0;
  transform: translateX(8px);
  transition:
    background .2s ease,
    color .2s ease,
    opacity .35s cubic-bezier(.22, 1, .36, 1),
    transform .4s cubic-bezier(.22, 1, .36, 1);
}
.shop-cat-children.open .shop-cat-item.child {
  opacity: 1;
  transform: translateX(0);
}
/* تأخیر نرم روی هر زیردسته */
.shop-cat-children.open .shop-cat-item.child:nth-child(1) { transition-delay: .04s; }
.shop-cat-children.open .shop-cat-item.child:nth-child(2) { transition-delay: .07s; }
.shop-cat-children.open .shop-cat-item.child:nth-child(3) { transition-delay: .1s; }
.shop-cat-children.open .shop-cat-item.child:nth-child(4) { transition-delay: .13s; }
.shop-cat-children.open .shop-cat-item.child:nth-child(5) { transition-delay: .16s; }
.shop-cat-children.open .shop-cat-item.child:nth-child(n+6) { transition-delay: .18s; }
.shop-cat-children:not(.open) .shop-cat-item.child {
  transition-delay: 0s;
  transition-duration: .22s;
}
.shop-cat-item.child.active {
  color: #93c5fd;
}
.shop-products .stats-grid {
  margin-top: 4px;
}

/* کارت محصول قابل انتخاب در فروشگاه */
.shop-product-card {
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .15s ease;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.shop-product-card .btn {
  user-select: none;
}
.shop-product-card:hover {
  border-color: rgba(147, 197, 253, 0.45);
  box-shadow: 0 0 0 1px rgba(147, 197, 253, 0.15), var(--shadow);
}
.shop-product-card:focus-visible {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.35);
}
.shop-product-card.selected {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35), 0 8px 24px rgba(15, 23, 42, 0.35);
}
.shop-product-card.selected .value {
  color: #93c5fd;
}

/* باکس توضیح محصول انتخاب‌شده */
.shop-product-desc {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: linear-gradient(145deg, rgba(30, 58, 138, 0.25), rgba(15, 23, 42, 0.5));
  line-height: 1.85;
  color: var(--text-muted, #cbd5e1);
  white-space: normal;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  animation: shopDescIn .25s ease;
}
@keyframes shopDescIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.shop-product-desc-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.shop-product-desc-header strong {
  font-size: 1.05rem;
  color: var(--text, #f1f5f9);
}
.shop-product-desc-meta {
  font-size: .82rem;
  color: #93c5fd;
  opacity: .9;
}
.shop-product-desc-body {
  color: var(--text-muted, #cbd5e1);
  font-size: .95rem;
}
.shop-product-desc-empty {
  font-size: .9rem;
  color: var(--text-muted, #94a3b8);
  font-style: italic;
  opacity: .85;
}

.shop-cat-desc {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.35);
  line-height: 1.8;
  color: var(--text-muted, #cbd5e1);
  white-space: pre-wrap;
}
.shop-cat-desc strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text, #f1f5f9);
}

/* تم روز (لایت): باکس توضیح محصول — بک‌گراند شفاف، متن یکدست و خوانا */
html.theme-light .shop-product-desc, body.theme-light .shop-product-desc {
  border-color: rgba(59, 130, 246, 0.28);
  background: transparent;
  color: var(--text-muted, #6b7280);
}
html.theme-light .shop-product-desc-header, body.theme-light .shop-product-desc-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
html.theme-light .shop-product-desc-header strong, body.theme-light .shop-product-desc-header strong {
  color: var(--text, #111827);
}
html.theme-light .shop-product-desc-meta, body.theme-light .shop-product-desc-meta {
  color: #2563eb;
  opacity: 1;
}
html.theme-light .shop-product-desc-body, body.theme-light .shop-product-desc-body {
  color: var(--text-muted, #6b7280);
}
html.theme-light .shop-product-desc-empty, body.theme-light .shop-product-desc-empty {
  color: var(--text-muted, #6b7280);
  opacity: 1;
}
html.theme-light .shop-cat-desc, body.theme-light .shop-cat-desc {
  border-color: rgba(0, 0, 0, 0.08);
  background: transparent;
  color: var(--text-muted, #6b7280);
}
html.theme-light .shop-cat-desc strong, body.theme-light .shop-cat-desc strong {
  color: var(--text, #111827);
}

@media (max-width: 900px) {
  .shop-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .shop-sidebar.card {
    position: static;
    order: -1;
  }
}

/* ========== Product Manager (admin) ========== */
.pm-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}
.pm-side { position: sticky; top: calc(var(--header-h, 64px) + 12px); align-self: start; }
.pm-cat-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0 10px;
  height: auto !important;
  overflow: visible;
}
.pm-cat-tree .shop-cat-group {
  flex: 0 0 auto;
  height: auto;
  margin: 0;
}
.pm-cat-tree .shop-cat-children {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  padding-right: 8px;
  overflow: hidden;
  transition:
    grid-template-rows .48s cubic-bezier(.22, 1, .36, 1),
    opacity .38s cubic-bezier(.22, 1, .36, 1);
}
.pm-cat-tree .shop-cat-children.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.pm-cat-tree .shop-cat-children-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transform: translateY(-4px);
  transition: transform .42s cubic-bezier(.22, 1, .36, 1);
}
.pm-cat-tree .shop-cat-children.open .shop-cat-children-inner {
  transform: translateY(0);
}
.pm-cat-tree .shop-cat-item.child {
  opacity: 0;
  transform: translateX(6px);
  transition:
    background .2s ease,
    color .2s ease,
    opacity .35s cubic-bezier(.22, 1, .36, 1),
    transform .4s cubic-bezier(.22, 1, .36, 1);
}
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child {
  opacity: 1;
  transform: translateX(0);
}
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child:nth-child(1) { transition-delay: .04s; }
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child:nth-child(2) { transition-delay: .07s; }
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child:nth-child(3) { transition-delay: .1s; }
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child:nth-child(4) { transition-delay: .13s; }
.pm-cat-tree .shop-cat-children.open .shop-cat-item.child:nth-child(n+5) { transition-delay: .16s; }
.pm-cat-tree .shop-cat-children:not(.open) .shop-cat-item.child {
  transition-delay: 0s;
  transition-duration: .2s;
}
.pm-cat-row {
  display: flex; align-items: center; gap: 4px;
  flex: 0 0 auto;
}
.pm-cat-row .shop-cat-item { flex: 1; min-width: 0; }
.pm-cat-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.pm-cat-row:hover .pm-cat-actions { opacity: 1; }
.pm-cat-actions button {
  border: none; background: transparent; color: var(--text-muted, #94a3b8);
  cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: .8rem;
}
.pm-cat-actions button:hover { background: rgba(148,163,184,.15); color: #e2e8f0; }
.pm-product-list { padding: 4px 0 12px; }
.pm-prod-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,.15);
  margin-bottom: 10px;
  background: rgba(15,23,42,.25);
  transition: border-color .15s;
}
.pm-prod-card:hover { border-color: rgba(59,130,246,.35); }
.pm-prod-card .meta { font-size: .8rem; color: var(--text-muted, #94a3b8); margin-top: 4px; }
.pm-prod-card .price {
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
}
html.theme-light .pm-prod-card .price, body.theme-light .pm-prod-card .price {
  color: #1d4ed8;
}
.pm-prod-card .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pm-badge {
  display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(148,163,184,.15); margin-left: 6px;
}
.pm-badge.off { background: rgba(239,68,68,.15); color: #fca5a5; }
.pm-badge.on { background: rgba(34,197,94,.15); color: #86efac; }
/* ===== Theme Light ===== */

/* حالت عادی */
html.theme-light .pm-badge, body.theme-light .pm-badge {
  background: transparent;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* غیرفعال */
html.theme-light .pm-badge.off, body.theme-light .pm-badge.off {
  background: transparent;
  color: #dc2626;
  border: 1px solid #aa0000;
}

/* فعال */
html.theme-light .pm-badge.on, body.theme-light .pm-badge.on {
  background: transparent;
  color: #16a34a;
  border: 1px solid #009300;
}
.pm-modal {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.pm-modal[hidden] { display: none !important; }
.pm-modal-backdrop {
  position: absolute; inset: 0; background: rgba(2,6,23,.72); backdrop-filter: blur(4px);
}
.pm-modal-box {
  position: relative; z-index: 1; width: min(520px, 100%);
  max-height: min(90vh, 800px); overflow: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.pm-modal-wide { width: min(680px, 100%); }
@media (max-width: 900px) {
  .pm-layout { grid-template-columns: 1fr; }
  .pm-side { position: static; }
}


/* Forgot password modal (panel) */
.forgot-modal {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}
.forgot-modal.open { opacity: 1; visibility: visible; }
.forgot-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8,12,24,.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.forgot-modal-box {
  position: relative; width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.forgot-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.forgot-modal-header h3 { margin: 0; font-size: 1.1rem; }
.forgot-modal-close {
  border: none; background: transparent; color: inherit;
  font-size: 1.5rem; cursor: pointer; opacity: .7; border-radius: 8px;
  padding: 4px 8px;
}
.forgot-modal-close:hover { opacity: 1; background: rgba(148,163,184,.12); }
.forgot-desc { color: var(--text-muted); font-size: .9rem; margin: 0 0 14px; line-height: 1.6; }
.btn-link { color: var(--primary); }

/* ========== DNS List ========== */
.dns-toolbar {
  margin-bottom: 16px;
  padding: 16px 18px;
}
.dns-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dns-toolbar-sub {
  margin: 4px 0 0;
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.dns-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.dns-last-check {
  font-size: .78rem;
  color: var(--text-muted);
}

.dns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.dns-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.dns-card:hover {
  border-color: rgba(37, 99, 235, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.dns-card-inactive {
  opacity: 0.65;
}
.dns-card-head {
  margin-bottom: 12px;
}
.dns-loc {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.dns-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.dns-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  margin-bottom: 12px;
}
.dns-ip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
}
.dns-ip {
  flex: 1;
  font-size: .88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.dns-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dns-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
}
.dns-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.dns-status-online .dns-status-dot { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.dns-status-offline .dns-status-dot { background: #ef4444; }
.dns-status-checking .dns-status-dot {
  background: #f59e0b;
  animation: dns-pulse 1s ease-in-out infinite;
}
.dns-status-online { color: #10b981; }
.dns-status-offline { color: #ef4444; }
.dns-status-checking { color: #f59e0b; }

@keyframes dns-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.dns-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.dns-tag {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.2);
}
html.theme-light .dns-tag, body.theme-light .dns-tag {
  background: rgba(37, 99, 235, 0.08);
}

.dns-card-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.dns-badge-off {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* DNS Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] {
  display: none !important;
}
.dns-modal {
  width: min(480px, 100%);
  max-height: min(90vh, 720px);
  overflow-y: auto;
  padding: 18px 20px 20px;
  margin: 0;
}
.dns-modal .card-header {
  margin-bottom: 12px;
}
.dns-modal .form-group {
  margin-bottom: 12px;
}
.dns-modal textarea.form-control {
  resize: vertical;
  min-height: 72px;
}

@media (max-width: 640px) {
  .dns-grid {
    grid-template-columns: 1fr;
  }
  .dns-toolbar-main {
    flex-direction: column;
    align-items: stretch;
  }
  .dns-toolbar-actions {
    justify-content: flex-start;
  }
}

/* تمدید سرویس */
.svc-renew-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.svc-renew-prices {
  margin-top: 4px;
  font-size: .72rem;
  color: var(--text-muted);
  line-height: 1.4;
}
@media (max-width: 640px) {
  .svc-renew-btns { flex-direction: column; }
}

/* مودال تمدید سرویس */
.renew-modal-overlay {
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(2, 6, 23, 0.55);
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.25);
}
html.theme-light .renew-modal-overlay, body.theme-light .renew-modal-overlay {
  background: rgba(15, 23, 42, 0.35);
}
body.modal-open {
  overflow: hidden;
}
.renew-modal {
  width: min(420px, 100%);
  max-height: min(90vh, 640px);
  overflow-y: auto;
  padding: 0;
  margin: 0;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--border);
  animation: renew-modal-in .18s ease-out;
}
@keyframes renew-modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.renew-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 0;
  margin-bottom: 0;
}
.renew-modal-body {
  padding: 14px 18px 18px;
}
.renew-product-name {
  margin: 0 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.renew-summary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 4px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.renew-sum-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: .9rem;
  color: var(--text-muted);
}
.renew-sum-row strong {
  color: var(--text);
  font-weight: 700;
}
.renew-price-val {
  color: var(--primary) !important;
}
.text-danger {
  color: #ef4444 !important;
}
.renew-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.renew-modal-actions .btn {
  min-width: 120px;
}
@media (max-width: 480px) {
  .renew-modal-actions {
    flex-direction: column-reverse;
  }
  .renew-modal-actions .btn {
    width: 100%;
  }
}

/* ---------- لینک خارجی لیست سرور TS ---------- */
.nav-item.tslist-sso-link {
  position: relative;
}
.nav-item .nav-ext-icon {
  width: 14px !important;
  height: 14px !important;
  margin-right: auto;
  margin-left: 0;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.nav-item:hover .nav-ext-icon {
  opacity: 0.85;
}
.app.sidebar-collapsed .sidebar:not(.hover-expand) .nav-ext-icon {
  display: none !important;
}

/* ===== ویرایش سرویس / نام کانال (هم‌استایل مودال تمدید) ===== */
.svc-edit-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0 16px;
  opacity: 0.8;
}
.svc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.svc-delivery-msg {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 220px;
  line-height: 1.35;
}
.svc-delivery-msg.is-error {
  color: #f87171;
}
html.theme-light .svc-delivery-msg.is-error,
body.theme-light .svc-delivery-msg.is-error {
  color: #dc2626;
}
.svc-delivery-msg.is-ok {
  color: #34d399;
}
html.theme-light .svc-delivery-msg.is-ok,
body.theme-light .svc-delivery-msg.is-ok {
  color: #059669;
}
.badge-processing {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}
html.theme-light .badge-processing,
body.theme-light .badge-processing {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}
@media (max-width: 768px) {
  #servicesList .table-wrap {
    overflow-x: auto;
  }
  .svc-delivery-msg {
    max-width: 160px;
  }
}


/* ========== 2FA / TOTP Profile ========== */
.totp-card .totp-secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  background: rgba(59, 130, 246, 0.08);
  margin-top: 8px;
}
.totp-card .totp-secret-label {
  width: 100%;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.totp-card .totp-secret-box code {
  flex: 1;
  min-width: 160px;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  color: var(--text);
  background: transparent;
  padding: 0;
}
.totp-card .totp-code-input {
  letter-spacing: 0.28em;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  max-width: 220px;
}
html.theme-light .totp-card .totp-secret-box,
body.theme-light .totp-card .totp-secret-box {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.2);
}
@media (max-width: 640px) {
  .totp-card .totp-code-input {
    max-width: 100%;
  }
}


/* ========== 2FA QR Setup ========== */
.totp-setup-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
}
.totp-qr-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.totp-qr-code {
  width: 180px;
  height: 180px;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.totp-qr-code img,
.totp-qr-code canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.totp-qr-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}
.totp-qr-fallback {
  font-size: 0.8rem;
  color: #94a3b8;
  text-align: center;
  padding: 12px;
  line-height: 1.5;
}
.totp-setup-manual {
  flex: 1 1 220px;
  min-width: 200px;
}
@media (max-width: 640px) {
  .totp-setup-layout {
    flex-direction: column;
    align-items: center;
  }
  .totp-setup-manual {
    width: 100%;
  }
  .totp-qr-code {
    width: 160px;
    height: 160px;
  }
}


/* ========== List pagination toolbar ========== */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.list-toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.list-per-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}
.list-per-select {
  width: 88px !important;
  min-width: 88px;
  padding: 6px 8px !important;
  font-size: 0.85rem !important;
}
.list-pager {
  margin-top: 14px;
}
.list-pager-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.list-pager-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.list-pager-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.list-pager-page {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0 4px;
}
@media (max-width: 640px) {
  .list-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .list-pager-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .list-pager-btns {
    justify-content: center;
  }
}


/* ========== Resources (دانلود / آموزش) ========== */
.res-grid .res-card {
  min-height: 160px;
}
.res-desc {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.res-content {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.6;
  max-height: 140px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.res-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.res-meta-label {
  font-weight: 600;
  color: var(--text);
}
.res-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
html.theme-light .res-content,
body.theme-light .res-content {
  background: rgba(15, 23, 42, 0.03);
}


/* ========== Resource upload progress ========== */
.res-upload-progress {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(16, 185, 129, 0.28);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
}
.res-upload-progress[hidden] {
  display: none !important;
}
.res-upload-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.res-upload-progress-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.res-upload-progress-pct {
  font-size: 0.9rem;
  font-weight: 700;
  color: #10b981;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.res-upload-progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  overflow: hidden;
  position: relative;
}
.res-upload-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #059669, #10b981 55%, #34d399);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
  transition: width 0.18s ease-out;
}
.res-upload-progress.is-done .res-upload-progress-fill {
  background: linear-gradient(90deg, #047857, #10b981);
}
.res-upload-progress.is-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.02));
}
.res-upload-progress.is-error .res-upload-progress-pct {
  color: #f87171;
}
.res-upload-progress.is-error .res-upload-progress-fill {
  background: linear-gradient(90deg, #dc2626, #f87171);
  box-shadow: none;
}
html.theme-light .res-upload-progress,
body.theme-light .res-upload-progress {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.03));
}
html.theme-light .res-upload-progress-track,
body.theme-light .res-upload-progress-track {
  background: rgba(15, 23, 42, 0.08);
}

/* نوار تنظیم حداکثر حجم آپلود منابع — تراز افقی RTL */
.res-max-upload-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 16px 4px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
  margin-bottom: 4px;
}
.res-max-upload-label {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted, #888e9e);
  white-space: nowrap;
  line-height: 1.2;
}
.res-max-upload-input {
  width: 88px !important;
  min-width: 72px;
  height: 36px;
  padding: 6px 10px;
  text-align: center;
  direction: ltr;
  flex: 0 0 auto;
}
.res-max-upload-btn {
  height: 36px;
  min-height: 36px;
  padding: 0 14px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1;
}
.res-max-upload-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}
@media (max-width: 520px) {
  .res-max-upload-bar {
    align-items: stretch;
  }
  .res-max-upload-input {
    width: 100% !important;
    max-width: 120px;
  }
  .res-max-upload-btn {
    width: auto;
  }
}


/* ---- فیلتر سرویس‌های من ---- */
.svc-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.08));
  background: rgba(0,0,0,.12);
}
.svc-filter-search input {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
}
.svc-filter-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.svc-filter-selects .form-control {
  min-height: 38px;
  min-width: 140px;
  flex: 1 1 140px;
  max-width: 200px;
  border-radius: 10px;
}
.svc-filter-selects .btn {
  min-height: 38px;
  border-radius: 10px;
  flex: 0 0 auto;
}
@media (max-width: 640px) {
  .svc-filter-selects .form-control {
    max-width: none;
    flex: 1 1 100%;
  }
  .svc-filter-selects .btn {
    flex: 1 1 auto;
  }
}

/* ---- جستجوی سراسری هدر ---- */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.global-search-wrap {
  position: relative;
  flex: 0 1 360px;
  max-width: 360px;
  min-width: 140px;
  margin: 0 8px 0 0;
  z-index: 60;
}
.header-start {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}
.header-start .global-search-wrap {
  flex: 1 1 280px;
  max-width: 360px;
}

.header > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
/* باکس جستجو بلافاصله بعد از عنوان در سمت راست هدر */
.header .global-search-wrap {
  order: 0;
}
.global-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated, rgba(0,0,0,.25));
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px;
  padding: 0 12px;
  min-height: 40px;
  transition: border-color .2s, box-shadow .2s;
}
.global-search-box:focus-within {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.global-search-box .gs-icon {
  flex: 0 0 auto;
  opacity: .65;
  color: var(--text-muted, #8b9bb0);
}
.global-search-input {
  flex: 1 1 auto;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  color: var(--text, #e8eef6);
  font-family: inherit;
  font-size: .9rem;
  min-width: 0;
  padding: 8px 0;
  height: auto;
}
.global-search-input::placeholder {
  color: var(--text-muted, #8b9bb0);
  opacity: .85;
}
.gs-clear {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--text-muted, #8b9bb0);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.gs-clear:hover {
  background: rgba(255,255,255,.08);
  color: var(--text, #fff);
}
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: var(--card, #1a2332);
  border: 1px solid var(--border, rgba(255,255,255,.12));
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.45);
  overflow: hidden;
  z-index: 80;
  max-height: min(70vh, 420px);
  overflow-y: auto;
}
.gs-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: right;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.06));
  transition: background .15s;
}
.gs-item:last-of-type {
  border-bottom: none;
}
.gs-item:hover,
.gs-item.is-active {
  background: rgba(59,130,246,.12);
}
.gs-item-body {
  flex: 1 1 auto;
  min-width: 0;
}
.gs-item-title {
  font-weight: 600;
  font-size: .92rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-sub {
  font-size: .78rem;
  color: var(--text-muted, #8b9bb0);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-badge {
  flex: 0 0 auto;
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(59,130,246,.15);
  color: #93c5fd;
  white-space: nowrap;
}
.gs-empty,
.gs-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-muted, #8b9bb0);
  font-size: .88rem;
}
.gs-footer {
  border-top: 1px solid var(--border, rgba(255,255,255,.08));
  padding: 8px;
}
.gs-view-all {
  width: 100%;
  border: none;
  background: rgba(59,130,246,.12);
  color: #93c5fd;
  font: inherit;
  font-weight: 600;
  font-size: .88rem;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}
.gs-view-all:hover {
  background: rgba(59,130,246,.22);
}
.search-page-results {
  padding: 8px 0 16px;
}
.search-result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 16px;
}
.search-result-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: right;
  padding: 14px 16px;
  border: 1px solid var(--border, rgba(255,255,255,.1));
  border-radius: 12px;
  background: rgba(0,0,0,.15);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: border-color .15s, background .15s;
}
.search-result-card:hover {
  border-color: var(--primary, #3b82f6);
  background: rgba(59,130,246,.1);
}
.search-result-card .gs-item-title {
  font-size: 1rem;
}
@media (max-width: 900px) {
  .global-search-wrap {
    max-width: 280px;
  }
}
@media (max-width: 640px) {
  .global-search-wrap {
    position: absolute;
    left: 12px;
    right: 12px;
    top: calc(var(--header-h, 64px) - 4px);
    max-width: none;
    margin: 0;
    transform: translateY(-100%);
    display: none;
  }
  .global-search-wrap.is-mobile-open {
    display: block;
    transform: none;
    top: var(--header-h, 64px);
    position: fixed;
    z-index: 70;
  }
  .header .global-search-wrap {
    /* در موبایل داخل ردیف هدر فشرده */
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    display: block;
    flex: 1 1 120px;
    max-width: none;
    min-width: 100px;
  }
  .header-title {
    display: none;
  }
}
