/* =========================================================================
   شیما سیستم — Premium Finance SaaS UI (پوسته‌ی آبی)
   یک لایه‌ی طراحی روی Bootstrap 5 RTL. تمام کلاس‌های قبلی حفظ شده‌اند و فقط
   بازطراحی شده‌اند؛ هیچ رفتار/منطقی تغییر نکرده است.
   ========================================================================= */

:root {
    /* --- Surfaces (خاکستری-آبی خیلی روشن، کارت‌های سفید) --- */
    --app-bg: #f4f6f9;
    --app-surface: #ffffff;
    --app-surface-soft: #f1f5fd;
    --app-surface-hover: #f7f9fc;
    --app-border: #e9edf3;
    --app-border-strong: #dbe1ea;

    /* --- Text --- */
    --app-text: #111827;
    --app-text-soft: #374151;
    --app-muted: #8a93a3;
    --app-faint: #a3abb8;
    --app-placeholder: #a3abb8;

    /* --- Brand / actions (آبی، هویت اصلی «شیما سیستم»؛ ته‌رنگ‌ها: آبی کم‌رنگ و سفید) --- */
    --app-primary: #2563eb;
    --app-primary-dark: #1d4ed8;
    --app-primary-soft: #eaf1fe;
    --app-on-primary: #ffffff;
    --app-accent: #3b82f6;
    --app-accent-soft: #eff5ff;
    --app-primary-light: #bfd4fd;

    /* --- Semantic --- */
    --app-success: #10b981;
    --app-success-dark: #047857;
    --app-success-soft: #e7f8f1;
    --app-warning: #f59e0b;
    --app-warning-dark: #b45309;
    --app-warning-soft: #fef5e6;
    --app-danger: #ef4444;
    --app-danger-soft: #fdecec;

    /* Legacy alias still referenced by a couple of inline templates */
    --app-table-head: #f6f8fb;

    /* --- Shape (گوشه‌های گردتر) --- */
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    /* --- Elevation (سایه‌ی نرم و خنثی) --- */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px -6px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 32px -12px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.2);

    /* --- Layout --- */
    --sidebar-w: 264px;
    --topbar-h: 60px;
    --content-max: 1440px;

    /* «Vazirmatn FD»: همان فونت با ارقام فارسی (فقط نمایش؛ داده‌ها و ورودی‌ها همان ارقام قبلی‌اند) */
    --font-fa: "Vazirmatn FD", "Vazirmatn", "IRANSansX", "IRANSans", "Segoe UI", Tahoma, sans-serif;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--app-border-strong) transparent;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-thumb {
    background: var(--app-border-strong);
    border-radius: var(--radius-pill);
    border: 2px solid var(--app-bg);
}

body,
.app-body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: var(--font-fa);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "ss02";
}

/* =========================================================================
   Layout shell
   ========================================================================= */

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

/* legacy wrapper — kept harmless in case anything still references it */
.app-layout {
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    height: 100vh;
    overflow-y: auto;
    background: var(--app-surface);
    border-inline-start: 1px solid var(--app-border);
    padding: 14px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 24px;
    background: rgba(248, 250, 252, 0.82);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--app-border);
}

.app-topbar__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--app-text);
    letter-spacing: -0.01em;
    min-height: 1em;
}

.app-topbar__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--app-muted);
    font-size: 12.5px;
}

.topbar-chip {
    display: inline-flex;
    align-items: center;
    max-width: 180px;
    padding: 5px 11px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    color: var(--app-text-soft);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

a.topbar-chip--link:hover {
    border-color: var(--app-primary-light);
    color: var(--app-primary-dark);
    background: var(--app-primary-soft);
    text-decoration: none;
}

.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-pill);
    background: var(--app-surface);
    color: var(--app-text);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
}

.topbar-user::after {
    margin-right: 2px;
}

.topbar-user__icon {
    width: 15px;
    height: 15px;
    color: var(--app-muted);
}

.topbar-user:hover,
.topbar-user:focus,
.topbar-user.show {
    border-color: var(--app-border-strong);
    background: var(--app-surface-soft);
    color: var(--app-text);
}

.app-topbar .dropdown-menu {
    min-width: 168px;
    border: 1px solid var(--app-border);
    border-radius: var(--radius);
    padding: 6px;
    font-size: 13px;
}

.app-topbar .dropdown-item {
    border-radius: 8px;
    padding: 8px 10px;
}

.app-topbar .dropdown-item.text-danger:hover {
    background: var(--app-danger-soft);
    color: var(--app-danger);
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-sm);
    background: var(--app-surface);
    color: var(--app-text-soft);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.app-main {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 24px;
    flex: 1 1 auto;
}

/* =========================================================================
   Brand + sidebar nav
   ========================================================================= */

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--app-text);
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: -0.01em;
    text-decoration: none;
    padding: 6px 8px 14px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--app-border);
}

.app-brand:hover {
    color: var(--app-text);
}

.app-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(145deg, var(--app-accent), var(--app-primary-dark));
    color: #fff;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.app-brand-mark::after {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(145deg, #fff 40%, var(--app-primary-light) 40%);
}

.app-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.app-brand-text small {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--app-faint);
    letter-spacing: 0.02em;
}

.app-nav-search {
    position: relative;
    margin: 4px 0 8px;
}

.app-nav-search-icon {
    position: absolute;
    top: 50%;
    right: 11px;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--app-faint);
    pointer-events: none;
}

.app-nav-search-input {
    width: 100%;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-sm);
    background: var(--app-surface-soft);
    font-size: 13px;
    font-family: inherit;
    padding: 8px 34px 8px 10px;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.app-nav-search-input::placeholder {
    color: var(--app-placeholder);
}

.app-nav-search-input:focus {
    outline: none;
    border-color: var(--app-accent);
    background: #fff;
    box-shadow: var(--shadow-focus);
}

.app-nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1 1 auto;
    padding-bottom: 8px;
}

.app-nav-divider {
    height: 1px;
    background: var(--app-border);
    margin: 8px 8px;
    opacity: 0.7;
}

.app-nav-group {
    display: grid;
    gap: 2px;
    padding: 2px 0;
}

.app-nav-group.is-search-hidden,
.app-nav-subgroup.is-search-hidden {
    display: none;
}

.app-nav-group-toggle,
.app-nav-subgroup-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--app-text);
    padding: 9px 10px;
    border-radius: 12px;
    font-weight: 700;
    transition: background 0.14s, color 0.14s;
    box-shadow: none;
}

/* عنوان ماژول فقط با hover روشن می‌شود؛ فوکوس/active صفحه نباید آبی بماند */
.app-nav-group-toggle:focus,
.app-nav-group-toggle:focus-visible,
.app-nav-group-toggle:active,
.app-nav-subgroup-toggle:focus,
.app-nav-subgroup-toggle:focus-visible,
.app-nav-subgroup-toggle:active {
    background: none;
    color: var(--app-text);
    box-shadow: none;
    outline: none;
}

.app-nav-group-toggle:hover {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

.app-nav-group-toggle .nav-icon {
    width: 18px;
    height: 18px;
    color: var(--app-text-soft);
    flex-shrink: 0;
}

.app-nav-group-toggle .app-nav-title {
    flex: 1 1 auto;
    text-align: start;
}

/* عنوان ماژول = لایهٔ اصلی منو (پررنگ‌تر از زیرمنو) */
.app-nav-title {
    color: inherit;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-transform: none;
    line-height: 1.4;
}

.app-nav-subgroup-toggle {
    color: var(--app-text-soft);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 10px;
}

.app-nav-subgroup-toggle:hover {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

.app-nav-subgroup-toggle .nav-icon {
    width: 16px;
    height: 16px;
}

.app-nav-subgroup-toggle .nav-label {
    flex: 1;
    text-align: right;
}

.nav-chevron {
    width: 13px;
    height: 13px;
    color: currentColor;
    transition: transform 0.18s ease;
    flex-shrink: 0;
    opacity: 0.75;
}

.is-collapsed > .app-nav-group-toggle .nav-chevron,
.is-collapsed > .app-nav-subgroup-toggle .nav-chevron {
    transform: rotate(-90deg);
}

.app-nav-group-body {
    display: grid;
    gap: 2px;
    overflow: hidden;
    max-height: 1400px;
    transition: max-height 0.22s ease;
}

.is-collapsed > .app-nav-group-body {
    max-height: 0;
}

.is-search-open > .app-nav-group-body {
    max-height: 1400px !important;
}

.app-nav-subgroup {
    display: grid;
    gap: 2px;
}

.app-nav-subgroup .app-nav-group-body {
    padding-right: 12px;
    position: relative;
}

.app-nav-subgroup .app-nav-group-body::before {
    content: "";
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    width: 1px;
    background: var(--app-border);
}

/* لینک سطح‌اول (مثل پیشخوان) = هم‌وزن عنوان ماژول */
.app-nav-links > .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--app-text);
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.4;
    padding: 9px 10px;
    transition: background 0.14s, color 0.14s;
}

.app-nav-links > .nav-link .nav-icon {
    width: 18px;
    height: 18px;
    color: var(--app-text-soft);
}

.app-nav-links > .nav-link:hover {
    background: var(--app-surface-soft);
    color: var(--app-text);
}

.app-nav-links > .nav-link:hover .nav-icon {
    color: var(--app-text-soft);
}

.app-nav-links > .nav-link.active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
}

.app-nav-links > .nav-link.active .nav-icon {
    color: var(--app-primary);
}

/* زیرمنو = لایهٔ دوم، کمرنگ‌تر از ماژول */
.app-nav-group-body > .nav-link,
.app-nav-group-body .app-nav-tools .nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--app-muted);
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
    padding: 7px 10px;
    margin-inline-start: 8px;
    transition: background 0.14s, color 0.14s;
}

.app-nav-group-body > .nav-link .nav-icon,
.app-nav-group-body .app-nav-tools .nav-link .nav-icon {
    width: 15px;
    height: 15px;
    color: var(--app-faint);
    flex-shrink: 0;
}

