/* Shared — loaded after theme for overrides */

/*
 * تاپ‌بار: عنوان اولویت اول؛ ساعت فقط به‌اندازه متن؛ ابزارها جمع‌شونده.
 * Flex (نه grid با عرض ثابت ساعت) تا عنوان دیگر به چند پیکسل فشرده نشود.
 */
.topbar {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start !important;
    gap: 0.65rem;
    min-width: 0;
    /* visible: دراپ‌داون اعلان/کاربر نباید زیر محتوا برود یا بریده شود؛
       کوتاه‌کردن عنوان با overflow روی .topbar-start / .page-title است. */
    overflow: visible;
}

.topbar-start {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto !important;
    min-width: 12rem !important;
    max-width: none;
    overflow: hidden;
    position: relative;
    z-index: 4;
}
.topbar-start .topbar-menu-btn,
.topbar-start #sidebarToggle {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    position: relative;
    z-index: 5;
    background-color: #fff !important;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    align-items: center;
    justify-content: center;
}
.topbar-start .topbar-help-btn {
    flex: 0 0 auto !important;
    margin-inline: 0;
    order: 0;
}
.topbar-start .btn-sidebar-collapse {
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
}
.topbar-clock-cluster {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto !important;
    min-width: 0;
    max-width: none;
    position: relative;
    z-index: 2;
    background: transparent;
    border-radius: 8px;
    overflow: visible;
}
.topbar-end {
    display: flex !important;
    align-items: center;
    gap: 0.5rem !important;
    flex: 0 1 auto !important;
    min-width: 0;
    max-width: none;
    margin-inline-start: 0;
    position: relative;
    z-index: 5;
    overflow: visible;
}
.topbar-end > .erp-context-switcher,
.topbar-end > .small.text-muted {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 20rem;
    overflow: hidden;
}
.topbar-end > .live-loc-status,
.topbar-end > .topbar-tools,
.topbar-end > .topbar-notif-menu,
.topbar-end > .topbar-user-menu {
    flex: 0 0 auto !important;
    position: relative;
    z-index: 6;
}
.topbar-tools {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    overflow: visible;
}
.topbar-notif-dropdown.dropdown-menu,
.topbar-user-dropdown.dropdown-menu {
    z-index: 1060;
}

.topbar .page-title {
    flex: 1 1 auto !important;
    min-width: 10rem !important;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden !important;
    text-overflow: ellipsis;
    line-height: 1.4;
    margin: 0;
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    letter-spacing: 0;
}
.topbar .page-title.page-title--rich {
    display: block;
    overflow: hidden !important;
}
.topbar .page-title .page-title-rich {
    display: none; /* پیش‌فرض: متن ساده تا جا تنگ نشود */
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}
.topbar .page-title .page-title-plain {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* فقط در عرض خیلی عریض پلاک گرافیکی در عنوان نشان داده شود */
@media (min-width: 1600px) {
    .topbar .page-title.page-title--rich .page-title-rich {
        display: inline-flex;
        max-width: 100%;
    }
    .topbar .page-title.page-title--rich .page-title-plain {
        display: none;
    }
    .topbar .page-title .page-title-prefix {
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .topbar .page-title .cc-iran-plate {
        flex: 0 0 auto;
        vertical-align: middle;
    }
}

.topbar-help-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    border-radius: 8px;
    flex-shrink: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}
.topbar-help-btn .fa {
    font-size: 14px;
}
.topbar-help-btn:hover,
.topbar-help-btn:focus {
    color: #fff;
    border-color: #2081af;
    background: #2081af;
}

/* مدال راهنمای صفحه */
.page-help-modal .modal-header {
    border-bottom-color: rgba(15, 23, 42, 0.08);
}
.page-help-modal .modal-title {
    font-size: 1.05rem;
    font-weight: 700;
}
.page-help-block {
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.06);
}
.page-help-block:last-child {
    margin-bottom: 0;
}
.page-help-label {
    font-weight: 700;
    font-size: 0.92rem;
    color: #1a567a;
    margin-bottom: 0.45rem;
}
.page-help-html {
    line-height: 1.85;
}
.page-help-html h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 1rem 0 0.5rem;
    color: #1a567a;
}
.page-help-html h3:first-child { margin-top: 0; }
.page-help-html ul,
.page-help-html ol {
    padding-inline-start: 1.25rem;
    margin-bottom: 0.75rem;
}
.page-help-steps,
.page-help-errors,
.page-help-terms,
.page-help-checklist {
    padding-right: 1.15rem;
    padding-left: 0;
}
.page-help-steps li,
.page-help-errors li,
.page-help-terms li,
.page-help-checklist li {
    margin-bottom: 0.45rem;
}
.page-help-checklist li::marker {
    content: "☐ ";
}
.page-help-modal .modal-body {
    max-height: min(70vh, 640px);
}
.page-help-meta {
    max-width: 75%;
}

/* ساعت زنده شمسی — فقط به‌اندازه متن (بدون عرض ثابت و فضای خالی) */
.topbar-server-clock {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto !important;
    box-sizing: border-box;
    width: max-content !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 1.75rem;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    color: #475569;
    white-space: nowrap;
    padding: 0.2rem 0.55rem;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.06);
    line-height: 1.3;
    overflow: visible;
    justify-content: flex-start;
    direction: ltr;
}
.topbar-server-clock::before {
    content: '\f017';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 11px;
    opacity: 0.7;
    flex-shrink: 0;
    width: 0.9rem;
    text-align: center;
}
.topbar-server-clock .clk-text {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
    overflow: visible;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}
