/* ورنا دُر — پوسته‌ی اصلی. موبایل، تبلت و لپ‌تاپ. */
@import url("https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap");

/* سبک v3: ساختار ساده‌ی Pipedrive (تابلوی مراحل، یک کار اصلی در هر صفحه) + ظاهر تمیز Attio (فونت ریز، خط نازک، رنگ کم). */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --border: #e6e8ec;
  --border-strong: #d5d9e0;
  --text: #1d2129;
  --muted: #6b7280;
  --primary: #3e5bd8;
  --primary-soft: #eef1fd;
  --primary-text: #ffffff;
  --success: #17804f;
  --success-soft: #e7f6ee;
  --danger: #c93c3c;
  --danger-soft: #fdeded;
  --warning: #a86a12;
  --warning-soft: #fdf4e3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-pop: 0 4px 6px -2px rgba(16, 24, 40, .05), 0 12px 32px -4px rgba(16, 24, 40, .12);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar: 232px;
  --sidebar-mini: 60px;
  --topbar: 52px;
  /* منوی کناری روشن و آرام */
  --nav-bg: #fbfbfc;
  --nav-border: #eceef1;
  --nav-text: #3d4350;
  --nav-muted: #8b919c;
  --nav-hover: #f0f1f4;
  --nav-active: #e9ecfb;
  --nav-active-text: #2f47b8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #16181d; --surface-2: #1c1f25; --border: #272a31; --border-strong: #353943; --text: #e7e9ee; --muted: #9399a5;
    --primary: #7b93f2; --primary-soft: #1d2340; --primary-text: #0e1220;
    --success: #4cc38a; --success-soft: #13291e; --danger: #ef6b6b; --danger-soft: #351a1a; --warning: #e0a84a; --warning-soft: #2e240f;
    --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-pop: 0 12px 32px rgba(0,0,0,.45);
    --nav-bg: #121418; --nav-border: #22252b; --nav-text: #c4c8d0; --nav-muted: #7d838f; --nav-hover: #1c1f25; --nav-active: #1d2340; --nav-active-text: #a9b8f7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #16181d; --surface-2: #1c1f25; --border: #272a31; --border-strong: #353943; --text: #e7e9ee; --muted: #9399a5;
  --primary: #7b93f2; --primary-soft: #1d2340; --primary-text: #0e1220;
  --success: #4cc38a; --success-soft: #13291e; --danger: #ef6b6b; --danger-soft: #351a1a; --warning: #e0a84a; --warning-soft: #2e240f;
  --shadow: 0 1px 2px rgba(0,0,0,.35); --shadow-pop: 0 12px 32px rgba(0,0,0,.45);
  --nav-bg: #121418; --nav-border: #22252b; --nav-text: #c4c8d0; --nav-muted: #7d838f; --nav-hover: #1c1f25; --nav-active: #1d2340; --nav-active-text: #a9b8f7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  font-size: 13px; line-height: 1.6;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.4; }
h1 { font-size: 15px; font-weight: 600; }
h2 { font-size: 14px; font-weight: 600; }
h3 { font-size: 13.5px; font-weight: 600; }
b, strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--primary-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ───── پوسته ───── */
.layout { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 0 0 auto; width: var(--sidebar);
  background: var(--nav-bg); color: var(--nav-text); border-inline-start: 1px solid var(--nav-border);
  display: flex; flex-direction: column; z-index: 40;
  transition: transform .22s ease, width .18s ease;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 12px 0 14px; height: var(--topbar); border-bottom: 1px solid var(--nav-border); }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; flex: none; }
.brand-logo svg.i { width: 17px; height: 17px; }
.brand-name { font-weight: 600; font-size: 14px; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.collapse-btn { background: none; border: 0; color: var(--nav-muted); cursor: pointer; width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.collapse-btn:hover { background: var(--nav-hover); color: var(--text); }
.collapse-btn svg.i { width: 16px; height: 16px; transform: scaleX(-1); transition: transform .18s; }
.nav { flex: 1; overflow-y: auto; padding: 8px 8px 20px; }
.nav-cat { font-size: 11px; font-weight: 500; color: var(--nav-muted); padding: 14px 10px 4px; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 10px; border-radius: 6px;
  color: var(--nav-text); font-weight: 500; font-size: 13px; white-space: nowrap;
}
.nav a svg.i { width: 17px; height: 17px; color: var(--nav-muted); }
.nav a span { overflow: hidden; text-overflow: ellipsis; }
.nav a:hover { background: var(--nav-hover); color: var(--text); }
.nav a.active { background: var(--nav-active); color: var(--nav-active-text); font-weight: 600; }
.nav a.active svg.i { color: var(--nav-active-text); }
.sidebar-foot { border-top: 1px solid var(--nav-border); padding: 8px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px; width: 100%; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; text-align: start; }
.user-chip:hover { background: var(--nav-hover); }
.sidebar .user-chip .small { color: var(--nav-muted); }
.sidebar .user-chip > span:last-child > div:first-child { color: var(--text); font-size: 13px; }
.sidebar .menu { color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: 12.5px; flex: none; }
.sidebar .avatar { width: 28px; height: 28px; }

.main { margin-inline-start: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; transition: margin .18s ease; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.topbar .ttl { min-width: 0; display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.topbar .ttl h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb { font-size: 13px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.crumb::after { content: "/"; color: var(--border-strong); }
.gsearch {
  flex: 0 1 300px; min-width: 0; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: 12.5px; cursor: pointer; text-align: start; margin-inline-start: auto;
}
.gsearch svg.i { width: 16px; height: 16px; }
.gsearch:hover { border-color: var(--border-strong); background: var(--surface); }
.gsearch span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch kbd, .kbd { font: 10.5px/1 Consolas, monospace; border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; background: var(--surface); color: var(--muted); direction: ltr; }
.page { padding: 20px 24px 40px; width: 100%; max-width: 1360px; }
/* دکمه‌های بالای صفحه هرگز دوخطی نشوند؛ جا کم شد، جستجو و عنوان کوتاه می‌شوند */
#topbar-actions { flex-wrap: nowrap; flex: none; }
.topbar > * { flex-shrink: 0; }
.topbar .ttl, .topbar .gsearch { flex-shrink: 1; }
@media (max-width: 1200px) { #topbar-actions .btn:not(.primary) > span { display: none; } #topbar-actions .btn:not(.primary) { width: 34px; padding: 0; } }

/* منوی جمع‌شده (فقط آیکون)، فقط روی صفحه‌های بزرگ */
@media (min-width: 1024px) {
  body.nav-mini .sidebar { width: var(--sidebar-mini); }
  body.nav-mini .main { margin-inline-start: var(--sidebar-mini); }
  body.nav-mini .brand { padding: 12px 8px; flex-direction: column; height: auto; gap: 6px; }
  body.nav-mini .brand-name, body.nav-mini .nav a span, body.nav-mini .user-chip > span:last-child { display: none; }
  body.nav-mini .nav-cat { font-size: 0; padding: 6px 0 2px; border-top: 1px solid var(--nav-border); margin: 6px 8px 0; }
  body.nav-mini .nav-cat:first-of-type { border-top: 0; }
  body.nav-mini .nav a { justify-content: center; padding: 0; height: 34px; }
  body.nav-mini .user-chip { justify-content: center; padding: 6px 0; }
  body.nav-mini .collapse-btn svg.i { transform: none; }
}

/* جستجوی سراسری */
.palette-back { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 70; display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; animation: fade .12s; }
.palette { width: 100%; max-width: 600px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); overflow: hidden; display: flex; flex-direction: column; max-height: 76vh; animation: pop .15s; }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.palette-in svg.i { color: var(--muted); }
.palette-in input { flex: 1; height: 48px; border: 0; outline: 0; background: none; font: inherit; font-size: 14px; color: var(--text); min-width: 0; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-grp { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; }
.palette-item .pi-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.palette-item .pi-ic svg.i { width: 18px; height: 18px; }
.palette-item .pi-main { flex: 1; min-width: 0; }
.palette-item .pi-t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item.sel { background: var(--primary-soft); }
.palette-item.sel .pi-ic { background: var(--primary); color: var(--primary-text); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
@media (max-width: 640px) {
  .palette-back { padding: 0; align-items: stretch; }
  .palette { max-width: none; max-height: none; border-radius: 0; }
  .palette-foot { display: none; }
}

/* دستور یا نشانی قابل کپی (تنظیمات https، صفحه‌ی نصب گواهی) */
.cmd-box { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-top: 4px; }
.cmd-box code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 12px; direction: ltr; text-align: left; }
.cmd-box .btn { flex: none; }

/* ───── دستور صوتی (js/voice.js) ───── */
.voice-btn { flex: none; }
.vc-head { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
.vc-mic { position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; cursor: pointer; --lvl: 0; }
.vc-mic svg.i { width: 22px; height: 22px; position: relative; z-index: 1; }
.vc-ring { position: absolute; inset: 0; border-radius: 50%; background: var(--primary); opacity: 0; transform: scale(1); transition: transform .08s linear; }
.vc[data-state=listening] .vc-mic { background: var(--primary); color: var(--primary-text); }
.vc[data-state=listening] .vc-ring { opacity: .22; transform: scale(calc(1 + var(--lvl) * .6)); animation: vc-pulse 1.4s ease-out infinite; }
.vc[data-state=working] .vc-mic { background: var(--surface-2); color: var(--muted); cursor: progress; }
.vc[data-state=working] .vc-mic svg.i { animation: spin 1.2s linear infinite; }
.vc[data-state=error] .vc-mic { background: var(--danger-soft, var(--surface-2)); color: var(--danger); }
.vc[data-state=error] .vc-st { color: var(--danger); }
@keyframes vc-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 35%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.vc-status { flex: 1; min-width: 0; }
.vc-st { font-weight: 600; font-size: 14px; }
.vc-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.vc-in input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; padding: 0 12px; }
.vc-in input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.vc-intent { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); }
.vc-intent.unknown { background: var(--surface-2); }
.vc-intent .pi-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-text); display: grid; place-items: center; flex: none; }
.vc-intent.unknown .pi-ic { background: var(--surface); color: var(--muted); }
.vc-intent .pi-t { font-weight: 600; }
.vc-intent .pi-s { font-size: 12.5px; color: var(--muted); }
.vc-warn { color: var(--danger); }
.vc-ex { line-height: 1.9; }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-align: start; }
.linkish:hover { text-decoration: underline; }
.vc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .vc-foot .small { display: none; } .vc-foot .btn { width: 100%; } }
/* دستیار هوشمند: گفت‌وگو، جدول‌های محاسبه‌شده و کار پیشنهادی */
.palette.vc-ai { max-width: 760px; max-height: 84vh; }
.vc-ai .vc-body { flex: 1; min-height: 0; }
.vc-static { cursor: default; }
.vc-chat { display: flex; flex-direction: column; gap: 8px; }
.vc-chat:empty { display: none; }
.vc-msg { display: flex; }
.vc-msg.user { justify-content: flex-start; }
.vc-msg.bot { justify-content: flex-end; }
.vc-bub { max-width: 92%; padding: 8px 11px; border-radius: 10px; line-height: 1.8; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.vc-msg.user .vc-bub { background: var(--primary); color: var(--primary-text); border-end-start-radius: 3px; }
.vc-msg.bot .vc-bub { background: var(--surface-2); border-end-end-radius: 3px; width: 92%; }
.vc-msg.bot .vc-bub:has(.vc-dots) { width: auto; }
.vc-err { color: var(--danger); }
.vc-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.vc-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: vc-dot 1s infinite ease-in-out; }
.vc-dots i:nth-child(2) { animation-delay: .15s; } .vc-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes vc-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.vc-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.vc-tt { padding: 7px 10px; font-weight: 500; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vc-tw { overflow-x: auto; }
.vc-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.vc-table th, .vc-table td { padding: 6px 10px; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--border); }
.vc-table th { font-weight: 500; color: var(--muted); background: var(--surface-2); }
.vc-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.vc-table tr:last-child td { border-bottom: 0; }
.vc-notes { margin: 0; padding: 7px 10px 8px 10px; padding-inline-start: 26px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); line-height: 1.8; }
@media (max-width: 640px) { .palette.vc-ai { max-height: 92vh; } .vc-bub, .vc-msg.bot .vc-bub { max-width: 100%; width: 100%; } }
.ai-log td { vertical-align: top; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 18px; }
.overlay { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }

@media (max-width: 1023px) {
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .overlay { opacity: 1; pointer-events: auto; }
  .main { margin-inline-start: 0; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-flex; }
  .collapse-btn { display: none; }
  .page { padding: 12px 16px 32px; }
}
@media (max-width: 700px) {
  .crumb { display: none; }
  .gsearch { flex: none; width: 40px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .gsearch span, .gsearch kbd { display: none; }
  /* دکمه‌های بالای صفحه روی گوشی فقط آیکون */
  #topbar-actions .btn > span { display: none; }
  #topbar-actions .btn { width: 40px; padding: 0; }
}

/* ───── اجزا ───── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: 12px; }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.stack > * + * { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 1px rgba(16, 24, 40, .04);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn svg.i { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.sm.icon { width: 28px; }
.btn.sm svg.i { width: 15px; height: 15px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.field { display: block; }
.field + .field { margin-top: 12px; }
.field > label, .field > .label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 12.5px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; line-height: 1.7; }
.input:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); }
.input.ltr { direction: ltr; text-align: left; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .field + .field { margin-top: 0; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 9px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 16px; }
.switch input:disabled { opacity: .5; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; line-height: 1; }
.badge.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px; color: var(--text); transition: border-color .12s, box-shadow .12s; }
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.tile-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.tile-icon svg.i { width: 18px; height: 18px; }
.tile-title { font-weight: 600; }
.tile-hint { font-size: 12px; color: var(--muted); }
.section-title { font-size: 12px; font-weight: 500; color: var(--muted); margin: 20px 0 8px; }

/* زبانه‌ها: خط زیرین (مثل Attio) */
.tabs { display: flex; gap: 2px; overflow-x: auto; margin-bottom: 14px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.tab .n, .tab-n { font-size: 11px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; color: var(--muted); line-height: 17px; }
.tab.active .n { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.notice { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); font-size: 13px; border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.notice.success { background: var(--success-soft, var(--surface-2)); border-color: color-mix(in srgb, var(--success, #16a34a) 22%, transparent); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 13px; }
.empty svg.i { width: 32px; height: 32px; margin-bottom: 6px; opacity: .5; }

/* ───── جدول ───── */
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.toolbar .search { flex: 1; min-width: 160px; max-width: 420px; position: relative; margin-inline-end: auto; }
.toolbar .search .input { padding-inline-start: 32px; height: 30px; font-size: 12.5px; background: var(--surface-2); border-color: var(--border); }
.toolbar .search .input:focus { background: var(--surface); }
.toolbar .search svg.i { position: absolute; inset-inline-start: 10px; top: 8px; width: 15px; height: 15px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: start; font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 7px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border); vertical-align: middle; height: 40px; }
table.data td strong { font-weight: 500; }
/* ردیف‌های یک‌خطی؛ متن بلند با «…» کوتاه می‌شود و کامل در پرونده دیده می‌شود */
table.data td { white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.data td > div { overflow: hidden; text-overflow: ellipsis; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
table.data td.actions { text-align: end; white-space: nowrap; width: 1%; }
@media (max-width: 700px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  table.data td { border: 0; padding: 3px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; white-space: normal; max-width: none; height: auto; text-align: end; }
  table.data td::before { content: attr(data-label); color: var(--muted); font-size: 13px; flex: none; }
  table.data td.actions { width: 100%; justify-content: flex-end; padding-top: 8px; }
  table.data td.actions::before { content: none; }
}

.dropdown { position: relative; }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); padding: 4px; z-index: 30; font-size: 13px; }
.menu label, .menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 5px; cursor: pointer; background: none; border: 0; font: inherit; color: inherit; text-align: start; }
.menu svg.i { width: 16px; height: 16px; color: var(--muted); }
.menu label:hover, .menu button:hover { background: var(--surface-2); }

/* ───── پنجره و پیام ───── */
.modal-back { position: fixed; inset: 0; background: rgba(15, 18, 25, .38); z-index: 60; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); width: 100%; max-width: 540px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .16s; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 14px; padding-inline-start: 6px; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 6px; justify-content: flex-end; padding: 10px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 12px 12px; }
@media (max-width: 640px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { max-width: none; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh; animation: up .2s; }
  .modal-foot .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.toasts { position: fixed; bottom: 18px; inset-inline-start: 50%; transform: translateX(50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 420px; }
.toast { background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); font-size: 13px; animation: up .2s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; color: var(--muted); }

/* ───── مجوزها ───── */
.perm-cat { font-weight: 600; font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.perm-row + .perm-row { margin-top: 8px; }
.perm-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); cursor: pointer; font-size: 13.5px; user-select: none; background: var(--surface); }
.chip input { display: none; }
.chip:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip.disabled { opacity: .35; pointer-events: none; }

/* ───── ورود ───── */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { border: 0; justify-content: center; height: auto; padding: 28px 18px 6px; flex-direction: column; }
.auth .brand-logo { width: 52px; height: 52px; border-radius: 14px; }
.auth .brand-logo svg.i { width: 28px; height: 28px; }

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.steps li:last-child { border-bottom: 0; }
.steps .ok { color: var(--success); }
.steps .bad { color: var(--danger); }
.mono { font-family: Consolas, "Courier New", monospace; direction: ltr; unicode-bidi: isolate; text-align: left; font-size: 12.5px; }
details.svc { border: 1px solid var(--border); border-radius: var(--radius-sm); }
details.svc + details.svc { margin-top: 8px; }
details.svc summary { cursor: pointer; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; }
details.svc summary::-webkit-details-marker { display: none; }
details.svc .ops { padding: 6px 12px 12px; max-height: 320px; overflow: auto; }
details.svc .ops div { padding: 2px 0; }

/* ───── CRM ───── */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 16px; }
.kv > div > div:first-child { font-size: 12.5px; color: var(--muted); }
.kv > div > div:last-child { font-weight: 500; word-break: break-word; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 12px; }
.filters select { width: auto; min-width: 150px; flex: 0 1 220px; height: 30px; font-size: 12.5px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.lnk { color: var(--primary); cursor: pointer; font-weight: 500; }
.lnk:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.profile { display: flex; gap: 14px; align-items: center; }
.avatar.lg { width: 54px; height: 54px; font-size: 21px; }
.avatar.org { border-radius: 14px; }
.contact-lines { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.contact-lines > div { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.contact-lines svg.i { width: 17px; height: 17px; color: var(--muted); margin-top: 3px; }
.avatar svg.i { width: 26px; height: 26px; }
.badge svg.i { width: 13px; height: 13px; }

/* ── پرونده‌ها (مشتری، فرصت، سند): سرِ پرونده، زبانه‌ها، کارت‌ها ── */
.phead { display: flex; gap: 14px; align-items: flex-start; }
.phead-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.phead-name { font-size: 17px; font-weight: 600; line-height: 1.5; word-break: break-word; }
.phead-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.phead-line { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--muted); }
.phead-line > * { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.phead-line a { color: var(--primary); font-weight: 500; }
.phead-line svg.i { width: 16px; height: 16px; }
.mini .v.due { color: var(--danger); }

.ptabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: -4px; }
.ptabs::-webkit-scrollbar { display: none; }
.ptabs button { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 500;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.ptabs button svg.i { width: 17px; height: 17px; }
.ptabs button .n { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }
.ptabs button:hover { color: var(--text); }
.ptabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.ptabs button.active .n { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.ptab-body { min-height: 120px; }

.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.pcard { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.pcard > header { display: flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pcard > header h3 { font-size: 13px; font-weight: 600; flex: 1; }
.pcard > header svg.i { width: 16px; height: 16px; color: var(--muted); }
.pcard > :not(header) { margin: 12px 14px; }
.pcard > .rowlist { margin: 0; border: 0; border-radius: 0; }
.pcard > .fgroups, .pcard > .inv { margin: 10px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 18px; margin: 0; }
.facts > div.wide { grid-column: 1 / -1; }
.facts dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; word-break: break-word; }
.facts a { color: var(--primary); text-decoration: none; }

.plist { display: flex; flex-direction: column; }
.plist > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0; }
.plist > div + div { border-top: 1px dashed var(--border); }
.plist .pl-k { color: var(--muted); font-size: 13px; min-width: 72px; }
.plist a { color: var(--text); font-weight: 600; text-decoration: none; font-size: 15px; }
.plist a:hover { color: var(--primary); }
.paddr { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.paddr + .paddr { border-top: 1px dashed var(--border); padding-top: 10px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.crumbs span { color: var(--muted); font-weight: 400; }
.pempty { color: var(--muted); font-size: 14px; text-align: center; padding: 22px 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.pcard .pempty { border: 0; padding: 8px 0; text-align: start; }
.pamount { font-size: 13.5px; color: var(--muted); padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.pamount b { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.chip.active { background: var(--primary-soft); color: var(--primary); border-color: transparent; font-weight: 600; }
.tl-month { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 2px 6px; }
.hist > .tl-month:first-child { margin-top: 2px; }
@media (max-width: 700px) {
  .phead-name { font-size: 17px; }
  .pgrid { grid-template-columns: minmax(0, 1fr); }
  .ptabs button { padding: 10px 10px; }
}

.minis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.mini { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.mini .v { font-size: 18px; font-weight: 600; line-height: 1.4; }
.mini .l { font-size: 12.5px; color: var(--muted); }

.block-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.block-title h3 { font-size: 15px; font-weight: 600; }
.rowlist { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.ri { display: flex; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; background: var(--surface); }
.ri + .ri { border-top: 1px solid var(--border); }
.ri:hover { background: var(--surface-2); }
.ri-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.ri-icon svg.i { width: 18px; height: 18px; }
.ri-main { flex: 1; min-width: 0; }
.ri-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-end { text-align: end; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
details.more { border: 1px solid var(--border); border-radius: var(--radius-sm); }
details.more summary { cursor: pointer; padding: 10px 12px; font-weight: 500; list-style: none; display: flex; justify-content: space-between; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { border-bottom: 1px solid var(--border); }
details.more .in { padding: 4px 12px 10px; }
.fl { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: 4px 14px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.fl:last-child { border-bottom: 0; }
.fl > div:first-child { color: var(--muted); }
.fl > div:last-child { white-space: pre-line; word-break: break-word; }
@media (max-width: 640px) { .fl { grid-template-columns: 1fr; gap: 0; } }

/* پرونده: «الان دست کیست» و نوار مراحل */
.owner-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); font-size: 14px; }
.owner-bar > svg.i { color: var(--primary); }
.owner-bar b { color: var(--primary); font-weight: 600; }
.owner-bar.won { background: var(--success-soft); } .owner-bar.won > svg.i, .owner-bar.won b { color: var(--success); }
.owner-bar.lost { background: var(--danger-soft); } .owner-bar.lost > svg.i, .owner-bar.lost b { color: var(--danger); }
.stagebar { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.stagebar > div {
  flex: 1 0 auto; min-width: 92px; max-width: 220px; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 7px 10px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.stagebar > div span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stagebar > div:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.stagebar > div:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.stagebar svg.i { width: 14px; height: 14px; }
.stagebar .done { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.stagebar .now { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.stagebar .lost { background: var(--danger); color: #fff; border-color: var(--danger); }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 12px 14px; color: var(--text); display: block; }
.kpi .v { font-size: 20px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.link:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-ic { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.kpi-ic svg.i { width: 19px; height: 19px; }
.kpi-danger .kpi-ic { background: var(--danger-soft); color: var(--danger); }
.kpi-warning .kpi-ic { background: var(--warning-soft); color: var(--warning); }
.kpi-primary .kpi-ic { background: var(--primary-soft); color: var(--primary); }
.kpi-success .kpi-ic { background: var(--success-soft); color: var(--success); }
/* میز کار خانه: کارهای من پهن‌تر از اعلان‌ها */
.desk-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.desk-grid .np-list { max-height: 420px; padding: 4px; margin: 0; }
.desk-grid .pcard > header .lnk, .pcard > header .lnk { margin-inline-start: auto; }
@media (max-width: 900px) { .desk-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } .kpi { padding: 12px; } .kpi .v { font-size: 20px; } .kpi-ic { width: 30px; height: 30px; } }
.pipe { display: flex; flex-direction: column; gap: 8px; }
.pipe a { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 10px; align-items: center; color: var(--text); font-size: 14px; }
.pipe .bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.pipe .bar > div { height: 100%; background: var(--primary); border-radius: 4px; }
@media (max-width: 640px) { .pipe a { grid-template-columns: 1fr auto; } .pipe .bar { grid-column: 1 / -1; order: 3; } }

/* ───── فیلدهای گروه‌بندی‌شده ───── */
.fgroups { display: flex; flex-direction: column; gap: 12px; }
.fgroup { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.fgroup > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; font-weight: 600; font-size: 14px; }
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: ""; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s; margin-inline-start: 8px; }
.fgroup:not([open]) > summary::after { transform: rotate(135deg); }
.fgroup[open] > summary { border-bottom: 1px solid var(--border); }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0; }
.fi { padding: 9px 14px; border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); min-width: 0; }
.fi.wide { grid-column: 1 / -1; }
.fi .l { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.fi .v { font-weight: 500; white-space: pre-line; word-break: break-word; }
.fgrid { margin-inline-start: -1px; margin-bottom: -1px; }
.fgroup { overflow: hidden; }

/* ───── پیش‌فاکتور / فاکتور ───── */
.inv { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.inv-head { display: grid; grid-template-columns: 1fr minmax(200px, 42%); gap: 16px; padding: 18px; background: linear-gradient(135deg, var(--primary-soft), transparent 70%); border-bottom: 1px solid var(--border); }
.inv-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.inv-title .tile-icon { width: 38px; height: 38px; }
.inv-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13.5px; }
.inv-meta span { color: var(--muted); }
.inv-meta b { font-weight: 600; color: var(--text); }
.inv-party { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); font-size: 13.5px; }
.inv-party .cap { font-size: 12px; color: var(--muted); }
.inv-party .nm { font-weight: 600; font-size: 15px; margin: 2px 0 4px; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 7px 8px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.inv-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 12.5px; }
.inv-table td.code { white-space: nowrap; width: 1%; color: var(--muted); }
.inv-table td.code .mono { font-size: 12px; }
.inv-table td.n, .inv-table th.n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-table td.idx { color: var(--muted); width: 1%; text-align: center; }
.inv-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.inv-table .pn { font-weight: 600; overflow-wrap: anywhere; }
.inv-table td.pd { min-width: 200px; }
.modal.wide { max-width: 960px; }
.inv-table .disc { color: var(--success); }
.inv-table .final { font-weight: 600; }
.inv-totals > div > span { white-space: nowrap; }
.inv-foot { display: grid; grid-template-columns: 1fr minmax(300px, 46%); gap: 16px; padding: 16px 18px; align-items: end; }
.inv-words { font-size: 13.5px; color: var(--muted); line-height: 1.9; }
.inv-words b { color: var(--text); font-weight: 600; }
.inv-totals { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; font-size: 13px; }
.inv-totals > div + div { border-top: 1px dashed var(--border); }
.inv-totals .minus { color: var(--success); }
.inv-totals .grand { background: var(--primary); color: var(--primary-text); font-weight: 600; font-size: 14.5px; border-top: 0 !important; padding: 8px 12px; }
@media (max-width: 700px) {
  .inv-head, .inv-foot { grid-template-columns: 1fr; }
  .inv-table thead { display: none; }
  .inv-table, .inv-table tbody, .inv-table tr, .inv-table td { display: block; width: 100%; }
  .inv-table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .inv-table td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 10px; background: none !important; }
  .inv-table td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; }
  .inv-table td.idx { display: none; }
  .inv-table td.code { width: 100%; }
  .inv-table td.pd { display: block; margin-bottom: 4px; }
  .inv-table td.pd::before { content: none; }
}
.theme-btn svg.i { width: 19px; height: 19px; }

@media print {
  body.print-doc .layout, body.print-doc .toasts { display: none !important; }
  body.print-doc .modal-back:not(:last-of-type) { display: none !important; }
  body.print-doc .modal-back { position: static; background: none; padding: 0; display: block; animation: none; }
  body.print-doc .modal { max-height: none; box-shadow: none; max-width: none; border: 0; animation: none; }
  body.print-doc .modal-head, body.print-doc .modal-foot, body.print-doc .no-print { display: none !important; }
  body.print-doc .modal-body { overflow: visible; padding: 0; }
  body.print-doc .inv-table td, body.print-doc .inv-table th { display: table-cell !important; }
  body.print-doc .inv-table tr { display: table-row !important; }
  body.print-doc .inv-table thead { display: table-header-group !important; }
  body.print-doc .inv-table td::before { content: none !important; }
  body.print-doc .fgroup:not([open]) { display: none; }
  body.print-doc .inv-totals .grand { background: #eee; color: #000; }
}
@media print {
  .sidebar, .topbar, .toolbar, .overlay, .no-print, td.actions, th.actions { display: none !important; }
  .main { margin: 0; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
  table.data thead { display: table-header-group !important; }
  table.data tr { display: table-row !important; }
  table.data td { display: table-cell !important; }
  table.data td::before { content: none !important; }
}

/* ───── زنگوله، اعلان و گفتگو (js/collab.js) ───── */
.bell-btn { position: relative; }
.bell-btn svg.i { width: 20px; height: 20px; }
.bell-count { position: absolute; top: 2px; inset-inline-end: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; line-height: 1; border: 2px solid var(--surface); }
.notif-panel { width: min(400px, calc(100vw - 24px)); padding: 0; display: flex; flex-direction: column; max-height: min(560px, calc(100vh - 90px)); }
.np-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.np-tabs { display: flex; gap: 4px; }
.notif-panel .np-tabs button { width: auto; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; color: var(--muted); }
.notif-panel .np-tabs button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.np-list { overflow-y: auto; flex: 1; padding: 4px; }
.np-list .empty { padding: 28px 10px; }
.np-foot { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.notif-panel .np-link, a.np-link { width: auto; padding: 5px 8px; font-size: 12.5px; color: var(--primary); text-decoration: none; border-radius: 8px; }
.np-foot a.np-link { margin-inline-start: auto; }
.np-link svg.i { width: 15px; height: 15px; }
.notif-row { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; color: inherit; text-decoration: none; position: relative; }
.notif-row:hover { background: var(--surface-2); }
.notif-row.unread { background: var(--primary-soft); }
.notif-row.unread::after { content: ""; position: absolute; top: 14px; inset-inline-end: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.nr-ic { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.nr-ic.mention { background: var(--warning-soft); color: var(--warning); }
.nr-ic.reply { background: var(--success-soft); color: var(--success); }
.nr-ic svg.i { width: 17px; height: 17px; }
.nr-tx { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 13px; padding-inline-end: 14px; }
.nr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-snip { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nr-time { color: var(--muted); font-size: 11.5px; }

.notif-pop-box { position: fixed; top: 70px; inset-inline-start: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.notif-pop { display: flex; gap: 10px; align-items: flex-start; padding: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow); text-decoration: none; animation: up .25s; font-size: 13.5px; }
.notif-pop.mention { border-inline-start-color: var(--warning); }
.notif-pop.reply { border-inline-start-color: var(--success); }
.np-ic svg.i { width: 20px; height: 20px; color: var(--primary); }
.notif-pop.mention .np-ic svg.i { color: var(--warning); }
.np-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.np-title { font-weight: 600; }
.np-snip { color: var(--muted); font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.np-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; }
.np-x svg.i { width: 15px; height: 15px; }

.cmts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cmts-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cmts-head h3 svg.i { width: 18px; height: 18px; color: var(--primary); }
.cmts-empty { text-align: center; padding: 22px 8px; color: var(--muted); }
.cmts-empty svg.i { width: 30px; height: 30px; opacity: .5; }
.cmts-stale { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; margin-bottom: 10px; padding: 7px; border: 1px dashed var(--primary); border-radius: 10px; background: var(--primary-soft); color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; }
.cmts-stale svg.i { width: 15px; height: 15px; }
.cmt-thread { padding: 10px 0; border-bottom: 1px solid var(--border); }
.cmt-thread:last-child { border-bottom: 0; }
.cmt-replies { margin-inline-start: 42px; border-inline-start: 2px solid var(--border); padding-inline-start: 10px; margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.cmt-reply-slot:not(:empty) { margin-inline-start: 42px; margin-top: 8px; }
.cmt { display: flex; gap: 10px; border-radius: 10px; transition: background .4s; }
.cmt.to-me { background: var(--warning-soft); padding: 6px; margin: -6px; }
.cmt.flash { background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary); padding: 6px; margin: -6px; }
.cmt-av { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: 13.5px; }
.cmt.mine .cmt-av { background: var(--success-soft); color: var(--success); }
.cmt-main { flex: 1; min-width: 0; }
.cmt-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.cmt-time { font-size: 12px; text-decoration: none; }
.cmt-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; margin-top: 2px; }
.mention { color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 0 4px; font-weight: 600; }
.mention.me { color: var(--warning); background: var(--warning-soft); }
.cmt-seen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.seen { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted); }
.seen.yes { color: var(--success); }
.seen svg.i { width: 12px; height: 12px; }
.cmt-acts { display: flex; gap: 2px; margin-top: 2px; opacity: .75; }
.cmt:hover .cmt-acts { opacity: 1; }
.cmt-acts button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; padding: 3px 6px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.cmt-acts button:hover { background: var(--surface-2); color: var(--text); }
.cmt-acts button.danger:hover { color: var(--danger); }
.cmt-acts svg.i { width: 13px; height: 13px; }
.cmt-compose { margin-top: 12px; }
.cmt-compose.compact { margin-top: 6px; }
.cmt-compose textarea { resize: vertical; min-height: 60px; }
.cc-wrap { position: relative; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.cc-hint { display: inline-flex; align-items: center; gap: 4px; }
.cc-hint svg.i { width: 13px; height: 13px; }
.mention-pop { position: absolute; inset-inline: 0; bottom: calc(100% + 4px); max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; z-index: 40; }
.mp-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; font-size: 13.5px; cursor: pointer; text-align: start; }
.mp-item.sel, .mp-item:hover { background: var(--primary-soft); }
.mp-item.off { opacity: .5; cursor: not-allowed; }
.mp-av { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.mp-n { flex: 1; }
.mp-u { color: var(--muted); font-size: 12px; }
.mp-no { font-size: 11px; color: var(--danger); }
.mp-empty { padding: 10px; color: var(--muted); font-size: 13px; }
@media (max-width: 700px) {
  .notif-pop-box { top: auto; bottom: 80px; }
  .cmt-replies, .cmt-reply-slot:not(:empty) { margin-inline-start: 16px; }
  #bell-slot .notif-panel { position: fixed; inset-inline: 8px; top: calc(var(--topbar) + 4px); width: auto; }
}
@media print { .cmts, #bell-slot, .notif-pop-box { display: none !important; } }

/* ───── صفحه‌ی کامل پرونده (record.html) ───── */
.rec-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.rec-side { position: sticky; top: calc(var(--topbar) + 12px); max-height: calc(100vh - var(--topbar) - 28px); overflow-y: auto; padding: 16px; }
.rec-main > .rec-body { min-width: 0; }
.inline-form header { display: flex; align-items: center; gap: 8px; }
.inline-form .if-body { padding-top: 6px; }
.inline-form .if-foot { justify-content: flex-end; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 1100px) {
  .rec-layout { grid-template-columns: 1fr; }
  .rec-side { position: static; max-height: none; }
}
@media (max-width: 640px) {
  #topbar-actions .btn span { display: none; }
  #topbar-actions .btn { padding-inline: 10px; }
  .inline-form .if-foot { position: sticky; bottom: 0; background: var(--surface); margin-inline: -16px; padding: 10px 16px; }
}
@media print { .rec-layout { display: block; } .rec-side { display: none !important; } }

/* ───── منابع انسانی ───── */
/* درخت واحدها */
.tree { display: flex; flex-direction: column; gap: 6px; }
.tree-node { --depth: 0; }
.tree-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(140px, 1fr) auto minmax(120px, 1.2fr) auto; align-items: center; gap: 10px;
  padding: 10px 12px; margin-inline-start: calc(var(--depth) * 22px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tree-node .tree-node > .tree-row { border-inline-start: 3px solid var(--primary-soft); }
.tree-kids { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.tree-kids:empty { display: none; }
.tree-row.inactive { opacity: .6; }
.tree-name { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.tree-toggle { width: 26px; height: 26px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; cursor: pointer; padding: 0; flex: none; }
.tree-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.tree-toggle.closed svg { transform: rotate(90deg); }
.tree-dot { width: 26px; height: 26px; flex: none; position: relative; }
.tree-dot::after { content: ""; position: absolute; inset: 0; margin: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.tree-mgr { display: flex; align-items: center; gap: 6px; font-size: 13.5px; min-width: 0; }
.tree-mgr svg, .tree-count svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.tree-count { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--text); text-decoration: none; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.tree-count:hover { background: var(--primary-soft); color: var(--primary); }
.tree-roles { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tree-acts { display: flex; gap: 2px; justify-content: flex-end; }
@media (max-width: 900px) {
  .tree-row { grid-template-columns: 1fr auto; margin-inline-start: calc(var(--depth) * 12px); }
  .tree-mgr, .tree-roles { grid-column: 1 / -1; }
  .tree-count { justify-self: start; }
  .tree-acts { grid-column: 2; grid-row: 1; }
}

/* بخش‌بندی فرم پرونده */
.fsec + .fsec { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.fsec-t { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--primary); margin-bottom: 10px; }
.fsec-t svg { width: 16px; height: 16px; }

/* فرم مرخصی */
.leave-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.leave-kinds .chip { height: 36px; }
.leave-kinds .chip svg { width: 15px; height: 15px; }
.leave-preview:empty { display: none; }
.leave-preview { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.leave-preview .notice { border-radius: 0; }
.lp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 13.5px; }
.lp-row + .lp-row { border-top: 1px solid var(--border); }
.lp-row span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.lp-row span svg { width: 15px; height: 15px; }
.lp-row.bad, .lp-row.bad span { color: var(--danger); background: var(--danger-soft); }
.jd-hint:empty { display: none; }
.jd-hint.bad { color: var(--danger); }

/* خط زمان (گردش تأیید، تاریخچه‌ی پرونده) */
.timeline { position: relative; display: flex; flex-direction: column; gap: 12px; }
.timeline::before { content: ""; position: absolute; top: 14px; bottom: 14px; inset-inline-start: 15px; width: 2px; background: var(--border); }
.tl-item { position: relative; display: flex; gap: 12px; align-items: flex-start; }
.tl-ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface-2); border: 2px solid var(--border); color: var(--muted); z-index: 1; }
.tl-ic svg { width: 15px; height: 15px; }
.tl-main { flex: 1; min-width: 0; padding-top: 5px; font-size: 14px; }
.tl-main .small { margin-top: 2px; }
.tl-changes { margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.tl-changes s { color: var(--muted); }
.tl-item.success .tl-ic, .tl-item.approved .tl-ic, .tl-item.hire .tl-ic, .tl-item.rehire .tl-ic { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.tl-item.danger .tl-ic, .tl-item.rejected .tl-ic, .tl-item.terminate .tl-ic { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.tl-item.waiting .tl-ic { background: var(--warning-soft); border-color: var(--warning); color: var(--warning); border-style: dashed; }
.tl-item.transfer .tl-ic, .tl-item.title .tl-ic, .tl-item.contract .tl-ic { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* منشن واحد */
.mention.group { color: var(--success); background: var(--success-soft); }
.mp-item.group .mp-av { background: var(--success-soft); color: var(--success); }
.mp-d { color: var(--muted); font-size: 11.5px; background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }

/* ───── تقویم مرخصی واحد ───── */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.cal-bar > select { width: auto; min-width: 200px; flex: 0 1 280px; }
.cal-nav { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.cal-nav b { min-width: 110px; text-align: center; font-size: 15px; }
.switch.small { font-size: 13.5px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--surface-2); gap: 2px; }
.seg button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500; height: 26px; padding: 0 10px; border-radius: 5px; cursor: pointer; }
.seg button svg.i { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }

/* ───── اقدام‌های فرآیند فروش ───── */
.pa-intro { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; line-height: 1.8; }
.pa-intro-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.pa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 10px; align-items: start; }
.pa-stage > header .btn { margin-inline-start: 4px; }
.pa-stage > header .small { white-space: nowrap; }
.pa-stage > .pempty { margin: 10px 14px; text-align: start; border: 0; padding: 4px 0; font-size: 12.5px; }
.pa-list { display: flex; flex-direction: column; }
.pa-row { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--border); }
.pa-list .pa-row:first-child { border-top: 0; }
.pa-row.off { opacity: .55; }
.pa-row .badge { flex: none; }
.pa-main { flex: 1; min-width: 0; }
.pa-t { font-weight: 500; }
.pa-s { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.pa-n { white-space: nowrap; }
.pa-acts { display: flex; flex: none; }
@media (max-width: 700px) { .pa-grid { grid-template-columns: minmax(0, 1fr); } .pa-n { display: none; } }

/* دکمه‌های اقدام در پرونده‌ی فرصت */
.deal-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.deal-acts .da-l { font-size: 12px; color: var(--muted); margin-inline-end: 4px; display: inline-flex; align-items: center; gap: 4px; }
.deal-acts .da-l svg.i { width: 15px; height: 15px; }
.deal-acts .btn.won { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border-strong)); }
.deal-acts .btn.lost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong)); }
.deal-acts .btn.off { opacity: .5; }
.deal-acts .da-more { margin-inline-start: auto; }
.run-list { display: flex; flex-direction: column; }
.run-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--border); font-size: 12.5px; }
.run-row:first-child { border-top: 0; }
.run-row .badge { flex: none; margin-top: 1px; }
.run-row .rr-main { flex: 1; min-width: 0; }
.run-row .rr-msg { color: var(--muted); font-size: 11.5px; word-break: break-word; }
.act-confirm .stagepair { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.act-confirm .stagepair svg.i { width: 15px; height: 15px; color: var(--muted); transform: scaleX(-1); }

/* ───── تابلوی مراحل فرصت‌ها (Pipedrive) ───── */
.view-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.view-bar select.input { width: auto; min-width: 150px; flex: 0 1 220px; height: 30px; font-size: 12.5px; }
.board-search { position: relative; flex: 0 1 280px; min-width: 160px; }
.board-search .search { position: relative; }
.board-search .input { height: 30px; font-size: 12.5px; padding-inline-start: 32px; }
.board-search svg.i { position: absolute; inset-inline-start: 10px; top: 8px; width: 15px; height: 15px; color: var(--muted); }
.board-hint { display: flex; align-items: center; gap: 6px; margin: 0 2px 10px; }
.board-hint svg.i { width: 14px; height: 14px; }
.board { display: flex; gap: 10px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; min-height: 300px; }
.bcol { flex: 0 0 264px; display: flex; flex-direction: column; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); max-height: calc(100vh - var(--topbar) - 150px); }
.bcol-h { padding: 9px 12px 8px; border-bottom: 2px solid var(--primary); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.bcol-t { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 13px; }
.bcol-t > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bcol-s { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bcol-b { padding: 8px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.bcard { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; color: var(--text); box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; }
.bcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.bcard.stale { opacity: .72; }
.bcard.stale .bc-a { color: var(--warning); }
.bc-t { font-weight: 500; font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bc-c { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); margin-top: 3px; min-width: 0; }
.bc-c svg.i { width: 13px; height: 13px; }
.bc-c span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-f { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; }
.bc-v { font-weight: 600; }
.bc-a { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); margin-inline-start: auto; }
.bc-a svg.i { width: 12px; height: 12px; }
.avatar.xs { width: 20px; height: 20px; font-size: 10.5px; }
/* هنگام کشیدن کارت: ستون‌هایی که اقدامی به آن‌ها می‌رسد پررنگ، بقیه کم‌رنگ */
.board.dragging .bcol { transition: opacity .12s, border-color .12s, background .12s; }
.board.dragging .bcol.drop-no { opacity: .45; }
.board.dragging .bcol.drop-ok { border: 1px dashed var(--primary); }
.board.dragging .bcol.drop-over { background: var(--primary-soft); border-style: solid; }
.bcard[draggable="true"] { cursor: pointer; }
.bcard:active { cursor: grabbing; }
.bcol-more { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 7px; border: 1px dashed var(--border-strong); border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.bcol-more:hover { color: var(--primary); border-color: var(--primary); }
.bcol-more svg.i { width: 13px; height: 13px; transform: scaleX(-1); }
@media (max-width: 700px) {
  .bcol { flex-basis: 82vw; max-height: none; }
  .board { scroll-snap-type: x mandatory; }
  .bcol { scroll-snap-align: start; }
  .board-search { flex: 1 1 100%; }
}
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.cal-legend i.off { background: var(--surface-2); border: 1px solid var(--border); }
.cal-k-leave { background: var(--primary); }
.cal-k-sick { background: var(--danger); }
.cal-k-other { background: var(--warning); }
.cal-k-mission { background: var(--success); }
.pending.cal-k-leave, .pending.cal-k-sick, .pending.cal-k-other, .pending.cal-k-mission {
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 3px, transparent 3px 6px); opacity: .75; }

.cal-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cal { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
.cal th, .cal td { border-bottom: 1px solid var(--border); text-align: center; padding: 0; height: 34px; min-width: 28px; }
.cal thead th { font-weight: 600; padding: 4px 0; background: var(--surface); position: sticky; top: 0; z-index: 2; }
.cal thead .wd { font-size: 11px; color: var(--muted); font-weight: 400; }
.cal .cal-name { position: sticky; inset-inline-start: 0; z-index: 1; background: var(--surface); text-align: start; padding: 4px 12px; min-width: 150px; max-width: 200px;
  font-weight: 500; border-inline-end: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal thead .cal-name { z-index: 3; }
.cal .off { background: var(--surface-2); }
.cal .cal-name.off { background: var(--surface); }
.cal th.today { color: var(--primary); }
.cal th.today > div:last-child { background: var(--primary); color: var(--primary-text); border-radius: 99px; display: inline-block; min-width: 22px; }
.cal td.today { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.cal tr.me .cal-name { color: var(--primary); }
.cal-group th { text-align: start; padding: 8px 12px 4px; font-size: 12px; color: var(--muted); background: var(--surface-2); position: sticky; inset-inline-start: 0; }
.cal-chip { display: block; height: 20px; margin: 0 1px; border-radius: 4px; cursor: default; }
.cal-chip[data-open] { cursor: pointer; }
.cal-chip.hourly { height: 8px; width: 60%; margin: 0 auto; border-radius: 99px; }
.cal tfoot th, .cal tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--border); }
.cal tfoot td.over { background: var(--danger-soft); color: var(--danger); }
.cal tbody tr:hover td:not(.off), .cal tbody tr:hover .cal-name { background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface)); }

.cal-day { padding: 10px 12px; }
.cal-day + .cal-day { border-top: 1px solid var(--border); }
.cal-day.today { background: var(--primary-soft); }
.cal-day.over { box-shadow: inset 3px 0 0 var(--danger); }
.cal-day-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.cal-day-p { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; color: #fff; }
.cal-pill[data-open] { cursor: pointer; }
.due { color: var(--danger); }
@media (max-width: 700px) {
  .cal-bar > select { flex: 1 1 100%; }
  .cal-nav { margin-inline-start: 0; }
  .cal .cal-name { min-width: 110px; max-width: 130px; padding: 4px 8px; }
}
@media print {
  .cal-bar .seg, .cal-nav button { display: none; }
  .cal-wrap { overflow: visible; }
  .cal { font-size: 9px; }
  .cal th, .cal td { min-width: 0; height: 22px; }
  .cal-k-leave, .cal-k-sick, .cal-k-other, .cal-k-mission { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ───── حضور و غیاب ───── */
.att-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.att-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.att-table th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.att-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.att-table tr:last-child td { border-bottom: 0; }
.att-table tr.att-off td, .att-table tr.att-na td { background: var(--surface-2); color: var(--muted); }
.att-table tr.att-absent td:first-child { box-shadow: inset -3px 0 0 var(--danger); }
.att-table tr.incomplete td:first-child { box-shadow: inset -3px 0 0 var(--warning); }
.att-table tr.att-leave td:first-child, .att-table tr.att-mission td:first-child { box-shadow: inset -3px 0 0 var(--primary); }
.att-table .badge { margin-bottom: 2px; }
.att-today { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; flex-wrap: wrap; }
.att-punch { min-width: 140px; height: 48px; font-size: 15px; }
.att-me .minis { margin-top: 4px; }
.kpi-success .v { color: var(--success); }
.kpi-warning .v { color: var(--warning); }
.kpi-danger .v { color: var(--danger); }
.kpi-primary .v { color: var(--primary); }
.mini small { font-size: 12px; font-weight: 500; color: var(--muted); }
@media (max-width: 700px) {
  .att-punch { width: 100%; }
  .att-table { font-size: 12.5px; }
  .att-table th, .att-table td { padding: 6px; }
}

/* ───── فرم فرصت و پیش‌فاکتور جدید ───── */
.ac { position: relative; }
.ac-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; z-index: 40; max-height: 300px; overflow-y: auto; }
.ac-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.ac-list button:hover, .ac-list button.on { background: var(--surface-2); }
.ac-list .ac-main { flex: 1; min-width: 0; }
.ac-list .ac-sub { font-size: 12px; color: var(--muted); }
.ac-list .ac-end { font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ac-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.picked { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--primary-soft); border-radius: var(--radius-sm); }
.picked .grow { flex: 1; min-width: 0; }
.picked .avatar { flex: none; }

/* قدم‌های شماره‌دار فرم */
.fsteps { gap: 14px; }
.fsec { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; background: var(--surface); }
.fsec h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13.5px; font-weight: 600; }
.fsec h4 small { font-weight: 400; font-size: 12.5px; }
.fsec .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-weight: 400; }
.fsec-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 600; flex: none; }

/* جعبه‌ی جستجو با ذره‌بین */
.qadd > svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.qadd > .input { padding-inline-start: 38px; height: 44px; font-size: 15px; }

/* ورودی مبلغ با «ریال» */
.amount { position: relative; }
.amount .input { padding-left: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.amount span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }

/* ردیف‌های پیش‌فاکتور */
.qlines { display: flex; flex-direction: column; gap: 10px; }
.qline { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.ql-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ql-no { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--muted); flex: none; }
.ql-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ql-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.ql-grid .field + .field { margin-top: 0; }
.ql-grid .field > label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.ql-sum { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-bottom: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ql-sum span:first-child { font-size: 12px; color: var(--muted); }
.ql-sum b { font-size: 15px; }
.ql-sum small { font-weight: 400; color: var(--muted); }
.ql-desc { margin-top: 10px; }
.stepper { display: flex; }
.stepper .input { text-align: center; border-radius: 0; min-width: 0; }
.stepper button { width: 38px; flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer; }
.stepper button:first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-inline-end: 0; }
.stepper button:last-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-inline-start: 0; }
.stepper button:hover { background: var(--surface-2); }
.linkbtn { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; }
.linkbtn svg { width: 14px; height: 14px; }
.qempty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 12px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); color: var(--muted); text-align: center; }
.qempty svg { width: 28px; height: 28px; margin-bottom: 4px; }

/* تخفیف، مالیات و جمع */
.qfoot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.qopts { display: flex; flex-direction: column; gap: 14px; }
.qtotal { border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); padding: 12px 14px; font-variant-numeric: tabular-nums; }
.qtotal dl { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.qtotal dl > div { display: flex; justify-content: space-between; gap: 12px; }
.qtotal dt { color: var(--muted); }
.qtotal dd { margin: 0; }
.qtotal .disc dd { color: var(--success); }
.qtotal .final { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
.qtotal .final dt { color: var(--text); font-weight: 600; }
.qtotal .final dd { font-size: 18px; font-weight: 600; }
.qtotal .final small { font-size: 12px; font-weight: 400; color: var(--muted); }
.qtotal .words { margin-top: 6px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.qmore summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; }
.qmore summary svg { width: 16px; height: 16px; }
@media (max-width: 700px) {
  .fsec { padding: 12px; }
  .ql-grid { grid-template-columns: 1fr; gap: 10px; }
  .ql-sum { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; padding: 6px 0 0; border-top: 1px dashed var(--border); }
  .qfoot { grid-template-columns: 1fr; }
}

/* ───── صفحه‌ی پیش‌فاکتور (quote.html): برگه‌ی مالی ───── */
.page:has(.qdoc) { max-width: 1560px; }
.qdoc { display: flex; flex-direction: column; gap: 14px; padding-bottom: 76px; }
.qd-note { align-items: center; }
.qd-head { padding: 0; }
.qd-title { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.qd-title h2 { margin: 0; font-size: 15px; font-weight: 600; }
.qd-logo { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.qd-logo svg { width: 19px; height: 19px; }
.qd-meta { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .8fr); gap: 16px 18px; padding: 16px 18px 18px; }
.qd-f > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.qd-f .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.qd-wide { grid-column: 1 / -1; }
.qd-ro { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.qd-ro svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.qd-ro a, .qd-ro span:not(.badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qd-replace { margin-top: 8px; }
.qd-cust .picked { padding: 7px 10px; }
.qd-cust .qadd > .input, .qd-add .qadd > .input { height: 38px; font-size: 13px; }

.qd-items { padding: 0; }
.qd-items-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.qd-items-head h3, .qd-sum h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.qd-scroll { overflow-x: auto; }
.qd-table { width: 100%; min-width: 900px; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.qd-table th { background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px; text-align: start; padding: 8px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.qd-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.qd-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.qd-table tr.bad td { background: color-mix(in srgb, var(--danger) 7%, transparent); }
.qd-table .c-no { width: 44px; text-align: center; color: var(--muted); padding-top: 16px; }
.qd-table .c-code { width: 92px; padding-top: 16px; }
.qd-table .c-name { min-width: 220px; }
.qd-table .c-unit { width: 64px; padding-top: 16px; color: var(--muted); }
.qd-table .c-qty { width: 84px; }
.qd-table .c-price, .qd-table .c-disc { width: 136px; }
.qd-table .c-sum, .qd-table .c-net { width: 118px; text-align: end; padding-top: 16px; white-space: nowrap; }
.qd-table th.c-sum, .qd-table th.c-net { padding-top: 8px; }
.qd-table .c-x { width: 72px; padding-top: 10px; }
.qd-table .num-in { height: 32px; text-align: center; font-variant-numeric: tabular-nums; }
.qd-table .c-price .num-in, .qd-table .c-disc .num-in { text-align: right; }
.qd-pname { font-weight: 500; line-height: 1.5; }
.qd-psub { font-size: 11.5px; color: var(--muted); margin: 1px 0 6px; min-height: 2px; }
.qd-desc { width: 100%; height: 30px; font-size: 12px; background: transparent; border-style: dashed; }
.qd-desc:focus { background: var(--surface); border-style: solid; }
.qd-rowbtns { display: flex; gap: 2px; justify-content: flex-end; }
.qd-empty td { padding: 18px; }
.qd-add { padding: 12px 18px 14px; }

.qd-foot { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
.qd-notes { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; }
.qd-sum { padding: 16px 18px; }
.qd-opts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.qd-opts .switch { min-height: 36px; }
.qd-sum { font-variant-numeric: tabular-nums; }
.qd-dl { margin: 12px 0 0; display: flex; flex-direction: column; }
.qd-dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.qd-dl dt { color: var(--muted); }
.qd-dl dd { margin: 0; }
.qd-dl .disc dd { color: var(--success); }
.qd-dl .sub dt { color: var(--text); }
.qd-dl .final { border-bottom: 0; border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 10px; align-items: baseline; }
.qd-dl .final dt { color: var(--text); font-weight: 600; }
.qd-dl .final dd { font-size: 18px; font-weight: 600; color: var(--primary); }
.qd-dl .final small { font-size: 12px; font-weight: 400; color: var(--muted); }
.qd-words { margin-top: 8px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.qd-sum .hint.bad { color: var(--danger); margin-top: 8px; font-size: 12px; }

.qd-bar { position: fixed; bottom: 0; inset-inline: 0; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 10px 24px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(15, 23, 42, .05); }
.qd-bar-sum { flex: 1; display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.qd-bar-sum b { font-size: 16px; font-weight: 600; }
@media (min-width: 1024px) { .qd-bar { inset-inline-start: var(--sidebar); padding-inline: 24px; } body.nav-mini .qd-bar { inset-inline-start: var(--sidebar-mini); } }

/* انتخاب کالا از گروه‌ها */
.modal.xl { max-width: 1100px; }
.gp { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; height: min(64vh, 600px); }
.gp-groups { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.gp-glist { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.gp-g { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 0; border-radius: 6px; background: none; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.gp-g svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.gp-g small { color: var(--muted); font-variant-numeric: tabular-nums; }
.gp-g:hover { background: var(--surface-2); }
.gp-g.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.gp-g.sub { padding-inline-start: 32px; font-size: 12.5px; }
.gp-g.on svg { color: var(--primary); }
.gp-main { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.gp-main .qadd > .input { height: 38px; font-size: 13px; }
.gp-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.gp-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); font: inherit; color: inherit; text-align: start; cursor: pointer; }
.gp-item:last-child { border-bottom: 0; }
.gp-item:hover { background: var(--surface-2); }
.gp-item.in { background: color-mix(in srgb, var(--success) 6%, var(--surface)); }
.gp-n { font-weight: 500; }
.gp-p { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.gp-add { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); color: var(--primary); flex: none; }
.gp-add svg { width: 15px; height: 15px; }
.gp-item.in .gp-add { background: var(--success); border-color: var(--success); color: #fff; font-size: 12px; }

@media (max-width: 1100px) {
  .qd-meta { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .qd-foot { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .qdoc { padding-bottom: 120px; }
  .qd-meta { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .qd-title, .qd-items-head { padding: 12px 14px; }
  .qd-items-head .btn > span { display: none; }
  .qd-opts { grid-template-columns: minmax(0, 1fr); }
  /* جدول اقلام → کارت */
  .qd-table thead { display: none; }
  .qd-table, .qd-table tbody { display: block; min-width: 0; }
  .qd-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .qd-table td { display: block; padding: 0 !important; border: 0; width: auto !important; min-width: 0 !important; text-align: start !important; }
  .qd-table td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
  .qd-table .c-no { display: none; }
  .qd-table .c-name { grid-column: 1 / -1; order: -2; }
  .qd-table .c-x { order: -1; grid-column: 1 / -1; }
  .qd-table .c-x .qd-rowbtns { justify-content: flex-start; }
  .qd-table .c-net { grid-column: 1 / -1; display: flex; justify-content: space-between; border-top: 1px dashed var(--border); padding-top: 6px !important; }
  .qd-table .c-net::before { margin: 0; }
  .qd-empty { display: block !important; }
  .qd-add { padding: 12px 14px; }
  .qd-bar { flex-wrap: wrap; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); }
  .qd-bar-sum { flex-basis: 100%; }
  .qd-bar [data-discard] > span { display: none; }
  .qd-bar [data-issue] { flex: 1; justify-content: center; }
  .gp { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 70vh; }
  .gp-groups [data-gq] { display: none; }
  .gp-glist { flex-direction: row; overflow-x: auto; overflow-y: hidden; border: 0; padding: 0; flex: none; }
  .gp-g { white-space: nowrap; border: 1px solid var(--border); border-radius: 16px; padding: 5px 10px; }
  .gp-p { display: none; }
}
@media print { .qd-bar, .qd-add, .qd-rowbtns { display: none !important; } .qdoc { padding-bottom: 0; } }

/* ───── کالاها: گروه‌ها کنار فهرست ───── */
.pr-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }
.pr-side { padding: 0; position: sticky; top: 12px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; }
.pr-side-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.prg-list { overflow-y: auto; padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.prg { display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 6px 0 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.prg small { color: var(--muted); font-variant-numeric: tabular-nums; }
.prg:hover { background: var(--surface-2); }
.prg.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.prg.sub { padding-inline-start: 24px; }
.prg.off { opacity: .55; }
.prg.all, .prg.none { font-weight: 500; }
.prg.none { margin-top: 6px; border-top: 1px dashed var(--border); border-radius: 0 0 6px 6px; }
.prg [data-edit] { opacity: 0; width: 24px; height: 24px; }
.prg:hover [data-edit], .prg.on [data-edit] { opacity: 1; }
.pr-side-empty { padding: 10px 12px 14px; line-height: 1.8; }
#group-m { display: none; }
.pf-switches { display: flex; flex-wrap: wrap; gap: 10px 22px; }
@media (max-width: 900px) {
  .pr-layout { grid-template-columns: minmax(0, 1fr); }
  .pr-side { display: none; }
  #group-m { display: block; }
}

/* ───── نمودارها (js/charts.js) ─────
   پالت دسته‌ای ۸ خانه با ترتیب ثابت (ایمن برای کوررنگی در جفت‌های کنار هم)، برای حالت تیره پله‌های خودش. */
:root {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --s-other: #b4b2ab; --seq: #3987e5; --seq-0: #cde2fb; --seq-1: #104281;
  --ch-grid: #ecebe6; --ch-base: #c3c2b7; --ch-ax: #898781;
  /* ترتیبی (سن کار در کارتابل): یک رنگ، روشن = تازه، تیره = قدیمی */
  --q1: #86b6ef; --q2: #3987e5; --q3: #1c5cab; --q4: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --s-other: #5c5b57; --seq: #3987e5; --seq-0: #1b2a40; --seq-1: #9ec5f4;
    --ch-grid: #24262b; --ch-base: #383835; --ch-ax: #898781;
    --q1: #184f95; --q2: #2a78d6; --q3: #6da7ec; --q4: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --s-other: #5c5b57; --seq: #3987e5; --seq-0: #1b2a40; --seq-1: #9ec5f4;
  --ch-grid: #24262b; --ch-base: #383835; --ch-ax: #898781;
  --q1: #184f95; --q2: #2a78d6; --q3: #6da7ec; --q4: #b7d3f6;
}
.ch-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }
.ch-tip { position: fixed; z-index: 9999; pointer-events: none; display: none; min-width: 140px; max-width: 280px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 7px 10px; font-size: 12px; }
.ch-tip-h { font-weight: 600; margin-bottom: 4px; }
.ch-tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.8; }
.ch-tip-row i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.ch-tip-row span { flex: 1; color: var(--muted); }
.ch-tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-keys { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ch-keys span { display: inline-flex; align-items: center; gap: 5px; }
.ch-keys i { width: 10px; height: 10px; border-radius: 3px; }
.ch-svg { display: block; overflow: visible; }
.ch-grid { stroke: var(--ch-grid); stroke-width: 1; }
.ch-base { stroke: var(--ch-base); stroke-width: 1; }
.ch-ax { fill: var(--ch-ax); font-size: 11px; font-family: inherit; }
.ch-col { transition: opacity .2s; }
.ch-col.dim { opacity: .3; }
.ch-col.hl { filter: brightness(1.08); }
.ch-hit { fill: transparent; }
.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-area { opacity: .1; }
.ch-cross { stroke: var(--ch-base); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-dot { stroke: var(--surface); stroke-width: 2; }
/* دونات */
.ch-donut { display: grid; grid-template-columns: minmax(130px, 170px) minmax(0, 1fr); gap: 16px; align-items: center; }
.ch-donut-fig { position: relative; }
.ch-donut-fig svg { display: block; width: 100%; height: auto; }
.ch-donut-fig path { cursor: pointer; transition: opacity .2s, transform .2s; transform-origin: 100px 100px; stroke: var(--surface); stroke-width: 0; }
.ch-donut-fig path.dim { opacity: .3; }
.ch-donut-fig path.hl { transform: scale(1.04); }
.ch-donut-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.ch-donut-c b { font-size: 18px; font-weight: 600; line-height: 1.2; }
.ch-donut-c span { font-size: 11px; color: var(--muted); }
.ch-legend { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ch-lg { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 38px; gap: 8px; align-items: center; border: 0; background: none; font: inherit; color: var(--text);
  font-size: 12.5px; padding: 4px 6px; border-radius: 6px; cursor: pointer; text-align: start; }
.ch-lg:hover { background: var(--surface-2); }
.ch-lg.static { cursor: default; }
.ch-lg.dim { opacity: .45; }
.ch-lg i { width: 10px; height: 10px; border-radius: 3px; }
.ch-lg-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-lg b { font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-lg small { color: var(--muted); font-size: 11.5px; text-align: end; font-variant-numeric: tabular-nums; }
/* میله‌ی افقی */
.ch-hbars { display: flex; flex-direction: column; gap: 3px; }
.ch-hb { display: grid; grid-template-columns: minmax(90px, 32%) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 3px 6px; border-radius: 6px; font-size: 12.5px; }
.ch-hb.click { cursor: pointer; }
.ch-hb:hover { background: var(--surface-2); }
.ch-hb.dim { opacity: .45; }
.ch-hb.sel { background: var(--primary-soft); }
.ch-hb-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-hb-l small { color: var(--muted); margin-inline-start: 6px; font-size: 11.5px; }
.ch-hb-track { height: 14px; }
.ch-hb-bar { height: 100%; width: 0; display: flex; gap: 2px; border-radius: 4px; overflow: hidden; transition: width .9s cubic-bezier(.2, .7, .2, 1); }
.ch-hb-bar span { min-width: 2px; }
.ch-hb-v { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 34px; text-align: end; white-space: nowrap; }
/* قیف */
.ch-funnel { display: flex; flex-direction: column; gap: 5px; }
.ch-fn { display: grid; grid-template-columns: minmax(110px, 30%) minmax(0, 1fr) minmax(70px, auto); gap: 10px; align-items: center; font-size: 12.5px; padding: 2px 6px; border-radius: 6px; }
.ch-fn.click { cursor: pointer; }
.ch-fn:hover { background: var(--surface-2); }
.ch-fn.dim { opacity: .45; }
.ch-fn-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.ch-fn-n { width: 18px; height: 18px; border-radius: 5px; background: var(--surface-2); color: var(--muted); font-size: 11px; display: grid; place-items: center; flex: none; }
.ch-fn-track { display: flex; justify-content: center; }
.ch-fn-bar { width: 0; height: 22px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: #fff; transition: width .9s cubic-bezier(.2, .7, .2, 1); }
.ch-fn-bar b { font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums; }
.ch-fn-s { color: var(--muted); font-size: 11.5px; white-space: nowrap; text-align: end; }
/* نیم‌دایره */
.ch-gauge { position: relative; max-width: 220px; margin: 0 auto; }
.ch-gauge svg { display: block; width: 100%; }
.ch-g-bg { fill: none; stroke: var(--surface-2); stroke-width: 14; stroke-linecap: round; }
.ch-g-fg { fill: none; stroke-width: 14; stroke-linecap: round; }
.ch-g-v { position: absolute; inset: auto 0 0; display: flex; flex-direction: column; align-items: center; }
.ch-g-v b { font-size: 22px; font-weight: 600; line-height: 1.1; }
.ch-g-v span { font-size: 12px; color: var(--muted); }
.ch-g-v small { font-size: 11.5px; color: var(--muted); }
/* نقشه‌ی گرمایی */
.ch-heat-wrap { overflow-x: auto; }
.ch-heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; min-width: 100%; }
.ch-heat th { font-weight: 500; color: var(--muted); padding: 4px 6px; white-space: nowrap; text-align: start; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.ch-heat thead th { vertical-align: bottom; font-size: 11.5px; max-width: 90px; }
.ch-heat td { min-width: 38px; height: 28px; text-align: center; border-radius: 4px; font-variant-numeric: tabular-nums; color: var(--text);
  background: color-mix(in srgb, var(--seq) calc(var(--k) * 100%), var(--surface-2)); transition: transform .15s; }
.ch-heat td.zero { background: var(--surface-2); }
.ch-heat td.dark { color: #fff; font-weight: 600; }
.ch-heat td.click { cursor: pointer; }
.ch-heat td.click:hover { transform: scale(1.08); }
.ch-heat td.sum { background: none; font-weight: 600; text-align: end; }

/* ───── داشبورد و کارتابل ───── */
.dash-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0; margin: -8px 0 4px; }
.dash-filters .input { height: 32px; font-size: 12.5px; width: auto; min-width: 130px; max-width: 200px; }
.dash-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 6px 0 10px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 500; border: 0; cursor: pointer; font-family: inherit; }
.dash-chip svg.i { width: 13px; height: 13px; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.dk { padding: 12px 14px; position: relative; overflow: hidden; animation: dk-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.dk .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dk .l svg.i { width: 15px; height: 15px; }
.dk .v { font-size: 21px; font-weight: 600; line-height: 1.35; margin-top: 2px; }
.dk .s { font-size: 11.5px; color: var(--muted); }
.dk .s .up { color: var(--success); } .dk .s .down { color: var(--danger); }
.dk.click { cursor: pointer; } .dk.click:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }
.dk.tone-danger .v { color: var(--danger); } .dk.tone-warning .v { color: var(--warning); } .dk.tone-success .v { color: var(--success); }
@keyframes dk-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-items: start; }
.dash-grid > .pcard { grid-column: span 6; animation: dk-in .55s cubic-bezier(.2, .7, .2, 1) both; }
.dash-grid > .w4 { grid-column: span 4; } .dash-grid > .w8 { grid-column: span 8; } .dash-grid > .w12 { grid-column: span 12; }
.dash-grid > .pcard > .ch-body { padding: 12px 14px 14px; }
.dash-grid .pcard > header .hint-s { font-size: 11.5px; color: var(--muted); margin-inline-start: auto; font-weight: 400; }
.dash-vs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dash-vs > div { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.dash-vs > div.dim { opacity: .45; }
.dash-vs > div:hover { border-color: var(--border-strong); }
.dash-vs h4 { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dash-vs h4 i { width: 10px; height: 10px; border-radius: 3px; }
.dash-vs dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12.5px; }
.dash-vs dt { color: var(--muted); } .dash-vs dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: end; }
.dash-note { font-size: 12px; color: var(--muted); }
.age { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.age.warn { color: var(--warning); font-weight: 500; } .age.bad { color: var(--danger); font-weight: 600; }
.age svg.i { width: 13px; height: 13px; }
.pa-duty { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }
.pa-duty > svg.i { width: 15px; height: 15px; color: var(--muted); flex: none; }
.pa-duty > span { flex: 1; min-width: 0; }
.cart-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (max-width: 1100px) {
  .dash-grid > .pcard, .dash-grid > .w4, .dash-grid > .w8 { grid-column: span 12; }
}
@media (max-width: 700px) {
  .ch-donut { grid-template-columns: minmax(0, 1fr); }
  .ch-donut-fig { max-width: 180px; margin: 0 auto; }
  .ch-hb { grid-template-columns: minmax(70px, 34%) minmax(0, 1fr) auto; }
  .ch-fn { grid-template-columns: minmax(80px, 34%) minmax(0, 1fr); }
  .ch-fn-s { display: none; }
  .dash-vs { grid-template-columns: minmax(0, 1fr); }
  .dash-filters { position: static; }
  .dash-filters .seg, .pcard > header .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .dash-filters .seg button, .pcard > header .seg button { white-space: nowrap; flex: none; }
  .pcard > header:has(.seg) { flex-wrap: wrap; }
  .dash-filters .input { flex: 1 1 140px; max-width: none; }
}
@media print {
  .dash-filters { position: static; }
  .dash-grid > .pcard { break-inside: avoid; }
  .dk, .dash-grid > .pcard { animation: none; }
}
