/* HBN CRM — استایل اصلی (راست‌به‌چپ، فونت وزیرمتن) */
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-ExtraBold.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --sidebar-w: 268px;
  --paper: #FFFFFF; --ink: #020508; --accent: #02B1C0;
  --ink-rgb: 2 5 8; --accent-rgb: 2 177 192;
  --bg: var(--paper); --card: var(--paper); --input-bg: var(--paper); --table-head: var(--paper);
  --text: var(--ink); --muted: var(--ink); --placeholder: rgb(var(--ink-rgb) / .68);
  --border: rgb(var(--ink-rgb) / .16); --border-soft: rgb(var(--ink-rgb) / .12);
  --soft: rgb(var(--accent-rgb) / .045); --hover: rgb(var(--accent-rgb) / .09);
  --primary: var(--ink); --primary-h: rgb(var(--accent-rgb) / .77);
  --primary-soft: rgb(var(--accent-rgb) / .12); --on-primary-soft: var(--text);
  --button-bg: var(--accent); --button-hover: var(--primary-h); --button-fg: var(--ink);
  --button-hover-fg: var(--ink); --button-edge: transparent;
  --disabled-bg: var(--soft); --disabled-fg: var(--text); --highlight: var(--text);
  --selection: var(--accent); --selection-bg: var(--accent); --selection-fg: var(--ink);
  --green: var(--text); --green-soft: var(--primary-soft); --amber: var(--text); --amber-soft: var(--soft);
  --rose: var(--text); --rose-soft: var(--soft); --sky: var(--text); --sky-soft: var(--primary-soft);
  --violet: var(--text); --violet-soft: var(--soft); --teal: var(--text); --teal-soft: var(--primary-soft);
  --slate: var(--text); --slate-soft: var(--soft);
  --scroll: rgb(var(--ink-rgb) / .25);
  --side-bg: var(--card); --side-text: var(--text); --side-muted: var(--muted);
  --side-active-bg: var(--selection-bg); --side-active-text: var(--selection-fg); --side-hover: var(--hover);
  --side-border: var(--border-soft); --side-glow: transparent;
  --chart-a: var(--accent); --chart-b: rgb(var(--ink-rgb) / .67);
  --chart-c: rgb(var(--accent-rgb) / .68); --chart-d: rgb(var(--ink-rgb) / .42);
  --chart-e: rgb(var(--accent-rgb) / .45); --chart-f: rgb(var(--ink-rgb) / .27);
  --chart-g: rgb(var(--accent-rgb) / .27); --chart-h: var(--ink);
  --scrim: rgb(var(--ink-rgb) / .48); --shade: rgb(var(--ink-rgb) / .20);
  --shadow-sm: 0 1px 2px rgb(var(--ink-rgb) / .05);
  --shadow-md: 0 4px 16px rgb(var(--ink-rgb) / .08);
  --shadow-lift: 0 12px 32px rgb(var(--ink-rgb) / .13);
}

/* ---------- پایداری چیدمان (ریسپانسیو) ----------
   جلوگیری از سرریز افقی صفحه: هیچ المانی نباید عرض صفحه را بیشتر کند
   (سایدبار آف‌کانواس و جدول‌های داخل ظرف اسکرول‌دار مستثنی هستند) */
html { overflow-x: hidden; }
/* فرزندان گرید همیشه اجازهٔ کوچک‌شدن دارند تا متن از کادر بیرون نزند */
.grid > * { min-width: 0; }
/* اعداد و کلمات طولانی داخل کارت‌ها و سلول‌ها می‌شکنند، نه اینکه بیرون بزنند */
.card, .stat-card, .as-msg, .dl, .totals { overflow-wrap: break-word; }
.stat-card .sv { overflow-wrap: anywhere; }

/* ---------- تم رنگ متن فرم‌ها (اصلاح خوانایی) ----------
   بدون این قاعده، مرورگر متن input/select را با رنگ سیستمی (سیاه) می‌کشد
   و در تم تاریک متن روی زمینهٔ تیره دیده نمی‌شود */
:root { color-scheme: light; }
input, select, textarea { color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
select option { color: var(--text); background: var(--input-bg); }

/* ---------- تم تاریک با پالت A.M ---------- */
html[data-theme='dark'] {
  color-scheme: dark;
  --charcoal: #1B2026; --metal-edge: #2A323A; --neon: #0EECF6; --selection: #168393;
  --disabled-bg: #025662; --glow: #03434D; --text: #E9E9EB; --muted: #CDC9CC;
  --placeholder: #ABA7AB; --highlight: #F8F6F7;
  --bg: var(--ink); --card: var(--charcoal); --input-bg: var(--ink); --table-head: var(--charcoal);
  --border: var(--metal-edge); --border-soft: var(--metal-edge);
  --soft: var(--metal-edge); --hover: var(--glow);
  --primary: var(--neon); --primary-h: var(--glow); --primary-soft: var(--glow); --on-primary-soft: var(--neon);
  --button-bg: var(--glow); --button-hover: var(--disabled-bg); --button-edge: var(--accent);
  --button-fg: var(--highlight); --button-hover-fg: var(--highlight); --disabled-fg: var(--highlight);
  --selection-bg: var(--glow); --selection-fg: var(--highlight);
  --green: var(--neon); --green-soft: var(--glow); --amber: var(--highlight); --amber-soft: var(--metal-edge);
  --rose: var(--highlight); --rose-soft: var(--metal-edge); --sky: var(--neon); --sky-soft: var(--glow);
  --violet: var(--text); --violet-soft: var(--metal-edge); --teal: var(--neon); --teal-soft: var(--glow);
  --slate: var(--muted); --slate-soft: var(--metal-edge); --scroll: var(--placeholder);
  --chart-b: var(--muted); --chart-c: var(--selection); --chart-d: var(--placeholder);
  --chart-e: var(--disabled-bg); --chart-f: var(--neon); --chart-g: var(--highlight); --chart-h: var(--glow);
  --scrim: rgb(var(--ink-rgb) / .69); --shade: rgb(var(--ink-rgb) / .58);
  --shadow-sm: 0 1px 2px var(--shade);
  --shadow-md: 0 4px 16px var(--shade);
  --shadow-lift: 0 0 20px var(--glow);
}
@supports (color: color-mix(in srgb, transparent, currentColor)) {
  html[data-theme='dark'] { --selection-bg: color-mix(in srgb,var(--selection) 32%,var(--card)); }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif; background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.8; min-height: 100vh; direction: rtl;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--primary); text-decoration-color: var(--accent); text-underline-offset: .25em; }
button, input, select, textarea { color: var(--text); }
button, input:not([type=checkbox]):not([type=radio]), select, textarea {
  background-color: var(--input-bg); border-color: var(--border);
}
::selection { color: var(--selection-fg); background: var(--selection-bg); }
table { border-collapse: collapse; width: 100%; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- صفحهٔ بارگذاری اولیه ---------- */
#boot-splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
}
#boot-splash img { width: 68px; height: 68px; border-radius: 16px; box-shadow: var(--shadow-lift); }
#boot-splash .spin {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border-soft); border-top-color: var(--accent);
  animation: hbn-spin .8s linear infinite;
}
#boot-splash .lbl { color: var(--muted); font-size: 13px; }
@keyframes hbn-spin { to { transform: rotate(360deg); } }