.app-nav-section-title {
    display: block;
    margin-block: .45rem .15rem;
    padding-inline: .65rem;
    font-size: .75rem;
    color: #596579;
}

.app-nav-group-body:has(> .app-nav-section-title) > .nav-link:not(.active) {
    color: var(--app-text-soft);
}

.is-search-open .app-nav-section-title {
    display: none;
}

.stock-source-list {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 10px;
}

.stock-source-row {
    padding: .8rem 1rem;
    overflow-wrap: anywhere;
}

.stock-source-row + .stock-source-row {
    border-top: 1px solid var(--app-border);
}

.stock-source-heading {
    display: grid;
    grid-template-columns: minmax(0, .7fr) minmax(0, 1.25fr) minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1.3fr);
    gap: .65rem;
    align-items: start;
}

.stock-source-heading > div > small {
    display: block;
    color: var(--app-text-soft);
    margin-bottom: .15rem;
}

.stock-source-action { grid-column: -2; justify-self: end; text-align: end; }
.stock-source-items { margin-top: .45rem; }
.stock-source-items summary { color: var(--app-primary); width: fit-content; }
.stock-source-quantities { table-layout: fixed; margin: .6rem 0 0; }
.stock-source-quantities th:first-child { width: 30%; }

@media (max-width: 900px) {
    .stock-source-heading { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stock-source-action { grid-column: auto; justify-self: start; text-align: start; }
}

.app-nav-group-body > .nav-link:hover,
.app-nav-group-body .app-nav-tools .nav-link:hover {
    background: var(--app-surface-hover);
    color: var(--app-text-soft);
    text-decoration: none;
}

.app-nav-group-body > .nav-link:hover .nav-icon,
.app-nav-group-body .app-nav-tools .nav-link:hover .nav-icon {
    color: var(--app-muted);
}

.app-nav-group-body > .nav-link.active,
.app-nav-group-body .app-nav-tools .nav-link.active {
    background: var(--app-primary-soft);
    color: var(--app-primary);
    font-weight: 700;
}

.app-nav-group-body > .nav-link.active .nav-icon,
.app-nav-group-body .app-nav-tools .nav-link.active .nav-icon {
    color: var(--app-primary);
}

.nav-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: var(--app-faint);
    transition: color 0.14s;
}

.app-nav-links .nav-link .nav-label {
    flex: 1 1 auto;
    min-width: 0;
}

.app-nav-links .nav-link.nav-link-hidden {
    display: none;
}

.nav-label mark {
    background: #fde68a;
    color: inherit;
    padding: 0 1px;
    border-radius: 3px;
}

/* =========================================================================
   Typography
   ========================================================================= */

h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5 {
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: -0.015em;
    color: var(--app-text);
}

h1, .h1 { font-size: 24px; }
h2, .h2 { font-size: 20px; }
h3, .h3 { font-size: 18px; }
h4, .h4 { font-size: 16px; }
h5, .h5 { font-size: 14px; }

a {
    color: var(--app-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.text-muted {
    color: var(--app-muted) !important;
}

.text-danger {
    color: var(--app-danger) !important;
}

small, .small {
    font-size: 12px;
    line-height: 1.6;
}

/* =========================================================================
   Page header / breadcrumb / icon toolbar (Hesabfa-like)
   ========================================================================= */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: 0 0 18px;
    padding: 4px 0 14px;
    border-bottom: 1px solid var(--app-border);
}

.page-header h1,
.page-header .h3,
.page-header .h4 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--app-text);
}

.breadcrumb-lite {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--app-faint);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 4px;
}