@media (max-width: 1399.98px) {
    .topbar-server-clock {
        font-size: 12px;
    }
    .erp-context-switcher .erp-ctx-select {
        max-width: 8.5rem;
    }
}
@media (max-width: 1199.98px) {
    .topbar-start {
        min-width: 10rem !important;
    }
    .topbar .page-title {
        min-width: 8rem !important;
        font-size: 1.0625rem !important;
    }
}
@media (max-width: 991.98px) {
    .erp-context-switcher--inline {
        display: none !important;
    }
}
@media (min-width: 992px) {
    .erp-context-compact {
        display: none !important;
    }
}
.erp-context-compact > .btn {
    max-width: 11rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.erp-context-compact .dropdown-menu {
    min-width: 16rem;
    padding: 0.75rem;
}
.erp-context-compact .erp-ctx-select {
    max-width: none;
    width: 100%;
}
@media (max-width: 991.98px) {
    .topbar-server-clock {
        font-size: 11.5px;
        padding: 0.15rem 0.4rem;
    }
}
@media (max-width: 767.98px) {
    .topbar {
        gap: 0.45rem;
        padding-inline: 10px;
    }
    .topbar-clock-cluster {
        display: none !important;
    }
    .topbar-start {
        min-width: 0 !important;
        flex: 1 1 auto !important;
        gap: 0.4rem !important;
    }
    .topbar-end {
        flex: 0 0 auto !important;
    }
    .topbar-start .topbar-menu-btn,
    .topbar-start #sidebarToggle,
    .topbar-help-btn {
        width: 2rem;
        height: 2rem;
        min-width: 2rem;
    }
    .topbar .page-title {
        min-width: 6rem !important;
        font-size: 1rem !important;
    }
}
@media (max-width: 575.98px) {
    .topbar-help-btn {
        flex-shrink: 0 !important;
    }
}
@media (max-width: 379.98px) {
    .topbar-clock-cluster {
        display: none !important;
    }
}

/* Topbar ERP company / fiscal-year switcher (RTL-safe caret) */
.erp-context-switcher {
    flex: 0 1 auto;
    flex-shrink: 1;
    min-width: 0;
    max-width: 20rem;
    overflow: hidden;
}
.erp-context-switcher .erp-ctx-select {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 10rem;
    padding-inline-start: 0.55rem;
    padding-inline-end: 1.85rem;
    background-position: left 0.45rem center;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}
.erp-context-switcher .erp-ctx-select--fy {
    max-width: 9.5rem;
}

/* Admin-selected UI font (settings → ui_font) */
html {
    --app-font-family: 'Vazirmatn', Tahoma, sans-serif;
}
body,
button,
input,
select,
textarea,
.btn,
.badge,
.form-control,
.form-select,
.sidebar,
.table,
.dropdown-menu,
.alert,
.nav,
.modal,
.card {
    font-family: var(--app-font-family) !important;
}

/* Sidebar menu search */
.sidebar-search {
    padding: 0 12px 10px;
}
.sidebar-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.sidebar-search-icon {
    position: absolute;
    right: 10px;
    color: rgba(255, 255, 255, .55);
    font-size: 12px;
    pointer-events: none;
}
.sidebar-search-input {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(0, 0, 0, .18);
    color: #fff;
    border-radius: 8px;
    padding: 7px 32px 7px 10px;
    font-size: 12.5px;
    outline: none;
    transition: border-color .15s, background .15s;
}
.sidebar-search-input::placeholder {
    color: rgba(255, 255, 255, .45);
}
.sidebar-search-input:focus {
    border-color: rgba(255, 255, 255, .35);
    background: rgba(0, 0, 0, .28);
}
.sidebar-tree .tree-node.is-search-hidden {
    display: none !important;
}
.sidebar-tree .tree-node-leaf.is-search-miss {
    display: none !important;
}
.sidebar-tree.is-filtering .tree-node[data-group-id] {
    /* keep matching groups open while filtering */
}
.sidebar-tree.is-filtering .tree-node[data-group-id].is-open > .tree-children {
    display: block !important;
}

/* زیرمنوی چندسطحی + آیتم سفارشی */
.sidebar-tree .tree-node-submenu > .tree-item-parent {
    margin-inline-start: 0.25rem;
}
.sidebar-tree .tree-node-submenu > .tree-item-parent .tree-parent-label {
    font-weight: 600;
    font-size: 12.5px;
    min-height: 34px;
}
.sidebar-tree .tree-node-submenu > .tree-item-parent .tree-parent-icon {
    font-size: 12px;
}
.sidebar-tree .tree-node-submenu > .tree-children {
    margin-inline-start: 0.5rem;
    border-inline-start: 1px dashed rgba(148, 163, 184, .4);
    padding-inline-start: 0.1rem;
}
.sidebar-tree .tree-node[data-depth="2"] > .tree-item-leaf {
    min-height: 34px;
    font-size: 13px;
}
.sidebar-tree .tree-node[data-depth="3"] > .tree-item-leaf {
    min-height: 32px;
    font-size: 12.5px;
}
.sidebar-tree .tree-item-leaf .sidebar-ext-icon {
    margin-inline-start: auto;
    font-size: 10px;
    opacity: .55;
}
.sidebar-tree .tree-node-submenu.is-search-hidden {
    display: none !important;
}

/* ─── آیکن‌های رنگی سایدبار (چیپ نرم + رنگ معنایی) ─── */
.sidebar-tree .sidebar-nav-icon {
    --si-c: #64748b;
    --si-bg: rgba(100, 116, 139, .12);
    --si-ring: rgba(100, 116, 139, .22);
    width: 28px !important;
    height: 28px;
    min-width: 28px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 8px;
    font-size: 13px !important;
    line-height: 1;
    color: var(--si-c) !important;
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--si-bg) 70%, #fff) 0%, var(--si-bg) 100%);
    box-shadow:
        inset 0 0 0 1px var(--si-ring),
        0 1px 2px rgba(15, 23, 42, .04);
    transition:
        transform .18s ease,
        box-shadow .18s ease,
        background .18s ease,
        color .18s ease,
        filter .18s ease;
}

.sidebar-tree .tree-node-submenu > .tree-item-parent .sidebar-nav-icon {
    width: 24px !important;
    height: 24px;
    min-width: 24px;
    border-radius: 7px;
    font-size: 11.5px !important;
}

.sidebar-tree .tree-item-leaf:hover > .sidebar-nav-icon,
.sidebar-tree .tree-parent-label:hover > .sidebar-nav-icon {
    transform: translateY(-1px) scale(1.06);
    filter: saturate(1.15);
    box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--si-c) 28%, transparent),
        0 4px 10px color-mix(in srgb, var(--si-c) 22%, transparent);
}

.sidebar-tree .tree-item-leaf.active > .sidebar-nav-icon {
    transform: scale(1.04);
    filter: saturate(1.2);
    box-shadow:
        inset 0 0 0 1px color-mix(in srgb, var(--si-c) 35%, transparent),
        0 0 0 3px color-mix(in srgb, var(--si-c) 14%, transparent),
        0 3px 8px color-mix(in srgb, var(--si-c) 20%, transparent);
}

.sidebar-tree .tree-node.has-active > .tree-item-parent .sidebar-nav-icon,
.sidebar-tree .tree-node.is-open > .tree-item-parent .sidebar-nav-icon {
    filter: saturate(1.12);
}

/* دامنه L1 — رنگ گروه */
.sidebar-tree .tree-node-group[data-group-id="accounting_finance"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #0284c7; --si-bg: rgba(2, 132, 199, .14); --si-ring: rgba(2, 132, 199, .22);
}
.sidebar-tree .tree-node-group[data-group-id="treasury_bank"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #059669; --si-bg: rgba(5, 150, 105, .14); --si-ring: rgba(5, 150, 105, .22);
}
.sidebar-tree .tree-node-group[data-group-id="sales_commerce"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #ea580c; --si-bg: rgba(234, 88, 12, .14); --si-ring: rgba(234, 88, 12, .22);
}
.sidebar-tree .tree-node-group[data-group-id="purchases_group"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #7c3aed; --si-bg: rgba(124, 58, 237, .14); --si-ring: rgba(124, 58, 237, .22);
}
.sidebar-tree .tree-node-group[data-group-id="supply_warehouse"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #4f46e5; --si-bg: rgba(79, 70, 229, .14); --si-ring: rgba(79, 70, 229, .22);
}
.sidebar-tree .tree-node-group[data-group-id="fixed_assets_group"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #0d9488; --si-bg: rgba(13, 148, 136, .14); --si-ring: rgba(13, 148, 136, .22);
}
.sidebar-tree .tree-node-group[data-group-id="hr_payroll"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #db2777; --si-bg: rgba(219, 39, 119, .14); --si-ring: rgba(219, 39, 119, .22);
}
.sidebar-tree .tree-node-group[data-group-id="carcare_group"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #0891b2; --si-bg: rgba(8, 145, 178, .14); --si-ring: rgba(8, 145, 178, .22);
}
.sidebar-tree .tree-node-group[data-group-id="crm_tasks"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #9333ea; --si-bg: rgba(147, 51, 234, .14); --si-ring: rgba(147, 51, 234, .22);
}
.sidebar-tree .tree-node-group[data-group-id="system_admin"] > .tree-item-parent .sidebar-nav-icon {
    --si-c: #475569; --si-bg: rgba(71, 85, 105, .14); --si-ring: rgba(71, 85, 105, .24);
}

/* پین / خانه */
.sidebar-tree .tree-node-pinned .sidebar-nav-icon.fa-home,
.sidebar-tree .sidebar-nav-icon.fa-home {
    --si-c: #2563eb; --si-bg: rgba(37, 99, 235, .15); --si-ring: rgba(37, 99, 235, .24);
}

