/* ════════════════════════════════════════════════════════════════════
   سیستم طراحی PooyaCRM — «میز فروش تلفنی»
   روشن، آرام، فشرده؛ یک خانواده‌ی حروف (Estedad)، مرز ۱px به‌جای سایه،
   لاجوردی برای برند و فیروزه‌ای فقط برای «تماس».
   رنگ‌های --primary / --primary-dark / --accent را برند اختصاصی مستاجر در App.razor بازنویسی می‌کند؛
   بقیه‌ی رنگ‌های برند (نسخه‌های کم‌رنگ) با color-mix از همین‌ها ساخته می‌شوند.
   لایه‌ی رنگی (گرادیان‌ها، پالت tone، حرکت‌ها، placeholder اسکلتی) در css/theme-vivid.css است که
   آخرین stylesheet است و بخشی از قواعد آرام این فایل (مثل «بدون گرادیان») را عمداً بازنویسی می‌کند.
   ════════════════════════════════════════════════════════════════════ */

@font-face {
    font-family: "Estedad";
    src: url("../fonts/estedad/Estedad-wght.woff2") format("woff2-variations"),
         url("../fonts/estedad/Estedad-wght.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ارقام فارسی بدون تغییر داده: همان Estedad که فقط کدهای ۰ تا ۹ لاتین را با شکل فارسی رسم می‌کند.
   متن زیرین لاتین می‌ماند (کپی شماره، شماره‌گیری و جست‌وجو درست کار می‌کنند).
   ساخته‌شده از Estedad v8.5 (OFL) — فقط جدول cmap و حذف بقیه‌ی گلیف‌ها. */
@font-face {
    font-family: "Estedad Digits";
    src: url("../fonts/estedad/EstedadDigits-wght.woff") format("woff");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0030-0039;
}

:root {
    /* برند (قابل بازنویسی توسط مستاجر) */
    --primary: #1f4e9e;        /* لاجوردی */
    --primary-dark: #173d7d;
    --accent: #0f8b7e;         /* فیروزه‌ای — فقط اقدام «تماس» */

    --primary-soft: color-mix(in srgb, var(--primary) 8%, #fff);
    --primary-line: color-mix(in srgb, var(--primary) 30%, #fff);
    --accent-soft: color-mix(in srgb, var(--accent) 10%, #fff);
    --accent-dark: color-mix(in srgb, var(--accent) 82%, #000);

    /* خنثی‌ها — خاکستری سرد با ته‌رنگ سبز بسیار کم */
    --canvas: #f5f6f4;
    --surface: #ffffff;
    --surface-sunken: #f0f2ef;
    --ink: #1e2422;
    --ink-2: #434b47;
    --muted: #6b736f;
    --faint: #9aa19d;
    --line: #e2e5e1;
    --line-strong: #cdd2cc;
    --hover: rgba(30, 36, 34, 0.045);

    /* معنایی */
    --success: #1e7f55;  --success-soft: #e6f3ec;
    --warning: #9a6410;  --warning-soft: #fbf0dc;
    --danger:  #b3381f;  --danger-soft:  #fbe9e4;
    --info:    #2f6d8f;  --info-soft:    #e5f0f6;

    /* حروف — مقیاس ۱۲ / ۱۳ / ۱۴ (متن) / ۱۶ / ۲۰ / ۲۶ */
    --font: "Estedad Digits", "Estedad", "Segoe UI", Tahoma, sans-serif;
    --font-latin-digits: "Estedad", "Segoe UI", Tahoma, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-md: 0.875rem;
    --text-lg: 1rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.625rem;
    --leading: 1.75;
    --leading-tight: 1.35;

    /* فاصله — پایه‌ی ۴px */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;

    /* گوشه‌ها بر اساس سلسله‌مراتب */
    --r-control: 6px;
    --r-panel: 10px;
    --r-pill: 999px;

    /* سایه فقط برای لایه‌های شناور */
    --shadow-pop: 0 1px 2px rgba(30, 36, 34, 0.06), 0 12px 32px rgba(30, 36, 34, 0.14);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--primary) 26%, transparent);

    --sidebar-width: 236px;
    --topbar-height: 56px;
    --content-max: 1240px;

    /* پل Bootstrap — همه‌ی صفحه‌های موجود از همین مقادیر ارث می‌برند */
    --bs-body-font-family: var(--font);
    --bs-body-font-size: var(--text-md);
    --bs-body-line-height: var(--leading);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--canvas);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--line);
    --bs-border-radius: var(--r-control);
    --bs-border-radius-sm: 5px;
    --bs-border-radius-lg: var(--r-panel);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-link-color-rgb: 31, 78, 158;
    /* کلاس‌های primary بوت‌استرپ (bg-primary-subtle، text-primary-emphasis، ...) هم از رنگ برند؛
       نسخه‌ی rgb برای برند اختصاصی در BrandingRules.CssVariables بازنویسی می‌شود */
    --bs-primary: var(--primary);
    --bs-primary-rgb: 31, 78, 158;
    --bs-primary-bg-subtle: var(--primary-soft);
    --bs-primary-border-subtle: var(--primary-line);
    --bs-primary-text-emphasis: var(--primary-dark);
    --bs-emphasis-color: var(--ink);
    --bs-heading-color: var(--ink);
}

/* ── پایه ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { max-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    direction: rtl;
    font-family: var(--font);
    font-size: var(--text-md);
    line-height: var(--leading);
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font); color: var(--ink); line-height: var(--leading-tight); }
h1 { font-size: var(--text-xl); font-weight: 650; }
h5 { font-size: var(--text-lg); font-weight: 600; }
h6 { font-size: var(--text-md); font-weight: 600; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-control); }

.text-muted, .text-secondary { color: var(--muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.small, small { font-size: var(--text-sm); }

/* اعداد هم‌عرض در جدول‌ها و شمارنده‌ها */
/* بدون tabular-nums: ارقام از «Estedad Digits» می‌آیند که در هر حال هم‌عرض نمی‌شوند، ولی tnum فونت Estedad
   جداکننده‌ی هزارگان «٬»، ممیز «٫» و رقم فارسی را هم‌عرض رقم می‌کرد و عدد با فاصله دیده می‌شد («۳۶ , ۳۰۰ , ۰۰۰»). */
.num { font-variant-numeric: normal; }
.ltr { direction: ltr; unicode-bidi: isolate; }
/* شناسه‌های فنی (IP، کلید، کد لایسنس) با ارقام لاتین */
.latin-digits { font-family: var(--font-latin-digits); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── پوسته‌ی برنامه ─────────────────────────────────────────────────── */

.app-shell { display: flex; width: 100%; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    border-inline-end: 1px solid var(--line);
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    height: var(--topbar-height);
    padding: 0 var(--s-4);
    flex-shrink: 0;
}

.sidebar-brand strong { display: block; font-size: var(--text-md); font-weight: 700; line-height: 1.3; }
.sidebar-brand small { display: block; color: var(--muted); font-size: var(--text-xs); line-height: 1.3; }

/* نشان برند: مربع رنگ اصلی با گوشه‌ی کنترل — بدون گرادیان */
.brand-mark,
.sidebar-brand > i {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--r-control);
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
}
.sidebar-brand img.brand-logo { width: 28px; height: 28px; border-radius: var(--r-control); object-fit: contain; background: #fff; border: 1px solid var(--line); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) var(--s-3) var(--s-4); }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }

.nav-module { margin-bottom: var(--s-4); }

.nav-module-title {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: 0 var(--s-2);
    margin-bottom: var(--s-1);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--faint);
}
.nav-module-title i { display: none; }

.sidebar-nav .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 32px;
    padding: 0 var(--s-2);
    border-radius: var(--r-control);
    color: var(--ink-2);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.sidebar-nav .nav-link i { width: 18px; font-size: 0.95rem; color: var(--faint); text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--hover); color: var(--ink); }
.sidebar-nav .nav-link.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.sidebar-nav .nav-link.active i { color: var(--primary); }
/* نشانگر صفحه‌ی فعال: نوار باریک رنگ اصلی در لبه‌ی بیرونی */
.sidebar-nav .nav-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: calc(-1 * var(--s-3));
    top: 7px;
    bottom: 7px;
    width: 2px;
    border-radius: var(--r-pill);
    background: var(--primary);
}