.page-header--compact .breadcrumb-lite {
    display: none;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* نوار ابزار آیکنی — اکشن اصلی؛ بقیه داخل ⋮ */
.page-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-tool {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text-soft);
    text-decoration: none;
    transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.page-tool:hover,
.page-tool:focus-visible {
    background: var(--app-surface-soft);
    color: var(--app-primary);
    border-color: var(--app-primary-light, #93c5fd);
    text-decoration: none;
}

.page-tool--primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: #fff;
}

.page-tool--primary:hover,
.page-tool--primary:focus-visible {
    background: var(--app-primary-dark, #1d4ed8);
    border-color: var(--app-primary-dark, #1d4ed8);
    color: #fff;
}

.page-tool--danger:hover,
.page-tool--danger:focus-visible {
    color: var(--app-danger, #dc2626);
    border-color: rgba(220, 38, 38, 0.35);
    background: #fef2f2;
}

.page-tool .nav-icon,
.page-tool svg {
    width: 17px;
    height: 17px;
}

.page-tool-menu .dropdown-menu {
    min-width: 220px;
    font-size: 13px;
    border-radius: 12px;
    padding: 6px;
}

.page-tool-menu .dropdown-item {
    border-radius: 8px;
    padding: 8px 10px;
}

/* =========================================================================
   App grid: header funnel + double-click sort (Hesabfa-like)
   ========================================================================= */

table.app-grid {
    --app-grid-head-bg: #f8fafc;
    border-color: var(--app-border) !important;
}

table.app-grid > thead > tr > th {
    background: var(--app-grid-head-bg) !important;
    color: var(--app-text-soft) !important;
    font-size: 12.5px;
    font-weight: 700;
    border-color: var(--app-border) !important;
    vertical-align: middle;
    padding: 10px 10px;
}

table.app-grid > thead > tr > th.app-grid-sortable {
    user-select: none;
    white-space: nowrap;
}

table.app-grid .app-grid-th-label {
    cursor: pointer;
}

/*
 * دستگیره روی چپِ فیزیکی ستون: همان خط، عرضِ ستونی را عوض می‌کند
 * که سمت راستِ خط نشسته (رفتار مورد انتظار در RTL).
 */
.app-main .table-responsive > table > thead > tr > th {
    overflow: visible;
}

.app-grid-col-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;
    right: auto;
    width: 16px;
    cursor: col-resize !important;
    z-index: 20;
    touch-action: none;
    user-select: none;
}

.app-grid-col-resizer::after {
    content: '';
    position: absolute;
    top: 12%;
    bottom: 12%;
    left: 6px;
    width: 3px;
    border-radius: 2px;
    background: #cbd5e1;
}

table.app-grid > thead > tr > th:hover > .app-grid-col-resizer::after,
.app-grid-col-resizer.is-dragging::after,
.app-grid-col-resizer:hover::after {
    background: #2563eb;
    width: 3px;
}

body.app-grid-resizing,
body.app-grid-resizing * {
    cursor: col-resize !important;
    user-select: none !important;
}

body.app-grid-resizing iframe {
    pointer-events: none;
}

table.app-grid.is-col-resized {
    table-layout: fixed !important;
}

/* فقط سلول بدنه؛ هدر overflow:visible بماند تا دستگیرهٔ عرض بریده نشود */
table.app-grid.is-col-resized > tbody > tr > td {
    overflow: hidden;
    text-overflow: ellipsis;
}

table.app-grid > thead > tr > th.is-sorted-asc .app-grid-th-label::after,
table.app-grid > thead > tr > th.is-sorted-desc .app-grid-th-label::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: 6px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

table.app-grid > thead > tr > th.is-sorted-asc .app-grid-th-label::after {
    border-bottom: 5px solid var(--app-primary);
}

table.app-grid > thead > tr > th.is-sorted-desc .app-grid-th-label::after {
    border-top: 5px solid var(--app-primary);
}

table.app-grid > thead > tr > th.is-filtered {
    color: var(--app-primary) !important;
}

.app-grid-funnel {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: 4px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--app-faint);
    vertical-align: middle;
    cursor: pointer;
}

.app-grid-funnel svg {
    width: 13px;
    height: 13px;
}

.app-grid-funnel:hover,
.app-grid-funnel.is-active {
    background: var(--app-primary-soft, #eaf1fe);
    color: var(--app-primary);
}

.app-grid-pop {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 8px;
    z-index: 50;
    width: 210px;
    padding: 10px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.app-grid-pop.is-open {
    display: grid;
    gap: 6px;
}

.app-grid-pop-label {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--app-muted);
}

.app-grid-pop-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.app-grid-pop-actions .btn {
    flex: 1;
}

/* ردیف عملیات: آیکن به‌جای متن */
.row-tools {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.row-tool {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--app-muted);
    text-decoration: none;
    line-height: 1;
}

.row-tool:hover,
.row-tool:focus-visible {
    background: var(--app-surface-soft);
    color: var(--app-primary);
    border-color: var(--app-border);
    text-decoration: none;
}

.row-tool--danger:hover,
.row-tool--danger:focus-visible {
    color: var(--app-danger, #dc2626);
    background: #fef2f2;
    border-color: rgba(220, 38, 38, 0.25);
}

.row-tool .nav-icon,
.row-tool svg {
    width: 15px;
    height: 15px;
}

.row-tool.is-disabled,
.row-tool:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* =========================================================================
   Cards / panels
   ========================================================================= */

.card,
form.border,
.table-responsive,
.panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-sm);
}

form.bg-light,
.bg-light {
    background: var(--app-surface-soft) !important;
}

.card-body {
    padding: 18px;
}

.app-card {
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.app-card-header,
.card > .card-header {
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    padding: 14px 18px;
    color: var(--app-text);
}

.app-card .card-body {
    font-size: 14px;
    padding: 18px;
}

.panel {
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--app-border);
}

.panel__title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    font-weight: 700;
    color: var(--app-text);
}

.panel__title svg {
    width: 17px;
    height: 17px;
    color: var(--app-muted);
}

.panel__action {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--app-accent);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.panel__action:hover {
    text-decoration: none;
    color: var(--app-primary);
}

.panel__action svg {
    width: 13px;
    height: 13px;
}

.panel__body {
    padding: 6px;
}

.panel__body--flush {
    padding: 0;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.45;
    min-height: 38px;
    padding: 0.45rem 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.14s, border-color 0.14s, box-shadow 0.14s, transform 0.05s;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    box-shadow: var(--shadow-focus);
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn-sm {
    font-size: 12px;
    min-height: 30px;
    padding: 0.25rem 0.6rem;
    border-radius: 7px;
}

.btn-lg {
    min-height: 44px;
    font-size: 14px;
    padding: 0.6rem 1.2rem;
}

.btn-primary,
.btn-success {
    background: var(--app-primary);
    border-color: var(--app-primary);
    color: var(--app-on-primary);
}

.btn-primary:hover,
.btn-success:hover,
.btn-primary:focus,
.btn-success:focus {
    background: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
    color: #fff;
}

.btn-success {
    background: var(--app-success-dark);
    border-color: var(--app-success-dark);
}

.btn-success:hover,
.btn-success:focus {
    background: #047857;
    border-color: #047857;
}

.btn-outline-primary,
.btn-outline-secondary {
    color: var(--app-text-soft);
    border-color: var(--app-border-strong);
    background: var(--app-surface);
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-primary:focus,
.btn-outline-secondary:focus {
    background: var(--app-surface-soft);
    border-color: var(--app-border-strong);
    color: var(--app-text);
}

.btn-outline-success {
    color: var(--app-success-dark);
    border-color: #a7f3d0;
    background: var(--app-surface);
}

.btn-outline-success:hover,
.btn-outline-success:focus {
    background: var(--app-success-soft);
    border-color: var(--app-success);
    color: var(--app-success-dark);
}

.btn-danger,
.btn-outline-danger {
    color: var(--app-danger);
    border-color: #fecaca;
    background: var(--app-surface);
}

.btn-danger {
    color: #fff;
    background: var(--app-danger);
    border-color: var(--app-danger);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    background: var(--app-danger-soft);
    border-color: var(--app-danger);
    color: var(--app-danger);
}

.btn-danger:hover,
.btn-danger:focus {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.btn-link {
    color: var(--app-accent);
    min-height: auto;
    padding: 0.2rem 0.35rem;
}

/* =========================================================================
   Forms
   ========================================================================= */

.form-label {
    color: var(--app-text-soft);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border-color: var(--app-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    font-weight: 400;
    color: var(--app-text);
    min-height: 40px;
    padding: 0.45rem 0.7rem;
    background-color: var(--app-surface);
    transition: border-color 0.14s, box-shadow 0.14s;
}

textarea.form-control {
    line-height: 1.7;
    min-height: 78px;
}

.form-control::placeholder {
    color: var(--app-placeholder);
    font-size: 13px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-accent);
    box-shadow: var(--shadow-focus);
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--app-danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
}

.form-check-input {
    width: 1.05em;
    height: 1.05em;
    border-color: var(--app-border-strong);
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.form-check-input:focus {
    border-color: var(--app-accent);
    box-shadow: var(--shadow-focus);
}

.form-check-label {
    font-size: 13px;
    color: var(--app-text-soft);
}

.invalid-feedback,
.text-danger.small {
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--app-danger);
}

/* =========================================================================
   Tables — نگاه نرم‌افزار مالی
   ========================================================================= */

/*
 * قاب دو‌محوره (table_hscroll.js → .app-table-frame):
 *   frame = اسکرول افقی (نوار چپ/راست همیشه پایینِ قاب)
 *   .table-responsive = اسکرول عمودی + عرض محتوا
 */
.app-table-frame {
    max-width: 100%;
    /* همیشه نوار افقی پایین قاب دیده شود (ارتفاع دقیق را JS می‌چیند) */
    overflow-x: scroll;
    overflow-y: hidden;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    -webkit-overflow-scrolling: touch;
    /* override global ``* { scrollbar-width: thin }`` — نوار باید کلفت و قابل کلیک باشد */
    scrollbar-width: auto !important;
    scrollbar-color: #334155 #e2e8f0;
    /* fallback تا قبل از اجرای JS؛ JS با اندازه‌گیری واقعی override می‌کند */
    max-height: calc(100vh - var(--topbar-h) - 14rem);
}

.app-table-frame::-webkit-scrollbar {
    height: 18px !important;
    width: 14px;
}

.app-table-frame::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 9px;
    border: 3px solid #e2e8f0;
    background-clip: padding-box;
    min-height: 18px;
}

.app-table-frame::-webkit-scrollbar-track {
    background: #e2e8f0;
}

.app-main .app-table-frame > .table-responsive {
    max-height: calc(100vh - var(--topbar-h) - 15rem);
    /* clip به‌جای hidden تا position:sticky هدر ستون‌ها نشکند */
    overflow-x: clip;
    overflow-y: auto;
    width: 100%;
    min-width: 100%;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.app-main .app-table-frame > .table-responsive:has(table.is-col-resized) {
    width: max-content;
}

.app-main .app-table-frame > .table-responsive::-webkit-scrollbar {
    width: 12px;
}

.app-main .app-table-frame > .table-responsive::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* بدون frame (صفحات قدیمی): رفتار قبلی امن */
.app-main .table-responsive {
    max-height: calc(100vh - var(--topbar-h) - 14rem);
    overflow: auto;
    overscroll-behavior: contain;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    -webkit-overflow-scrolling: touch;
}

.table-responsive {
    overflow: auto;
    box-shadow: var(--shadow-sm);
}

/* هدر ستون‌ها داخل قاب لیست می‌چسبد */
.app-main .table-responsive > .table > thead > tr > th,
.app-main .table-responsive > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--app-grid-head-bg, #f8fafc) !important;
    box-shadow: inset 0 -1px 0 var(--app-border);
}

.table-responsive > .table.table-dark > thead > tr > th,
.table-responsive > table.table-dark > thead > tr > th {
    background: #212529;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
}

/*
 * جدول باید با محتوا بزرگ شود تا overflow افقی ساخته شود.
 * width:100% (پیش‌فرض Bootstrap) ستون‌ها را فشرده می‌کند و اسکرول چپ/راست
 * هرگز ظاهر نمی‌شود.
 */
/* لیست کارکرد ماه: ارتفاع آزاد (محتوای زیاد بالای جدول) */
.app-main .app-table-frame:has(table.sheet-table) {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
}
.app-main .app-table-frame:has(table.sheet-table) > .table-responsive,
.app-main .table-responsive:has(table.sheet-table) {
    max-height: none;
    overflow: visible;
}

.app-main .table-responsive > table.app-grid,
.app-main .table-responsive > table[data-app-grid],
.app-main .table-responsive > table.sheet-table {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.app-main .table-responsive > table.app-grid.is-col-resized,
.app-main .table-responsive > table[data-app-grid].is-col-resized {
    width: max-content;
}

.app-main .table-responsive > table.app-grid th,
.app-main .table-responsive > table.app-grid td,
.app-main .table-responsive > table[data-app-grid] th,
.app-main .table-responsive > table[data-app-grid] td {
    white-space: nowrap;
}

/* توضیحات و ستون‌های متنی: جمع بمانند تا جدول اول پهن نشود */
.app-main .table-responsive > table.app-grid td[data-grid-wrap],
.app-main .table-responsive > table.app-grid th[data-grid-wrap],
.app-main .table-responsive > table[data-app-grid] td[data-grid-wrap],
.app-main .table-responsive > table[data-app-grid] th[data-grid-wrap] {
    white-space: normal;
    max-width: 12rem;
    word-break: break-word;
}

@media print {
    .table-responsive,
    .app-table-frame > .table-responsive {
        max-height: none !important;
        overflow: visible !important;
        width: auto !important;
    }

    .app-table-frame {
        overflow: visible !important;
        box-shadow: none !important;
    }
}

.table {
    margin-bottom: 0;
    background: var(--app-surface);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--app-text-soft);
    --bs-table-striped-bg: #fafbfc;
    --bs-table-hover-bg: var(--app-accent-soft);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--app-border);
    padding: 11px 10px;
}

.table.table-bordered > :not(caption) > * > * {
    border-color: var(--app-border);
}

.table th {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.5;
    color: var(--app-muted);
    vertical-align: middle;
    white-space: nowrap;
    background: var(--app-surface-soft);
}

.table td {
    vertical-align: middle;
    color: var(--app-text-soft);
}

.table thead th {
    border-bottom: 1px solid var(--app-border-strong);
    position: sticky;
    top: 0;
}

/* Old dark headers → light finance headers */
.table-dark,
.table .table-dark,
thead.table-dark {
    --bs-table-bg: var(--app-surface-soft);
    --bs-table-color: var(--app-muted);
    --bs-table-border-color: var(--app-border);
}

.table-dark th,
thead.table-dark th {
    background: var(--app-surface-soft);
    color: var(--app-muted);
    border-bottom: 1px solid var(--app-border-strong);
}

.table tbody tr {
    transition: background 0.12s;
}

.table tbody tr:hover {
    --bs-table-bg-state: var(--app-accent-soft);
}

.table tfoot td {
    background: var(--app-surface-soft);
    font-weight: 700;
    color: var(--app-text);
    border-top: 1px solid var(--app-border-strong);
}

.table .text-end,
.numeric,
.money,
.qty {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    text-align: left !important;
    unicode-bidi: plaintext;
}

.table .text-center:first-child,
.table td.text-center,
.table th.text-center {
    font-variant-numeric: tabular-nums;
}

.table td.text-end,
.money {
    font-weight: 600;
    color: var(--app-text);
}

/* =========================================================================
   Alerts / badges
   ========================================================================= */

.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 14px;
}

.alert-danger {
    border-color: #fecaca;
    background: var(--app-danger-soft);
    color: #991b1b;
}

.alert-success {
    border-color: #a7f3d0;
    background: var(--app-success-soft);
    color: var(--app-success-dark);
}

.alert-warning {
    border-color: #fde68a;
    background: var(--app-warning-soft);
    color: var(--app-warning-dark);
}

.alert-info {
    border-color: var(--app-border-strong);
    background: var(--app-accent-soft);
    color: var(--app-primary-dark);
}

.badge {
    font-weight: 700;
    font-size: 11px;
    padding: 0.35em 0.6em;
    border-radius: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    background: var(--app-surface-soft);
    color: var(--app-muted);
}

.chip--success { background: var(--app-success-soft); color: var(--app-success-dark); }
.chip--warning { background: var(--app-warning-soft); color: var(--app-warning-dark); }
.chip--danger { background: var(--app-danger-soft); color: #b91c1c; }
.chip--accent { background: var(--app-accent-soft); color: var(--app-primary-dark); }

/* =========================================================================
   Tabs (Bootstrap nav-tabs used in some forms)
   ========================================================================= */

.nav-tabs {
    border-bottom: 1px solid var(--app-border);
    gap: 2px;
}

.nav-tabs .nav-link {
    border: none;
    border-radius: 0;
    color: var(--app-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-bottom: 2px solid transparent;
}

.nav-tabs .nav-link.active {
    color: var(--app-text);
    background: none;
    border-bottom-color: var(--app-primary);
}

/* «کاردکس و موجودی انبار» alert cards */
.stock-alerts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

.stock-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid #f1f5f9;
    border-radius: 14px;
    background: var(--app-surface);
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    color: var(--app-text);
    text-decoration: none;
    transition: border-color .15s, transform .1s;
}

a.stock-alert:hover {
    border-color: #cbd5e1;
    color: var(--app-text);
    transform: translateY(-1px);
}

.stock-alert__icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: #f1f5f9;
    color: #475569;
}

.stock-alert__icon svg { width: 18px; height: 18px; }
.stock-alert--warning .stock-alert__icon { background: #fef3c7; color: #b45309; }
.stock-alert--primary .stock-alert__icon { background: var(--app-primary-soft); color: var(--app-primary); }

.stock-alert__value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.stock-alert__label {
    font-size: 12px;
    color: var(--app-muted);
}

/* Segmented «به تفکیک» switch under a tab bar (e.g. سفارش‌های خرید) */
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-pill);
    background: #f1f5f9;
    font-size: 12.5px;
}

