/* ══════════════════════════════════════════════════════════════════════
   Shared Navigation — Sidebar + Top-bar layout
   ══════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 0px;
  /* 56px = meeting point of the old 52px top-bar and ~60px sidebar header, so
     the sidebar header's bottom line and the top-bar's bottom line ALIGN. */
  --topbar-h: 56px;
  --sidebar-bg: #f8f9fb;
  --sidebar-text: #64748b;
  --sidebar-text-hover: #1e293b;
  --sidebar-active: #2563eb;
  --sidebar-active-bg: rgba(37,99,235,.10);
  --sidebar-section-text: #94a3b8;
  --sidebar-border: #e5e7eb;
}

/* ── Page layout ─────────────────────────────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

/* ── Top Bar ─────────────────────────────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 900;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: var(--topbar-h);
  gap: 12px;
  font-family: inherit;
  direction: rtl;
}

/* «ما» — creator-team panels carry a distinct colored identity (gradient bar
   on top + badge) so they are never mistaken for client panels.
   The gradient is ONE fixed full-viewport bar (body::before) instead of a
   border-image on the nav: with the sidebar open, a nav-only bar stopped at
   the sidebar's edge and the line visibly broke. Both the nav and the sidebar
   reserve its 3px with a transparent border so their bottom hairlines still
   meet at the same y. */