.main-content {
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-start: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.main-content.full-width { margin-inline-start: 0; align-items: center; justify-content: center; }

.page-body {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: var(--s-5) var(--s-6) var(--s-7);
    min-width: 0;
}
.page-body > * { max-width: 100%; min-width: 0; }
.page-body .row > * { min-width: 0; }

/* نوار بالا */
.app-header {
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    height: var(--topbar-height);
    padding: 0 var(--s-6);
    background: color-mix(in srgb, var(--canvas) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.header-actions { display: flex; align-items: center; gap: var(--s-2); margin-inline-start: auto; }

.nav-toggle { display: none; }

.header-search { position: relative; display: flex; align-items: center; width: min(420px, 100%); }
.header-search > i { position: absolute; inset-inline-start: 10px; color: var(--faint); pointer-events: none; }
.header-search input {
    width: 100%;
    height: 34px;
    padding: 0 34px 0 44px;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: var(--text-sm);
}
.header-search input::placeholder { color: var(--faint); }
.header-search input:focus { outline: none; border-color: var(--primary-line); box-shadow: var(--focus-ring); }
.header-search kbd {
    position: absolute;
    inset-inline-end: 8px;
    min-width: 20px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--canvas);
    color: var(--muted);
    font: 500 var(--text-xs)/18px var(--font);
    text-align: center;
}
.header-search-submit { display: none; }

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline: 0;
    max-height: 360px;
    overflow-y: auto;
    padding: var(--s-1);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-pop);
    z-index: 200;
}
.search-result { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-control); color: var(--ink); }
.search-result:hover { background: var(--hover); color: var(--ink); }
.search-result > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.search-result strong { font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result small { color: var(--muted); font-size: var(--text-xs); }
.search-result-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-control); background: var(--primary-soft); color: var(--primary); }
.search-result > i { color: var(--faint); }
.search-empty { padding: var(--s-3); color: var(--muted); font-size: var(--text-sm); text-align: center; }