/* رنگ معنایی بر اساس نوع آیکن */
.sidebar-tree .sidebar-nav-icon.fa-calculator,
.sidebar-tree .sidebar-nav-icon.fa-balance-scale,
.sidebar-tree .sidebar-nav-icon.fa-book,
.sidebar-tree .sidebar-nav-icon.fa-folder-tree,
.sidebar-tree .sidebar-nav-icon.fa-project-diagram,
.sidebar-tree .sidebar-nav-icon.fa-list-ol,
.sidebar-tree .sidebar-nav-icon.fa-landmark {
    --si-c: #0284c7; --si-bg: rgba(2, 132, 199, .14); --si-ring: rgba(2, 132, 199, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-file-invoice,
.sidebar-tree .sidebar-nav-icon.fa-file-invoice-dollar,
.sidebar-tree .sidebar-nav-icon.fa-copy,
.sidebar-tree .sidebar-nav-icon.fa-receipt,
.sidebar-tree .sidebar-nav-icon.fa-file-alt,
.sidebar-tree .sidebar-nav-icon.fa-file-contract,
.sidebar-tree .sidebar-nav-icon.fa-file-signature {
    --si-c: #0ea5e9; --si-bg: rgba(14, 165, 233, .14); --si-ring: rgba(14, 165, 233, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-wallet,
.sidebar-tree .sidebar-nav-icon.fa-money-bill-transfer,
.sidebar-tree .sidebar-nav-icon.fa-money-bill-wave,
.sidebar-tree .sidebar-nav-icon.fa-money-check-alt,
.sidebar-tree .sidebar-nav-icon.fa-hand-holding-usd,
.sidebar-tree .sidebar-nav-icon.fa-cash-register,
.sidebar-tree .sidebar-nav-icon.fa-coins,
.sidebar-tree .sidebar-nav-icon.fa-building-columns,
.sidebar-tree .sidebar-nav-icon.fa-university {
    --si-c: #059669; --si-bg: rgba(5, 150, 105, .14); --si-ring: rgba(5, 150, 105, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-chart-pie,
.sidebar-tree .sidebar-nav-icon.fa-chart-line,
.sidebar-tree .sidebar-nav-icon.fa-chart-bar,
.sidebar-tree .sidebar-nav-icon.fa-chart-column,
.sidebar-tree .sidebar-nav-icon.fa-chart-area,
.sidebar-tree .sidebar-nav-icon.fa-table {
    --si-c: #7c3aed; --si-bg: rgba(124, 58, 237, .14); --si-ring: rgba(124, 58, 237, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-store,
.sidebar-tree .sidebar-nav-icon.fa-shopping-cart,
.sidebar-tree .sidebar-nav-icon.fa-cart-shopping,
.sidebar-tree .sidebar-nav-icon.fa-tags,
.sidebar-tree .sidebar-nav-icon.fa-address-book {
    --si-c: #ea580c; --si-bg: rgba(234, 88, 12, .14); --si-ring: rgba(234, 88, 12, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-boxes,
.sidebar-tree .sidebar-nav-icon.fa-boxes-stacked,
.sidebar-tree .sidebar-nav-icon.fa-box,
.sidebar-tree .sidebar-nav-icon.fa-cube,
.sidebar-tree .sidebar-nav-icon.fa-cubes,
.sidebar-tree .sidebar-nav-icon.fa-warehouse,
.sidebar-tree .sidebar-nav-icon.fa-layer-group,
.sidebar-tree .sidebar-nav-icon.fa-sitemap,
.sidebar-tree .sidebar-nav-icon.fa-arrow-down,
.sidebar-tree .sidebar-nav-icon.fa-arrow-up,
.sidebar-tree .sidebar-nav-icon.fa-clipboard-check {
    --si-c: #4f46e5; --si-bg: rgba(79, 70, 229, .14); --si-ring: rgba(79, 70, 229, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-users,
.sidebar-tree .sidebar-nav-icon.fa-user-tie,
.sidebar-tree .sidebar-nav-icon.fa-user-plus,
.sidebar-tree .sidebar-nav-icon.fa-users-gear,
.sidebar-tree .sidebar-nav-icon.fa-id-card,
.sidebar-tree .sidebar-nav-icon.fa-door-open,
.sidebar-tree .sidebar-nav-icon.fa-plane,
.sidebar-tree .sidebar-nav-icon.fa-calendar-minus,
.sidebar-tree .sidebar-nav-icon.fa-laptop {
    --si-c: #db2777; --si-bg: rgba(219, 39, 119, .14); --si-ring: rgba(219, 39, 119, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-building,
.sidebar-tree .sidebar-nav-icon.fa-city,
.sidebar-tree .sidebar-nav-icon.fa-wrench,
.sidebar-tree .sidebar-nav-icon.fa-tools {
    --si-c: #0d9488; --si-bg: rgba(13, 148, 136, .14); --si-ring: rgba(13, 148, 136, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-car,
.sidebar-tree .sidebar-nav-icon.fa-car-side,
.sidebar-tree .sidebar-nav-icon.fa-gauge,
.sidebar-tree .sidebar-nav-icon.fa-oil-can,
.sidebar-tree .sidebar-nav-icon.fa-cogs {
    --si-c: #0891b2; --si-bg: rgba(8, 145, 178, .14); --si-ring: rgba(8, 145, 178, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-briefcase,
.sidebar-tree .sidebar-nav-icon.fa-comments,
.sidebar-tree .sidebar-nav-icon.fa-clipboard-list,
.sidebar-tree .sidebar-nav-icon.fa-tasks,
.sidebar-tree .sidebar-nav-icon.fa-check-double,
.sidebar-tree .sidebar-nav-icon.fa-magic {
    --si-c: #9333ea; --si-bg: rgba(147, 51, 234, .14); --si-ring: rgba(147, 51, 234, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-cog,
.sidebar-tree .sidebar-nav-icon.fa-gear,
.sidebar-tree .sidebar-nav-icon.fa-sliders-h,
.sidebar-tree .sidebar-nav-icon.fa-shield-alt,
.sidebar-tree .sidebar-nav-icon.fa-shield-halved,
.sidebar-tree .sidebar-nav-icon.fa-bars-staggered,
.sidebar-tree .sidebar-nav-icon.fa-puzzle-piece,
.sidebar-tree .sidebar-nav-icon.fa-print,
.sidebar-tree .sidebar-nav-icon.fa-th-large,
.sidebar-tree .sidebar-nav-icon.fa-stethoscope,
.sidebar-tree .sidebar-nav-icon.fa-question-circle,
.sidebar-tree .sidebar-nav-icon.fa-calendar-check {
    --si-c: #475569; --si-bg: rgba(71, 85, 105, .14); --si-ring: rgba(71, 85, 105, .24);
}
.sidebar-tree .sidebar-nav-icon.fa-folder,
.sidebar-tree .sidebar-nav-icon.fa-folder-open {
    --si-c: #ca8a04; --si-bg: rgba(202, 138, 4, .14); --si-ring: rgba(202, 138, 4, .22);
}
.sidebar-tree .sidebar-nav-icon.fa-link,
.sidebar-tree .sidebar-nav-icon.fa-bolt,
.sidebar-tree .sidebar-nav-icon.fa-handshake,
.sidebar-tree .sidebar-nav-icon.fa-ruler,
.sidebar-tree .sidebar-nav-icon.fa-hourglass-half,
.sidebar-tree .sidebar-nav-icon.fa-ellipsis {
    --si-c: #6366f1; --si-bg: rgba(99, 102, 241, .14); --si-ring: rgba(99, 102, 241, .22);
}

/* تم کلاسیک — سایدبار آبی تیره: پالت یخی/فیروزه‌ای یکدست (بدون رنگین‌کمان) */
body.theme-classic .sidebar-tree .sidebar-nav-icon {
    --si-c: #7dd3fc;
    --si-bg: rgba(125, 211, 252, .14);
    --si-ring: rgba(186, 230, 253, .22);
    color: #bae6fd !important;
    background: rgba(255, 255, 255, .1) !important;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .14),
        0 1px 2px rgba(0, 0, 0, .12) !important;
    filter: none;
}
/* همهٔ رنگ‌های معنایی را روی طیف آبی کلاسیک هم‌تراز کن */
body.theme-classic .sidebar-tree .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .sidebar-nav-icon[class*="fa-"] {
    --si-c: #7dd3fc;
    --si-bg: rgba(125, 211, 252, .14);
    --si-ring: rgba(186, 230, 253, .22);
    color: #bae6fd !important;
    background: rgba(255, 255, 255, .1) !important;
}
/* تمایز خیلی ملایم فقط برای گروه‌های L1 (همان خانواده آبی) */
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="accounting_finance"] > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="treasury_bank"] > .tree-item-parent .sidebar-nav-icon {
    color: #e0f2fe !important;
    background: rgba(224, 242, 254, .14) !important;
}
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="sales_commerce"] > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="purchases_group"] > .tree-item-parent .sidebar-nav-icon {
    color: #7dd3fc !important;
    background: rgba(125, 211, 252, .16) !important;
}
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="supply_warehouse"] > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="fixed_assets_group"] > .tree-item-parent .sidebar-nav-icon {
    color: #67e8f9 !important;
    background: rgba(103, 232, 249, .12) !important;
}
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="hr_payroll"] > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="crm_tasks"] > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="carcare_group"] > .tree-item-parent .sidebar-nav-icon {
    color: #93c5fd !important;
    background: rgba(147, 197, 253, .14) !important;
}
body.theme-classic .sidebar-tree .tree-node-group[data-group-id="system_admin"] > .tree-item-parent .sidebar-nav-icon {
    color: #cbd5e1 !important;
    background: rgba(255, 255, 255, .08) !important;
}
body.theme-classic .sidebar-tree .tree-item-leaf:hover > .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-parent-label:hover > .sidebar-nav-icon {
    transform: translateY(-1px) scale(1.04);
    filter: none;
    color: #fff !important;
    background: rgba(255, 255, 255, .18) !important;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .28),
        0 4px 10px rgba(0, 0, 0, .18) !important;
}
body.theme-classic .sidebar-tree .tree-item-leaf.active > .sidebar-nav-icon {
    transform: scale(1.04);
    filter: none;
    color: #fff !important;
    background: rgba(125, 211, 252, .28) !important;
    box-shadow:
        inset 0 0 0 1px rgba(186, 230, 253, .45),
        0 0 0 2px rgba(125, 211, 252, .2),
        0 3px 8px rgba(0, 0, 0, .16) !important;
}
body.theme-classic .sidebar-tree .tree-node.has-active > .tree-item-parent .sidebar-nav-icon,
body.theme-classic .sidebar-tree .tree-node.is-open > .tree-item-parent .sidebar-nav-icon {
    filter: none;
    color: #e0f2fe !important;
    background: rgba(255, 255, 255, .14) !important;
}