.view-toggle__label {
    padding: 0 8px 0 4px;
    color: var(--app-muted);
}

.view-toggle__option {
    padding: 5px 14px;
    border-radius: var(--radius-pill);
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.view-toggle__option:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.view-toggle__option.is-active {
    background: var(--app-surface);
    color: var(--app-primary);
    font-weight: 700;
    box-shadow: var(--shadow-xs);
}

/* =========================================================================
   Dashboard — control center
   ========================================================================= */

/* --- Desk (پیشخوان سپیدارمانند) --- */

.desk-hero-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.desk-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 16px;
    border-radius: var(--radius-lg);
    color: #fff;
    min-height: 92px;
    box-shadow: var(--shadow-sm);
}

.desk-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
}

.desk-tile__icon svg {
    width: 22px;
    height: 22px;
}

.desk-tile__label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.88;
    margin-bottom: 4px;
}

.desk-tile__value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.desk-tile__value--sm {
    font-size: 14px;
    font-weight: 700;
}

.desk-tile__hint {
    margin-top: 4px;
    font-size: 11.5px;
    opacity: 0.85;
}

.desk-tile--emerald { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.desk-tile--blue { background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); }
.desk-tile--indigo { background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%); }
.desk-tile--teal { background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%); }

.desk-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.desk-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 16px 10px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.16s ease, transform 0.16s ease;
}

a.desk-chart:hover {
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.desk-chart__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.desk-chart__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-muted);
    margin-bottom: 6px;
}

.desk-chart__value {
    font-size: 20px;
    font-weight: 800;
    color: var(--app-text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    unicode-bidi: plaintext;
}

.desk-chart__value span {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-faint);
}

.desk-chart__trend {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding-top: 4px;
}

.desk-chart__trend--up { color: var(--app-success-dark); }
.desk-chart__trend--down { color: var(--app-danger); }
.desk-chart__trend--flat { color: var(--app-faint); }

.desk-chart__spark {
    width: 100%;
    height: 72px;
    color: var(--app-primary);
}

.desk-mid-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.9fr;
    gap: 14px;
    margin-bottom: 16px;
    align-items: stretch;
}

.desk-panel {
    margin: 0;
    height: 100%;
}

.desk-donut-body {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 210px;
}

.desk-donut {
    width: 132px;
    height: 132px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.desk-donut__hole {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    background: var(--app-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: inset 0 0 0 1px var(--app-border);
}

.desk-donut__hole strong {
    font-size: 12px;
    font-weight: 800;
    color: var(--app-text);
    font-variant-numeric: tabular-nums;
    unicode-bidi: plaintext;
    line-height: 1.2;
}

.desk-donut__hole span {
    font-size: 10px;
    color: var(--app-faint);
    font-weight: 600;
}

.desk-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.desk-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
}

.desk-legend i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.desk-legend__name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--app-text-soft);
    font-weight: 600;
}

.desk-legend__val {
    font-weight: 700;
    color: var(--app-text);
    font-variant-numeric: tabular-nums;
    unicode-bidi: plaintext;
    flex-shrink: 0;
}

.desk-favs {
    display: flex;
    flex-direction: column;
}

.desk-fav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--app-border);
    text-decoration: none;
    color: var(--app-text);
    font-size: 13px;
    font-weight: 600;
    transition: background 0.12s ease;
}

.desk-fav:last-child { border-bottom: none; }

.desk-fav:hover {
    background: var(--app-surface-soft);
    text-decoration: none;
    color: var(--app-primary-dark);
}

.desk-fav svg {
    width: 16px;
    height: 16px;
    color: var(--app-muted);
    flex-shrink: 0;
}

.desk-status-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

.desk-status {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-xs);
}

.desk-status:hover {
    text-decoration: none;
    color: inherit;
    border-color: var(--app-border-strong);
}

.desk-status strong {
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.desk-status span {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-muted);
}

.desk-status--info strong { color: var(--app-primary); }
.desk-status--warning strong { color: var(--app-warning-dark); }
.desk-status--danger strong { color: var(--app-danger); }
.desk-status--neutral strong { color: var(--app-text); }

@media (max-width: 1200px) {
    .desk-hero-grid { grid-template-columns: repeat(2, 1fr); }
    .desk-chart-grid { grid-template-columns: 1fr; }
    .desk-mid-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .desk-hero-grid { grid-template-columns: 1fr; }
    .desk-status-strip { grid-template-columns: 1fr; }
    .desk-donut-body { flex-direction: column; }
}

.dash-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.dash-hero__greeting {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--app-text);
    margin: 0 0 4px;
}

.dash-hero__sub {
    color: var(--app-muted);
    font-size: 13px;
    margin: 0;
}

.dash-hero__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

a.stat-card:hover {
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--app-border-strong);
}

.stat-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--app-surface-soft);
    color: var(--app-muted);
    flex-shrink: 0;
}

.stat-card__icon svg {
    width: 18px;
    height: 18px;
}

.stat-card__icon--success { background: var(--app-success-soft); color: var(--app-success-dark); }
.stat-card__icon--warning { background: var(--app-warning-soft); color: var(--app-warning-dark); }
.stat-card__icon--accent { background: var(--app-accent-soft); color: var(--app-primary-dark); }
.stat-card__icon--primary { background: var(--app-primary); color: #fff; }

.stat-card__delta {
    font-size: 11px;
    font-weight: 700;
    color: var(--app-faint);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.stat-card__delta svg { width: 13px; height: 13px; }
.stat-card__delta--up { color: var(--app-success-dark); }
.stat-card__delta--down { color: var(--app-danger); }

.stat-card__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-muted);
    margin-bottom: 4px;
}

.stat-card__value {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--app-text);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    unicode-bidi: plaintext;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 5px;
}

.stat-card__value .unit {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-faint);
}

.stat-card__hint {
    display: block;
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--app-faint);
}

.dash-columns {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
}

.dash-columns--even {
    grid-template-columns: 1fr 1fr;
}

/* --- Flow chart (inline, no JS lib) --- */

.flow-chart {
    padding: 18px;
}

.flow-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 14px;
    font-size: 12px;
    color: var(--app-muted);
}

.flow-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.flow-legend i {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.flow-legend .in { background: var(--app-primary); }
.flow-legend .out { background: var(--app-primary-light); }

.flow-bars {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding-top: 8px;
}

.flow-day {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.flow-day__pair {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    width: 100%;
    height: 130px;
}

.flow-day__bar {
    width: 42%;
    max-width: 14px;
    border-radius: 6px 6px 0 0;
    min-height: 3px;
    transition: height 0.3s ease;
}

.flow-day__bar--in { background: var(--app-primary); }
.flow-day__bar--out { background: var(--app-primary-light); }

.flow-day__label {
    font-size: 9.5px;
    color: var(--app-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.flow-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--app-faint);
    font-size: 13px;
}

/* --- Compact data list (recent docs, low stock) --- */

.data-list {
    display: flex;
    flex-direction: column;
}

.data-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--app-border);
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
}

.data-row:last-child {
    border-bottom: none;
}

a.data-row:hover {
    background: var(--app-surface-soft);
    text-decoration: none;
    color: inherit;
}

.data-row__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--app-surface-soft);
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.data-row__avatar svg { width: 15px; height: 15px; }
.data-row__avatar--warning { background: var(--app-warning-soft); color: var(--app-warning-dark); }

.data-row__main {
    flex: 1 1 auto;
    min-width: 0;
}

.data-row__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-row__meta {
    font-size: 11.5px;
    color: var(--app-faint);
    font-variant-numeric: tabular-nums;
}

.data-row__amount {
    font-size: 13px;
    font-weight: 700;
    color: var(--app-text);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: plaintext;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.data-row__amount .unit {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--app-faint);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 34px 18px;
    text-align: center;
    color: var(--app-faint);
}

.empty-state svg {
    width: 26px;
    height: 26px;
    opacity: 0.6;
}

.empty-state p {
    margin: 0;
    font-size: 12.5px;
}