.header-icon-button {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: var(--r-control);
    background: transparent;
    color: var(--ink-2);
}
.header-icon-button:hover { background: var(--hover); color: var(--ink); }
.notification-badge {
    position: absolute;
    top: 1px;
    inset-inline-end: -3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--r-pill);
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--canvas);
}

.profile-menu { position: relative; }
.header-avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    font-size: var(--text-sm);
    cursor: pointer;
}
.profile-popover {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: 240px;
    padding: var(--s-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-pop);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
    z-index: 200;
}
.profile-menu:hover .profile-popover,
.profile-menu:focus-within .profile-popover { opacity: 1; visibility: visible; transform: none; }
.profile-popover-user { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-bottom: 1px solid var(--line); margin-bottom: var(--s-1); }
.profile-popover-user > div { display: flex; flex-direction: column; min-width: 0; }
.profile-popover-user strong { font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-popover-user small { color: var(--muted); font-size: var(--text-xs); }
.profile-popover-user .header-avatar { width: 28px; height: 28px; font-size: var(--text-xs); cursor: default; }
.profile-link {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2);
    border-radius: var(--r-control);
    color: var(--ink-2);
    font-size: var(--text-sm);
}
.profile-link:hover { background: var(--hover); color: var(--ink); }
.profile-logout {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    width: 100%;
    padding: var(--s-2);
    border: 0;
    border-radius: var(--r-control);
    background: transparent;
    color: var(--danger);
    font: inherit;
    font-size: var(--text-sm);
    text-align: start;
}
.profile-logout:hover, .profile-logout:focus-visible { background: var(--danger-soft); }

.nav-backdrop { display: none; }

/* ── سربرگ صفحه ─────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-bottom: var(--s-5);
}
.page-header h1 { margin: 0; font-size: var(--text-xl); font-weight: 650; letter-spacing: 0; }
.page-header h1 > i { display: none; }
.page-header p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-sm); }

/* ── پنل‌ها ─────────────────────────────────────────────────────── */

.card-panel,
.form-section {
    min-width: 0;
    max-width: 100%;
    margin-bottom: var(--s-4);
    padding: var(--s-5);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: none;
}
.card-panel > h5:first-child,
.form-section > h5:first-child {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    margin: 0 0 var(--s-4);
    padding: 0;
    border: 0;
    font-size: var(--text-md);
    font-weight: 600;
}
.card-panel > h5:first-child > i, .form-section > h5:first-child > i { display: none; }
.card-panel h5, .card-panel p { overflow-wrap: anywhere; }

.card-panel.panel-flush { padding: 0; overflow: hidden; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: var(--text-md); font-weight: 600; }
.panel-head .meta { color: var(--muted); font-size: var(--text-sm); }

/* ── دکمه‌ها ───────────────────────────────────────────────────── */