/* ---------- صفحهٔ ورود — دوپنلی (فرم + پنل آبی) ---------- */
#login-screen, #fpw-screen {
  min-height: 100vh; display: none; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 90% 0%, var(--primary-soft), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-shell {
  width: min(460px, 100%); border-radius: 26px; overflow: hidden;
  background: var(--card); border: 1px solid var(--border-soft); box-shadow: var(--shadow-lift);
}
/* پنل آبی معرفی */
.login-hero {
  flex: 1.15; min-width: 0; position: relative; color: var(--text); padding: 36px 38px 34px;
  display: flex; flex-direction: column; gap: 20px;
  background: var(--card);
}
.login-hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(420px 300px at 85% -10%, var(--primary-soft), transparent 65%);
}
.login-hero > * { position: relative; }
.lh-brand { display: flex; align-items: center; gap: 13px; }
.lh-brand img { width: 52px; height: 52px; border-radius: 14px; background: var(--paper); padding: 4px; box-shadow: var(--shadow-md); }
.lh-brand .lh-bt b { display: block; font-size: 16.5px; font-weight: 800; line-height: 1.5; }
.lh-brand .lh-bt span { display: block; font-size: 12px; color: var(--muted); }
.lh-copy h2 { font-size: 25px; font-weight: 800; line-height: 1.6; letter-spacing: -.2px; }
.lh-copy p { font-size: 13.5px; line-height: 2; color: var(--text); margin-top: 8px; max-width: 40ch; }
.lh-cards { display: flex; flex-direction: column; gap: 10px; }
.lh-chip {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--soft); border: 1px solid var(--border); border-radius: 14px;
  backdrop-filter: blur(4px); transition: background .2s ease, transform .2s ease;
}
.lh-chip:hover { background: var(--hover); transform: translateX(-3px); }
.lh-chip-ic {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); border: 1px solid var(--border);
}
.lh-chip-ic .ic-svg { width: 18px; height: 18px; color: var(--text); }
.lh-chip b { display: block; font-size: 13px; font-weight: 700; }
.lh-chip span:not(.lh-chip-ic) { display: block; font-size: 11.5px; color: var(--text); margin-top: 2px; }
/* کارت نمودار */
.lh-chart-card {
  margin-top: auto; background: var(--card); border-radius: 16px; padding: 16px 18px 12px;
  color: var(--text); box-shadow: var(--shadow-lift);
}
/* کارت ثابت است؛ اثر هاور فقط روی خود نمودار (خطوط و نقاط) اعمال می‌شود */
.lh-svg .lh-line, .lh-svg .lh-line2, .lh-svg .lh-dots circle {
  transition: stroke-width .25s ease, stroke .25s ease, r .25s ease;
}
.lh-svg:hover .lh-line { stroke-width: 4; filter: drop-shadow(0 0 5px var(--primary-soft)); }
.lh-svg:hover .lh-line2 { stroke: var(--chart-b); stroke-dasharray: none; }
.lh-svg:hover .lh-dots circle { r: 6px; }
.lh-cc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.lh-cc-head b { font-size: 13px; font-weight: 700; flex: 1; color: var(--text); }
.lh-legend { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.lh-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot-blue { background: var(--chart-a); } .dot-gray { background: var(--chart-b); }
.lh-svg { width: 100%; height: auto; display: block; }
.lh-svg .lh-grid line { stroke: var(--border-soft); stroke-width: 1; }
.lh-svg .lh-line { fill: none; stroke: var(--chart-a); stroke-width: 2.5; stroke-linecap: round; }
.lh-svg .lh-line2 { fill: none; stroke: var(--chart-b); stroke-width: 2; stroke-dasharray: 5 5; stroke-linecap: round; }
.lh-svg .lh-dots circle { fill: var(--card); stroke: var(--chart-a); stroke-width: 2; }
.lh-svg .lh-months text { font-size: 10.5px; fill: var(--muted); text-anchor: middle; font-family: Vazirmatn, sans-serif; }
/* فرم ورود */
.login-form {
  min-width: 0; padding: 40px 44px 34px; display: flex; flex-direction: column;
  justify-content: center; gap: 6px; background: var(--card);
}
.lf-head { margin-bottom: 18px; text-align: center; }
.lf-logo { display: block; width: 170px; height: auto; margin: 0 auto 20px; }
.login-form h1 { font-size: 21px; font-weight: 800; letter-spacing: -.2px; line-height: 1.6; }
.login-form .sub { font-size: 13px; color: var(--muted); line-height: 1.9; margin-top: 4px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.login-form input {
  width: 100%; padding: 12px 15px; border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--input-bg); transition: border .15s, box-shadow .15s;
}
.login-form input:focus { outline: 0; border-color: var(--primary); background: var(--card); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-form .btn { margin-top: 26px; }
.lf-foot { margin-top: 26px; font-size: 11.5px; color: var(--muted); text-align: center; }
/* فراموشی رمز عبور */
.lf-forgot { margin-top: 14px; text-align: center; }
.lf-forgot a { color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none; }
.lf-forgot a:hover { text-decoration: underline; }
.login-form .sub2 { font-size: 13.5px; color: var(--primary); font-weight: 700; margin-top: 6px; }
/* پنل بازیابی رمز */
.fw-radio {
  display: flex; align-items: center; gap: 9px; margin: 8px 0 0 !important;
  padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 11px;
  background: var(--input-bg); cursor: pointer; font-weight: 500 !important;
}
.fw-radio:hover { border-color: var(--primary); }
.fw-radio input { width: auto; accent-color: var(--primary); }
.fw-code { text-align: center; letter-spacing: 8px; font-size: 18px; font-weight: 700; direction: ltr; }
.fw-note { font-size: 11.5px; color: var(--muted); margin: -6px 0 12px; line-height: 1.7; }
.fw-info {
  background: var(--primary-soft); color: var(--on-primary-soft); border: 1px solid var(--primary-soft);
  border-radius: 11px; padding: 11px 14px; font-size: 12.5px; line-height: 2; margin-bottom: 6px;
}
.fw-info b { font-size: 16px; letter-spacing: 3px; direction: ltr; display: inline-block; }
/* موبایل: پنل آبی سمت راست کاملاً حذف می‌شود و فقط فرم ورود نمایش داده می‌شود */
@media (max-width: 920px) {
  #login-screen, #fpw-screen {
    padding: 18px 16px;
    background:
      radial-gradient(600px 400px at 50% -5%, var(--primary-soft), transparent 60%),
      var(--bg);
  }
  .login-shell {
    flex-direction: column; min-height: 0; max-width: 460px;
    border-radius: 24px; box-shadow: var(--shadow-lift);
  }
  .login-hero { display: none; }
  .login-form { padding: 30px 24px 24px; }
  .lf-logo { width: 120px; margin-bottom: 12px; }
  .lf-head { margin-bottom: 8px; }
  .login-form h1 { font-size: 19px; }
  .login-form .sub { font-size: 12.5px; }
}
@media (max-width: 480px) {
  .login-form { padding: 26px 18px 20px; }
  .login-form h1 { font-size: 17px; }
}
.login-err {
  background: var(--rose-soft); color: var(--rose); border-radius: 10px; padding: 9px 14px;
  font-size: 13px; margin-bottom: 14px; display: none;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--button-bg); color: var(--button-fg); border: 1px solid var(--button-edge); border-radius: 10px;
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  transition: background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.btn:hover { background: var(--primary-h); box-shadow: 0 4px 14px var(--primary-soft); }
.btn:active { transform: scale(.98); }
.btn.wide { width: 100%; padding: 12px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--hover); }
.btn:is(.green,.rose,.danger) { background: var(--soft); color: var(--text); border: 1px solid var(--border); }
.btn:is(.green,.rose,.danger):hover { background: var(--hover); color: var(--text); }
.btn.sm { padding: 6px 13px; font-size: 13px; border-radius: 8px; }

/* ---------- پوستهٔ برنامه ---------- */
#app { display: none; min-height: 100vh; }
#app.on { display: flex; }
#sidebar {
  width: var(--sidebar-w); background: var(--side-bg); color: var(--side-text); flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-left: 1px solid var(--side-border);
  position: sticky;
  /* جهت ظرف LTR می‌شود تا اسکرول‌بار روی لبهٔ راست (خارجی) سایدبار بیفتد؛
     محتوای داخل با خط پایین دوباره RTL می‌شود. */
  direction: ltr;
}
#sidebar * { direction: rtl; }
/* هالهٔ نور آبی ملایم بالای سایدبار (طرح‌مرجع) */
#sidebar::before {
  content: ''; position: absolute; top: 0; inset-inline: 0; height: 210px; pointer-events: none;
  background: radial-gradient(340px 190px at 20% 0%, var(--side-glow), transparent 70%);
}
#sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px 14px; position: relative; }
#sidebar .brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: var(--shadow-sm); }
#sidebar .brand .t1 { font-size: 13.5px; font-weight: 800; color: var(--text); line-height: 1.55; letter-spacing: -.1px; }
.nav-group { padding: 10px 12px 0; position: relative; }
.nav-group .gl { font-size: 11px; color: var(--side-muted); font-weight: 700; padding: 4px 10px 6px; letter-spacing: .3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--side-text); font-size: 13.5px; font-weight: 500; cursor: pointer; margin-bottom: 1px; border: 0; background: 0;
  width: 100%; text-align: right; transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.nav-item:hover { background: var(--side-hover); color: var(--text); }