/* زمینه ناوبری بین‌ماژولی — گروه مبدأ در سایدبار */
.sidebar-tree .tree-node.nav-context-origin > .tree-item-parent .tree-parent-label {
    outline: 1px dashed rgba(13, 110, 253, .45);
    outline-offset: 1px;
    border-radius: 8px;
}
.sidebar-tree .nav-context-origin-tag {
    margin-inline-start: auto;
    font-size: 10px;
    font-weight: 600;
    color: #0d6efd;
    background: rgba(13, 110, 253, .08);
    border: 1px solid rgba(13, 110, 253, .25);
    border-radius: 6px;
    padding: 1px 6px;
    line-height: 1.4;
}
.nav-context-banner {
    border-inline-start: 4px solid #0d6efd;
}

@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar-search {
        display: none;
    }
}

/* Notification bell */
.topbar-notif-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.topbar-notif-dropdown {
    width: min(360px, 92vw);
    max-height: 70vh;
    overflow: hidden;
}
.topbar-notif-list {
    max-height: 320px;
    overflow-y: auto;
}
.topbar-notif-item {
    white-space: normal;
    border-bottom: 1px solid rgba(0,0,0,.06);
}
.topbar-notif-item.is-unread {
    background: rgba(32, 129, 175, 0.08);
}
.topbar-notif-badge {
    font-size: 10px;
    min-width: 1.1rem;
}
.topbar-notif-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    cursor: zoom-in;
}
.notification-full-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    cursor: zoom-in;
}
.notification-portal-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    cursor: zoom-in;
}

/* Lightbox تصویر اعلان */
.notif-lightbox {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .72);
    backdrop-filter: blur(4px);
}
.notif-lightbox.is-open {
    display: flex;
}
body.notif-lightbox-open {
    overflow: hidden;
}
.notif-lightbox-img {
    max-width: min(960px, 94vw);
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .45);
    background: #fff;
}
.notif-lightbox-img[hidden] {
    display: none !important;
}
.notif-lightbox-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: #0f172a;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
}
.notif-lightbox-close:hover {
    background: #fff;
}