.btn {
    --bs-btn-font-family: var(--font);
    --bs-btn-font-size: var(--text-sm);
    --bs-btn-font-weight: 600;
    --bs-btn-padding-y: 0.4rem;
    --bs-btn-padding-x: 0.85rem;
    --bs-btn-border-radius: var(--r-control);
    --bs-btn-focus-box-shadow: var(--focus-ring);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn-sm { --bs-btn-padding-y: 0.2rem; --bs-btn-padding-x: 0.6rem; --bs-btn-font-size: var(--text-xs); min-height: 28px; }
.btn-lg { min-height: 40px; --bs-btn-font-size: var(--text-md); }

.btn-primary {
    --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--primary-dark); --bs-btn-active-border-color: var(--primary-dark);
    --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary);
}
/* «تماس» تنها اقدامی است که رنگ دوم برند (فیروزه‌ای) را می‌گیرد */
.btn-success, .btn-call {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-color: #fff;
    --bs-btn-hover-bg: var(--accent-dark); --bs-btn-hover-border-color: var(--accent-dark); --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--accent-dark); --bs-btn-active-border-color: var(--accent-dark);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-primary, .btn-outline-secondary, .btn-outline-info, .btn-outline-dark, .btn-light, .btn-secondary {
    --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line-strong); --bs-btn-color: var(--ink);
    --bs-btn-hover-bg: var(--surface-sunken); --bs-btn-hover-border-color: var(--line-strong); --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: var(--surface-sunken); --bs-btn-active-border-color: var(--line-strong); --bs-btn-active-color: var(--ink);
    --bs-btn-disabled-bg: var(--surface); --bs-btn-disabled-color: var(--faint);
}
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-hover-color: var(--primary-dark); }
.btn-outline-success { --bs-btn-color: var(--accent); --bs-btn-border-color: color-mix(in srgb, var(--accent) 40%, #fff); --bs-btn-hover-bg: var(--accent-soft); --bs-btn-hover-color: var(--accent-dark); --bs-btn-hover-border-color: var(--accent); }
.btn-outline-danger, .btn-danger {
    --bs-btn-bg: var(--surface); --bs-btn-border-color: color-mix(in srgb, var(--danger) 35%, #fff); --bs-btn-color: var(--danger);
    --bs-btn-hover-bg: var(--danger-soft); --bs-btn-hover-border-color: var(--danger); --bs-btn-hover-color: var(--danger);
}
.btn-ghost {
    --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-color: var(--ink-2);
    --bs-btn-hover-bg: var(--hover); --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: var(--ink);
}
.btn-icon { width: 30px; min-height: 30px; padding: 0; }

/* ── فرم ──────────────────────────────────────────────────────── */

.form-label { margin-bottom: 6px; color: var(--ink-2); font-size: var(--text-sm); font-weight: 500; }
.form-control, .form-select {
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-control);
    background-color: var(--surface);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--text-md);
    box-shadow: none;
}
/* فلش کشو در RTL سمت چپ (انتهای خط) است؛ فاصله‌ی خالی هم باید همان سمت باشد تا متن زیر فلش نرود */
.form-select { padding-inline: 0.7rem 2rem; background-position: left 0.6rem center; text-overflow: ellipsis; }
.form-select[multiple], .form-select[size]:not([size="1"]) { padding-inline-end: 0.7rem; }
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus { border-color: var(--primary-line); box-shadow: var(--focus-ring); }
.form-control-sm, .form-select-sm { min-height: 30px; font-size: var(--text-sm); }
.form-text { color: var(--muted); font-size: var(--text-xs); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: var(--focus-ring); }

/* ── جدول ─────────────────────────────────────────────────────── */

.table-responsive { max-width: 100%; min-width: 0; }
.table {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: var(--hover);
    --bs-table-striped-bg: transparent;
    width: 100%;
    margin-bottom: 0;
    font-size: var(--text-sm);
    vertical-align: middle;
}
.table > thead > tr > th {
    padding: 10px var(--s-3);
    background: transparent;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
}
.table > tbody > tr > td {
    padding: 10px var(--s-3);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    overflow-wrap: anywhere;
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--hover); }
.table a:not(.btn) { color: var(--ink); font-weight: 600; }
.table a:not(.btn):hover { color: var(--primary); }

/* ── برچسب‌های وضعیت (badge) — پس‌زمینه‌ی کم‌رنگ، متن پررنگ ───────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-family: var(--font);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.6;
}
.badge.bg-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.badge.bg-secondary, .badge.bg-light, .badge.bg-dark { background: var(--surface-sunken) !important; color: var(--ink-2) !important; }
.badge.bg-success { background: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-info { background: var(--info-soft) !important; color: var(--info) !important; }
.badge-hot { background: var(--danger-soft); color: var(--danger); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }

/* نقطه‌ی وضعیت + متن — برای ستون‌های وضعیت در جدول */
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: var(--text-sm); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.status-new::before { background: var(--primary); }
.status-contacted::before { background: var(--info); }
.status-followup::before { background: var(--warning); }
.status-qualified::before { background: var(--accent); }
.status-converted::before { background: var(--success); }
.status-lost { color: var(--muted); }
.status-lost::before { background: var(--line-strong); }