.nav-item.on {
  background: var(--side-active-bg); color: var(--side-active-text); font-weight: 700;
  box-shadow: inset -3px 0 0 var(--selection), var(--shadow-sm);
}
.nav-item .ic { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
#sidebar .foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--side-border); position: relative; }
#sidebar .foot .uinfo { display: flex; align-items: center; gap: 10px; }
#sidebar .foot .avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--button-bg); color: var(--button-fg);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
  box-shadow: 0 3px 10px var(--primary-soft);
}
#sidebar .foot .un { font-size: 13px; color: var(--text); font-weight: 700; line-height: 1.4; }
#sidebar .foot .ur { font-size: 11.5px; color: var(--side-muted); }
#btn-logout { margin-top: 10px; width: 100%; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  background: var(--card); border-bottom: 1px solid var(--border-soft); padding: 13px 26px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow-sm);
}
#topbar .ttl { font-size: 17px; font-weight: 700; }
#topbar .crumb { color: var(--muted); font-size: 12.5px; }
#topbar .spacer { flex: 1; }
#content { padding: 24px 26px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- کارت‌ها و داشبورد ---------- */
.grid { display: grid; gap: 14px; }
.grid.stat { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; padding: 18px 20px;
  box-shadow: var(--shadow-sm); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--border); }