body.is-creator-tier::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #ec4899, #8b5cf6);
  z-index: 2000;
  pointer-events: none;
}
body.is-creator-tier .top-nav { border-top: 3px solid transparent; }
body.is-creator-tier .nav-sidebar { border-top: 3px solid transparent; }
.top-nav--creator {
  background: linear-gradient(180deg, #fdf2f8 0%, #fff 65%);
}
.nav-tier-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #9d174d;
  background: #fce7f3;
  border: 1px solid #f9a8d4;
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

.nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 6px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  transition: background .15s, width .3s cubic-bezier(.22,.61,.36,1),
              opacity .22s ease, transform .3s cubic-bezier(.22,.61,.36,1),
              padding .3s cubic-bezier(.22,.61,.36,1), margin .3s cubic-bezier(.22,.61,.36,1);
}
.nav-hamburger:hover { background: #f3f4f6; }
.nav-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: #374151;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

/* Menu open → the hamburger collapses away (and swallows the flex gap) so the
   brand glides to the right into its place; closing reverses it. Driven by
   body.sidebar-open, which auth.js toggles on open/close. */
body.sidebar-open .nav-hamburger {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  margin-inline-end: -12px;
  opacity: 0;
  transform: scale(.5);
  pointer-events: none;
}

/* The brand doubles as the way home (the old «بازگشت به خانه» button is gone). */
.nav-brand {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -.3px;
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s, transform .3s cubic-bezier(.22,.61,.36,1);
}
.nav-brand:hover { color: #4338ca; }

.nav-breadcrumb {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Back-to-home — only rendered when a page is entered from the home wizard. */
/* REMOVED ۱۴۰۵/۰۴/۳۰ per user: the «بازگشت به خانه» button — brand + sidebar
   خانه cover the way home. Rules kept harmlessly for any cached HTML. */
.nav-back-home {
  display: none;
  align-items: center;
  gap: 6px;
  font-family: "Vazir", "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.nav-back-home:hover { background: #e0e7ff; border-color: #a5b4fc; }
.nav-back-home .nav-icon { display: inline-flex; }
.nav-back-home .nav-icon svg { width: 15px; height: 15px; }
.nav-back-home .nav-back-arrow { font-size: 14px; line-height: 1; }

.nav-spacer { flex: 1; }

/* ── User info (top-bar right side) ──────────────────────────────────── */
.nav-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Identity chip — name/role + avatar at the far inline-end, one hoverable unit. */
.nav-profile-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px 4px 4px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background .15s;
}
.nav-profile-link:hover { background: rgba(15, 23, 42, .05); }

.nav-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #e2e8f0;
}
.nav-profile-link:hover .nav-user-avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #a5b4fc; }

/* thin vertical rule between the action buttons and the identity chip */
.nav-vsep {
  width: 1px;
  height: 22px;
  background: #e2e8f0;
  flex-shrink: 0;
}
.nav-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nav-user-avatar-ph {
  width: 19px;
  height: 19px;
  color: rgba(255, 255, 255, 0.92);
}

.nav-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.nav-user-name {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
}

.nav-user-role {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-user-role.role-cto       { color: #d97706; }
.nav-user-role.role-sysadmin   { color: #be185d; }
.nav-user-role.role-admin      { color: #7c3aed; }
.nav-user-role.role-manager    { color: #0891b2; }
.nav-user-role.role-seller     { color: #2563eb; }
.nav-user-role.role-accountant { color: #16a34a; }

/* ── ONE button template for every top-bar action ──────────────────────
   «هم‌نمایی», «ورود به‌جای کاربر» and «خروج» used to carry two different
   styles (999px pill vs 8px corners, 11px/600 vs 11px/500). Same height,
   radius, border, font for all three now — only hover intent differs. */
.nav-logout-btn,
.nav-roleswitch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #475569;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.nav-logout-btn:hover {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fef2f2;
}

/* ── Role-switcher (creator-tier impersonation) ───────────────────────── */
.nav-roleswitch { position: relative; flex-shrink: 0; }
.nav-roleswitch-btn {
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  max-width: 160px;
}
.nav-roleswitch-btn svg { flex-shrink: 0; opacity: .85; }
.nav-roleswitch-label { overflow: hidden; text-overflow: ellipsis; }
.nav-roleswitch-caret { font-size: 9px; opacity: .6; }
.nav-roleswitch-btn:hover { border-color: #cbd5e1; background: #f8fafc; color: #1e293b; }
/* Actively impersonating → amber/warning treatment so it's unmistakable. */
.nav-roleswitch.is-acting .nav-roleswitch-btn {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #b45309;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}
.nav-roleswitch.open .nav-roleswitch-btn { border-color: #94a3b8; }

.nav-roleswitch-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
  padding: 6px;
  z-index: 1200;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  direction: rtl;
}
.nav-roleswitch.open .nav-roleswitch-menu { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.nav-roleswitch-head {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  padding: 4px 10px 6px;
  letter-spacing: .2px;
}
.nav-roleswitch-opt {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: right;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #334155;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-roleswitch-opt:hover { background: #f1f5f9; color: #0f172a; }
.nav-roleswitch-opt.active { background: #eef2ff; color: #4338ca; font-weight: 700; }
.nav-roleswitch-opt[data-role=""] { color: #b45309; }
.nav-roleswitch-opt[data-role=""].active { background: #fff7ed; color: #b45309; }

/* When impersonating, give the whole bar an amber accent (the creator gradient
   is suppressed because the effective role is now a client role). */
.top-nav.nav--impersonating {
  border-top: 3px solid #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #fff 60%);
}

/* ── User-switcher («ورود به‌جای کاربر») ─────────────────────────────────
   Reuses the role-switcher button/menu shell; adds a search box, a read/write
   mode toggle, and a scrollable target list. */
.nav-userswitch.is-acting .nav-roleswitch-btn {
  background: #fff7ed; border-color: #ea580c; color: #9a3412;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, .15);
}
.nav-userswitch-menu { min-width: 300px; max-width: 360px; }
.nav-userswitch-search {
  width: 100%; box-sizing: border-box; margin: 2px 0 8px; padding: 7px 10px;
  border: 1px solid #e5e7eb; border-radius: 8px; font-family: inherit;
  font-size: 12px; direction: rtl;
}
.nav-userswitch-search:focus { outline: none; border-color: #6366f1; }
.nav-userswitch-modes { display: flex; gap: 6px; margin-bottom: 8px; }
.nav-userswitch-mode {
  flex: 1; padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 8px;
  background: #fff; font-family: inherit; font-size: 11px; font-weight: 700;
  color: #64748b; cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.nav-userswitch-mode.active { border-color: #6366f1; background: #eef2ff; color: #4338ca; }
.nav-userswitch-hint { font-size: 10px; color: #94a3b8; margin: -4px 2px 8px; line-height: 1.5; }
.nav-userswitch-list { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-userswitch-opt { flex-direction: column; align-items: flex-start; gap: 1px; }
.nav-userswitch-opt .u-name { font-weight: 700; font-size: 12px; color: #0f172a; }
.nav-userswitch-opt .u-role { font-size: 10px; color: #94a3b8; }
.nav-userswitch-empty { padding: 14px; text-align: center; color: #94a3b8; font-size: 12px; }

/* ── Impersonation banner (active user-impersonation) ─────────────────── */
/* FULL-VIEWPORT fixed bar, exactly --topbar-h tall: it runs across the top-nav
   AND the sidebar column (above the materialboard/pin/close header), instead of
   the old in-flow sticky strip that stopped at the sidebar's edge and was
   shorter than the menu header. The bars below shift down by the same height. */
.imp-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1450;
  height: var(--topbar-h); box-sizing: border-box;
  display: flex; align-items: center;
  gap: 12px; padding: 0 16px; direction: rtl;
  background: linear-gradient(90deg, #b45309, #d97706); color: #fff;
  font-size: 12.5px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.18);
  font-family: "Vazir", "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  overflow: hidden;
}
/* Push the whole chrome down by the banner's height while impersonating. */
body.is-user-impersonating { padding-top: var(--topbar-h); }
body.is-user-impersonating .top-nav { top: var(--topbar-h); }
body.is-user-impersonating .nav-sidebar {
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
@media (max-width: 768px) {
  /* Small screens: the message wraps — fall back to an auto-height sticky bar. */
  .imp-banner { position: sticky; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: 9px 16px; }
  body.is-user-impersonating { padding-top: 0; }
  body.is-user-impersonating .top-nav { top: 0; }
  body.is-user-impersonating .nav-sidebar { top: 0; height: 100vh; }
}
.imp-banner .imp-msg { flex: 1; min-width: 200px; }
.imp-banner b { font-weight: 800; }
.imp-banner .imp-mode-badge { padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.22); font-size: 11px; }
.imp-banner button {
  border: 1px solid rgba(255,255,255,.6); background: rgba(255,255,255,.14);
  color: #fff; padding: 5px 13px; border-radius: 999px; font-family: inherit;
  font-size: 11.5px; font-weight: 700; cursor: pointer; transition: background .12s;
}
.imp-banner button:hover { background: rgba(255,255,255,.30); }
.imp-banner .imp-exit { background: #fff; color: #b45309; border-color: #fff; }

/* ── «ورود به‌جای کاربر» — modal picker (scales to thousands: search + recent +
   org groups + in-org hierarchy) ─────────────────────────────────────────── */
.impm-overlay {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: flex-start;
  justify-content: center; padding: 6vh 16px 16px; direction: rtl;
  background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px);
  font-family: "Vazir", "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  animation: impmFade .15s ease;
}
@keyframes impmFade { from { opacity: 0; } to { opacity: 1; } }
.impm {
  width: 100%; max-width: 640px; max-height: 86vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; box-shadow: 0 24px 64px rgba(15, 23, 42, .35);
  overflow: hidden; animation: impmPop .18s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes impmPop { from { transform: translateY(-10px) scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }
.impm-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid #eef0f5; }
.impm-title { display: flex; align-items: flex-start; gap: 12px; flex: 1; }
.impm-title-ic { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #eef2ff, #e0e7ff); color: #4f46e5; flex-shrink: 0; }
.impm-title h2 { margin: 0; font-size: 18px; color: #1f2733; }
.impm-title p { margin: 3px 0 0; font-size: 12.5px; color: #94a3b8; line-height: 1.7; }
.impm-close { border: none; background: #f1f5f9; color: #64748b; width: 32px; height: 32px; border-radius: 9px; font-size: 20px; line-height: 1; cursor: pointer; flex-shrink: 0; transition: background .12s, color .12s; }
.impm-close:hover { background: #e2e8f0; color: #0f172a; }
.impm-controls { display: flex; gap: 10px; padding: 14px 22px 6px; align-items: center; flex-wrap: wrap; }
.impm-search-wrap { position: relative; flex: 1; min-width: 200px; }
.impm-search-ic { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.impm-search { width: 100%; box-sizing: border-box; padding: 11px 14px 11px 38px; border: 1px solid #e2e8f0; border-radius: 11px; font-family: inherit; font-size: 13.5px; direction: rtl; background: #f8fafc; }
.impm-search:focus { outline: none; border-color: #6366f1; background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.impm-modes { display: flex; gap: 4px; background: #f1f5f9; padding: 3px; border-radius: 11px; }
.impm-mode { border: none; background: none; padding: 7px 14px; border-radius: 8px; font-family: inherit; font-size: 12px; font-weight: 700; color: #64748b; cursor: pointer; transition: background .12s, color .12s, box-shadow .12s; }
.impm-mode.active { background: #fff; color: #4338ca; box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.impm-hint { padding: 4px 22px 12px; font-size: 11px; color: #94a3b8; line-height: 1.7; }
.impm-body { flex: 1; overflow-y: auto; padding: 6px 14px 16px; scrollbar-width: thin; }
.impm-loading, .impm-empty, .impm-more { padding: 24px; text-align: center; color: #94a3b8; font-size: 13px; }
.impm-more { padding: 10px; font-size: 11.5px; }
.impm-section-head { font-size: 11px; font-weight: 800; color: #94a3b8; letter-spacing: .3px; padding: 12px 10px 6px; }

/* Recent chips */
.impm-recent-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 8px 8px; }
.impm-chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 7px; border: 1px solid #e2e8f0; border-radius: 999px; background: #fff; font-family: inherit; font-size: 12.5px; font-weight: 600; color: #334155; cursor: pointer; transition: border-color .12s, background .12s; }
.impm-chip:hover { border-color: #6366f1; background: #f5f3ff; }
.impm-chip-ava { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; }

/* Org groups */
.impm-org { border: 1px solid #eef0f5; border-radius: 12px; margin: 6px 6px 8px; overflow: hidden; }
.impm-org-head { display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 14px; background: #fafbff; border: none; font-family: inherit; cursor: pointer; text-align: right; }
.impm-org-head:hover { background: #f1f5f9; }
.impm-chev { color: #94a3b8; transition: transform .18s; flex-shrink: 0; }
.impm-org.open .impm-chev { transform: rotate(-90deg); }
.impm-org-name { font-weight: 700; font-size: 13.5px; color: #1f2733; flex: 1; }
.impm-org-count { font-size: 11px; color: #94a3b8; background: #eef2ff; color: #6366f1; padding: 2px 9px; border-radius: 999px; }
.impm-org-list { display: none; padding: 4px; }
.impm-org.open .impm-org-list { display: block; }
.impm-flat { padding: 4px; }

/* Member row */
.impm-member { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 14px; border: none; background: none; border-radius: 10px; font-family: inherit; cursor: pointer; text-align: right; transition: background .1s; }
.impm-member:hover { background: #f5f3ff; }
.impm-ava { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #fff; flex-shrink: 0; }
.impm-ava--cto, .impm-ava--sysadmin { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.impm-ava--admin { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.impm-ava--manager { background: linear-gradient(135deg, #10b981, #059669); }
.impm-ava--accountant { background: linear-gradient(135deg, #f59e0b, #d97706); }
.impm-ava--seller { background: linear-gradient(135deg, #64748b, #475569); }
.impm-member-main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.impm-member-name { font-weight: 700; font-size: 13.5px; color: #1f2733; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.impm-member-sub { font-size: 11px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: right; }
.impm-go { font-size: 11.5px; font-weight: 700; color: #6366f1; opacity: 0; transition: opacity .12s; flex-shrink: 0; }
.impm-member:hover .impm-go { opacity: 1; }

/* Blocked (org opted out): visible but greyed, un-enterable. */
.impm-member--blocked { cursor: not-allowed; opacity: .5; }
.impm-member--blocked:hover { background: none; }
.impm-member--blocked .impm-ava { filter: grayscale(1); }
.impm-blocked-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; padding: 3px 8px; border-radius: 999px; flex-shrink: 0; white-space: nowrap; }
.impm-chip--blocked { opacity: .5; cursor: not-allowed; }
.impm-chip--blocked:hover { border-color: #e2e8f0; background: #fff; }
.impm-org--blocked .impm-org-head { opacity: .6; }
.impm-org-lock { font-size: 10.5px; font-weight: 700; color: #b45309; background: #fff7ed; border: 1px solid #fed7aa; padding: 2px 8px; border-radius: 999px; }
body.impm-open { overflow: hidden; }
@media (max-width: 560px) { .impm-controls { flex-direction: column; align-items: stretch; } .impm-modes { justify-content: stretch; } .impm-mode { flex: 1; } }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.nav-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--sidebar-border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  /* Scrolling lives on .nav-sidebar-scroll (below the header) — the sidebar
     itself must never scroll, so the logo/pin/close header stays put. */
  overflow: hidden;
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  direction: rtl;
}

/* The scrollable body of the menu: everything under the fixed logo header.
   Scrolling starts below the header's border, with a breathing padding. */
.nav-sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.1) transparent;
}

.nav-sidebar.collapsed {
  transform: translateX(100%);
}

/* Sidebar header / logo — EXACTLY --topbar-h tall so its bottom border sits on
   the same line as the top-bar's (no vertical padding: height is the anchor). */
.nav-sidebar-header {
  height: var(--topbar-h);
  box-sizing: border-box;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* Text fallback when the logo image cannot load (e.g. missing data folder). */
.nav-sidebar-logo-text { font-size: 15px; font-weight: 800; color: #111827; letter-spacing: -.3px; }
.nav-sidebar-logo-img {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

.nav-sidebar-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s;
  font-size: 16px;
}
.nav-sidebar-close:hover {
  background: rgba(0,0,0,.06);
  color: #1e293b;
}

/* ── Sidebar pin/lock button ──────────────────────────────────────────── */
.nav-sidebar-pin {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: none;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s, border-color .15s;
  font-size: 15px;
}
.nav-sidebar-pin:hover {
  background: rgba(0,0,0,.06);
  color: #1e293b;
}
/* ONE pin glyph, state via transform/fill only — no icon swap, no jump.
   Tilted outline = free; upright & filled = pinned. */
.nav-sidebar-pin .pin-icon {
  transform: rotate(-38deg);
  transition: transform .18s ease;
}
.nav-sidebar-pin.pinned .pin-icon {
  /* upright + active tint (NOT filled — the solid glyph read as a blob). */
  transform: rotate(0deg);
}
.nav-sidebar-pin.pinned {
  color: var(--sidebar-active);
  background: var(--sidebar-active-bg);
  border-color: rgba(37,99,235,.2);
}

/* When sidebar is pinned: no overlay, always visible */
.nav-sidebar.pinned {
  transform: translateX(0) !important;
}

/* ── Sidebar section group ───────────────────────────────────────────── */
.nav-section {
  padding: 6px 10px;
}
/* Clear separation between consecutive groups — the old flat list made the
   collapsible sections almost indistinguishable from one another. */
.nav-section + .nav-section {
  border-top: 1px solid var(--sidebar-border);
  margin-top: 2px;
  padding-top: 8px;
}

.nav-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: rgba(100,116,139,.06); /* neutral chip — same slate family */
  color: #64748b;                    /* darker than the old #94a3b8 — readable */
  font-size: 12.5px;                 /* was 10px — the "خیلی ریز" complaint */
  font-weight: 800;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: .6px;
  cursor: pointer;
  border-radius: 6px;
  transition: color .15s;
  direction: rtl;
}
.nav-section-toggle:hover {
  color: var(--sidebar-text-hover);
  background: rgba(100,116,139,.11);
}
/* The «اخیر» header is a label, not a collapse control. */
.nav-section-toggle--static {
  cursor: default;
  pointer-events: none;
}

.nav-section-arrow {
  font-size: 10px;
  transition: transform .2s;
  opacity: .6;
  margin-right: auto;
}
.nav-section.open .nav-section-arrow {
  transform: rotate(180deg);
}

/* ── «اخیر» (recent pages) ───────────────────────────────────────────── */
/* Same neutral language as the groups; the tinted header separates it just
   enough to read as "yours", without introducing a new color. */
.nav-section--recent .nav-section-toggle {
  background: rgba(100,116,139,.10);
}
.nav-section--recent .nav-section-items a {
  font-size: 12.5px;
}
/* Hover-only «×» on a recent row, pinned to the far inline-end (left in RTL)
   via margin-inline-start:auto — removes the entry without navigating. */
.nav-recent-remove {
  margin-inline-start: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.nav-recent-item:hover .nav-recent-remove,
.nav-recent-remove:focus-visible {
  opacity: .65;
}
.nav-recent-remove:hover {
  opacity: 1;
  background: rgba(225, 29, 72, .12);
  color: #e11d48;
}

.nav-section-items {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 4px 0 4px 0;
}
.nav-section.open .nav-section-items {
  display: flex;
}

/* ── Sidebar link ────────────────────────────────────────────────────── */
.nav-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 450;
  transition: color .12s, background .12s;
  direction: rtl;
  white-space: nowrap;
}
.nav-sidebar a:hover {
  color: var(--sidebar-text-hover);
  background: rgba(0,0,0,.04);
}
.nav-sidebar a.active {
  color: var(--sidebar-active);
  background: var(--sidebar-active-bg);
  font-weight: 600;
}

.nav-sidebar a .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-sidebar a.active .nav-icon {
  opacity: 1;
}
.nav-sidebar a .nav-icon svg {
  width: 18px;
  height: 18px;
}

/* Home link at top (no section) */
.nav-sidebar-home {
  padding: 8px 18px 2px;
}

/* ── Sidebar divider ─────────────────────────────────────────────────── */
.nav-sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 4px 18px;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────── */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
  opacity: 0;
  transition: opacity .25s;
}
.nav-overlay.visible {
  display: block;
  opacity: 1;
}

/* ── Body offset when sidebar open (desktop) ─────────────────────────── */
body {
  transition: padding-right .25s cubic-bezier(.4,0,.2,1);
}
body.sidebar-open {
  padding-right: var(--sidebar-w);
}

/* ══════════════════════════════════════════════════════════════════════
   Responsive — Mobile
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 260px;
  }

  .top-nav {
    height: 48px;
    padding: 0 12px;
    gap: 8px;
  }
  /* Match the smaller mobile flex gap when collapsing the hamburger. */
  body.sidebar-open .nav-hamburger { margin-inline-end: -8px; }

  .nav-user-meta { display: none; }

  /* Sidebar always overlays on mobile, no body offset */
  body.sidebar-open {
    padding-right: 0;
  }
  body.sidebar-open .top-nav {
    margin-right: 0;
  }
  body.sidebar-open .app-main,
  body.sidebar-open > main {
    margin-right: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════════ 
   Backward compatibility — old classes that some pages may still use
   ══════════════════════════════════════════════════════════════════════ */
.nav-group,
.nav-group-toggle,
.nav-group-menu,
.nav-group-arrow,
.nav-mobile-links,
.nav-m-group-label,
.nav-mobile-divider {
  display: none !important;
}

/* ── Version chip (top-nav) + changelog modal ──────────────────────────── */
.nav-version-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.nav-version-chip:hover { background: #f3f4f6; border-color: #d1d5db; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.nav-version-chip .nvc-env-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.nav-version-chip.is-live .nvc-env-dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.nav-version-chip.is-local .nvc-env-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.nav-version-chip.is-live .nvc-env { color: #047857; }
.nav-version-chip.is-local .nvc-env { color: #b45309; }
.nav-version-chip .nvc-ver { color: #6b7280; direction: ltr; }

/* changelog modal */
.nvc-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; direction: rtl;
}
.nvc-modal {
  background: #fff; border-radius: 16px;
  width: min(640px, 100%); max-height: min(80vh, 720px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  font-family: "Vazir", "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
}
.nvc-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid #eef0f4;
}
.nvc-modal-title { margin: 0 0 3px; font-size: 17px; color: #111827; }
.nvc-modal-sub { font-size: 12px; color: #6b7280; }
.nvc-modal-sub code { direction: ltr; background: #f3f4f6; padding: 1px 6px; border-radius: 6px; font-size: 11px; }
.nvc-modal-close {
  border: none; background: #f3f4f6; color: #6b7280;
  width: 30px; height: 30px; border-radius: 8px; font-size: 20px; line-height: 1;
  cursor: pointer; flex-shrink: 0;
}
.nvc-modal-close:hover { background: #e5e7eb; color: #111827; }
.nvc-list { list-style: none; margin: 0; padding: 8px 12px 14px; overflow-y: auto; }
.nvc-item { padding: 11px 8px; border-bottom: 1px solid #f1f3f7; }
.nvc-item:last-child { border-bottom: none; }
.nvc-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.nvc-subject { color: #1f2937; font-size: 13.5px; line-height: 1.7; }
.nvc-scope { font-size: 11px; color: #4f46e5; background: #eef2ff; border-radius: 6px; padding: 1px 7px; }
.nvc-sha { font-size: 11px; color: #9ca3af; direction: ltr; font-family: "Cascadia Code", Consolas, monospace; }
.nvc-date { font-size: 11px; color: #9ca3af; margin-inline-start: auto; }
.nvc-empty { color: #9ca3af; text-align: center; padding: 28px; }
.nvc-badge { font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 1px 8px; white-space: nowrap; }
.nvc-badge--feat { color: #047857; background: #d1fae5; }
.nvc-badge--fix { color: #b91c1c; background: #fee2e2; }
.nvc-badge--refactor { color: #6d28d9; background: #ede9fe; }
.nvc-badge--perf { color: #b45309; background: #fef3c7; }
.nvc-badge--docs { color: #1d4ed8; background: #dbeafe; }
.nvc-badge--chore, .nvc-badge--build, .nvc-badge--ci, .nvc-badge--style, .nvc-badge--test, .nvc-badge--revert { color: #4b5563; background: #f3f4f6; }

/* ── «کسی در حسابِ شماست» — the OWNER's blue bar ───────────────────────────
   The mirror image of .imp-banner: that one warns the VISITOR they are inside
   someone else's account; this one tells the OWNER, on their own screen, that
   someone is in theirs — with a button to watch what that person is doing.
   Blue on purpose (information, not a warning about your own state) and it
   reuses the same geometry so the two never fight over the top strip. */
.impown-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1450;
  height: var(--topbar-h); box-sizing: border-box;
  display: flex; align-items: center;
  gap: 12px; padding: 0 16px; direction: rtl;
  background: linear-gradient(90deg, #1d4ed8, #2563eb); color: #fff;
  font-size: 12.5px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.18);
  font-family: "Vazir", "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  overflow: hidden;
}
body.is-imp-watched { padding-top: var(--topbar-h); }
body.is-imp-watched .top-nav { top: var(--topbar-h); }
body.is-imp-watched .nav-sidebar { top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
@media (max-width: 768px) {
  .impown-banner { position: sticky; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: 9px 16px; }
  body.is-imp-watched { padding-top: 0; }
  body.is-imp-watched .top-nav { top: 0; }
  body.is-imp-watched .nav-sidebar { top: 0; height: 100vh; }
}
.impown-banner .impown-ic { flex: none; opacity: .95; }
.impown-banner .impown-msg { flex: 1; min-width: 200px; }
.impown-banner b { font-weight: 800; }
.impown-banner .impown-mode,
.impown-banner .impown-pages,
.impown-banner .impown-watching {
  padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.22); font-size: 11px; white-space: nowrap;
}
.impown-banner .impown-watching { background: #fff; color: #1d4ed8; font-weight: 800; }
.impown-banner .impown-watch {
  border: 1px solid #fff; background: #fff; color: #1d4ed8;
  padding: 5px 13px; border-radius: 999px; font-family: inherit;
  font-size: 11.5px; font-weight: 800; cursor: pointer; transition: opacity .12s;
}
.impown-banner .impown-watch:hover { opacity: .88; }
.impown-banner .impown-watch:disabled { opacity: .6; cursor: default; }