/* ── تراشه‌های فیلتر ─────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink-2);
    font: 500 var(--text-sm)/1 var(--font);
    cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip .count { color: var(--faint); font-variant-numeric: normal; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .count { color: rgba(255, 255, 255, 0.65); }

/* ── هشدار و وضعیت خالی ────────────────────────────────────────── */

.alert {
    --bs-alert-border-radius: var(--r-panel);
    padding: var(--s-3) var(--s-4);
    border: 1px solid transparent;
    font-size: var(--text-sm);
}
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 18%, #fff); color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 18%, #fff); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 20%, #fff); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 18%, #fff); color: var(--info); }

.empty-state { padding: var(--s-6) var(--s-4); color: var(--muted); font-size: var(--text-sm); text-align: center; }
.empty-state strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: var(--text-md); font-weight: 600; }

/* ── مودال ─────────────────────────────────────────────────────── */

.modal-content { border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-pop); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-size: var(--text-lg); font-weight: 600; }

/* ── ورود ─────────────────────────────────────────────────────── */

.login-page-shell { width: 100%; min-height: 100vh; padding: var(--s-5); display: grid; place-items: center; }
.login-card {
    width: 100%;
    max-width: 380px;
    padding: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
}
.login-card-spacious { max-width: 420px; }
.login-brand { margin-bottom: var(--s-5); }
.login-logo {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-bottom: var(--s-4);
    border-radius: var(--r-control);
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
}
.login-logo.has-image { background: #fff; border: 1px solid var(--line); overflow: hidden; }
.login-logo.has-image img { width: 100%; height: 100%; object-fit: contain; }
.login-wordmark { font-size: var(--text-xl); font-weight: 700; color: var(--ink); line-height: var(--leading-tight); }
.login-brand p { margin: var(--s-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.login-card .form-label { display: block; }
.login-input-wrap { position: relative; }
.login-input-wrap > i { display: none; }
.login-input-wrap .form-control { min-height: 40px; }
.btn-login { width: 100%; min-height: 40px; margin-top: var(--s-2); }
.login-security-note { margin-top: var(--s-4); color: var(--faint); font-size: var(--text-xs); text-align: center; }
.login-security-note i { margin-inline-end: 4px; }
.login-card-loading { opacity: 0.6; pointer-events: none; }

/* انتقال پس از ورود — یک نشانگر ساده و آرام */
.auth-transition {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--s-2);
    background: var(--canvas);
    color: var(--ink);
    font-size: var(--text-md);
}
.auth-transition > span { color: var(--muted); font-size: var(--text-sm); }
.auth-loader { position: relative; width: 36px; height: 36px; margin-bottom: var(--s-2); }
.loader-orbit {
    position: absolute;
    inset: 0;
    border: 2px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ds-spin 0.9s linear infinite;
}
.orbit-two, .loader-core { display: none; }
.button-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: 50%;
    animation: ds-spin 0.75s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── خطای Blazor ───────────────────────────────────────────────── */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: var(--s-4);
    inset-inline: var(--s-4);
    z-index: 1000;
    padding: var(--s-3) var(--s-4);
    background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, #fff);
    border-radius: var(--r-panel);
    color: var(--danger);
    box-shadow: var(--shadow-pop);
}
#blazor-error-ui .dismiss { cursor: pointer; float: left; }

/* ── واکنش‌گرا ─────────────────────────────────────────────────── */

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform 0.18s ease;
        background: var(--surface);
        box-shadow: none;
    }
    .app-shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
    .app-shell.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 99; background: rgba(30, 36, 34, 0.28); }
    .main-content { margin-inline-start: 0; }
    .nav-toggle { display: grid; }
    .app-header { padding: 0 var(--s-4); }
    .page-body { padding: var(--s-4) var(--s-4) var(--s-6); }
}

@media (max-width: 600px) {
    .header-search kbd { display: none; }
    .card-panel, .form-section { padding: var(--s-4); }
}

/* انتخاب مدل هوش مصنوعی از فهرست تأمین‌کننده (AiModelPicker) */
.model-picker { position: relative; }
.model-picker-field { text-align: start; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-backdrop { position: fixed; inset: 0; z-index: 29; }
.model-picker-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: 30;
    max-height: 320px;
    padding: 4px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    box-shadow: var(--shadow-pop);
}
.model-picker-search { position: sticky; top: -4px; display: flex; align-items: center; gap: var(--s-2); padding: 4px; background: var(--surface); }
.model-picker-search i { color: var(--faint); }
.model-picker-option {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
    width: 100%; padding: 6px var(--s-2); border: 0; border-radius: var(--r-control);
    background: none; color: var(--ink); font-size: var(--text-sm); text-align: start;
}
.model-picker-option:hover { background: var(--hover); }
.model-picker-option.is-selected { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