.stat-card .sv { font-size: 24px; font-weight: 800; margin-top: 2px; letter-spacing: -.3px; }
.stat-card .sl { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
/* نشان آیکون قاب‌دار (مثل طرح‌مرجع) */
.stat-card .si {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0; background: var(--card); border: 1px solid var(--border);
  transition: border-color .2s ease;
}
.stat-card:hover .si { border-color: currentColor; opacity: .9; }
.h2 { font-size: 15px; font-weight: 700; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
.h2:first-child { margin-top: 0; }
/* ردیف نمودارهای داشبورد: نمودار اصلی پهن‌تر (مثل طرح‌مرجع) */
.grid.dash-charts { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; }
.dash-charts .card { display: flex; }
.dash-charts .card-ct { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.dash-charts .chart-box, .dash-charts .donut-wrap { margin-inline: auto; width: 100%; }
.dash-charts .donut-wrap { justify-content: center; }
.muted { color: var(--muted); }
.mono { direction: ltr; display: inline-block; font-family: ui-monospace, monospace; font-size: 12.5px; }

/* ---------- جدول ---------- */
.tbl-wrap { background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
table.tbl { font-size: 13.5px; }
.tbl th {
  background: var(--soft); color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
.tbl td { padding: 10.5px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; transition: background .15s ease; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl .num { direction: ltr; text-align: left; font-family: ui-monospace, monospace; font-size: 12.5px; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- نشان وضعیت ---------- */
.badge {
  display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.b-slate { background: var(--slate-soft); color: var(--slate); } .b-sky { background: var(--sky-soft); color: var(--sky); }
.b-green { background: var(--green-soft); color: var(--green); } .b-amber { background: var(--amber-soft); color: var(--amber); }
.b-rose { background: var(--rose-soft); color: var(--rose); } .b-violet { background: var(--violet-soft); color: var(--violet); }
.b-teal { background: var(--teal-soft); color: var(--teal); } .b-primary { background: var(--primary-soft); color: var(--on-primary-soft); }

/* ---------- نوار ابزار جدول ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 14px; align-items: center; }
.toolbar input:is([type=text],[type=search]), .toolbar select {
  padding: 9px 13px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--card);
}
.toolbar input:is([type=text],[type=search]) { min-width: 230px; }
.toolbar .grow { flex: 1; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; justify-content: center; font-size: 13px; }

/* ---------- مودال ---------- */
.modal-bg {
  position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: none;
  align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto;
}
.modal-bg.on { display: flex; }
.modal {
  background: var(--card); border-radius: 16px; width: 720px; max-width: 100%;
  box-shadow: 0 30px 80px var(--shade); animation: pop .16s ease;
}
.modal.wide { width: 940px; }
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .mh {
  padding: 12px clamp(12px, 3vw, 22px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px;
}
.modal .mh .mt { font-size: 16px; font-weight: 700; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.modal .mh .modal-back { min-height: 44px; flex-shrink: 0; }
.modal .mh .modal-back[hidden] { display: none; }
.modal .mb { padding: 20px 22px; max-height: calc(100vh - 210px); overflow-y: auto; }
.modal .mf { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-start; }

/* ---------- فرم ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .fld { min-width: 0; }
.fld label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.fld label .req { color: var(--rose); }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--input-bg); transition: border .15s;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 0; border-color: var(--primary); background: var(--card); }
.fld textarea { min-height: 76px; resize: vertical; }
.fld .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.date-toolbar { align-items: flex-end; }
.date-filter { flex: 0 1 180px; min-width: min(100%, 158px); display: grid; gap: 4px; }
.date-filter label { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.jalali-field {
  width: 100%; min-width: 0; min-height: 44px; display: grid;
  grid-template-columns: minmax(0,1fr) 44px; align-items: stretch;
  border: 1.5px solid var(--border); border-radius: 9px; background: var(--input-bg);
}
.toolbar > .jalali-field { flex: 0 1 180px; min-width: min(100%,158px); }
.jalali-field:focus-within { border-color: var(--primary); }
.fld .jalali-field .jalali-input, .toolbar .jalali-field .jalali-input, .jalali-field .jalali-input {
  grid-column: 1; width: 100%; min-width: 0; min-height: 40px; margin: 0; border: 0; border-radius: 0;
  box-shadow: none; background: transparent; padding: 6px 8px; text-align: right; outline-offset: -2px;
}
.jalali-trigger {
  grid-column: 2; width: 44px; min-height: 42px; padding: 0; display: grid; place-items: center;
  border: 0; border-inline-start: 1px solid var(--border); border-radius: 8px 0 0 8px;
  background: transparent; color: var(--primary); cursor: pointer;
}
.jalali-trigger:disabled { color: var(--muted); cursor: default; }
.jalali-trigger:not(:disabled):hover, .jalali-trigger[aria-expanded=true] { background: var(--primary-soft); }
.jalali-panel {
  position: fixed; z-index: 5000; direction: rtl; width: min(326px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px); overflow: auto; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  color: var(--text); box-shadow: var(--shadow-lift);
}
.jalali-head { display: grid; grid-template-columns: 34px minmax(74px,1fr) 73px 34px; gap: 4px; }
.jalali-panel select, .jalali-panel button {
  min-height: 37px; border: 1px solid var(--border); border-radius: 7px; background: var(--input-bg);
  color: var(--text); font: inherit; font-size: 12px;
}
.jalali-panel select { padding: 0 5px; }
.jalali-panel button { cursor: pointer; padding: 0 4px; }
.jalali-panel button:disabled { color: var(--placeholder); cursor: default; }
.jalali-panel button:not(:disabled):hover { background: var(--primary-soft); }
.jalali-panel button[aria-pressed=true], .jalali-panel button[aria-pressed=true]:hover {
  background: var(--selection-bg); color: var(--selection-fg); border-color: var(--selection);
}
.jalali-panel :focus-visible, .jalali-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.jalali-grid {
  display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 2px; text-align: center; margin: 6px 0;
}
.jalali-grid button { min-height: 36px; border-color: transparent; background: transparent; }
.jalali-grid button[aria-current=date] { border-color: var(--primary); font-weight: 700; }
.jalali-week { font-size: 12px; color: var(--muted); line-height: 27px; }
.jalali-actions { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 6px; }
.jalali-actions button { min-width: 56px; }
.catalog-note { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.catalog-totals { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,190px),1fr)); gap: 10px; margin-bottom: 14px; }
.catalog-totals > div { display: grid; gap: 5px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; }
.catalog-totals span { color: var(--muted); font-size: 12px; }
.catalog-totals strong { font-size: 17px; }
.catalog-map { margin: 0 0 14px; }
.catalog-map h2, .catalog-map summary { font-size: 14px; font-weight: 750; margin: 0 0 9px; }
.catalog-map summary { cursor: pointer; }
.catalog-groups { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,360px),1fr)); gap: 10px; }
.catalog-group { min-width: 0; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; font-size: 13px; }
.catalog-group :is(header,li) { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; padding: 10px 12px; }
.catalog-group h3 { flex: 1 1 auto; font-size: 14px; margin: 0; }
.catalog-group li { border-top: 1px solid var(--border); background: var(--soft); }
.catalog-group li > span:first-child { flex: 1 1 auto; overflow-wrap: anywhere; }
.catalog-group :is(ul,p) { margin: 0; list-style: none; padding: 0; }
.catalog-group p { padding: 9px 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.catalog-group :is(a,button) { white-space: nowrap; }
.catalog-links { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.catalog-links a { color: var(--primary); font-weight: 650; }
.exact-money { font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .date-filter { flex: 1 1 140px; min-width: min(100%,135px); }
}
.sheet-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.sheet-actions .btn { white-space: nowrap; }
.sheet-help { color: var(--muted); margin: 0 0 6px; font-size: 13px; }
.sheet-upload-form {
  display: grid; gap: 7px; margin-top: 12px; padding: 14px;
  background: var(--soft); border: 1px solid var(--border); border-radius: 10px;
}
.sheet-upload-form label { font-weight: 600; }
.sheet-upload-form input { width: 100%; min-width: 0; }
.sheet-upload-form input::file-selector-button {
  font: inherit; background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 9px; margin-inline-end: 8px; cursor: pointer;
}
.sheet-upload-form .btn { justify-self: start; }
.sheet-selection { overflow-wrap: anywhere; font-size: 13px; }
.sheet-status:not(:empty), .sheet-error:not([hidden]) { margin-top: 10px; font-size: 13px; }
.sheet-error { color: var(--rose); }
.sheet-heading { margin: 16px 0 6px; font-size: 14px; }
.sheet-list { list-style: none; border-top: 1px solid var(--border); }
.sheet-list li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.sheet-row-name { flex: 1 1 170px; min-width: 0; overflow-wrap: anywhere; }
.sheet-row-name small { display: block; }
.sheet-remove { color: var(--rose) !important; }
.sheet-empty { font-size: 13px; padding: 8px 0; }
.sheet-import-controls { margin: 12px 0; }
.sheet-import-controls [hidden], #modal-foot [hidden] { display: none !important; }
.import-table { margin-top: 8px; max-height: 265px; overflow: auto; }
.import-table .tbl th { position: sticky; top: 0; z-index: 1; }
.import-table .tbl td { white-space: normal; overflow-wrap: anywhere; }
.stock-import-preview .tbl { width: 100%; }
@media (max-width: 600px) {
  .stock-import-preview .tbl :is(th,td) { padding-inline: 5px; }
  .stock-import-preview .tbl th { white-space: normal; }
  .stock-import-preview .tbl td:nth-last-child(-n+3) { white-space: nowrap; font-variant-numeric: tabular-nums; }
  .inventory-import-modal #import-mapping .tbl { width: 100%; table-layout: fixed; }
  .inventory-import-modal #import-mapping th:last-child { width: 48%; }
  .inventory-import-modal #import-mapping .import-table select { min-width: 0; width: 100%; }
}
.modal.inventory-import-modal { display: flex; flex-direction: column; max-height: calc(100dvh - 60px); }
.modal.inventory-import-modal :is(.mh,.mf) { flex: 0 0 auto; }
.modal.inventory-import-modal .mb { flex: 1 1 auto; min-height: 0; max-height: none; }
@media (max-width: 600px) {
  .modal.inventory-import-modal { max-height: calc(100dvh - 20px); }
}
.import-table select { min-width: 175px; max-width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 7px; padding: 6px; }
.import-errors { padding-inline-start: 20px; margin-top: 6px; }
.import-errors li { margin-bottom: 3px; }
.product-qty-filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  margin-bottom: 10px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--soft);
}
.product-qty-group { flex: 0 1 230px; min-width: 0; display: grid; gap: 5px; align-self: flex-start; }
.product-qty-group label { display: block; color: var(--text); font-size: 12px; font-weight: 600; }
.product-qty-group input, .product-qty-group select {
  width: 100%; min-width: 0; min-height: 40px; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}
.product-qty-range { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; margin-top: 3px; }
.product-qty-range[hidden], .product-qty-error[hidden] { display: none; }
.product-qty-range label { margin-bottom: 3px; color: var(--muted); }
.product-qty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.product-qty-error { flex: 1 1 100%; margin: 0; font-size: 13px; color: var(--rose); }
.product-qty-filters [aria-invalid=true] { border-color: var(--rose); }
.stock-filter-mark { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-start: 5px; background: var(--primary); }
.stock-filter-sr { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
@media (max-width: 600px) {
  .product-qty-group { flex: 1 1 142px; }
  .product-qty-actions { flex: 1 1 100%; }
}
.tbl-wrap.product-catalog { overflow: auto; }
.btn.ghost:is(#btn-stock-summary,#btn-catalog-source)[aria-pressed=true] { border-color: var(--primary); color: var(--on-primary-soft); background: var(--primary-soft); }
.product-catalog th, .product-catalog td { white-space: nowrap; padding-inline: 9px; }
.product-catalog td.catalog-text { min-width: 135px; max-width: 245px; white-space: pre-wrap; overflow-wrap: anywhere; }
.product-catalog :is(th,td).catalog-live { background: var(--soft); }
.product-stock-count { color: var(--primary); font-weight: 700; }
.items-empty { text-align: center; margin: 0; padding: 12px; font-size: 13px; }
.form-err { background: var(--rose-soft); color: var(--rose); border-radius: 9px; padding: 9px 14px; font-size: 13px; margin-bottom: 13px; display: none; }

/* ---------- اقلام سند ---------- */
.items-box { border: 1.5px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 6px; }
.items-box .ih {
  background: var(--soft); padding: 10px 14px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
.items-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.items-tbl { font-size: 12.5px; width: 100%; table-layout: fixed; }
/* اسناد مالی: جدول اقلام در موبایل هم بدون جابه‌جایی، با اسکرول افقی عرض ثابت می‌گیرد */
.items-tbl.items-money { min-width: 880px; }
.items-tbl:not(.items-money) { min-width: 460px; }
.items-tbl th { background: var(--soft); padding: 7px 8px; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; }
.items-tbl td { padding: 5px 6px; border-bottom: 1px solid var(--border-soft); }
.items-tbl input, .items-tbl select {
  width: 100%; padding: 6px 7px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 12.5px;
  background: var(--card); min-width: 0;
}
.items-tbl .del { background: none; border: 0; color: var(--rose); font-size: 16px; padding: 2px 7px; }

/* ---------- انتخابگر کالا با جستجوی سریع (در اقلام سند) ---------- */
.ppick { position: relative; width: 100%; min-width: 0; }
.ppick-in {
  width: 100%; padding: 6px 7px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 12.5px; background: var(--card); color: var(--text); min-width: 0;
}
.ppick-in:focus { outline: 0; border-color: var(--primary); }
.ppick.has-val .ppick-in { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.ppick-drop {
  position: fixed; z-index: 300;
  background: var(--card); border: 1.5px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow-lift); max-height: 270px; overflow-y: auto; display: none; padding: 4px;
}
.ppick-drop.on { display: block; }
.pp-opt {
  padding: 7px 9px; border-radius: 7px; cursor: pointer; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; font-size: 12px; line-height: 1.6;
}
.pp-opt:hover, .pp-opt.act { background: var(--hover); }
.pp-opt .pp-name { min-width: 0; flex: 1; }
.pp-opt .pp-name b { display: block; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-opt .pp-name span { display: block; font-size: 10.5px; color: var(--muted); direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-opt .pp-price { font-size: 11px; color: var(--green); font-weight: 700; white-space: nowrap; direction: ltr; }
.pp-empty { padding: 14px; text-align: center; font-size: 12px; color: var(--muted); }
.totals { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; margin-inline-start: auto; width: 300px; font-size: 13.5px; }
.totals .row { display: flex; justify-content: space-between; padding: 2px 4px; }
.totals .row.grand { border-top: 1.5px solid var(--text); margin-top: 4px; padding-top: 7px; font-weight: 800; font-size: 15px; }

/* ---------- جزئیات سند ---------- */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 11px; }
.dl .dt { font-size: 11.5px; color: var(--muted); } .dl .dd { font-weight: 600; font-size: 13.5px; }

/* ---------- پیام‌ها ---------- */
#toast-box { position: fixed; bottom: 22px; left: 22px; z-index: 100; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent); border-radius: 11px; padding: 12px 20px; font-size: 13.5px;
  box-shadow: var(--shadow-lift); animation: pop .18s ease; max-width: 380px;
}
.toast.err { border-inline-start-style: double; font-weight: 700; }

/* ---------- گزارش‌ها ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .bl { color: var(--muted); text-align: left; font-size: 12px; direction: ltr; }
.bar-row .track { background: var(--soft); border-radius: 7px; height: 22px; overflow: hidden; }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, var(--chart-c), var(--accent)); border-radius: 7px; transition: filter .2s ease; }
.bar-row:hover .fill { filter: brightness(1.08); }
.bar-row .bv { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- چاپ ---------- */
@media print {
  #sidebar, #topbar, .toolbar, .product-qty-filters, .pager, .modal .mf { display: none !important; }
  #content { padding: 0; max-width: none; }
  .tbl-wrap { border: 0; }
}

@media (max-width: 920px) {
  #sidebar { position: fixed; z-index: 60; right: -280px; transition: right .2s; }
  #sidebar.open { right: 0; box-shadow: 0 0 60px var(--shade); }
  #menu-btn { display: inline-flex !important; }
  .form-grid { grid-template-columns: 1fr; }
}
#menu-btn { display: none; background: 0; border: 1.5px solid var(--border); border-radius: 9px; padding: 8px 12px; }

/* ============================================================
   افزوده‌های نسخهٔ اصلی — نمودارها، نقش‌ها و دستیار هوشمند
   ============================================================ */

/* ---------- نمودارهای SVG ---------- */
.chart-box { width: 100%; overflow: hidden; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg rect:hover { opacity: .85; }
.chart-empty { text-align: center; padding: 26px 0; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 10px; justify-content: center; }
.chart-legend.col { flex-direction: column; gap: 7px; margin-top: 0; justify-content: flex-start; }
.cl-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); }
.cl-item b { font-weight: 700; color: var(--muted); }
.cl-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

/* نمودار ستونی افقی */
.hbar-chart { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 150px 1fr 130px; align-items: center; gap: 12px; font-size: 13px; }
.hbar-row .hbar-l {
  color: var(--text); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: end; direction: rtl;
}
.hbar-row .hbar-track { background: var(--soft); border-radius: 7px; height: 20px; overflow: hidden; }
.hbar-row .hbar-fill { height: 100%; border-radius: 7px; transition: width .3s; }
.hbar-row .hbar-v { font-weight: 700; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- دونات ---------- */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
.donut-wrap .chart-svg { width: 200px; flex-shrink: 0; }

/* ---------- نقش‌ها و مجوزها ---------- */
.role-card .role-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.role-card .role-head .ri { font-size: 17px; }
.role-card .role-head b { flex: 1; font-size: 14px; }
.role-card .role-desc { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.role-card .role-groups { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow-y: auto; }
.rg-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; }
.role-matrix th { font-size: 11px; white-space: nowrap; }
.role-matrix td { font-size: 12px; }
.role-matrix tr.rg td {
  background: var(--soft); font-weight: 700; font-size: 11.5px; color: var(--muted); padding: 6px 10px;
}

/* ---------- ویجت دستیار هوشمند ---------- */
#assistant-fab {
  position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 90;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--button-bg); color: var(--button-fg); font-size: 22px;
  box-shadow: 0 12px 32px var(--primary-soft); transition: transform .15s;
}
#assistant-fab:hover { transform: scale(1.08); }
#assistant-panel {
  position: fixed; bottom: 88px; inset-inline-end: 22px; z-index: 95;
  width: 360px; max-width: calc(100vw - 34px); height: 460px; max-height: calc(100vh - 120px);
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 25px 70px var(--shade); display: none; flex-direction: column; overflow: hidden;
}
#assistant-panel.on { display: flex; animation: pop .16s ease; }
#assistant-panel .as-head {
  background: var(--card); color: var(--text); padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; font-weight: 700;
}
#assistant-panel .as-head button {
  background: 0; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; padding: 2px 8px;
}
#assistant-panel .as-head button:hover { color: var(--primary); background: var(--hover); }
#assistant-panel .as-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; background: var(--soft); }
.as-msg {
  max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
}
.as-msg.bot { background: var(--card); border: 1px solid var(--border); align-self: flex-start; border-start-start-radius: 3px; }
.as-msg.me { background: var(--button-bg); color: var(--button-fg); align-self: flex-end; border-start-end-radius: 3px; }
.as-msg.err { background: var(--rose-soft); color: var(--rose); border-color: var(--rose); }
.as-msg.typing { color: var(--muted); font-size: 12px; }
#assistant-panel .as-foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--card); }
#assistant-panel .as-foot textarea {
  flex: 1; resize: none; border: 1.5px solid var(--border); border-radius: 10px; padding: 9px 12px;
  font-family: inherit; font-size: 13px; max-height: 110px; background: var(--input-bg);
}
#assistant-panel .as-foot textarea:focus { outline: 0; border-color: var(--primary); background: var(--card); }
#assistant-panel .as-foot button {
  background: var(--button-bg); color: var(--button-fg); border: 1px solid var(--button-edge); border-radius: 10px; width: 44px;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
}
#assistant-panel .as-foot button:hover { background: var(--primary-h); }

@media (max-width: 640px) {
  .hbar-row { grid-template-columns: 100px 1fr 90px; }
}

/* ============================================================
   بخش ریسپانسیو کامل — موبایل و تبلت (افزودهٔ درخواست کاربر)
   ساختار قواعد اصلی تغییر نکرده؛ همهٔ قواعد این بخش تکمیلی است
   ============================================================ */

/* ---------- پایه: جدول‌های پهن در همهٔ اندازه‌ها به‌جای بریده‌شدن، اسکرول افقی ---------- */
@media (max-width: 1100px) {
  #content { padding: 18px 18px 60px; }
}

@media (max-width: 920px) {
  /* سایدبار کشویی: حداکثر ۸۵٪ عرض تا صفحهٔ پشتش دیده شود */
  #sidebar { width: min(280px, 85vw); }
  #sidebar .nav-item { padding: 11px 12px; font-size: 14px; }
  #sidebar .brand { padding: 16px 16px 12px; }
  .chart-box { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chart-box .chart-svg { min-width: 520px; }
}

/* ---------- موبایل (تلفن) ---------- */
@media (max-width: 768px) {
  html, body { font-size: 13.5px; }
  #topbar { padding: 10px 14px; gap: 10px; }
  #topbar .ttl { font-size: 15px; }
  #topbar .crumb { font-size: 11.5px; }
  #menu-btn { padding: 9px 13px; font-size: 17px; min-width: 44px; min-height: 40px; }
  #content { padding: 14px 12px 90px; }

  /* کارت‌ها: دو ستون مناسب صفحهٔ گوشی */
  .grid.stat { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 14px; border-radius: 12px; }
  .stat-card .sv { font-size: 19px; }
  .stat-card .sl { font-size: 11.5px; }
  .stat-card .si { width: 30px; height: 30px; font-size: 14px; }
  .h2 { font-size: 14px; margin: 20px 0 10px; }

  /* دکمه‌ها و ورودی‌ها: هدف لمسی مناسب (حداقل ۴۰px) */
  .btn { min-height: 42px; padding: 10px 16px; }
  .btn.sm { min-height: 36px; }
  .toolbar { gap: 8px; }
  .toolbar input:is([type=text],[type=search]), .toolbar select { width: 100%; flex: 1 1 100%; min-width: 0; padding: 10px 12px; }
  .toolbar .grow { display: none; }

  /* عرض جدول در اسکرول‌گیر خودش می‌ماند. */
  .tbl .actions .btn.sm { min-width: 34px; }

  /* مودال: تقریباً تمام‌صفحه */
  .modal-bg { padding: 10px; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-width: 100%; }
  .modal .mh { padding: 13px 14px; }
  .modal .mh .mt { font-size: 14.5px; }
  .modal .mb { padding: 14px; max-height: calc(100dvh - 175px); }
  .modal .mf { padding: 12px 14px; flex-wrap: wrap; }
  .modal .mf .btn { flex: 1 1 auto; min-width: 120px; }

  .totals { width: 100%; }

  /* نمودارها: در موبایل نمودار پهن به‌صورت اسکرول افقی؛ نمودارهای کم‌عرض خودش می‌گنجد */
  .donut-wrap .chart-svg { width: 170px; }
  .chart-box .chart-svg { min-width: min(480px, 120vw); }
  .chart-box { padding-bottom: 4px; }
  .chart-legend { font-size: 11px; gap: 8px 14px; }

  /* نقش‌ها و ماتریس */
  .role-card .role-groups { max-height: none; }
  .role-matrix:not(.data-table) { display: block; overflow-x: auto; }
  .role-matrix th, .role-matrix td { padding: 8px 9px; }

  /* ویجت دستیار: شیت پایینی تمام‌عرض (هماهنگ با کیبورد مجازی از طریق assistant.js) */
  #assistant-fab { width: 44px; height: 44px; bottom: 14px; inset-inline-end: 14px; font-size: 17px; }
  #assistant-fab.hide { display: none; }
  #assistant-panel {
    inset-inline: 0; bottom: 0; width: 100%; max-width: 100%;
    height: min(74dvh, 540px); max-height: calc(100dvh - 24px);
    border-radius: 16px 16px 0 0; border-bottom: 0;
    box-shadow: 0 -18px 50px var(--shade);
  }
  #assistant-panel .as-head { border-radius: 16px 16px 0 0; cursor: default; }
  .as-msg { max-width: 88%; font-size: 12.5px; }
  body.as-open { overflow: hidden; }

  /* اعلان‌ها: تمام‌عرض پایین صفحه */
  #toast-box { left: 12px; right: 12px; bottom: 84px; }
  .toast { max-width: 100%; font-size: 12.5px; padding: 11px 14px; }

  /* صفحهٔ ورود (موبایل): ورودی‌های لمسی بزرگ‌تر */
  .login-form input { padding: 13px 14px; font-size: 15px; }

  .pager { gap: 8px; font-size: 12px; flex-wrap: wrap; }
  .pager .btn.sm { min-height: 34px; min-width: 34px; }
  .dl { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modal .mf { justify-content: stretch; }
}

/* ---------- گوشی‌های کوچک ---------- */
@media (max-width: 480px) {
  #topbar .crumb { display: none; }
  .grid.stat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card .sv { font-size: 17px; }
  .hbar-row { grid-template-columns: 1fr 84px; grid-template-areas: 'l v' 't t'; gap: 4px 8px; }
  .hbar-row > :nth-child(1) { grid-area: l; text-align: start; }
  .hbar-row > :nth-child(2) { grid-area: t; }
  .hbar-row > :nth-child(3) { grid-area: v; }
  .bar-row { grid-template-columns: 1fr 84px; grid-template-areas: 'l v' 't t'; gap: 4px 8px; }
  .bar-row > :nth-child(1) { grid-area: l; text-align: start; }
  .bar-row > :nth-child(2) { grid-area: t; }
  .bar-row > :nth-child(3) { grid-area: v; }
  .chart-box .chart-svg { min-width: 440px; }
  .role-head b { font-size: 13px; }
  .cl-item { font-size: 11px; }
}

/* ---------- لمس: بدون هاورِ چسبنده ---------- */
@media (hover: none) {
  .nav-item:hover { background: transparent; color: var(--side-text); }
  .nav-item.on:hover { background: var(--side-active-bg); color: var(--side-active-text); }
  .btn:hover { transform: none; }
  .card:hover { transform: none; }
}

/* ---------- بک‌دراپ منوی موبایل (افزودهٔ ریسپانسیو) ---------- */
#nav-backdrop {
  position: fixed; inset: 0; background: var(--scrim); z-index: 55;
  display: none; border: 0; padding: 0;
}
#nav-backdrop.on { display: block; animation: navbd .15s ease; }
@keyframes navbd { from { opacity: 0; } to { opacity: 1; } }
body.nav-open { overflow: hidden; }

/* ---------- ریسپانسیو: اصلاحات جزئی منوی کشویی موبایل ---------- */
@media (max-width: 920px) {
  /* سایدبار باز روی دکمهٔ شناور دستیار قرار می‌گیرد تا همپوشانی نداشته باشد */
  #sidebar { z-index: 96; }
  #sidebar .foot { padding: 12px 14px 18px; }
}

/* ---------- فونت وزیرمتن برای اعداد فارسی جدول‌ها (خوانایی جداکنندهٔ هزارگان) ---------- */
.tbl .num { font-family: Vazirmatn, ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.hbar-row .hbar-v, .bar-row .bv { font-family: Vazirmatn, ui-monospace, monospace; }

/* ---------- موبایل: چیدمان تک‌ستونه برای بخش‌های دو ستونه گزارش‌ها ---------- */
@media (max-width: 768px) {
  .grid[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }
  .grid.dash-charts { grid-template-columns: 1fr; }
}

/* ============================================================
   لوگوی شرکت HBN (افزودهٔ درخواست کاربر)
   ============================================================ */

/* سایدبار: لوگوی کوچک در هدر منو */
#sidebar .brand img {
  width: 46px; height: auto; border-radius: 10px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* نوار بالای داشبورد: لوگو کنار عنوان صفحه */
#topbar-logo {
  height: 38px; width: auto; border-radius: 10px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .lf-logo { width: 130px; }
  #topbar-logo { height: 30px; }
}
@media (max-width: 480px) {
  #topbar-logo { height: 26px; }
  #sidebar .brand img { width: 40px; }
}

/* ============================================================
   افزوده‌های نسخهٔ بهبودیافته — جستجوی سراسری، حالت تاریک و بهبود UI
   ============================================================ */

/* ---------- جستجوی سراسری ---------- */
.gsearch { position: relative; width: 320px; max-width: 34vw; }
.gsearch input {
  width: 100%; padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--input-bg); font-size: 13px; transition: border .15s, box-shadow .15s;
}
.gsearch input:focus { outline: 0; border-color: var(--primary); background: var(--card); box-shadow: 0 0 0 3px var(--primary-soft); }
.gsearch input::placeholder { color: var(--muted); font-size: 12px; }
.gsearch-drop {
  position: absolute; top: calc(100% + 7px); inset-inline: 0; min-width: 340px; z-index: 80;
  background: var(--card); border: 1px solid var(--border); border-radius: 13px;
  box-shadow: 0 22px 55px var(--shade); max-height: 62vh; overflow-y: auto; overscroll-behavior: contain; display: none;
}
.gsearch-drop.on { display: block; animation: pop .14s ease; }
.gs-group {
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 9px 14px 4px;
  border-bottom: 1px solid var(--border-soft); background: var(--soft);
  position: sticky; top: 0; z-index: 1;
}
.gs-item {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: right;
  background: 0; border: 0; padding: 8px 14px; cursor: pointer; font-family: inherit;
}
.gs-item:hover, .gs-item.sel { background: var(--hover); }
.gs-item .gs-t { font-size: 13px; font-weight: 600; color: var(--text); }
.gs-item .gs-s { font-size: 11.5px; color: var(--muted); }
.gs-empty { padding: 18px 14px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- آیکون‌های SVG خطی ---------- */
.ic-svg { width: 17px; height: 17px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.nav-item .ic { display: inline-flex; align-items: center; justify-content: center; }
.nav-item .ic .ic-svg { width: 17px; height: 17px; opacity: .85; }
.nav-item.on .ic .ic-svg, .nav-item:hover .ic .ic-svg { opacity: 1; }
.stat-card .si .ic-svg { width: 16px; height: 16px; }
.h2 .ic-svg { width: 16px; height: 16px; color: var(--primary); }
.btn .ic-svg { width: 15px; height: 15px; }
.btn.sm .ic-svg { width: 13px; height: 13px; }
.tbl .actions .btn .ic-svg { width: 14px; height: 14px; }
#assistant-fab .ic-svg { width: 20px; height: 20px; }
#assistant-fab .ic-svg, #assistant-send .ic-svg { margin: 0 auto; }
.role-card .role-head .ri .ic-svg { width: 17px; height: 17px; }

/* ---------- دکمهٔ تغییر تم (طراحی مجدد) ---------- */
#theme-toggle {
  position: relative; background: var(--card); border: 1.5px solid var(--border); border-radius: 12px;
  width: 42px; height: 42px; flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .2s, box-shadow .2s;
}
#theme-toggle::before {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: var(--primary-soft);
}
html[data-theme='dark'] #theme-toggle::before { opacity: 1; }
#theme-toggle .tt-ic {
  position: absolute; display: flex; align-items: center; justify-content: center;
  transition: transform .4s cubic-bezier(.34,1.4,.64,1), opacity .25s;
}
#theme-toggle .tt-moon { color: var(--primary); transform: none; opacity: 1; }
#theme-toggle .tt-sun { color: var(--on-primary-soft); transform: rotate(120deg) scale(.3); opacity: 0; }
html[data-theme='dark'] #theme-toggle .tt-moon { transform: rotate(-120deg) scale(.3); opacity: 0; }
html[data-theme='dark'] #theme-toggle .tt-sun { transform: none; opacity: 1; }
html[data-theme='dark'] #theme-toggle { border-color: var(--selection); }
#theme-toggle:hover { border-color: var(--primary); box-shadow: 0 4px 14px var(--primary-soft); }
#theme-toggle .tt-ic .ic-svg { width: 19px; height: 19px; }
html[data-theme='dark'] #theme-toggle .tt-sun .ic-svg { filter: drop-shadow(0 0 6px var(--selection)); }

/* ---------- بهبودهای تجربهٔ کاربری ---------- */
.tbl tr { transition: background .1s; }
.tbl th { position: sticky; top: 0; z-index: 2; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus:not(:focus-visible) { outline: 0; }
#content > .card, #content > .tbl-wrap, #content > .grid, #content > .h2, #content > .toolbar { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
#content > .h2:nth-of-type(n+4) { animation-delay: .05s; }
.tbl-wrap { max-height: 76vh; overflow-y: auto; }


/* موبایل: جستجو در ردیف خودش باقی می‌ماند. */
@media (max-width: 900px) {
  #topbar { flex-wrap: wrap; }
  .gsearch { display: block; order: 5; width: 100%; max-width: none; }
  .gsearch-drop { min-width: 0; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .gsearch { width: 240px; }
}

/* ============ داشبورد مدیریتی — طراحی جدید (طرح‌مرجع) ============ */
.db { display: flex; flex-direction: column; gap: 18px; }

/* عنوان و دکمه‌ها */
.db-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.db-title { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin: 0 0 4px; color: var(--text); }
.db-sub { font-size: 13px; color: var(--muted); }
.db-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.db-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 9px 16px; border-radius: 12px; text-decoration: none; transition: all .2s ease; white-space: nowrap; }
.db-btn.primary { background: var(--button-bg); color: var(--button-fg); border: 1px solid var(--button-edge); box-shadow: 0 6px 16px var(--primary-soft); }
.db-btn.primary:hover { background: var(--primary-h); transform: translateY(-1px); }
.db-btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.db-btn.ghost:hover { border-color: var(--primary); color: var(--primary); }

/* کارت‌های شاخص اصلی */
.db-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.db-kpi { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; padding: 16px 18px 0; text-decoration: none; box-shadow: var(--shadow-sm); transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.db-kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); border-color: var(--border); }
.db-kpi-top { display: flex; align-items: center; gap: 13px; }
.db-kpi-ic { width: 44px; height: 44px; min-width: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.db-kpi-ic .ic-svg { width: 21px; height: 21px; }
.db-kpi-body { min-width: 0; }
.db-kpi-val { font-size: 21px; font-weight: 800; letter-spacing: -.4px; color: var(--text); line-height: 1.35; overflow-wrap: anywhere; }
.db-kpi-lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.db-delta { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-inline-start: 7px; vertical-align: 3px; }
.db-delta.up { color: var(--green); background: var(--green-soft); }
.db-delta.down { color: var(--rose); background: var(--rose-soft); }
.db-kpi-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; padding: 10px 0 12px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--muted); transition: color .2s ease; }
.db-kpi:hover .db-kpi-foot { color: var(--primary); }
.db-arrow { transition: transform .2s ease; }
.db-kpi:hover .db-arrow { transform: translateX(-3px); }
.tone-blue { background: var(--primary-soft); color: var(--on-primary-soft); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-rose { background: var(--rose-soft); color: var(--rose); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-teal { background: var(--teal-soft); color: var(--teal); }
.tone-sky { background: var(--sky-soft); color: var(--sky); }

/* ردیف نمودارها */
.db-row { display: grid; gap: 14px; }
.db-row-charts { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; }
.db-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.db-panel { background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-width: 0; }
.db-panel-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; flex-wrap: wrap; }
.db-panel-t { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 700; color: var(--text); }
.db-panel-t .ic-svg { width: 17px; height: 17px; color: var(--primary); }
.db-panel-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.db-big { font-size: 20px; font-weight: 800; letter-spacing: -.4px; color: var(--text); margin-top: 6px; }
.db-unit { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-inline-start: 6px; }
.db-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding-top: 4px; }
.db-legend span { display: inline-flex; align-items: center; gap: 6px; }
.db-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.db-chart-body { padding: 0 18px 16px; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.db-chart-body .chart-box, .db-chart-body .donut-wrap { width: 100%; margin: auto 0; }
.db-chart-main .chart-svg { width: 100%; height: auto; }
.db-link { font-size: 12.5px; color: var(--primary); text-decoration: none; font-weight: 600; white-space: nowrap; }
.db-link:hover { text-decoration: underline; }

/* شاخص‌های کوچک */
.db-minis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.db-mini { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--border-soft); border-radius: 14px; padding: 13px 15px; box-shadow: var(--shadow-sm); transition: transform .2s ease, border-color .2s ease; }
.db-mini:hover { transform: translateY(-2px); border-color: var(--border); }
.db-mini-ic { width: 38px; height: 38px; min-width: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.db-mini-ic .ic-svg { width: 17px; height: 17px; }
.db-mini-lbl { font-size: 11.5px; color: var(--muted); }
.db-mini-val { font-size: 15.5px; font-weight: 800; color: var(--text); margin-top: 1px; letter-spacing: -.2px; overflow-wrap: anywhere; }
.db-mini-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* جدول‌های داشبورد */
.db-tbl { border-radius: 0 0 15px 15px; border-top: 1px solid var(--border-soft); }
.db-tbl .tbl { border: none; }
.db-tbl thead th { position: sticky; top: 0; }

/* ریسپانسیو */
@media (max-width: 1100px) {
  .db-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-minis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .db-row-charts { grid-template-columns: 1fr; }
  .db-row-2 { grid-template-columns: 1fr; }
  .db-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 620px) {
  .db-kpis { grid-template-columns: 1fr; }
  .db-minis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-title { font-size: 18px; }
}
@media (max-width: 420px) {
  .db-minis { grid-template-columns: 1fr; }
}

/* ---------- صورتحساب مشتری ---------- */
.stmt-sum {
  display: flex; flex-wrap: wrap; gap: 10px 22px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 4px;
}
.stmt-sum div { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.stmt-sum span { color: var(--muted); }
.stmt-sum b { color: var(--text); }

/* هماهنگی اجزای مشترک و حالت‌های تمرکز */
.btn:not(.ghost):not(.danger):not(.green):not(.rose), .db-btn.primary, #sidebar .foot .avatar, #assistant-fab, #assistant-send {
  background: var(--button-bg); color: var(--button-fg); box-shadow: 0 4px 14px var(--primary-soft);
}
.btn:not(.ghost):not(.danger):not(.green):not(.rose):hover, .db-btn.primary:hover, #assistant-fab:hover, #assistant-send:hover {
  background: var(--button-hover); color: var(--button-hover-fg);
}
.btn:disabled, .btn:disabled:hover { opacity: 1; background: var(--disabled-bg) !important; color: var(--disabled-fg) !important; border-color: var(--border); box-shadow: none; cursor: not-allowed; }
.btn.ghost.danger-text { color: var(--rose); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: .28em; }
#sidebar .brand .t1, #sidebar .foot .un, #sidebar .nav-item:not(.on):hover { color: var(--side-text); }
#sidebar #btn-logout { color: var(--side-text); border-color: var(--border); }
#sidebar #btn-logout:hover { background: var(--hover); }
.num, .db-kpi-val, .db-big, .db-mini-val, .sv, [data-money-input] { font-variant-numeric: tabular-nums lining-nums; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.gs-item:focus-visible { outline-offset: -2px; }
.gsearch input::placeholder { color: var(--placeholder); }
.product-focus { margin: 12px 0; border-inline-start: 4px solid var(--accent); }
.product-focus:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.product-price-grid { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.product-price-grid div { flex: 1 1 160px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; }
.product-price-grid dd { font-size: 18px; font-weight: 700; }

/* ---------- قیمت واحد اقلام: برچسب ریال داخل فیلد ---------- */
.items-tbl td.price-cell { position: relative; }
.items-tbl td.price-cell::after {
  content: 'ریال'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--muted); pointer-events: none; white-space: nowrap;
}
.items-tbl td.price-cell input {
  direction: ltr; text-align: left; padding-left: 46px; font-variant-numeric: tabular-nums;
}
#branch-control { flex:none; max-width:20vw; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#branch-picker-open { width:100%; min-width:0; min-height:36px; overflow:hidden; }
#branch-picker-open span { min-width:0; overflow:hidden; text-overflow:ellipsis; }
#branch-picker-open svg { flex:none; }
.modal.branch-picker-modal { align-self:center; width:520px; max-height:calc(100dvh - 20px); display:flex; flex-direction:column; }
.branch-picker-modal :is(.mh,.mf) { flex:none; }
.branch-picker-modal .mb { min-height:0; max-height:none; }
.branch-options { border:0; padding:0; margin:0; min-width:0; display:grid; gap:8px; }
.branch-options legend { margin-bottom:8px; font-size:12px; color:var(--muted); }
.branch-option { display:flex; align-items:center; gap:10px; padding:11px 12px; border:1px solid var(--border); border-radius:9px; background:var(--card); cursor:pointer; }
.branch-option:has(input:checked) { border-color:var(--primary); background:var(--primary-soft); }
.branch-option:focus-within { outline:2px solid var(--primary); outline-offset:1px; }
.branch-option input { flex:none; margin:0; accent-color:var(--primary); width:17px; height:17px; }

/* سطح‌ها و حالت‌های مشترک؛ رنگ متن هیچ‌وقت از رنگ کنترل ارث نمی‌رسد. */
:is(.lf-forgot,.catalog-links) a, a.db-link {
  text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .25em;
}
.badge { border-color: var(--border); }
:is(.b-amber,.b-rose) { border-inline-start: 2px solid var(--selection); }
:is(.b-primary,.b-teal,.b-green) {
  border-color: var(--selection); background: var(--selection-bg); color: var(--selection-fg);
}
input, textarea, select { accent-color: var(--accent); }
input:not([type=checkbox]):not([type=radio]):is(:disabled,[readonly]), select:disabled, textarea:is(:disabled,[readonly]) {
  color: var(--disabled-fg); -webkit-text-fill-color: var(--disabled-fg);
  background: var(--disabled-bg); opacity: 1;
}
input:is(:-webkit-autofill,:-webkit-autofill:hover,:-webkit-autofill:focus),
textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--text); caret-color: var(--text);
  box-shadow: inset 0 0 0 1000px var(--input-bg);
}
:is(input,select,textarea):focus-visible, .jalali-field:focus-within { border-color: var(--accent); }
:is([aria-invalid=true],.import-error) { border-color: var(--selection); }
#assistant-fab { border: 1px solid var(--button-edge); }