/* Dynamic fill tables: usable inputs */
.dynamic-table {
    table-layout: fixed;
    width: 100%;
}
.dynamic-table th,
.dynamic-table td {
    vertical-align: middle;
    text-align: center;
}
.dynamic-table th.col-desc,
.dynamic-table td.col-desc {
    text-align: right;
    width: 56%;
    min-width: 0;
}
.dynamic-table input {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.dynamic-table th.col-row,
.dynamic-table td.col-row {
    width: 36px;
    max-width: 36px;
    padding-left: 2px !important;
    padding-right: 2px !important;
    font-size: 12px;
}
.dynamic-table th.col-qty,
.dynamic-table td.col-qty { width: 88px; }
.dynamic-table th.col-price,
.dynamic-table td.col-price { width: 110px; }
.dynamic-table th.col-total,
.dynamic-table td.col-total { width: 100px; }
.dynamic-table th.col-action,
.dynamic-table td.col-action {
    width: 72px;
    position: sticky;
    left: 0;
    z-index: 4;
    background: #fff;
    box-shadow: 6px 0 14px rgba(0, 0, 0, 0.08);
}
.dynamic-table thead th.col-action {
    z-index: 5;
    background: var(--bs-table-bg, #fff);
}
.dynamic-table .billable-search-wrap {
    width: 100%;
    min-width: 0;
}
.dynamic-table .billable-search-wrap .billable-search {
    flex: 1 1 auto;
    min-width: 0;
    width: 1%;
}

.billable-search-wrap {
    position: relative;
    flex-wrap: nowrap;
    display: flex;
    width: 100%;
}
.billable-search-wrap .billable-pick-btn {
    flex: 0 0 auto;
    min-width: 2.25rem;
}

.billable-composer .billable-draft-row {
    background: rgba(13, 110, 253, 0.04);
}
.billable-composer .billable-draft-row.billable-draft-dirty {
    background: rgba(255, 193, 7, 0.12);
    outline: 1px solid rgba(255, 193, 7, 0.55);
}
.billable-composer .billable-draft-row td.col-action {
    background: rgba(232, 242, 255, 0.98);
}
.billable-draft-actions {
    display: inline-flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: center;
    min-width: 0;
}
.billable-draft-actions .btn {
    width: 28px;
    height: 28px;
    min-height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    box-shadow: none;
}
.billable-draft-actions .btn-outline-secondary {
    box-shadow: none;
}

.dynamic-table-wrap.hide-billable-prices .col-price,
.dynamic-table-wrap.hide-billable-prices .col-total {
    display: none !important;
}

/* لایهٔ شناور سراسری — منوی پیشنهاد/دراپ‌داون نباید داخل overflow جدول بماند */
:root {
    --z-ui-float: 20050;
}
.ui-float-root {
    position: absolute;
    width: 0;
    height: 0;
    overflow: visible;
    pointer-events: none;
}
.ui-float-root > * {
    pointer-events: auto;
}
.ui-float-portal {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
    z-index: var(--z-ui-float);
}
/* مگامنو: در دسکتاپ زیرشاخه‌ها داخل سایدبار باز نشوند */
@media (min-width: 769px) {
    .tree-node-group[data-mega-panel="1"] > .tree-children {
        display: none !important;
    }
    .sidebar-nav.is-filtering .tree-node-group[data-mega-panel="1"] > .tree-children {
        display: block !important;
    }
    .tree-node-group[data-mega-panel="1"] > .tree-item-parent .tree-toggle {
        display: none;
    }
    .tree-node-group[data-mega-panel="1"].is-mega-open > .tree-item-parent .tree-parent-label,
    .tree-node-group[data-mega-panel="1"].has-active > .tree-item-parent .tree-parent-label {
        background: rgba(32, 129, 175, 0.22);
        box-shadow: inset -3px 0 0 #2081af;
    }
    body.theme-classic .tree-node-group[data-mega-panel="1"].is-mega-open > .tree-item-parent .tree-parent-label,
    body.theme-classic .tree-node-group[data-mega-panel="1"].has-active > .tree-item-parent .tree-parent-label {
        background: rgba(255, 255, 255, 0.16);
        box-shadow: inset -3px 0 0 #fff;
    }
}

.erp-mega-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    z-index: 1015;
}
body.erp-mega-open {
    overflow: hidden;
    padding-right: var(--erp-mega-sbw, 0px);
}
@media (min-width: 769px) {
    body.erp-mega-open .sidebar {
        right: var(--erp-mega-sbw, 0px);
    }
}
@media (max-width: 768px) {
    /* مگامنو روی موبایل استفاده نمی‌شود؛ اگر کلاس گیر کرد، صفحه را قفل نکند */
    body.erp-mega-open {
        overflow: auto;
        padding-right: 0;
    }
    .erp-mega-panel,
    .erp-mega-backdrop {
        display: none !important;
    }

    /*
     * دراور موبایل: مخفی‌سازی با right (نه translateX).
     * در html[dir=rtl] بعضی مرورگرهای موبایل translateX(100%) را معکوس می‌کنند
     * و سایدبار همیشه روی صفحه می‌ماند — X و overlay بی‌اثر به نظر می‌رسند.
     */
    .sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        width: min(86vw, 20rem) !important;
        max-width: 86vw;
        transform: none !important;
        z-index: 1040;
        left: auto !important;
        transition: right 0.28s ease, visibility 0s linear 0.28s, width 0.25s ease;
    }
    .sidebar:not(.open) {
        right: -110% !important;
        visibility: hidden;
        pointer-events: none;
    }
    .sidebar.open {
        right: 0 !important;
        visibility: visible;
        pointer-events: auto;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.28);
        transition: right 0.28s ease, visibility 0s, width 0.25s ease;
    }
    .sidebar-close {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 36px;
        height: 36px;
        border: 1px solid rgba(255, 255, 255, 0.4);
        border-radius: 6px;
        background: rgba(0, 0, 0, 0.18);
        color: #fff;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        z-index: 6;
        pointer-events: auto;
        cursor: pointer;
    }
    .sidebar-brand { position: relative; }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1035;
        pointer-events: auto;
    }
    .sidebar-backdrop.show,
    .sidebar-backdrop.is-closing {
        display: block !important;
    }
    .sidebar-backdrop.is-closing {
        opacity: 0;
    }
    body.sidebar-open { overflow: hidden; }
    .main-wrapper { margin-right: 0 !important; }
    #sidebarToggle.topbar-menu-btn {
        display: inline-flex !important;
    }
    .sidebar-footer {
        position: relative;
        z-index: 4;
        flex-shrink: 0;
    }
    .sidebar-foot-link {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
        padding: 10px 8px;
        font-size: 0.9rem;
        pointer-events: auto;
        cursor: pointer;
    }
}
.erp-mega-panel {
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #1e293b;
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.14);
    border-left: 1px solid #e2e8f0;
    direction: rtl;
    overflow: hidden;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
}
.erp-mega-panel.d-none { display: none !important; }
.erp-mega-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 16px 10px;
    border-bottom: 1px solid #eef2f7;
    flex: 0 0 auto;
}
.erp-mega-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
}
.erp-mega-search-wrap i { color: #94a3b8; }
.erp-mega-search {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    font-size: 0.875rem;
}
.erp-mega-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.erp-mega-chip-label {
    font-size: 0.7rem;
    color: #64748b;
    margin-inline-start: 4px;
}
.erp-mega-chip {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    text-decoration: none;
}
.erp-mega-chip:hover { background: #e2e8f0; }
.erp-mega-fav {
    border: 0;
    background: transparent;
    color: #cbd5e1;
    padding: 0 2px;
    margin-inline-start: auto;
    cursor: pointer;
}
.erp-mega-fav.is-on { color: #f59e0b; }
.sidebar-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
.sidebar-foot-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: 0.9;
    font-size: 0.78rem;
    padding: 4px 6px;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
}
.sidebar-foot-link:hover { background: rgba(255,255,255,0.08); opacity: 1; }
body.sidebar-collapsed .sidebar-footer-links .sidebar-label { display: none; }
body.sidebar-collapsed .tree-node-group .tree-parent-text { /* tooltip via title attr */ }

.erp-mega-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #eef2f7;
    flex: 0 0 auto;
}
.erp-mega-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}
.erp-mega-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.erp-mega-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}
/* ستون‌ها تا ارتفاع پنل پر می‌شوند و ادامه به ستون بعدی می‌رود؛ اسکرول فقط روی body */
.erp-mega-body {
    --erp-mega-col-w: 168px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px 20px;
    display: flex;
    flex-flow: row wrap;
    align-content: flex-start;
    align-items: flex-start;
    gap: 12px 18px;
}
.erp-mega-col {
    flex: 0 0 var(--erp-mega-col-w);
    width: var(--erp-mega-col-w);
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}
.erp-mega-section {
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px 8px 6px;
    box-sizing: border-box;
    flex: 0 0 auto;
}
.erp-mega-col > .erp-mega-section + .erp-mega-section {
    margin-top: 12px;
}
.erp-mega-col-title {
    margin: 0 0 6px;
    padding: 0 0 5px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.78rem;
    font-weight: 700;
    color: #0f172a;
    flex: 0 0 auto;
}
.erp-mega-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
}
.erp-mega-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #334155;
    text-decoration: none;
    line-height: 1.3;
}
.erp-mega-link:hover {
    background: #f0f7fb;
    color: #17698f;
}
.erp-mega-link.active {
    background: #e8f4fa;
    color: #146387;
    font-weight: 600;
}
.erp-mega-link i {
    width: 1rem;
    text-align: center;
    color: #64748b;
    flex: 0 0 auto;
    font-size: 0.78rem;
}
.erp-mega-link .sidebar-label { flex: 1 1 auto; }

/* سازگاری نام قدیمی */
.sales-mega-panel { /* deprecated alias */ }

/* ─── Command palette / جستجوی هدر ─── */
.erp-cmd-palette {
    position: fixed;
    inset: 0;
    z-index: 20060;
}
.erp-cmd-palette.d-none { display: none !important; }
.erp-cmd-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.erp-cmd-dialog {
    position: relative;
    width: min(560px, calc(100vw - 24px));
    margin: 12vh auto 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
    overflow: hidden;
    direction: rtl;
}
.erp-cmd-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #eef2f7;
}
.erp-cmd-search-icon { color: #94a3b8; }
.erp-cmd-input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    font-size: 1rem;
    background: transparent;
    min-width: 0;
}
.erp-cmd-kbd {
    font-size: 0.72rem;
    padding: 3px 7px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}