/* --- Quick actions row --- */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px;
    border: 1px solid var(--app-border);
    border-radius: var(--radius-lg);
    background: var(--app-surface);
    text-decoration: none;
    color: var(--app-text);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.quick-action:hover {
    text-decoration: none;
    color: var(--app-text);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--app-border-strong);
}

.quick-action__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    flex-shrink: 0;
}

.quick-action__icon svg { width: 17px; height: 17px; }

.quick-action__text b {
    display: block;
    font-size: 13px;
    font-weight: 700;
}

.quick-action__text span {
    font-size: 11px;
    color: var(--app-faint);
}

/* =========================================================================
   Legacy metric-card (still used by old dashboard markup / other pages)
   ========================================================================= */

.metric-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius);
    padding: 16px;
    height: 100%;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.16s ease, transform 0.16s ease;
}

a:hover > .metric-card,
.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.metric-card .metric-label {
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.metric-card .metric-value {
    margin-top: 0.4rem;
    font-size: 18px;
    font-weight: 800;
    color: var(--app-text);
}

/* =========================================================================
   Invoice entry grid + summary (خرید/فروش forms)
   ========================================================================= */

.invoice-table thead {
    background: var(--app-surface-soft);
}

.invoice-table thead th {
    color: var(--app-muted);
    border-bottom: 1px solid var(--app-border-strong);
}

.invoice-table input,
.invoice-table select,
.invoice-table .select2-selection {
    font-size: 13px;
    min-height: 36px;
}

.invoice-table .form-control,
.invoice-table .form-select {
    font-size: 13px;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

.row-number-col { width: 56px; }
.product-col { min-width: 420px; }
.unit-col,
.delete-col { width: 76px; }
.description-col { min-width: 160px; }
.stock-col { min-width: 120px; }
.qty-col { min-width: 150px; }
.price-col { min-width: 240px; }
.amount-col { min-width: 190px; }

/* --fit: every column on screen at once (percentage <col> widths, no
   sideways scrolling) - the compact, Sepidar-style entry grid */
.invoice-table--fit {
    table-layout: fixed;
    width: 100%;
    margin: 0;
}

/* a spreadsheet-like entry grid: the cell borders are the grid, the inputs
   inside are borderless and fill their cell; the focused cell is outlined */
.invoice-table--fit {
    border: 1px solid var(--app-border-strong);
    --grid-row-height: 34px;
}

.invoice-table--fit > :not(caption) > * > * {
    padding: 0;
    border-color: var(--app-border);
}

.invoice-table--fit thead th {
    padding: 7px 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--app-text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--app-border-strong);
}

.invoice-table--fit tbody tr:hover > td { background: var(--app-surface-soft); }

.invoice-table--fit input,
.invoice-table--fit select,
.invoice-table--fit .form-control,
.invoice-table--fit .form-select {
    display: block;
    width: 100%;
    min-width: 0;
    height: var(--grid-row-height);
    min-height: var(--grid-row-height);
    border: 0;
    border-radius: 0;
    background-color: transparent;
    box-shadow: none;
    padding: 0 6px;
    font-size: 13px;
}

.invoice-table--fit .form-select {
    padding-left: 18px;
    background-position: left 5px center;
    background-size: 9px 7px;
}

.invoice-table--fit input:focus,
.invoice-table--fit select:focus {
    outline: 2px solid var(--bs-primary, #2563eb);
    outline-offset: -2px;
    background-color: var(--app-surface);
    box-shadow: none;
}

.invoice-table--fit input[name$="-quantity"],
.invoice-table--fit input[name$="-unit_price"],
.invoice-table--fit input[name$="-discount_amount"],
.invoice-table--fit input[name$="-tax_amount"] {
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.invoice-table--fit input[name$="-quantity"],
.invoice-table--fit input[name$="-unit_price"] { font-weight: 700; }

.invoice-table--fit [data-row-number] {
    color: var(--app-muted);
    font-size: 12px;
    background: var(--app-surface-soft);
}

.invoice-table--fit [data-row-total] {
    padding: 0 6px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    background: var(--app-surface-soft);
}

.invoice-table--fit .grid-delete {
    border: 0;
    background: transparent;
    color: var(--app-muted);
    width: 100%;
    height: var(--grid-row-height);
    font-size: 16px;
    line-height: 1;
    opacity: 0.35;
}

.invoice-table--fit tr:hover .grid-delete,
.invoice-table--fit .grid-delete:focus-visible { opacity: 1; color: #dc2626; }

.invoice-table--fit tfoot td {
    height: var(--grid-row-height);
    padding: 0 6px;
    font-weight: 800;
    font-size: 13px;
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
    background: var(--app-surface-soft);
    border-top: 1px solid var(--app-border-strong);
}

.invoice-table--fit tfoot .grid-foot-label {
    direction: rtl;
    text-align: right;
}

.invoice-table input[name$="-quantity"],
.invoice-table input[name$="-unit_price"] {
    min-width: 100%;
    direction: ltr;
    font-weight: 700;
}

.invoice-table [data-row-total] {
    direction: ltr;
    font-size: 13px;
    font-weight: 800;
    color: var(--app-text);
}

.invoice-summary {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.invoice-summary > div {
    min-width: 190px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--radius);
    padding: 0.85rem 1.05rem;
    box-shadow: var(--shadow-xs);
}

.invoice-summary span {
    display: block;
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 600;
}

.invoice-summary strong {
    display: block;
    margin-top: 0.3rem;
    font-size: 18px;
    font-weight: 800;
    color: var(--app-text);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: plaintext;
    text-align: right;
}

.invoice-summary .invoice-total {
    color: var(--app-primary);
    font-size: 24px;
    font-weight: 800;
    line-height: 1.2;
}

.voucher-diff strong {
    font-size: 15px;
    font-weight: 700;
}

.voucher-diff--ok {
    border-color: #a7f3d0 !important;
    background: var(--app-success-soft) !important;
}

.voucher-diff--ok strong {
    color: var(--app-success-dark);
}

.voucher-diff--bad {
    border-color: #fecaca !important;
    background: var(--app-danger-soft) !important;
}

.voucher-diff--bad strong {
    color: var(--app-danger);
}

.action-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    background: rgba(248, 250, 252, 0.9);
    border-top: 1px solid var(--app-border);
    padding: 0.9rem 0;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.invoice-row-warning td,
.invoice-row-error td {
    background: var(--app-danger-soft) !important;
}

.invoice-row-warning input,
.invoice-row-warning select,
.invoice-row-error input,
.invoice-row-error select,
.invoice-row-error .select2-selection {
    border-color: var(--app-danger) !important;
}

/* =========================================================================
   Select2
   ========================================================================= */

.select2-container--default .select2-selection--single {
    border-color: var(--app-border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    min-height: 40px;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--app-accent);
    box-shadow: var(--shadow-focus);
}

.invoice-table .select2-container--default .select2-selection--single {
    min-height: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
    padding-right: 0.75rem;
    padding-left: 2rem;
    color: var(--app-text);
}

.invoice-table .select2-container--default .select2-selection--single .select2-selection__rendered {
    font-size: 13px;
    line-height: 34px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
    left: 6px;
    right: auto;
}

.invoice-table .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 34px;
}

.select2-dropdown {
    border-color: var(--app-border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--app-primary);
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1200px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .dash-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 991.98px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        transform: translateX(100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-md);
        width: min(300px, 84vw);
        flex-basis: auto;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        z-index: 25;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .app-main {
        padding: 16px;
    }

    .dash-hero {
        flex-direction: column;
        gap: 12px;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-actions {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .action-bar,
    .tab-bar {
        display: none !important;
    }
    .app-main {
        padding: 0;
        max-width: none;
    }
}

/* ---------------------------------------------------------------------
   داشبورد مدیریتی (management dashboard) - a small, self-contained ranked
   horizontal-bar list, reused for "پرفروش‌ترین کالاها", "سودآورترین کالاها",
   "کالاهای پرتکرار خرید" and the sales/purchase trend bars. Everything else
   on that page reuses .stat-card / .panel / .data-row already defined above.
   --------------------------------------------------------------------- */
.rank-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-item__label {
    flex: 0 0 38%;
    font-size: 13px;
    color: var(--app-text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-item__bar-track {
    flex: 1 1 auto;
    height: 9px;
    background: var(--app-surface-soft);
    border-radius: 6px;
    overflow: hidden;
}

.rank-item__bar-fill {
    height: 100%;
    background: var(--app-accent);
    border-radius: 6px;
}

.rank-item__bar-fill--success { background: var(--app-success); }
.rank-item__bar-fill--warning { background: var(--app-warning); }

.rank-item__value {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--app-text);
    min-width: 90px;
    text-align: left;
}

.credit-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--app-danger-soft);
    border: 1px solid rgba(220, 38, 38, 0.18);
}

.credit-alert + .credit-alert {
    margin-top: 8px;
}

.credit-alert__name {
    font-weight: 600;
    color: var(--app-text);
    font-size: 13px;
}

.credit-alert__meta {
    font-size: 12px;
    color: var(--app-muted);
}

.credit-alert__percent {
    font-weight: 700;
    color: var(--app-danger);
    font-size: 13px;
    white-space: nowrap;
}

.dash-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}

.dash-filter-bar .form-label {
    font-size: 12px;
    color: var(--app-muted);
    margin-bottom: 4px;
}

.dash-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--app-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 28px 0 12px;
}

.dash-section-title:first-of-type { margin-top: 0; }

/* In-page quick create (e.g. «+ دسته جدید»): <details>, no JS needed offline */
.quick-create > summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
}
.quick-create > summary::-webkit-details-marker { display: none; }
.quick-create:not([open]) > summary { border-bottom: 0; }

/* Second-level hub tabs (e.g. «پیکربندی سیستم» → مالی / انبار / فروش) */
.nav-hub-pills {
    gap: .25rem;
    flex-wrap: wrap;
}
.nav-hub-pills .nav-link {
    padding: .3rem .85rem;
    font-size: .875rem;
    border-radius: 999px;
}

/* «داشبورد»: عملیات روزمره / تحلیل مدیریتی switcher */
.dash-switcher .nav-tabs { margin-bottom: 12px !important; }

/* «ابزارهای اختصاصی»: links filled in from the API, plus a short hint */
.app-nav-tools {
    display: grid;
    gap: 2px;
}
.app-nav-tools:empty { display: none; }
.app-nav-hint {
    margin: 2px 10px 4px;
    color: var(--app-faint);
    font-size: 11.5px;
    line-height: 1.7;
}
.app-nav-hint[hidden] { display: none; }


/* =========================================================================
   Sales invoice detail (.inv-view) - calm, neutral-grey document page:
   one primary action + «عملیات بیشتر» menu, one summary card, tabs.
   Colours are local on purpose (the rest of the app keeps its palette).
   ========================================================================= */
.inv-view {
    --iv-text: #111827;
    --iv-text-soft: #374151;
    --iv-muted: #6b7280;
    --iv-faint: #9ca3af;
    --iv-border: #e5e7eb;
    --iv-border-soft: #f0f1f3;
    --iv-soft: #f9fafb;
    --iv-surface: #ffffff;
    --iv-ink: #1f2937;
    --iv-danger: #b91c1c;
    color: var(--iv-text);
    max-width: 1200px;
}

.inv-view a { color: var(--iv-ink); text-decoration: underline; text-decoration-color: var(--iv-border); text-underline-offset: 3px; }
.inv-view a:hover { text-decoration-color: var(--iv-ink); }
.inv-muted { color: var(--iv-muted); }
.inv-small { font-size: 12px; }
.inv-strong { font-weight: 700; }
.inv-num { font-variant-numeric: tabular-nums; text-align: left; direction: ltr; white-space: nowrap; }

/* header */
.inv-head {
    display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between;
    margin: 4px 0 20px;
}
.inv-head__title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.inv-head__title h1 { font-size: 22px; font-weight: 800; margin: 0; color: var(--iv-text); }
.inv-back {
    flex-basis: 100%; font-size: 12px; color: var(--iv-muted) !important; text-decoration: none !important;
}
.inv-back::before { content: '→ '; }
.inv-head__actions { display: flex; gap: 8px; align-items: center; }
.inv-head__actions form { margin: 0; }

.inv-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border: 1px solid var(--iv-border); border-radius: 999px;
    font-size: 12px; font-weight: 600; color: var(--iv-text-soft); background: var(--iv-surface);
}
.inv-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--iv-faint); }
.inv-badge--confirmed i, .inv-badge--completed i,
.inv-badge--fully_delivered i, .inv-badge--fully_received i { background: #16a34a; }
.inv-badge--partially_delivered i, .inv-badge--partially_received i { background: #2563eb; }
.inv-badge--draft i { background: #d97706; }
.inv-badge--cancelled i { background: var(--iv-danger); }
.inv-badge--cancelled { color: var(--iv-danger); }

/* buttons */
.inv-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
    border: 1px solid var(--iv-border); border-radius: 8px; background: var(--iv-surface);
    color: var(--iv-text) !important; font-size: 13px; font-weight: 600; text-decoration: none !important;
    cursor: pointer; transition: background .15s, border-color .15s;
}
.inv-btn:hover { background: var(--iv-soft); border-color: #d1d5db; }
.inv-btn:focus-visible { outline: 2px solid var(--iv-ink); outline-offset: 2px; }
.inv-btn--primary { background: var(--iv-ink); border-color: var(--iv-ink); color: #fff !important; }
.inv-btn--primary:hover { background: #374151; border-color: #374151; }
/* «→ بازگشت به گردش حساب» - back to the page this one was opened from */
.inv-btn--back { color: var(--app-primary, #2563eb) !important; border-color: rgba(37, 99, 235, .35); background: var(--app-primary-soft, #eaf1fe); }
.inv-btn--back:hover { border-color: var(--app-primary, #2563eb); }

.inv-menu { min-width: 210px; padding: 6px; border: 1px solid var(--iv-border); border-radius: 10px; box-shadow: 0 10px 30px rgba(17, 24, 39, .08); }
.inv-menu form { margin: 0; }
.inv-menu .dropdown-item {
    border-radius: 6px; padding: 7px 10px; font-size: 13px; color: var(--iv-text);
    text-decoration: none; text-align: right; width: 100%;
}
.inv-menu .dropdown-item:hover, .inv-menu .dropdown-item:focus { background: var(--iv-soft); color: var(--iv-text); }
.inv-menu .inv-menu__danger { color: var(--iv-danger); }
.inv-menu .inv-menu__danger:hover { background: #fef2f2; color: var(--iv-danger); }
.inv-menu .dropdown-divider { margin: 6px 0; border-color: var(--iv-border-soft); }

/* cards */
.inv-card {
    background: var(--iv-surface); border: 1px solid var(--iv-border); border-radius: 12px;
    padding: 20px 24px; margin-bottom: 16px;
}
.inv-card--flush { padding: 0; overflow: hidden; }
.inv-section-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; color: var(--iv-text); }
.inv-card--flush .inv-section-title { padding: 14px 20px 0; }

/* delivery: a small badge beside the status, with a tiny progress bar */
.inv-badge--delivery { gap: 8px; font-variant-numeric: tabular-nums; }
.inv-minibar { width: 36px; height: 4px; border-radius: 999px; background: var(--iv-border); overflow: hidden; }
.inv-minibar > span { display: block; height: 100%; background: var(--iv-ink); }

/* «مشخصات فاکتور» card: soft background, even 4-column grid */
.inv-card--info { background: #f8fafc; border-color: #e2e8f0; }
.inv-card--info .inv-section-title { color: var(--iv-muted); font-size: 12px; font-weight: 600; margin-bottom: 16px; }

.inv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 24px; margin: 0; }
.inv-grid > div { min-width: 0; }
.inv-grid__full { grid-column: 1 / -1; padding-top: 16px; border-top: 1px solid #e2e8f0; }
.inv-grid dt { font-size: 12px; font-weight: 500; color: var(--iv-muted); margin-bottom: 6px; }
.inv-grid dd { margin: 0; font-size: 15px; font-weight: 700; color: var(--iv-text); overflow-wrap: anywhere; }
.inv-grid dd.inv-num { text-align: right; direction: rtl; }
@media (max-width: 992px) { .inv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .inv-grid { grid-template-columns: 1fr; } }

/* tabs */
.inv-tabs { gap: 4px; border-bottom: 1px solid var(--iv-border); margin: 8px 0 16px; }
.inv-tabs .nav-link {
    border: 0; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px;
    padding: 10px 14px; background: none; color: var(--iv-muted); font-size: 13px; font-weight: 600;
}
.inv-tabs .nav-link:hover { color: var(--iv-text); }
.inv-tabs .nav-link.active { color: var(--iv-text); border-bottom-color: var(--iv-ink); }
.inv-count {
    display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 4px;
    border-radius: 999px; background: var(--iv-border-soft); color: var(--iv-text-soft);
    font-size: 11px; line-height: 18px; text-align: center;
}

/* tables */
.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-table th {
    padding: 12px 16px; background: var(--iv-soft); color: var(--iv-muted);
    font-size: 12px; font-weight: 600; text-align: right; white-space: nowrap;
    border-bottom: 1px solid var(--iv-border);
}
.inv-table td { padding: 14px 16px; border-bottom: 1px solid var(--iv-border-soft); vertical-align: middle; color: var(--iv-text); }
.inv-table tbody tr:last-child td { border-bottom: 0; }
.inv-table tbody tr:hover td { background: #fcfcfd; }
.inv-table th.inv-num { text-align: left; }
.inv-table__n { width: 44px; color: var(--iv-faint); text-align: center !important; }
.inv-table__link { text-align: start; }
.inv-product { font-weight: 600; }

/* totals */
.inv-totals-row { display: flex; justify-content: flex-end; }
.inv-totals { width: min(360px, 100%); padding: 16px 20px; margin: 0 0 16px; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 13px; }
.inv-totals dt { font-weight: 500; color: var(--iv-muted); }
.inv-totals dd { margin: 0; font-variant-numeric: tabular-nums; direction: ltr; color: var(--iv-text); }
.inv-totals__grand { margin-top: 6px; padding-top: 12px !important; border-top: 1px solid var(--iv-border); }
.inv-totals__grand dt { color: var(--iv-text); font-weight: 700; }
.inv-totals__grand dd { font-size: 18px; font-weight: 800; }

/* forms, files */
.inv-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
.inv-form--inline { grid-template-columns: minmax(0, 260px) auto; }
.inv-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--iv-muted); margin: 0; }
.inv-form .form-control, .inv-form .form-select { border-color: var(--iv-border); font-size: 13px; }
.inv-form__submit { grid-column: 1 / -1; }
.inv-form--inline .inv-form__submit { grid-column: auto; }
@media (max-width: 768px) { .inv-form { grid-template-columns: 1fr; } }
.inv-sep { margin: 24px 0 20px; border-color: var(--iv-border-soft); opacity: 1; }
.inv-empty { margin: 0; padding: 12px 0; color: var(--iv-muted); font-size: 13px; }
.inv-files { list-style: none; padding: 0; margin: 0 0 16px; }
.inv-files li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--iv-border-soft); }
.inv-files form { margin: 0 auto 0 0; }
.inv-link-danger { border: 0; background: none; padding: 0; color: var(--iv-danger); font-size: 12px; }
.inv-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inv-qty-input { direction: ltr; font-variant-numeric: tabular-nums; border-color: var(--iv-border); max-width: 200px; margin-inline-start: auto; }
.inv-card form > .inv-card--flush { margin-bottom: 16px; }
.inv-upload input[type=file] { max-width: 360px; font-size: 13px; }

/* کدینگ حساب‌ها */
.coding-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.coding-option {
    display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
    padding: 16px; border: 1px solid var(--iv-border); border-radius: 10px; background: var(--iv-surface);
}
.coding-option__title { font-size: 16px; font-weight: 800; }
.coding-option .inv-btn:disabled { opacity: .45; cursor: not-allowed; }
.coding-counts { columns: 3 180px; padding-inline-start: 18px; margin: 0 0 16px; }
.coding-danger { color: var(--iv-danger) !important; border-color: #fecaca; }
.coding-danger:hover { background: #fef2f2; }
.account-tree .tree-group-label {
    list-style: none; margin: 10px 0 4px; padding: 4px 8px; border-radius: 6px;
    background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 700;
}
.account-tree .tree-group-label:first-child { margin-top: 0; }

/* جریان‌های خودکار */
.flow-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.flow-grid__wide { grid-column: span 2; }
.flow-grid__full { grid-column: 1 / -1; }
@media (max-width: 900px) { .flow-grid { grid-template-columns: 1fr 1fr; } .flow-grid__wide { grid-column: 1 / -1; } }
.flow-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--iv-muted); width: 100%; margin: 0; }
.flow-field .form-control, .flow-field .form-select { font-size: 13px; border-color: var(--iv-border); }
/* flow editor (n8n-like): board | settings panel - see flows/static/flows/js/flow_editor.js */
.fe {
    --fe-wire: #a3abb8; --fe-wire-hover: #6b7280; --fe-tile: 84px;
    display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start;
    grid-template-areas: "errors errors" "board panel";
}
@media (max-width: 1200px) { .fe { grid-template-columns: 1fr; grid-template-areas: "errors" "board" "panel"; } }
.fe-errors {
    grid-area: errors; background: var(--app-danger-soft); border: 1px solid var(--app-danger); border-radius: 10px;
    padding: 10px 14px; font-size: 13px; color: var(--iv-text);
}
.fe-errors ul { margin: 6px 0 0; padding-inline-start: 18px; }
.fe-errors li.is-link { cursor: pointer; text-decoration: underline; text-decoration-color: var(--app-danger); }

/* palette strip */
.fe-palette {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--iv-border-soft);
    background: var(--iv-surface);
}
.fe-palette__title { font-weight: 700; font-size: 13px; flex: none; }
.fe-palette__list { display: flex; flex-wrap: wrap; gap: 6px; }
.fe-palette__item, .fe-menu__item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; border: 1px solid var(--iv-border); border-radius: 10px;
    background: var(--iv-surface); font: inherit; font-size: 12px; font-weight: 600; color: var(--iv-text); text-align: right;
    cursor: grab; touch-action: none; user-select: none;
}
.fe-palette__item:hover, .fe-menu__item:hover { border-color: var(--app-primary-light); background: var(--app-primary-soft); }
.fe-mini-icon {
    flex: none; width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--app-primary-soft); color: var(--app-primary-dark);
}
.fe-mini-icon svg { width: 15px; height: 15px; }
.fe-mini-icon--create_draft { background: var(--iv-ink); color: #fff; }
.fe-mini-icon--validate { background: #e0f2fe; color: #0369a1; }
.fe-mini-icon--extract { background: #ede9fe; color: #6d28d9; }
.fe-mini-icon--ask_clarification { background: var(--app-warning-soft); color: var(--app-warning-dark); }
.fe-mini-icon--run_tool { background: #dcfce7; color: #15803d; }
.fe-ghost {
    position: fixed; z-index: 2000; width: var(--fe-tile); height: var(--fe-tile); pointer-events: none; opacity: .9;
    display: flex; align-items: center; justify-content: center; border-radius: 14px; background: var(--iv-surface);
    border: 2px solid var(--app-primary); box-shadow: 0 10px 28px rgba(17, 24, 39, .2); color: var(--app-primary-dark);
}
.fe-ghost svg { width: 36px; height: 36px; }

/* board */
.fe-board { grid-area: board; background: var(--iv-surface); border: 1px solid var(--iv-border); border-radius: 12px; overflow: hidden; min-width: 0; }
.fe-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px;
    padding: 9px 14px; border-bottom: 1px solid var(--iv-border-soft); font-size: 11.5px; color: var(--iv-muted);
}
.fe-tools { display: flex; align-items: center; gap: 6px; }
.fe-zoom {
    min-width: 28px; height: 28px; padding: 0 9px; border: 1px solid var(--iv-border); border-radius: 8px;
    background: var(--iv-surface); color: var(--iv-text); font: inherit; font-size: 14px; line-height: 1;
}
.fe-zoom:hover { border-color: var(--app-primary-light); background: var(--app-primary-soft); }
.fe-zoom--text { font-size: 12px; font-weight: 600; }
.fe-scroll {
    height: 580px; overflow: auto; direction: ltr;
    background-color: #f6f7f9;
    background-image: radial-gradient(#d5d9e0 1.2px, transparent 1.2px);
    background-size: 20px 20px;
}
.fe-scroll { cursor: grab; }
.fe-scroll.is-panning, .fe-scroll.is-panning * { cursor: grabbing !important; }
.fe-sizer { position: relative; }
.fe-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }

/* wires: gray like n8n, darker on hover, the step colour when selected */
.fe-edges { position: absolute; inset: 0; overflow: visible; }
.fe-edges path { fill: none; }
.fe-edge__hit { stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: pointer; }
.fe-edge__line { stroke: var(--fe-wire); stroke-width: 2.5; pointer-events: none; transition: stroke .12s; }
.fe-edge--fail .fe-edge__line { stroke-dasharray: 7 5; }
.fe-edge.is-hover .fe-edge__line { stroke: var(--fe-wire-hover); stroke-width: 3; }
.fe-edge.is-selected .fe-edge__line { stroke: var(--app-primary); stroke-width: 3; }
.fe-arrow { fill: var(--fe-wire-hover); }
.fe-temp { stroke: var(--app-primary); stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; }

/* things laid over the wires: tags, «+», the add menu */
.fe-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; direction: rtl; }
.fe-overlay > * { pointer-events: auto; }
.fe-tag {
    position: absolute; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; line-height: 1;
}
.fe-tag__label {
    background: var(--iv-surface); border: 1px solid var(--iv-border); border-radius: 999px; padding: 4px 9px;
    color: var(--iv-text-soft); font-weight: 600; box-shadow: 0 1px 2px rgba(17, 24, 39, .06); cursor: pointer;
}
.fe-tag--fail .fe-tag__label { color: var(--app-warning-dark); border-color: #f3d9a4; background: var(--app-warning-soft); }
.fe-tag--ok .fe-tag__label { color: var(--app-success-dark); border-color: #b9e8d8; background: var(--app-success-soft); }
.fe-tag__delete {
    width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--iv-border); background: var(--iv-surface);
    color: var(--app-danger); font-size: 15px; line-height: 1; padding: 0; display: none; cursor: pointer;
}
.fe-tag.is-hover .fe-tag__delete, .fe-tag.is-selected .fe-tag__delete { display: inline-block; }
.fe-tag.is-selected .fe-tag__label { border-color: var(--app-primary); }
.fe-plus { position: absolute; width: 0; height: 0; }
.fe-plus::before {     /* the stub from the free output */
    content: ''; position: absolute; right: 7px; top: -1px; width: 30px; border-top: 2px solid var(--fe-wire);
}
.fe-plus__btn {
    position: absolute; right: 36px; top: -12px; width: 24px; height: 24px; border-radius: 7px; padding: 0;
    border: 1.5px solid var(--fe-wire); background: var(--iv-surface); color: var(--fe-wire-hover);
    font-size: 17px; line-height: 1; cursor: pointer;
}
.fe-plus__btn:hover { border-color: var(--app-primary); color: var(--app-primary); background: var(--app-primary-soft); }
.fe-menu {
    position: absolute; z-index: 5; min-width: 210px; padding: 8px; display: flex; flex-direction: column; gap: 5px;
    background: var(--iv-surface); border: 1px solid var(--iv-border); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(17, 24, 39, .18); transform: translateX(-100%);
}
.fe-menu__title { font-size: 11.5px; color: var(--iv-muted); padding: 2px 4px 4px; }
.fe-menu__item { cursor: pointer; }

/* tiles */
.fe-node {
    position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center;
    background: var(--iv-surface); border: 2px solid #c9ced6; border-radius: 14px;
    box-shadow: 0 2px 6px rgba(17, 24, 39, .08); cursor: grab; user-select: none; touch-action: none; color: var(--iv-text);
    transition: border-color .12s, box-shadow .12s;
}
.fe-node:hover { border-color: #9aa3b0; box-shadow: 0 4px 12px rgba(17, 24, 39, .12); }
.fe-node:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 3px; }
.fe-node.is-selected { border-color: var(--app-primary); box-shadow: 0 0 0 5px var(--app-primary-soft); }
.fe-node.is-target { border-color: var(--app-success); box-shadow: 0 0 0 5px var(--app-success-soft); }
.fe-node.has-warning { border-color: var(--app-warning); }
.fe-node.has-error { border-color: var(--app-danger); box-shadow: 0 0 0 4px var(--app-danger-soft); }
.fe-node.has-warning::after, .fe-node.has-error::after {
    content: '!'; position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--iv-surface); background: var(--app-warning); color: #fff; font-size: 11px; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
}
.fe-node.has-error::after { background: var(--app-danger); }
.fe-node__icon { display: inline-flex; color: var(--app-primary-dark); }
.fe-node__icon svg { width: 36px; height: 36px; stroke-width: 1.7; }
.fe-node--validate .fe-node__icon { color: #0369a1; }
.fe-node--extract .fe-node__icon { color: #6d28d9; }
.fe-node--ask_clarification .fe-node__icon { color: var(--app-warning-dark); }
.fe-node--run_tool .fe-node__icon { color: #15803d; }
.fe-node--create_draft { background: var(--iv-ink); border-color: var(--iv-ink); }
.fe-node--create_draft .fe-node__icon { color: #fff; }
.fe-node--trigger { border-radius: 42px 14px 14px 42px; }      /* rounded on the start side, like n8n's triggers */
.fe-node--trigger .fe-node__icon { color: var(--app-success-dark); }
.fe-node__name {
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 176px;
    direction: rtl; text-align: center; display: flex; flex-direction: column; gap: 2px; pointer-events: none;
}
.fe-node__name b { font-size: 13px; font-weight: 700; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-node__name small { font-size: 11px; color: var(--iv-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* handles */
.fe-port {
    position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--iv-surface);
    border: 2px solid #9aa3b0; transform: translate(-50%, -50%);
}
.fe-port--in { left: 100%; top: 50%; border-radius: 3px; width: 10px; height: 18px; transform: translate(-30%, -50%); background: #9aa3b0; border: 0; }
.fe-port--out { left: 0; cursor: crosshair; z-index: 1; }
.fe-port--out:hover { transform: translate(-50%, -50%) scale(1.35); border-color: var(--app-primary); }
.fe-port--ok { border-color: var(--app-success); }
.fe-port--fail { border-color: var(--app-warning-dark); }
.fe-port__label {
    position: absolute; right: 18px; top: -16px; white-space: nowrap; pointer-events: none; direction: rtl;
    font-size: 10.5px; font-weight: 600; color: var(--iv-muted);
}
.fe-port--fail .fe-port__label { top: auto; bottom: -16px; color: var(--app-warning-dark); }
.fe-port--ok .fe-port__label { color: var(--app-success-dark); }

/* side panel */
.fe-panel { grid-area: panel; }
.fe-panel .flow-panel__head .fe-mini-icon { width: 34px; height: 34px; border-radius: 10px; }
.fe-panel .flow-panel__head .fe-mini-icon svg { width: 18px; height: 18px; }
.fe-panel__title { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
.fe-check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.fe-outputs { margin-top: 16px; border-top: 1px solid var(--iv-border-soft); padding-top: 12px; font-size: 12px; }
.fe-outputs__title { font-weight: 700; margin-bottom: 6px; }
.fe-outputs__row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--iv-muted); }
.fe-outputs__row b { color: var(--iv-text); font-weight: 600; }
.fe-outputs__row b.is-missing { color: var(--app-warning-dark); }
.fe-delete { margin-top: 16px; color: var(--app-danger); border-color: var(--app-danger-soft); }
.flow-panel {
    background: var(--iv-surface); border: 1px solid var(--iv-border); border-radius: 12px; padding: 16px 18px;
    position: sticky; top: 12px;
}
.flow-panel__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.flow-panel__head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.flow-panel__note { font-size: 12px; color: var(--iv-muted); margin: 0 0 14px; line-height: 1.8; }
.flow-panel__fields { display: flex; flex-direction: column; gap: 14px; }
.flow-filter { flex-wrap: wrap; }
.flow-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
@media (max-width: 900px) { .flow-detail { grid-template-columns: 1fr; } }
.flow-timeline { list-style: none; margin: 0; padding: 0; }
.flow-timeline li { position: relative; padding: 0 22px 14px 0; border-right: 2px solid var(--iv-border-soft); margin-right: 5px; }
.flow-timeline li:last-child { border-right-color: transparent; padding-bottom: 0; }
.flow-timeline li > i {
    position: absolute; right: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--iv-faint); border: 2px solid var(--iv-surface);
}
.flow-chat { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow: auto; }
.flow-msg { max-width: 85%; padding: 8px 12px; border-radius: 10px; font-size: 13px; }
.flow-msg--out { align-self: flex-start; background: var(--iv-soft); border: 1px solid var(--iv-border-soft); }
.flow-msg--in { align-self: flex-end; background: #eef6ff; border: 1px solid #dbeafe; }
.flow-msg__meta { font-size: 11px; color: var(--iv-muted); margin-bottom: 2px; }
/* status dots (badges and timeline) */
.flow-status--sent i, .flow-status--awaiting_reply i { background: #2563eb !important; }
.flow-status--incomplete i { background: #d97706 !important; }
.flow-status--needs_review i { background: #9333ea !important; }
.flow-status--approved i, .flow-status--posted i { background: #16a34a !important; }
.flow-status--failed i { background: var(--iv-danger) !important; }
/* =========================================================================
   پوسته‌ی آبی - جزئیات به سبک «تایم‌لاین موعدها»: کارت‌های سفید با گوشه‌ی گرد
   و خط رنگی کنار، آیکون روی کاشی کم‌رنگ، برچسب‌های کپسولی، عنوان‌های پررنگ.
   (فقط ظاهر؛ همه‌ی رنگ‌ها از متغیرهای :root بالا می‌آیند)
   ========================================================================= */

h1, .h1, h2, .h2, .page-header h1, .inv-head__title h1 { font-weight: 800; letter-spacing: -0.2px; }

/* cards */
.card, .app-card, .inv-card { border-color: var(--app-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

/* stat cards: the thin coloured stripe on the start side, like the timeline cards */
.stat-card { position: relative; border-radius: var(--radius-lg); padding: 18px 22px 18px 18px; }
.stat-card::before {
    content: ''; position: absolute; inset-inline-start: 9px; top: 22px; bottom: 22px; width: 3px;
    border-radius: 3px; background: var(--app-primary); opacity: .9;
}
.stat-card:has(.stat-card__icon--warning)::before { background: var(--app-warning); }
.stat-card:has(.stat-card__icon--success)::before { background: var(--app-success); }
.stat-card:has(.stat-card__delta--down)::before, .stat-card:has(.stat-card__icon--danger)::before { background: var(--app-danger); }

/* icon tiles: soft rounded squares */
.stat-card__icon { width: 44px; height: 44px; border-radius: 12px; background: var(--app-primary-soft); color: var(--app-primary); }
.stat-card__icon svg { width: 20px; height: 20px; }
.stat-card__icon--primary { background: var(--app-primary-soft); color: var(--app-primary); }
.stat-card__icon--accent { background: var(--app-accent-soft); color: var(--app-primary); }
.stat-card__icon--danger { background: var(--app-danger-soft); color: var(--app-danger); }

/* pill badges («۳ روز دیگه») */
.chip { padding: 4px 12px; font-size: 12px; font-weight: 700; background: var(--app-primary-soft); color: var(--app-primary-dark); }
.chip--danger { background: var(--app-danger-soft); color: #dc2626; }
.inv-badge { border: 0; background: var(--app-surface-soft); padding: 4px 12px; }

/* buttons */
.btn, .inv-btn { border-radius: 12px; }
.btn-primary, .inv-btn--primary { box-shadow: 0 6px 14px -6px rgba(37, 99, 235, 0.55); }

/* sidebar active accent kept above in the hierarchy block */

/* tabs and inputs */
.form-control, .form-select { border-radius: 12px; border-color: var(--app-border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--app-primary); box-shadow: var(--shadow-focus); }

/* searchable selects (select2 loads its own CSS after this file - win by specificity) */
body .select2-container--default .select2-selection--single,
body .select2-container--default .select2-selection--multiple {
    border: 1px solid var(--app-border-strong); border-radius: 12px; min-height: 40px; background: var(--app-surface);
}
body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 38px; padding-inline: 12px; }
body .select2-container--default .select2-selection--single .select2-selection__arrow { height: 38px; }
body .select2-container--default.select2-container--focus .select2-selection--single,
body .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--app-primary); box-shadow: var(--shadow-focus); }
body .select2-dropdown { border-color: var(--app-border-strong); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-md); }
body .select2-container--default .select2-results__option--highlighted[aria-selected],
body .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--app-primary); }

/* «انتخاب پوشه‌ی ابزار»: a Windows-like folder dialog (custom tools) */
.folder-dialog {
    width: min(760px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--app-border); border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.35); color: var(--app-text); direction: rtl;
}
.folder-dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.folder-dialog__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--app-border); }
.folder-dialog__x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--app-muted); padding: 0 4px; }
.folder-dialog__x:hover { color: var(--app-text); }
.folder-dialog__bar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--app-surface-hover); border-bottom: 1px solid var(--app-border); }
.folder-dialog__up {
    width: 32px; height: 32px; flex: none; border: 1px solid var(--app-border-strong); border-radius: 8px; background: var(--app-surface);
    font-size: 16px; line-height: 1;
}
.folder-dialog__up:disabled { opacity: .45; }
.folder-dialog__path {
    flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--app-border-strong); border-radius: 8px; background: var(--app-surface);
    font-size: 12.5px; color: var(--app-text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}
.folder-dialog__body { display: grid; grid-template-columns: 170px minmax(0, 1fr); height: 360px; }
.folder-dialog__places { border-inline-end: 1px solid var(--app-border); padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.folder-dialog__place, .folder-dialog__item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 8px;
    background: transparent; color: var(--app-text); font: inherit; font-size: 13px; text-align: right; cursor: default;
}
.folder-dialog__place:hover, .folder-dialog__item:hover { background: var(--app-surface-hover); }
.folder-dialog__item.is-selected { background: var(--app-primary-soft); box-shadow: inset 0 0 0 1px var(--app-primary-light); }
.folder-dialog__item:focus-visible, .folder-dialog__place:focus-visible { outline: 2px solid var(--app-primary); outline-offset: -2px; }
.folder-dialog__list { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 1px; }
.folder-dialog__icon { display: inline-flex; color: #e8b33a; flex: none; }
.folder-dialog__item.is-tool .folder-dialog__icon { color: var(--app-primary); }
.folder-dialog__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-dialog__item .chip { padding: 2px 9px; font-size: 11px; }
.folder-dialog__empty { padding: 30px 10px; text-align: center; color: var(--app-muted); font-size: 13px; }
.folder-dialog__foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--app-border); }
.folder-dialog__status { flex: 1; font-size: 12px; color: var(--app-muted); }
@media (max-width: 600px) { .folder-dialog__body { grid-template-columns: 1fr; } .folder-dialog__places { display: none; } }