/* جدول مشترک: ظرف اسکرول و هدر ثابت، بدون تغییر در عناصر و رویدادهای جدول. */
.data-table-wrap {
  min-width: 0; max-width: 100%; max-height: 72dvh; overflow: auto;
  background: var(--card); scrollbar-color: var(--scroll) var(--card);
}
.data-table-wrap:focus-visible { outline-offset: -2px; }
.data-table-wrap:is(.import-table) { max-height: min(265px,60dvh); }
.data-table {
  --cell-pad: 9px 12px; --table-line: var(--border-soft);
  inline-size: 100%; border-collapse: collapse; border-spacing: 0; font-size: 13px;
}
.data-table :is(th,td) {
  display: table-cell; padding: var(--cell-pad); line-height: 1.5; height: 40px;
  vertical-align: middle; text-align: start; white-space: nowrap; border: 0;
  border-block-end: 1px solid var(--table-line); font-variant-numeric: tabular-nums lining-nums;
}
.data-table :is(th,td).hbn-table-num, .data-table td.num { text-align: end; }
.data-table th.hbn-table-code { text-align: start; }
.data-table td.hbn-table-code, .data-table td.mono {
  text-align: end; direction: ltr; unicode-bidi: isolate;
}
.data-table td:is(.mono,.hbn-table-code) {
  font-family: ui-monospace,monospace; max-inline-size: 34ch; overflow: hidden; text-overflow: ellipsis;
}
.data-table td.num { direction: rtl; font-family: inherit; }
.data-table td.num > bdi, .data-table td.mono { unicode-bidi: isolate; }
.data-table td.hbn-table-text {
  max-inline-size: 27ch; overflow: hidden; text-overflow: ellipsis;
}
.data-table td.catalog-text { min-inline-size: 12ch; }
.data-table td.hbn-table-field { min-inline-size: 9rem; }
.data-table td.hbn-table-field :is(select,input):not([type=checkbox]):not([type=radio]) { max-inline-size: 100%; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--table-head); color: var(--text);
  font-size: 12px; font-weight: 700; border-block-end-color: transparent;
  box-shadow: inset 0 -1px var(--table-line);
}
.data-table tbody tr:last-child td { border-block-end: 0; }
.data-table :is(th,td)[colspan] { white-space: normal; }
.data-table tbody tr:hover td { background: var(--hover); }
.data-table td .actions { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
.data-table td .actions > * { flex-shrink: 0; }
.data-table .catalog-live { background: var(--soft); }
.data-table thead .catalog-live { background: var(--table-head); }
.data-table:not(.items-tbl) { table-layout: auto; }
.data-table.items-tbl { table-layout: fixed; }
.data-table.items-tbl :is(th,td) { text-align: center; }
.data-table.items-tbl td.hbn-table-field { min-inline-size: 0; }
.data-table.items-tbl td.price-cell::after { left: 15px; }
.data-table-wrap.items-scroll { margin: 0; }
.data-table tr[data-journal-row] { cursor: pointer; }
.catalog-group li[data-level="1"] { padding-inline-start: 28px; }
.catalog-group li[data-level="2"] { padding-inline-start: 44px; }
.catalog-group li[data-level="3"] { padding-inline-start: 60px; }
.catalog-group li[data-level="4"] { padding-inline-start: 76px; }
.catalog-group li[data-level="5"] { padding-inline-start: 92px; }
.catalog-node { min-width: 0; border-inline-start: 2px solid var(--border); padding-inline-start: 8px; }
.catalog-group li[data-level="0"] .catalog-node { border: 0; padding-inline-start: 0; }
@media (max-width: 600px) {
  .data-table { --cell-pad: 8px 10px; }
  .inventory-import-modal #import-mapping .data-table { min-width: 410px; table-layout: auto; }
  .inventory-import-modal #import-mapping .data-table th:last-child { width: auto; }
  .stock-import-preview .data-table :is(th,td) { padding: var(--cell-pad); white-space: nowrap; }
}
@media print {
  .data-table-wrap { max-height: none; overflow: visible; }
  .data-table thead th { position: static; }
  .gl-filter { display: none; }
}

/* دفتر کل */
.gl-filter {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,170px),1fr));
  gap: 10px 14px; align-items: end; margin-block: 12px 16px;
}
.gl-filter .fld { margin: 0; min-width: 0; }
.gl-filter .date-filter, .gl-filter .jalali-field { width: 100%; min-width: 0; }
.gl-buttons, .gl-error { grid-column: 1/-1; }
.gl-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.gl-error:empty { display: none; }
.gl-error { font-weight: 700; border-inline-start: 3px solid var(--selection); padding-inline-start: 8px; }
.gl-note { max-width: 76ch; }
.gl-title { margin-block: 0 6px; font-size: 16px; }
.gl-check { border: 1px solid var(--border); padding: 8px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--card); }
.gl-check.gl-warning { border-inline-start: 4px double var(--selection); }
.gl-summary { margin-block: 12px; display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,160px),1fr)); gap: 8px; }
.gl-summary div { min-width: 0; border: 1px solid var(--border); background: var(--card); border-radius: 10px; padding: 8px 12px; }
.gl-summary dt { color: var(--muted); font-size: 12px; }
.gl-summary dd { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.gl-pages { margin-block: 10px; }
.branch-option span { min-width:0; overflow-wrap:anywhere; font-weight:650; }
.branch-option small { font-size:11px; color:var(--muted); font-weight:400; margin-inline-start:4px; }
.branch-option .branch-help { display:block; margin:2px 0 0; }
@media (max-width:700px) {
  #branch-control { max-width:33vw; }
  #branch-picker-open { padding-inline:7px; }
}
.branch-context {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--soft);
  padding: 8px 12px; margin: 0 0 10px; color: var(--text); font-size: 13px;
}
.branch-global { justify-content: space-between; }
input[data-money-input] { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.hbn-qty input { min-width:70px; max-width:110px; }
.hbn-ledger-amount { white-space:nowrap; }