.erp-cmd-results {
    max-height: min(420px, 52vh);
    overflow: auto;
    padding: 8px;
}
.erp-cmd-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: #1e293b;
}
.erp-cmd-item i { margin-top: 3px; color: #64748b; width: 1.1rem; text-align: center; }
.erp-cmd-item.is-active,
.erp-cmd-item:hover { background: #f0f7fb; }
.erp-cmd-item-label { display: block; font-weight: 600; font-size: 0.92rem; }
.erp-cmd-item-path { display: block; font-size: 0.75rem; color: #94a3b8; margin-top: 2px; }
.erp-cmd-empty { padding: 24px; text-align: center; }
.erp-cmd-foot { padding: 8px 16px 12px; border-top: 1px solid #eef2f7; }

/* ─── هدر دوردیفی ─── */
.topbar.topbar--erp {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible;
}
.topbar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    width: 100%;
}
.topbar-row-main {
    padding: 10px 16px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.topbar-row-sub {
    padding: 6px 16px 10px;
    gap: 0.65rem;
}
.topbar-search {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 42rem;
    margin-inline: auto;
}
.topbar-search-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border: 1px solid #dbe3ec;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    text-align: right;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.topbar-search-btn:hover,
.topbar-search-btn:focus {
    background: #fff;
    border-color: #2081af;
    box-shadow: 0 0 0 3px rgba(32, 129, 175, 0.12);
    outline: none;
    color: #334155;
}
.topbar-search-btn .fa-search { flex: 0 0 auto; }
.topbar-search-placeholder {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}
.topbar-search-kbd {
    flex: 0 0 auto;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #94a3b8;
    font-family: ui-monospace, monospace;
    direction: ltr;
}
.topbar-icon-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid #dbe3ec;
    background: #fff;
    color: #475569;
    text-decoration: none;
    position: relative;
}
.topbar-icon-btn:hover {
    border-color: #2081af;
    color: #2081af;
    background: #f0f7fb;
}
.topbar-utils {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.topbar-utils::-webkit-scrollbar { display: none; }
.topbar-util-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
    flex: 0 0 auto;
}
.topbar-util-chip:hover {
    border-color: #2081af;
    color: #17698f;
    background: #f0f7fb;
}
.topbar-util-chip i { font-size: 0.78rem; }
.topbar.topbar--erp .topbar-start {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: none;
    overflow: visible;
}
.topbar.topbar--erp .topbar-end {
    flex: 0 0 auto !important;
}
.topbar.topbar--erp .page-title {
    flex: 1 1 auto !important;
    min-width: 8rem !important;
    font-size: 1rem !important;
}
@media (max-width: 991px) {
    .topbar-search { max-width: none; }
    .topbar-search-kbd { display: none; }
    .topbar-util-chip span { display: none; }
    .topbar-util-chip { padding: 7px 9px; border-radius: 10px; }
}
@media (max-width: 768px) {
    .topbar-row-main { flex-wrap: wrap; }
    .topbar-search { order: 3; flex: 1 1 100%; max-width: none; }
    .topbar.topbar--erp .topbar-start {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: 100%;
        overflow: hidden;
    }
    .topbar.topbar--erp .topbar-end {
        flex: 0 1 auto !important;
        min-width: 0;
        max-width: 58%;
    }
    .topbar.topbar--erp .page-title {
        min-width: 0 !important;
    }
}
.ui-float-portal.list-group .list-group-item,
.ui-float-portal .list-group-item {
    border-left: 0;
    border-right: 0;
}
.ui-float-portal.list-group .list-group-item:first-child,
.ui-float-portal .list-group-item:first-child {
    border-top: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.ui-float-portal.list-group .list-group-item:last-child,
.ui-float-portal .list-group-item:last-child {
    border-bottom: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}
.ui-float-root > .dropdown-menu,
.dropdown-menu.ui-float-bs {
    z-index: var(--z-ui-float) !important;
}

/* پیشنهاد جستجوی خدمات/کالا — روی body تا زیر table-responsive بریده نشود */
.billable-suggest-portal {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.billable-suggest-portal .list-group-item {
    border-left: 0;
    border-right: 0;
}
.billable-suggest-portal .list-group-item:first-child {
    border-top: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.billable-suggest-portal .list-group-item:last-child {
    border-bottom: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Product picker — جستجوی کالا انبار/فروش */
.product-search-wrap {
    position: relative;
    min-width: 180px;
}
.product-search-wrap .product-pick-btn {
    flex: 0 0 auto;
}
.product-suggest-portal {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.product-suggest-portal .list-group-item {
    border-left: 0;
    border-right: 0;
}
.product-suggest-portal .list-group-item:first-child {
    border-top: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.product-suggest-portal .list-group-item:last-child {
    border-bottom: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Customer picker — جستجوی طرف‌حساب فاکتور/اسناد */
.customer-search-wrap {
    position: relative;
    min-width: 160px;
}
.customer-search-wrap > select.customer-id {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.customer-search-wrap .customer-pick-btn {
    flex: 0 0 auto;
}

/* User picker — select مخفی است؛ فقط جستجو دیده می‌شود */
.user-search-wrap {
    position: relative;
    min-width: 160px;
}
.user-search-wrap > select.user-id {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
.user-search-wrap .user-pick-btn {
    flex: 0 0 auto;
}
.user-suggest-portal {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.customer-suggest-portal {
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.customer-suggest-portal .list-group-item {
    border-left: 0;
    border-right: 0;
}
.customer-suggest-portal .list-group-item:first-child {
    border-top: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.customer-suggest-portal .list-group-item:last-child {
    border-bottom: 0;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* Mobile: فرم‌ها خوانا — خدمت/کالا به‌صورت جدول افقی (نه کارت) */
@media (max-width: 768px) {
    .form-card {
        padding: 14px;
    }

    .main-wrapper,
    .content-area {
        min-width: 0;
        max-width: 100%;
    }
    .content-area {
        overflow-x: hidden;
    }

    .form-control,
    .form-select,
    textarea.form-control {
        font-size: 16px;
        min-height: 44px;
        padding: 10px 12px;
    }

    textarea.form-control {
        min-height: 96px;
    }

    .dynamic-table-wrap,
    .table-responsive.dynamic-table-wrap {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        margin-inline: 0;
        padding-inline: 0;
    }

    .dynamic-table {
        display: table;
        width: 100%;
        min-width: 640px;
        table-layout: fixed;
        margin: 0;
    }

    .dynamic-table-wrap.hide-billable-prices .dynamic-table {
        min-width: 480px;
    }

    .dynamic-table thead {
        display: table-header-group;
    }

    .dynamic-table tbody {
        display: table-row-group;
    }

    .dynamic-table tr {
        display: table-row;
        background: transparent;
        border: none;
        border-radius: 0;
        margin: 0;
        padding: 0;
    }

    .dynamic-table td,
    .dynamic-table th {
        display: table-cell;
        max-width: none;
        min-width: 0;
        padding: 6px 4px !important;
        border: 1px solid var(--border, #e0e0e0) !important;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
    }

    .dynamic-table th.col-desc,
    .dynamic-table td.col-desc {
        width: 56% !important;
        text-align: right;
        white-space: normal;
        min-width: 160px;
    }

    .dynamic-table td[data-label]::before {
        content: none;
        display: none;
    }

    .dynamic-table th.col-row,
    .dynamic-table td.col-row {
        width: 32px !important;
        max-width: 32px !important;
        font-weight: 600;
        font-size: 11px;
        color: var(--primary, #2081af);
        padding-left: 2px !important;
        padding-right: 2px !important;
    }

    .dynamic-table th.col-action,
    .dynamic-table td.col-action {
        width: 68px !important;
        position: sticky;
        left: 0;
        z-index: 6;
        background: #fff;
        box-shadow: 6px 0 14px rgba(0, 0, 0, 0.1);
    }

    .billable-composer .billable-draft-row td.col-action {
        background: rgba(232, 242, 255, 0.98);
    }

    .dynamic-table input,
    .dynamic-table .form-control {
        width: 100% !important;
        min-width: 0;
        min-height: 40px;
        font-size: 14px;
        padding: 6px 8px;
        box-sizing: border-box;
    }

    .dynamic-table .billable-search-wrap {
        width: 100%;
        min-width: 140px;
    }

    .dynamic-table .total-cell {
        font-size: 13px;
        font-weight: 600;
        background: transparent;
        border-style: solid !important;
        border-radius: 0;
    }

    .dynamic-table .btn-remove-row {
        width: 100%;
        min-height: 36px;
        padding: 4px 6px;
        border: 1px solid #f5c2c7;
        border-radius: 4px;
        background: #fff5f5;
        color: #dc3545;
        font-size: 12px;
        white-space: nowrap;
    }

    .billable-draft-actions {
        flex-direction: row;
        gap: 4px;
        width: auto;
        min-width: 0;
    }

    .billable-draft-actions .btn {
        width: 30px;
        height: 30px;
        min-height: 30px;
        font-size: 12px;
        font-weight: 600;
        padding: 0;
        white-space: nowrap;
    }
}

/* ─── Desktop sidebar collapse (icon rail) ───────────────── */
:root {
    --sidebar-collapsed-width: 72px;
}

@media (min-width: 769px) {
    body.sidebar-collapsed {
        --sidebar-width: var(--sidebar-collapsed-width);
    }

    body.sidebar-collapsed .sidebar-brand {
        padding: 12px 6px;
    }
    body.sidebar-collapsed .sidebar-brand .company-name,
    body.sidebar-collapsed .sidebar-brand .system-name {
        display: none;
    }
    body.sidebar-collapsed .sidebar-logo img {
        max-width: 40px !important;
        max-height: 40px !important;
    }

    /* ریل آیکونی: فقط دامنه‌های L1 و پین‌ها */
    body.sidebar-collapsed .sidebar-tree .tree-node-group > .tree-children {
        display: none !important;
    }
    body.sidebar-collapsed .sidebar-tree .tree-item-parent {
        display: flex !important;
        justify-content: center;
        align-items: center;
        margin: 3px 8px;
        padding: 0;
    }
    body.sidebar-collapsed .sidebar-tree .tree-toggle {
        display: none !important;
    }
    body.sidebar-collapsed .sidebar-tree .tree-parent-label {
        justify-content: center;
        width: 100%;
        padding: 11px 0;
        border-radius: 8px;
        gap: 0;
    }
    body.sidebar-collapsed .sidebar .sidebar-tree .tree-parent-text,
    body.sidebar-collapsed .sidebar .sidebar-tree .nav-context-origin-tag,
    body.sidebar-collapsed .sidebar .sidebar-tree .tree-item-leaf span,
    body.sidebar-collapsed .sidebar .sidebar-nav .nav-link span,
    body.sidebar-collapsed .sidebar .sidebar-label {
        display: none !important;
    }
    /* مگامنو بیرون سایدبار است؛ جمع‌شدن ریل نباید اسم آیتم‌های پنل را مخفی کند */
    body.sidebar-collapsed .erp-mega-panel .sidebar-label,
    body.sidebar-collapsed .erp-mega-link .sidebar-label,
    body.sidebar-collapsed .erp-mega-link span {
        display: inline !important;
        flex: 1 1 auto;
        width: auto;
        overflow: visible;
        white-space: nowrap;
    }
    body.sidebar-collapsed .sidebar-tree .tree-item-leaf {
        justify-content: center;
        gap: 0;
        margin: 3px 8px;
        padding: 11px 0;
        border-radius: 8px;
    }
    body.sidebar-collapsed .sidebar-tree .tree-parent-icon,
    body.sidebar-collapsed .sidebar-tree .tree-item-leaf i,
    body.sidebar-collapsed .sidebar-nav .nav-link i {
        width: 30px !important;
        height: 30px;
        min-width: 30px;
        font-size: 14px !important;
        margin: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    body.sidebar-collapsed .tree-node-group.is-mega-open > .tree-item-parent .tree-parent-label,
    body.sidebar-collapsed .tree-node-group.has-active > .tree-item-parent .tree-parent-label {
        background: rgba(32, 129, 175, 0.35);
    }

    body.sidebar-collapsed .sidebar-footer {
        padding: 10px 6px;
        text-align: center;
    }
    body.sidebar-collapsed .sidebar-user-card {
        justify-content: center;
        margin-bottom: 8px;
    }
    body.sidebar-collapsed .sidebar-user-meta {
        display: none;
    }
    body.sidebar-collapsed .sidebar-footer .btn-logout {
        padding: 8px;
        width: auto;
        min-width: 40px;
        margin: 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    body.sidebar-collapsed .sidebar-footer .btn-logout .sidebar-label {
        display: none;
    }

    body.sidebar-collapsed .sidebar-nav {
        padding: 8px 0;
    }
}

.btn-sidebar-collapse {
    display: none;
}
@media (min-width: 769px) {
    .btn-sidebar-collapse {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        border: 1px solid #d0d7de;
        border-radius: 8px;
        background: #fff;
        color: #475569;
        cursor: pointer;
        line-height: 1;
    }
    .btn-sidebar-collapse:hover {
        border-color: #2081af;
        color: #2081af;
        background: #f0f7fb;
    }
    body.sidebar-collapsed .btn-sidebar-collapse .icon-collapse { display: none; }
    body.sidebar-collapsed .btn-sidebar-collapse .icon-expand { display: inline-block; }
    body:not(.sidebar-collapsed) .btn-sidebar-collapse .icon-expand { display: none; }
    body:not(.sidebar-collapsed) .btn-sidebar-collapse .icon-collapse { display: inline-block; }
}

/* ─── پیوست قبل/بعد فرم فنی ─── */
.task-media-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.task-media-actions .js-media-submit {
    min-height: 40px;
}
.task-media-source-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1080;
}
.task-media-source-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 1081;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.task-media-source-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: right;
    padding: 14px 12px;
    border-radius: 10px;
    font-size: 15px;
    color: #0f2744;
    cursor: pointer;
}
.task-media-source-item i {
    width: 1.25rem;
    text-align: center;
    color: #2081af;
}
.task-media-source-item:hover,
.task-media-source-item:focus {
    background: #f0f7fb;
}
.task-media-source-cancel {
    margin-top: 4px;
    width: 100%;
    border: 0;
    background: #f8fafc;
    color: #64748b;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    cursor: pointer;
}
.task-media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
}
.task-media-chip {
    position: relative;
    width: 88px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}
.task-media-chip img {
    display: block;
    width: 100%;
    height: 72px;
    object-fit: cover;
}
.task-media-chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 72px;
    color: #64748b;
    font-size: 1.4rem;
}
.task-media-chip-name {
    display: block;
    padding: 4px 6px;
    font-size: 10px;
    line-height: 1.3;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-media-chip-remove {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}
.task-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}
.task-media-item {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    background: #fff;
    color: inherit;
}
.task-media-item img {
    display: block;
    width: 100%;
    height: 88px;
    object-fit: cover;
}
.task-media-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 88px;
    background: #f1f5f9;
    color: #dc2626;
    font-size: 1.5rem;
}
.task-media-name {
    display: block;
    padding: 5px 6px;
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 768px) {
    .task-media-actions .js-media-submit {
        min-height: 44px;
        width: 100%;
    }
}

/* ─── آپلود پیشرفته تصویر کالا ─── */
.product-image-composer {
    outline: none;
}
.product-image-drop {
    border: 1.5px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.product-image-drop:hover,
.product-image-drop.is-dragover {
    border-color: #2081af;
    background: #f0f7fb;
    box-shadow: 0 0 0 3px rgba(32, 129, 175, .12);
}
.product-image-drop.is-busy {
    opacity: .65;
    pointer-events: none;
}
.product-image-drop-icon {
    font-size: 1.75rem;
    color: #2081af;
    margin-bottom: 8px;
}
.product-image-drop-title {
    font-weight: 600;
    color: #0f2744;
    margin-bottom: 4px;
}
.product-image-drop-hint {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 12px;
}
.product-image-drop-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.product-image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.product-image-chip {
    position: relative;
    width: 104px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.product-image-chip img {
    display: block;
    width: 100%;
    height: 88px;
    object-fit: cover;
}
.product-image-chip-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 88px;
    color: #64748b;
}
.product-image-chip-name {
    display: block;
    padding: 4px 6px;
    font-size: 10px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-image-chip-remove {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .75);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.product-image-chip-primary {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .65);
    color: #fbbf24;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.product-image-chip.is-primary {
    border-color: #2081af;
    box-shadow: 0 0 0 2px rgba(32, 129, 175, .25);
}
.product-image-chip.is-primary .product-image-chip-primary {
    background: #2081af;
    color: #fff;
}
.product-image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.product-image-thumb {
    position: relative;
    width: 120px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.product-image-thumb.is-primary {
    border-color: #2081af;
    box-shadow: 0 0 0 2px rgba(32, 129, 175, .2);
}
.product-image-thumb img {
    display: block;
    width: 100%;
    height: 100px;
    object-fit: cover;
}
.product-image-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #2081af;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 999px;
}
.product-image-thumb-actions {
    display: flex;
    gap: 4px;
    padding: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

/* تب‌های کارت حساب کالا (سبک حسابفا) */
.product-card-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: 1px solid var(--border, #e2e8f0);
    gap: 0;
    -webkit-overflow-scrolling: touch;
}
.product-card-tabs .nav-item {
    flex: 1 1 0;
    min-width: max-content;
    text-align: center;
}
.product-card-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: #64748b;
    font-size: 13px;
    font-weight: 600;
    padding: 0.7rem 0.85rem;
    white-space: nowrap;
}
.product-card-tabs .nav-link:hover {
    color: #2081af;
    border-color: transparent;
}
.product-card-tabs .nav-link.active {
    color: #2081af;
    background: transparent;
    border-bottom-color: #2081af;
}
@media (max-width: 768px) {
    .product-card-tabs .nav-item {
        flex: 0 0 auto;
    }
}

/* فیلتر جمع‌شونده مکاتبات */
.requests-filter {
    border: 1px solid var(--border, #e8ecf0);
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
}
.requests-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}
.requests-filter-summary {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.requests-filter-summary.is-active {
    color: var(--primary, #2081af) !important;
    font-weight: 600;
}
.requests-filter-toggle .requests-filter-chevron {
    font-size: 11px;
    transition: transform .2s ease;
}
.requests-filter-toggle[aria-expanded="true"] .requests-filter-chevron {
    transform: rotate(180deg);
}
.requests-filter-form {
    padding-top: 4px;
    border-top: 1px dashed var(--border, #e8ecf0);
}

/* ─── Global nav / submit loading (branded) ───────────────── */
.app-nav-loading {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: rgba(12, 28, 42, 0.72);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    transition: opacity 0.18s ease, visibility 0.18s ease;
}
.app-nav-loading.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.app-nav-loading.is-instant {
    transition: none !important;
}
.app-nav-loading.is-instant .app-nav-loading__panel {
    transition: none !important;
    transform: none !important;
}
.app-nav-loading__panel {
    width: min(280px, 100%);
    padding: 1.75rem 1.5rem 1.4rem;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 18px 48px rgba(12, 28, 42, 0.28);
    text-align: center;
    transform: translateY(10px) scale(0.97);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-transform: translateZ(0);
}
.app-nav-loading.is-visible .app-nav-loading__panel {
    transform: translateY(0) scale(1);
}
.app-nav-loading__orb {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-nav-loading__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(32, 129, 175, 0.18);
    border-top-color: var(--primary, #2081af);
    border-right-color: rgba(32, 129, 175, 0.55);
    animation: app-nav-spin 0.9s linear infinite;
}
.app-nav-loading__ring::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-bottom-color: rgba(32, 129, 175, 0.35);
    animation: app-nav-spin 1.4s linear infinite reverse;
}
.app-nav-loading__logo-wrap {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: var(--primary-light, #edf9ff);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    animation: app-nav-breathe 1.8s ease-in-out infinite;
}
.app-nav-loading__logo {
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
}
.app-nav-loading__icon {
    font-size: 28px;
    color: var(--primary, #2081af);
}
.app-nav-loading__title {
    margin: 0 0 0.25rem;
    font-size: 15px;
    font-weight: 700;
    color: #1a2b3a;
}
.app-nav-loading__subtitle {
    margin: 0;
    font-size: 12.5px;
    color: #6b7c8c;
}
@keyframes app-nav-spin {
    to { transform: rotate(360deg); }
}
@keyframes app-nav-breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
@media (max-width: 768px) {
    .app-nav-loading {
        background: rgba(12, 28, 42, 0.82);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .app-nav-loading__panel {
        width: min(300px, calc(100vw - 40px));
        padding: 1.5rem 1.25rem 1.25rem;
    }
}
@media (prefers-reduced-motion: reduce) {
    .app-nav-loading,
    .app-nav-loading__panel {
        transition: none;
    }
    .app-nav-loading__ring,
    .app-nav-loading__ring::after,
    .app-nav-loading__logo-wrap {
        animation: none;
    }
}

/*
 * استاندارد ظاهر جدول داده (مرجع: مکاتبات)
 * بعد از تم لود می‌شود تا border/alignment تم را override کند.
 * مستثنی: dynamic-table، no-std-table
 */
.content-area .form-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table),
.content-area .table-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table),
.content-area .form-card > table.table:not(.dynamic-table):not(.no-std-table),
.content-area .list-table-view > table.table {
    border-collapse: separate !important;
    border-spacing: 0;
    margin-bottom: 0;
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}
.content-area .form-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > :is(thead, tbody) > tr > :is(th, td),
.content-area .table-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > :is(thead, tbody) > tr > :is(th, td),
.content-area .form-card > table.table:not(.dynamic-table):not(.no-std-table) > :is(thead, tbody) > tr > :is(th, td),
.content-area .list-table-view > table.table > :is(thead, tbody) > tr > :is(th, td) {
    border: 1px solid #e2e8f0 !important;
    vertical-align: middle;
    padding: 0.45rem 0.55rem;
    white-space: nowrap;
}
.content-area .form-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > thead > tr > th,
.content-area .table-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > thead > tr > th,
.content-area .form-card > table.table:not(.dynamic-table):not(.no-std-table) > thead > tr > th,
.content-area .list-table-view > table.table > thead > tr > th {
    background: #f8fafc !important;
    font-weight: 700;
    text-align: start;
    min-width: 5.5rem;
    position: sticky;
    top: 0;
    z-index: 5;
}
.content-area .list-table-view > table.table > thead > tr.list-filter-row > th {
    top: var(--list-thead-h, 2.4rem);
    z-index: 4;
    background: #f7f9fb !important;
}
.content-area .form-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > tbody > tr > td,
.content-area .table-card .table-responsive > table.table:not(.dynamic-table):not(.no-std-table) > tbody > tr > td,
.content-area .list-table-view > table.table > tbody > tr > td {
    text-align: start;
    min-width: 5.5rem;
}
.content-area .form-card .table-responsive > table.table :is(th, td)[dir="ltr"],
.content-area .table-card .table-responsive > table.table :is(th, td)[dir="ltr"],
.content-area .list-table-view > table.table :is(th, td)[dir="ltr"] {
    text-align: left;
    font-variant-numeric: tabular-nums;
}
.content-area .form-card .table-responsive > table.table td:has(.form-control),
.content-area .form-card .table-responsive > table.table td:has(.form-select),
.content-area .form-card .table-responsive > table.table td:has(input),
.content-area .table-card .table-responsive > table.table td:has(.form-control),
.content-area .table-card .table-responsive > table.table td:has(input) {
    white-space: normal;
    min-width: 6.5rem;
}
.content-area .form-card .table-responsive:not(.dynamic-table-wrap),
.content-area .table-card .table-responsive:not(.dynamic-table-wrap),
.content-area .list-table-view.table-responsive,
.content-area .list-enhance .list-table-view {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    max-height: calc(100vh - 11rem);
}

/* قفل عرض موبایل: اسکرول افقی صفحه (نه اسکرول داخل جدول) */
@media (max-width: 991.98px) {
    html {
        overflow-x: hidden;
        max-width: 100%;
    }
    body {
        max-width: 100%;
        overflow-x: hidden;
    }
    .main-wrapper,
    .content-area,
    .form-card,
    .table-card,
    .list-enhance,
    .tc-wrap,
    .tc-card {
        max-width: 100%;
        min-width: 0;
    }
    .content-area {
        overflow-x: hidden;
        padding-inline: 12px;
    }
}

/* فیلدهای نامعتبر — هایلایت قرمز پس از خطا (سراسری) */
.form-control.is-invalid,
.form-select.is-invalid,
textarea.is-invalid,
.was-validated .form-control:invalid,
.was-validated .form-select:invalid,
.form-was-validated .form-control:invalid,
.form-was-validated .form-select:invalid {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, .18) !important;
}
.form-control.is-invalid:focus,
.form-select.is-invalid:focus,
.was-validated .form-control:invalid:focus,
.was-validated .form-select:invalid:focus,
.form-was-validated .form-control:invalid:focus,
.form-was-validated .form-select:invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, .28) !important;
}
.input-group.is-invalid .form-control,
.input-group.is-invalid .form-select,
.input-group.is-invalid .btn,
.user-search-wrap.is-invalid .form-control,
.customer-search-wrap.is-invalid .form-control,
.user-search-wrap.is-invalid .btn,
.customer-search-wrap.is-invalid .btn {
    border-color: #dc3545 !important;
}
.user-search-wrap.is-invalid .form-control,
.customer-search-wrap.is-invalid .form-control,
.input-group.is-invalid .form-control {
    background-color: #fff5f5 !important;
}
.invalid-feedback.d-block,
.field-error-msg {
    display: block;
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 0.3rem;
}


