/* ==========================================================================
   Flour admin panel design system (from HavirTax) — RTL, light/dark, Vazirmatn
   ========================================================================== */

@font-face { font-family: Vazirmatn; src: url("../lib/vazirmatn/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("../lib/vazirmatn/Vazirmatn-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url("../lib/vazirmatn/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --ht-primary: #4361ee;
    --ht-primary-rgb: 67, 97, 238;
    --ht-primary-hover: #3651d4;
    --ht-primary-light: #5b7cfa;
    --ht-primary-deep: #2f45c9;
    /* Second color of brand gradients; each color theme sets its own. */
    --ht-accent: #7a5af8;    --ht-accent-rgb: 122, 90, 248;
    --ht-success: #12b76a;   --ht-success-rgb: 18, 183, 106;
    --ht-warning: #f79009;   --ht-warning-rgb: 247, 144, 9;
    --ht-danger: #f04438;    --ht-danger-rgb: 240, 68, 56;
    --ht-info: #0ba5ec;      --ht-info-rgb: 11, 165, 236;
    --ht-violet: #7a5af8;    --ht-violet-rgb: 122, 90, 248;

    --ht-body: #f3f5fa;
    --ht-surface: #ffffff;
    --ht-surface-2: #f8f9fc;
    --ht-border: #e6e9f2;
    --ht-text: #1d2539;
    --ht-muted: #6b7489;
    --ht-subtle: #9aa2b6;

    --ht-sidebar: #18203a;
    --ht-sidebar-2: #1f2847;
    --ht-sidebar-text: #a8b1cc;
    --ht-sidebar-strong: #ffffff;

    --ht-radius: 14px;
    --ht-radius-lg: 20px;
    --ht-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 30px -18px rgba(16, 24, 40, .18);
    --ht-shadow-lg: 0 24px 60px -24px rgba(16, 24, 40, .35);
    --ht-sidebar-width: 276px;
    --ht-sidebar-mini: 84px;
    --ht-topbar-height: 70px;

    --bs-body-font-family: Vazirmatn, Tahoma, sans-serif;
    --bs-body-bg: var(--ht-body);
    --bs-body-color: var(--ht-text);
    --bs-border-color: var(--ht-border);
    --bs-primary: var(--ht-primary);
    --bs-primary-rgb: var(--ht-primary-rgb);
    --bs-link-color: var(--ht-primary);
    --bs-link-color-rgb: var(--ht-primary-rgb);
    --bs-secondary-color: var(--ht-muted);
}

[data-bs-theme="dark"] {
    --ht-body: #0d1220;
    --ht-surface: #151b2e;
    --ht-surface-2: #1a2137;
    --ht-border: #252e4a;
    --ht-text: #e7eaf3;
    --ht-muted: #929bb6;
    --ht-subtle: #6c7593;
    --ht-sidebar: #0a0f1d;
    --ht-sidebar-2: #121a30;
    --ht-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .6);
    --bs-body-bg: var(--ht-body);
    --bs-body-color: var(--ht-text);
    --bs-border-color: var(--ht-border);
    --bs-secondary-bg: var(--ht-surface-2);
    --bs-tertiary-bg: var(--ht-surface-2);
}

/* ---------- Color themes: <html data-ht-theme="..."> (picked in the top bar; no attribute = indigo) ---------- */
[data-ht-theme="emerald"] {
    --ht-primary: #0e9f6e; --ht-primary-rgb: 14, 159, 110; --ht-primary-hover: #0b8a5f;
    --ht-primary-light: #34c38f; --ht-primary-deep: #08734f;
    --ht-accent: #0d9488; --ht-accent-rgb: 13, 148, 136;
    --ht-sidebar: #0f2a24; --ht-sidebar-2: #153a32; --ht-sidebar-text: #a7c4bb;
}
[data-ht-theme="ocean"] {
    --ht-primary: #0284c7; --ht-primary-rgb: 2, 132, 199; --ht-primary-hover: #0369a1;
    --ht-primary-light: #38bdf8; --ht-primary-deep: #075985;
    --ht-accent: #06b6d4; --ht-accent-rgb: 6, 182, 212;
    --ht-sidebar: #0c1f33; --ht-sidebar-2: #12304d; --ht-sidebar-text: #a5bdd6;
}
[data-ht-theme="sunset"] {
    --ht-primary: #ea580c; --ht-primary-rgb: 234, 88, 12; --ht-primary-hover: #c2410c;
    --ht-primary-light: #fb923c; --ht-primary-deep: #9a3412;
    --ht-accent: #e11d48; --ht-accent-rgb: 225, 29, 72;
    --ht-sidebar: #2a1611; --ht-sidebar-2: #3a1f17; --ht-sidebar-text: #d6b5a8;
}
[data-ht-theme="rose"] {
    --ht-primary: #db2777; --ht-primary-rgb: 219, 39, 119; --ht-primary-hover: #be185d;
    --ht-primary-light: #f472b6; --ht-primary-deep: #9d174d;
    --ht-accent: #9333ea; --ht-accent-rgb: 147, 51, 234;
    --ht-sidebar: #2a1022; --ht-sidebar-2: #3b1630; --ht-sidebar-text: #d4aec4;
}
[data-ht-theme="purple"] {
    --ht-primary: #7c3aed; --ht-primary-rgb: 124, 58, 237; --ht-primary-hover: #6d28d9;
    --ht-primary-light: #a78bfa; --ht-primary-deep: #5b21b6;
    --ht-accent: #c026d3; --ht-accent-rgb: 192, 38, 211;
    --ht-sidebar: #1e1336; --ht-sidebar-2: #2a1b4a; --ht-sidebar-text: #b9acd6;
}
[data-ht-theme="graphite"] {
    --ht-primary: #475569; --ht-primary-rgb: 71, 85, 105; --ht-primary-hover: #334155;
    --ht-primary-light: #64748b; --ht-primary-deep: #1e293b;
    --ht-accent: #0ea5e9; --ht-accent-rgb: 14, 165, 233;
    --ht-sidebar: #111827; --ht-sidebar-2: #1f2937; --ht-sidebar-text: #aab3c2;
}
/* Dark mode: darker sidebars in each theme's tint; graphite's primary is lifted to stand out on dark surfaces. */
[data-bs-theme="dark"][data-ht-theme="emerald"] { --ht-sidebar: #07150f; --ht-sidebar-2: #0d241b; }
[data-bs-theme="dark"][data-ht-theme="ocean"] { --ht-sidebar: #06111d; --ht-sidebar-2: #0b1f33; }
[data-bs-theme="dark"][data-ht-theme="sunset"] { --ht-sidebar: #160b08; --ht-sidebar-2: #24130d; }
[data-bs-theme="dark"][data-ht-theme="rose"] { --ht-sidebar: #150812; --ht-sidebar-2: #240d1d; }
[data-bs-theme="dark"][data-ht-theme="purple"] { --ht-sidebar: #0f0a1d; --ht-sidebar-2: #1a1230; }
[data-bs-theme="dark"][data-ht-theme="graphite"] {
    --ht-primary: #64748b; --ht-primary-rgb: 100, 116, 139; --ht-primary-hover: #526077;
    --ht-primary-light: #94a3b8; --ht-primary-deep: #334155;
    --ht-sidebar: #0a0d14; --ht-sidebar-2: #151a24;
}

* { -webkit-font-smoothing: antialiased; }
html, body { font-family: Vazirmatn, Tahoma, sans-serif; }
body { background: var(--ht-body); color: var(--ht-text); font-size: .925rem; }
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--ht-muted) !important; }
.fw-medium { font-weight: 500 !important; }
.ltr { direction: ltr; unicode-bidi: embed; }
::selection { background: rgba(var(--ht-primary-rgb), .18); }

/* ---------- Layout ---------- */
.app { min-height: 100vh; }
.app-main { margin-right: var(--ht-sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin .25s ease; }
.app-content { padding: 28px 32px 40px; flex: 1; }
/* Footer mirrors the topbar: same tinted background, with a separator line on top instead of below. */
.app-footer {
    min-height: 56px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    color: var(--ht-subtle); font-size: .8rem;
    background: color-mix(in srgb, var(--ht-body) 82%, transparent);
    border-top: 1px solid color-mix(in srgb, var(--ht-border) 70%, transparent);
}
.app-footer span { display: inline-flex; align-items: center; gap: 6px; }
.app-footer .ti { font-size: 16px; color: var(--ht-primary); opacity: .8; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; inset: 0 0 0 auto; width: var(--ht-sidebar-width); z-index: 1040;
    background: var(--ht-sidebar); color: var(--ht-sidebar-text);
    display: flex; flex-direction: column; transition: width .25s ease, transform .25s ease;
    background-image: radial-gradient(600px 300px at 120% -10%, rgba(var(--ht-primary-rgb), .28), transparent 60%),
                      radial-gradient(400px 260px at -30% 110%, rgba(var(--ht-accent-rgb), .18), transparent 60%);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 22px; height: var(--ht-topbar-height); }
.brand-mark {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center; color: #fff; font-size: 22px;
    background: linear-gradient(135deg, var(--ht-primary-light) 0%, var(--ht-accent) 100%);
    box-shadow: 0 8px 20px -6px rgba(var(--ht-primary-rgb), .7);
}
.brand-text { line-height: 1.25; white-space: nowrap; overflow: hidden; }
.brand-text strong { display: block; color: #fff; font-size: 1.05rem; font-weight: 700; }
.brand-text small { color: var(--ht-sidebar-text); font-size: .75rem; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 14px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.sidebar-label { font-size: .7rem; color: rgba(168, 177, 204, .55); padding: 18px 12px 8px; letter-spacing: .02em; white-space: nowrap; }

.nav-group { margin-bottom: 2px; }
.nav-link-x {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; border-radius: 12px; border: 0; background: transparent;
    color: var(--ht-sidebar-text); font-size: .9rem; text-align: right; white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav-link-x:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-link-x .ti { font-size: 21px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-link-x .chev { margin-right: auto; font-size: 15px; transition: transform .2s; opacity: .6; }
.nav-link-x[aria-expanded="true"] .chev { transform: rotate(-90deg); }
.nav-group.active > .nav-link-x { color: #fff; background: rgba(255,255,255,.06); }
.nav-link-x.single.active {
    color: #fff; background: linear-gradient(90deg, rgba(var(--ht-primary-rgb), .15), rgba(var(--ht-primary-rgb), .55));
    box-shadow: 0 8px 24px -12px rgba(var(--ht-primary-rgb), .9);
}
.nav-sub { padding: 4px 0 6px; margin-right: 22px; border-right: 1px dashed rgba(255,255,255,.1); }
.nav-sub a {
    display: flex; align-items: center; gap: 10px; padding: 7px 18px 7px 10px; margin-right: -1px;
    color: var(--ht-sidebar-text); font-size: .84rem; border-radius: 0 10px 10px 0; position: relative; white-space: nowrap;
}
.nav-sub a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.18); flex-shrink: 0; transition: all .15s; }
.nav-sub a:hover { color: #fff; }
.nav-sub a.active { color: #fff; background: rgba(var(--ht-primary-rgb), .18); border-right: 2px solid #6f8cff; }
.nav-sub a.active::before { background: #8ea4ff; box-shadow: 0 0 0 4px rgba(142, 164, 255, .18); }
.nav-sub .soon { margin-right: auto; font-size: .62rem; padding: 1px 7px; border-radius: 20px; background: rgba(255,255,255,.07); color: rgba(168,177,204,.8); }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-card {
    border-radius: 14px; padding: 14px; background: rgba(255,255,255,.05);
    display: flex; gap: 10px; align-items: center; font-size: .8rem; white-space: nowrap; overflow: hidden;
}
.sidebar-card .ti { font-size: 22px; color: #8ea4ff; }

/* Collapsed (desktop): icons only, expands on hover */
@media (min-width: 992px) {
    .sidebar-collapsed .app-main { margin-right: var(--ht-sidebar-mini); }
    .sidebar-collapsed .sidebar:not(:hover) { width: var(--ht-sidebar-mini); }
    .sidebar-collapsed .sidebar:not(:hover) :is(.brand-text, .sidebar-label, .nav-link-x span, .nav-link-x .chev, .nav-sub, .sidebar-card div) { display: none !important; }
    .sidebar-collapsed .sidebar:not(:hover) .nav-link-x { justify-content: center; }
    .sidebar-collapsed .sidebar:hover { box-shadow: var(--ht-shadow-lg); }
}

/* Mobile: off-canvas */
@media (max-width: 991.98px) {
    .app-main { margin-right: 0; }
    .sidebar { transform: translateX(100%); }
    .sidebar-open .sidebar { transform: none; box-shadow: var(--ht-shadow-lg); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 29, .5); z-index: 1035; opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(2px); }
    .sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    .app-content { padding: 20px 16px 32px; }
    .app-footer { padding: 14px 16px; flex-direction: column; gap: 4px; }
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020; height: var(--ht-topbar-height);
    display: flex; align-items: center; gap: 14px; padding: 0 32px;
    background: color-mix(in srgb, var(--ht-body) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid color-mix(in srgb, var(--ht-border) 70%, transparent);
}
@media (max-width: 991.98px) { .topbar { padding: 0 16px; } }
.icon-btn {
    width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; flex-shrink: 0;
    border: 1px solid var(--ht-border); background: var(--ht-surface); color: var(--ht-muted);
    font-size: 20px; transition: all .15s; position: relative;
}
.icon-btn:hover { color: var(--ht-primary); border-color: rgba(var(--ht-primary-rgb), .35); }
.icon-btn .dot { position: absolute; top: 9px; left: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--ht-danger); border: 2px solid var(--ht-surface); }

.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box > .ti { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ht-subtle); font-size: 18px; pointer-events: none; }
.search-box input {
    width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--ht-border);
    background: var(--ht-surface); padding: 0 42px 0 54px; color: var(--ht-text); font-size: .875rem; outline: none; transition: all .15s;
}
.search-box input:focus { border-color: rgba(var(--ht-primary-rgb), .5); box-shadow: 0 0 0 4px rgba(var(--ht-primary-rgb), .1); }
.search-box kbd { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); background: var(--ht-surface-2); color: var(--ht-subtle); border: 1px solid var(--ht-border); font-family: inherit; font-size: .7rem; padding: 2px 7px; border-radius: 6px; }
.search-results {
    position: absolute; top: calc(100% + 8px); right: 0; left: 0; z-index: 1050; display: none;
    background: var(--ht-surface); border: 1px solid var(--ht-border); border-radius: 14px; box-shadow: var(--ht-shadow-lg); padding: 6px; max-height: 360px; overflow-y: auto;
}
.search-results.show { display: block; }
.search-results a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ht-text); }
.search-results a small { color: var(--ht-subtle); margin-right: auto; font-size: .75rem; }
.search-results a:hover, .search-results a.focused { background: rgba(var(--ht-primary-rgb), .08); color: var(--ht-primary); }
.search-results .empty { padding: 14px; text-align: center; color: var(--ht-subtle); font-size: .85rem; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; border-radius: 14px; border: 1px solid transparent; background: transparent; color: var(--ht-text); }
.user-chip:hover, .user-chip[aria-expanded="true"] { background: var(--ht-surface); border-color: var(--ht-border); }
.user-chip .meta { line-height: 1.3; text-align: right; }
.user-chip .meta strong { display: block; font-size: .85rem; font-weight: 500; }
.user-chip .meta small { color: var(--ht-subtle); font-size: .72rem; }

/* ---------- Avatars ---------- */
.avatar { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.avatar-sm { width: 34px; height: 34px; border-radius: 10px; font-size: .75rem; }
.avatar-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.3rem; }
.tone-1 { background: rgba(var(--ht-primary-rgb), .12); color: var(--ht-primary); }
.tone-2 { background: rgba(var(--ht-success-rgb), .12); color: #079455; }
.tone-3 { background: rgba(var(--ht-warning-rgb), .14); color: #b54708; }
.tone-4 { background: rgba(var(--ht-violet-rgb), .12); color: var(--ht-violet); }
.tone-5 { background: rgba(var(--ht-info-rgb), .12); color: #0086c9; }
.tone-6 { background: rgba(var(--ht-danger-rgb), .1); color: #d92d20; }
[data-bs-theme="dark"] :is(.tone-2) { color: #47cd89; }
[data-bs-theme="dark"] :is(.tone-3) { color: #fdb022; }
[data-bs-theme="dark"] :is(.tone-5) { color: #36bffa; }
[data-bs-theme="dark"] :is(.tone-6) { color: #f97066; }

/* ---------- Page header ---------- */
/* Page header: a bordered card with an accent strip, the page's menu icon (added by site.js) and actions.
   No overflow clipping (the glow is a background layer) and a raised z-index, so action dropdowns open over the page. */
.page-header {
    position: relative; z-index: 20; isolation: isolate;
    display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap;
    margin-bottom: 24px; padding: 20px 26px;
    background:
        radial-gradient(200px circle at left -40px top -60px, rgba(var(--ht-accent-rgb), .16), transparent 70%),
        linear-gradient(120deg, rgba(var(--ht-primary-rgb), .07) 0%, rgba(var(--ht-accent-rgb), .03) 38%, transparent 62%), var(--ht-surface);
    border: 1px solid var(--ht-border); border-radius: var(--ht-radius-lg); box-shadow: var(--ht-shadow);
}
.page-header .dropdown-menu { z-index: 30; }
.page-header::before {
    content: ""; position: absolute; inset-block: 18px; inset-inline-start: 0; width: 4px;
    border-start-end-radius: 4px; border-end-end-radius: 4px;
    background: linear-gradient(180deg, var(--ht-primary), var(--ht-accent));
}
.page-header-main { display: flex; align-items: center; gap: 16px; min-width: 0; flex: 1 1 320px; }
.page-header-main > div { min-width: 0; }
.page-header-icon {
    width: 52px; height: 52px; flex-shrink: 0; border-radius: 16px; display: grid; place-items: center;
    font-size: 26px; color: #fff; background: linear-gradient(135deg, var(--ht-primary), var(--ht-accent));
    box-shadow: 0 12px 24px -12px rgba(var(--ht-primary-rgb), .8), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0; line-height: 1.5; }
.page-header p { color: var(--ht-muted); margin: 4px 0 0; font-size: .85rem; max-width: 72ch; }
.page-header > :last-child:not(:first-child) { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs {
    display: inline-flex; gap: 6px; align-items: center; margin-bottom: 8px; padding: 3px 12px;
    font-size: .74rem; color: var(--ht-subtle); background: var(--ht-surface-2); border: 1px solid var(--ht-border); border-radius: 30px;
}
.crumbs a { color: var(--ht-muted); }
.crumbs a:hover { color: var(--ht-primary); }
.crumbs > span:last-child { color: var(--ht-text); font-weight: 500; }
.crumbs .ti { font-size: 12px; opacity: .7; }
@media (max-width: 575.98px) {
    .page-header { padding: 16px 18px; }
    .page-header-icon { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
    .page-header h1 { font-size: 1.2rem; }
    .page-header > :last-child:not(:first-child) { width: 100%; }
    .page-header > :last-child:not(:first-child) > .btn { flex: 1; }
}

/* ---------- Cards ---------- */
.card-x { background: var(--ht-surface); border: 1px solid var(--ht-border); border-radius: var(--ht-radius-lg); box-shadow: var(--ht-shadow); }
.card-x-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--ht-border); }
.card-x-header h2, .card-x-header h3 { font-size: 1rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-x-header h2 .ti, .card-x-header h3 .ti { color: var(--ht-primary); font-size: 20px; }
.card-x-body { padding: 22px; }

.stat-card { padding: 20px; display: flex; gap: 16px; align-items: flex-start; height: 100%; position: relative; overflow: hidden; }
.stat-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; flex-shrink: 0; }
.stat-card .label { color: var(--ht-muted); font-size: .82rem; }
.stat-card .value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.stat-card .hint { font-size: .75rem; color: var(--ht-subtle); margin-top: 6px; }
.stat-card::after { content: ""; position: absolute; width: 120px; height: 120px; border-radius: 50%; left: -40px; bottom: -60px; background: currentColor; opacity: .03; }

.welcome-card {
    border-radius: var(--ht-radius-lg); padding: 28px 30px; color: #fff; position: relative; overflow: hidden;
    background: linear-gradient(120deg, var(--ht-primary-deep) 0%, var(--ht-primary) 45%, var(--ht-accent) 100%);
    box-shadow: 0 20px 50px -25px rgba(var(--ht-primary-rgb), .9);
}
.welcome-card::before, .welcome-card::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); }
.welcome-card::before { width: 280px; height: 280px; left: -60px; top: -120px; }
.welcome-card::after { width: 180px; height: 180px; left: 140px; bottom: -110px; }
.welcome-card h2 { font-size: 1.35rem; font-weight: 700; margin: 0 0 6px; }
.welcome-card p { margin: 0; opacity: .85; }
.welcome-card .pill { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.2); border-radius: 30px; padding: 6px 14px; font-size: .8rem; display: inline-flex; gap: 6px; align-items: center; backdrop-filter: blur(4px); }
.welcome-card > * { position: relative; z-index: 1; }

/* ---------- Badges ---------- */
.badge-soft { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 30px; font-size: .74rem; font-weight: 500; white-space: nowrap; }
.badge-soft .ti { font-size: 14px; }
.badge-soft.primary { background: rgba(var(--ht-primary-rgb), .1); color: var(--ht-primary); }
.badge-soft.success { background: rgba(var(--ht-success-rgb), .12); color: #079455; }
.badge-soft.warning { background: rgba(var(--ht-warning-rgb), .14); color: #b54708; }
.badge-soft.danger { background: rgba(var(--ht-danger-rgb), .1); color: #d92d20; }
.badge-soft.violet { background: rgba(var(--ht-violet-rgb), .12); color: var(--ht-violet); }
.badge-soft.neutral { background: var(--ht-surface-2); color: var(--ht-muted); border: 1px solid var(--ht-border); }
[data-bs-theme="dark"] .badge-soft.success { color: #47cd89; }
[data-bs-theme="dark"] .badge-soft.warning { color: #fdb022; }
[data-bs-theme="dark"] .badge-soft.danger { color: #f97066; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 500; padding: .58rem 1.1rem; font-size: .875rem; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn .ti { font-size: 18px; }
.btn-sm { padding: .38rem .8rem; font-size: .8rem; border-radius: 10px; }
.btn-primary { --bs-btn-bg: var(--ht-primary); --bs-btn-border-color: var(--ht-primary); --bs-btn-hover-bg: var(--ht-primary-hover); --bs-btn-hover-border-color: var(--ht-primary-hover); --bs-btn-active-bg: var(--ht-primary-hover); box-shadow: 0 8px 20px -10px rgba(var(--ht-primary-rgb), .9); }
.btn-light-x { background: var(--ht-surface); border: 1px solid var(--ht-border); color: var(--ht-text); }
.btn-light-x:hover { border-color: rgba(var(--ht-primary-rgb), .4); color: var(--ht-primary); background: var(--ht-surface); }
.btn-soft-danger { background: rgba(var(--ht-danger-rgb), .08); color: #d92d20; border: 1px solid transparent; }
.btn-soft-danger:hover { background: rgba(var(--ht-danger-rgb), .14); color: #b42318; }
.btn-soft-warning { background: rgba(var(--ht-warning-rgb), .1); color: #b54708; border: 1px solid transparent; }
.btn-soft-warning:hover { background: rgba(var(--ht-warning-rgb), .18); color: #93370d; }
.btn-soft-success { background: rgba(var(--ht-success-rgb), .1); color: #079455; border: 1px solid transparent; }
.btn-soft-success:hover { background: rgba(var(--ht-success-rgb), .18); color: #067647; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; color: var(--ht-muted); background: transparent; border: 1px solid transparent; }
.btn-icon:hover { background: var(--ht-surface-2); color: var(--ht-primary); border-color: var(--ht-border); }
.btn-icon.danger:hover { color: var(--ht-danger); }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: .84rem; margin-bottom: 7px; color: var(--ht-text); }
/* Required mark: inline right after the field name (labels and table headers). */
.req { display: inline; color: var(--ht-danger); font-weight: 700; margin-inline-start: 3px; }
.form-control, .form-select {
    border-radius: 12px; border-color: var(--ht-border); background-color: var(--ht-surface); color: var(--ht-text);
    min-height: 46px; font-size: .9rem; padding: .6rem .9rem; transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: 92px; }
.form-control:focus, .form-select:focus { border-color: rgba(var(--ht-primary-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--ht-primary-rgb), .12); background-color: var(--ht-surface); color: var(--ht-text); }
.form-control::placeholder { color: var(--ht-subtle); }
.form-text { color: var(--ht-subtle); font-size: .76rem; }
.input-icon { position: relative; }
.input-icon > .ti { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ht-subtle); font-size: 19px; pointer-events: none; }
.input-icon > .form-control { padding-right: 44px; }
.input-icon > .form-control:has(+ .toggle-pass) { padding-left: 46px; }
.input-icon .toggle-pass { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ht-subtle); width: 36px; height: 36px; border-radius: 10px; }
.input-icon .toggle-pass:hover { color: var(--ht-primary); }
.field-validation-error, .text-danger { color: #d92d20 !important; font-size: .78rem; display: block; margin-top: 6px; }
.input-validation-error { border-color: rgba(var(--ht-danger-rgb), .6) !important; }
.form-check-input { width: 1.15em; height: 1.15em; border-color: var(--ht-subtle); }
.form-check-input:checked { background-color: var(--ht-primary); border-color: var(--ht-primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; cursor: pointer; }
.form-section-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: .95rem; margin: 0 0 18px; }
.form-section-title .num { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: .8rem; background: rgba(var(--ht-primary-rgb), .1); color: var(--ht-primary); }

.alert-x { border-radius: 14px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; font-size: .86rem; border: 1px solid; }
.alert-x .ti { font-size: 21px; flex-shrink: 0; }
.alert-x.danger { background: rgba(var(--ht-danger-rgb), .06); border-color: rgba(var(--ht-danger-rgb), .25); color: #b42318; }
.alert-x.info { background: rgba(var(--ht-primary-rgb), .06); border-color: rgba(var(--ht-primary-rgb), .2); color: var(--ht-primary); }
.alert-x.warning { background: rgba(var(--ht-warning-rgb), .08); border-color: rgba(var(--ht-warning-rgb), .3); color: #b54708; }
.alert-x.success { background: rgba(var(--ht-success-rgb), .07); border-color: rgba(var(--ht-success-rgb), .28); color: #067647; }
[data-bs-theme="dark"] .alert-x.success { color: #75e0a7; }
[data-bs-theme="dark"] .alert-x.danger { color: #fda29b; }
[data-bs-theme="dark"] .alert-x.warning { color: #fec84b; }
.alert-x ul { margin: 0; padding-right: 18px; }

/* ---------- Tables ---------- */
.table-x { width: 100%; margin: 0; }
.table-x thead th { background: var(--ht-surface-2); color: var(--ht-muted); font-weight: 500; font-size: .78rem; padding: 12px 18px; border-bottom: 1px solid var(--ht-border); white-space: nowrap; }
.table-x tbody td { padding: 14px 18px; border-bottom: 1px solid var(--ht-border); vertical-align: middle; font-size: .87rem; }
.table-x tbody tr:last-child td { border-bottom: 0; }
.table-x tbody tr { transition: background .12s; }
.table-x tbody tr:hover { background: color-mix(in srgb, var(--ht-primary) 3%, transparent); }
.table-x .cell-user { display: flex; align-items: center; gap: 12px; }
.table-x .cell-user strong { display: block; font-weight: 500; }
.table-x .cell-user small { color: var(--ht-subtle); font-size: .76rem; }
.table-responsive { border-radius: 0 0 var(--ht-radius-lg) var(--ht-radius-lg); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--ht-border); }
.toolbar .search-box { max-width: 320px; }
.toolbar .search-box input { padding-left: 14px; }
.chip-filter { display: inline-flex; gap: 4px; background: var(--ht-surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--ht-border); }
.chip-filter a { padding: 6px 14px; border-radius: 9px; color: var(--ht-muted); font-size: .8rem; white-space: nowrap; }
.chip-filter a.active { background: var(--ht-surface); color: var(--ht-text); box-shadow: 0 1px 3px rgba(16,24,40,.1); font-weight: 500; }
.chip-filter a .count { font-size: .7rem; color: var(--ht-subtle); margin-right: 4px; }

.empty-state { text-align: center; padding: 56px 20px; }
.empty-state .icon { width: 76px; height: 76px; border-radius: 24px; display: inline-grid; place-items: center; font-size: 36px; background: rgba(var(--ht-primary-rgb), .08); color: var(--ht-primary); margin-bottom: 16px; }
.empty-state h3 { font-size: 1.05rem; font-weight: 700; }
.empty-state p { color: var(--ht-muted); font-size: .87rem; max-width: 380px; margin: 0 auto 18px; }

.pager { display: flex; gap: 6px; justify-content: center; padding: 16px; }
.pager a, .pager span { min-width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; border: 1px solid var(--ht-border); color: var(--ht-muted); font-size: .82rem; padding: 0 10px; background: var(--ht-surface); }
.pager a:hover { color: var(--ht-primary); border-color: rgba(var(--ht-primary-rgb), .4); }
.pager .current { background: var(--ht-primary); border-color: var(--ht-primary); color: #fff; }

/* ---------- Auth (sign-in, access denied, error): one card on guilloche "security paper" ---------- */
.auth {
    --paper: color-mix(in srgb, var(--ht-primary) 4%, #ffffff);
    --paper-edge: color-mix(in srgb, var(--ht-primary) 11%, #ffffff);
    --line-a: rgba(var(--ht-primary-rgb), .30);
    --line-b: rgba(var(--ht-accent-rgb), .26);
    position: relative; isolation: isolate; overflow: hidden; min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    padding: 40px 16px 88px;
    background: radial-gradient(ellipse 70% 60% at 50% 46%, var(--paper) 0%, var(--paper) 45%, var(--paper-edge) 100%);
}
[data-bs-theme="dark"] .auth {
    --paper: color-mix(in srgb, var(--ht-primary) 7%, #0b0f1a);
    --paper-edge: #070a12;
    --line-a: rgba(var(--ht-primary-rgb), .42);
    --line-b: rgba(var(--ht-accent-rgb), .34);
}
.auth-guilloche { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; fill: none; pointer-events: none; }
.auth-guilloche path { stroke-width: .7; vector-effect: non-scaling-stroke; }
.auth-guilloche .g-main path { stroke: var(--line-a); }
.auth-guilloche .g-inner path { stroke: var(--line-b); }
.auth-guilloche .g-outer path { stroke: var(--line-a); opacity: .55; }
.auth-guilloche .g-ring { stroke: var(--line-a); stroke-width: .6; vector-effect: non-scaling-stroke; opacity: .7; }
@keyframes guilloche-draw { to { stroke-dashoffset: 0; } }

.auth-card {
    width: 100%; max-width: 420px; padding: 34px 34px 30px;
    background: var(--ht-surface); border: 1px solid var(--ht-border); border-radius: 24px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 30px 70px -36px rgba(var(--ht-primary-rgb), .55), 0 2px 6px rgba(16, 24, 40, .04);
}
[data-bs-theme="dark"] .auth-card { box-shadow: 0 30px 70px -36px rgba(0, 0, 0, .85), 0 0 0 1px rgba(var(--ht-primary-rgb), .08); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-brand strong { font-size: 1.2rem; font-weight: 700; display: block; line-height: 1.3; }
.auth-brand small { color: var(--ht-muted); font-size: .78rem; }
.auth-card h1 { font-size: 1.25rem; font-weight: 700; margin: 26px 0 4px; text-align: center; }
.auth-card .lead-x { color: var(--ht-muted); font-size: .86rem; margin-bottom: 24px; text-align: center; }
.auth-card .btn-primary { height: 50px; font-size: .95rem; }
.auth-card .empty-state { padding: 28px 0 4px; }
.auth-hint { margin: 20px 0 0; color: var(--ht-muted); font-size: .76rem; line-height: 1.9; text-align: center; }
.auth-note { margin: 0; display: inline-flex; align-items: center; gap: 6px; color: var(--ht-muted); font-size: .8rem; }
.auth-note .ti { color: var(--ht-success); font-size: 17px; }
.auth-foot { position: absolute; bottom: 18px; right: 24px; left: 24px; display: flex; justify-content: space-between; align-items: center; color: var(--ht-subtle); font-size: .76rem; }
@media (max-width: 575.98px) {
    .auth { justify-content: flex-start; padding-top: 28px; }
    .auth-card { padding: 28px 22px 24px; border-radius: 20px; }
}

/* ---------- Toasts / dropdowns / modal ---------- */
.toast-x {
    position: fixed; bottom: 24px; left: 24px; z-index: 2000; min-width: 300px; max-width: 420px;
    background: var(--ht-surface); border: 1px solid var(--ht-border); border-radius: 16px; box-shadow: var(--ht-shadow-lg);
    padding: 14px 16px; display: flex; gap: 12px; align-items: center; animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
.toast-x .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.toast-x.success .ic { background: rgba(var(--ht-success-rgb), .12); color: var(--ht-success); }
.toast-x.danger .ic { background: rgba(var(--ht-danger-rgb), .1); color: var(--ht-danger); }
.toast-x.warning .ic { background: rgba(var(--ht-warning-rgb), .14); color: var(--ht-warning); }
.toast-x .msg { flex: 1; font-size: .86rem; }
.toast-x .close { border: 0; background: transparent; color: var(--ht-subtle); font-size: 18px; }
.toast-x.hide { animation: toast-out .3s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(20px); } }

.dropdown-menu { border-radius: 14px; border: 1px solid var(--ht-border); box-shadow: var(--ht-shadow-lg); padding: 6px; background: var(--ht-surface); min-width: 220px; --bs-dropdown-link-color: var(--ht-text); }
.dropdown-item { border-radius: 10px; padding: 9px 12px; font-size: .86rem; display: flex; align-items: center; gap: 10px; color: var(--ht-text); }
.dropdown-item .ti { font-size: 18px; color: var(--ht-muted); }
.dropdown-item:hover, .dropdown-item:focus { background: rgba(var(--ht-primary-rgb), .07); color: var(--ht-primary); }
.dropdown-item:hover .ti { color: var(--ht-primary); }
.dropdown-item.danger:hover, .dropdown-item.danger:hover .ti { color: var(--ht-danger); background: rgba(var(--ht-danger-rgb), .07); }
.dropdown-header-x { padding: 12px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--ht-border); margin-bottom: 6px; }
.modal-content { border-radius: 22px; border: 1px solid var(--ht-border); background: var(--ht-surface); box-shadow: var(--ht-shadow-lg); }
.modal-confirm .ic { width: 60px; height: 60px; border-radius: 20px; display: inline-grid; place-items: center; font-size: 30px; background: rgba(var(--ht-danger-rgb), .1); color: var(--ht-danger); margin-bottom: 14px; }

.fade-up { animation: fade-up .45s ease both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ==========================================================================
   Invoicing
   ========================================================================== */
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; direction: ltr; unicode-bidi: embed; letter-spacing: .02em; }
.spin { display: inline-block; animation: spin 1.2s linear infinite; }

/* In-place navigation (site.js): top progress bar, dimmed content and busy buttons while a request runs. */
.nav-progress { position: fixed; inset-inline: 0; top: 0; height: 3px; z-index: 2000; pointer-events: none; opacity: 0;
    background: linear-gradient(90deg, var(--ht-primary), color-mix(in srgb, var(--ht-primary) 55%, #fff)); transform-origin: right; transform: scaleX(0); }
.nav-progress.active { opacity: 1; animation: nav-progress 8s cubic-bezier(.1, .7, .2, 1) forwards; box-shadow: 0 0 10px rgba(var(--ht-primary-rgb), .6); }
.nav-progress.done { animation: none; transform: scaleX(1); opacity: 0; transition: transform .2s ease, opacity .3s ease .15s; }
@keyframes nav-progress { from { transform: scaleX(0); } 20% { transform: scaleX(.45); } to { transform: scaleX(.92); } }
.app-content.is-loading { opacity: .55; pointer-events: none; transition: opacity .15s ease .12s; cursor: progress; }
.is-busy { pointer-events: none; opacity: .8; cursor: progress; }
.btn.is-busy .busy-ic { margin-inline-end: 2px; }
.btn.is-busy .busy-ic + .ti { display: none; }
.btn-icon.is-busy > .ti:not(.busy-ic) { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.pop { animation: pop .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(.8); opacity: .3; } }
.text-success { color: #079455 !important; }
.text-warning { color: #b54708 !important; }
[data-bs-theme="dark"] .text-success { color: #47cd89 !important; }
[data-bs-theme="dark"] .text-warning { color: #fdb022 !important; }

/* Segmented radio */
.seg { display: flex; background: var(--ht-surface-2); border: 1px solid var(--ht-border); border-radius: 12px; padding: 4px; gap: 4px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { flex: 1; text-align: center; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: .86rem; color: var(--ht-muted); transition: all .15s; }
.seg input:checked + label { background: var(--ht-surface); color: var(--ht-primary); font-weight: 500; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.seg input:disabled + label { cursor: not-allowed; opacity: .7; }
.seg input:focus-visible + label { box-shadow: 0 0 0 3px rgba(var(--ht-primary-rgb), .25); }

/* Key-value lists */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0; font-size: .86rem; }
.kv dt { color: var(--ht-muted); font-weight: 400; }
.kv dd { margin: 0; }

.memory-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--ht-border); color: var(--ht-text); transition: all .15s; }
.memory-row:hover { border-color: rgba(var(--ht-primary-rgb), .4); color: var(--ht-text); }

/* Reports: CSS bar charts in the theme color (no chart library), and VAT subtotal rows. */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 230px; padding-top: 22px; overflow-x: auto; direction: rtl; }
.bar-col { flex: 1 0 34px; max-width: 70px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar { width: 70%; min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--ht-primary), color-mix(in srgb, var(--ht-primary) 55%, transparent)); transition: opacity .15s; }
.bar.neg { background: rgba(var(--ht-danger-rgb), .7); }
.bar-col:hover .bar { opacity: .75; }
.bar-value { font-size: .68rem; color: var(--ht-muted); white-space: nowrap; }
.bar-label { font-size: .68rem; color: var(--ht-muted); white-space: nowrap; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: 12px; font-size: .85rem; }
.hbar-track { display: block; height: 8px; border-radius: 99px; background: var(--ht-surface-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 99px; background: var(--ht-primary); }
.hbar-val { font-weight: 500; white-space: nowrap; }
.table-x tr.vat-subtotal td { background: var(--ht-surface-2); font-weight: 600; }
.table-x tr.vat-total td { background: rgba(var(--ht-primary-rgb), .08); font-weight: 700; color: var(--ht-primary); }

/* ==========================================================================
   Form modals (same markup works as a modal or as a standalone page)
   ========================================================================== */
.form-modal .modal-header, .page-modal .modal-header { padding: 18px 22px; border-bottom: 1px solid var(--ht-border); }
.form-modal .modal-title, .page-modal .modal-title { font-size: 1.05rem; font-weight: 700; }
.form-modal .modal-body, .page-modal .modal-body { padding: 22px; }
.form-modal .modal-footer, .page-modal .modal-footer { padding: 14px 22px; border-top: 1px solid var(--ht-border); gap: 8px; justify-content: flex-start; }
.form-modal .modal-footer > *, .page-modal .modal-footer > * { margin: 0; }
.modal-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; background: rgba(var(--ht-primary-rgb), .1); color: var(--ht-primary); flex-shrink: 0; }
.form-modal .btn-close, .page-modal .btn-close { filter: var(--ht-close-filter, none); }
[data-bs-theme="dark"] { --ht-close-filter: invert(1) grayscale(100%) brightness(200%); }
.modal-backdrop.show { opacity: .45; backdrop-filter: blur(2px); }
.form-modal .modal-content { animation: modal-in .25s ease; }
@keyframes modal-in { from { transform: translateY(12px) scale(.98); opacity: .6; } }
/* Forms sit between .modal-content and .modal-body, which breaks Bootstrap's scrollable dialog (the body is clipped
   instead of scrolling). The form passes the height through, so a tall form scrolls its body between a fixed header
   and footer. */
.form-modal .modal-dialog-scrollable .modal-content > form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.form-modal .modal-dialog-scrollable .modal-content > form > .modal-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.form-modal .section-title { font-size: .85rem; font-weight: 700; color: var(--ht-muted); margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
.form-modal .section-title::after, .page-modal .section-title::after { content: ""; flex: 1; height: 1px; background: var(--ht-border); }
.page-modal .section-title { font-size: .85rem; font-weight: 700; color: var(--ht-muted); margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
/* Standalone page version */
.page-modal { margin: 8px auto 24px; pointer-events: auto; }
.page-modal.modal-dialog-scrollable { height: auto; }
.page-modal .modal-content { max-height: none; overflow: visible; box-shadow: var(--ht-shadow); }
.page-modal .modal-body { overflow: visible; }

/* ==========================================================================
   Select2 — matches .form-select (RTL, light/dark)
   ========================================================================== */
.select2-container { font-family: inherit; font-size: .9rem; }
.select2-container--default .select2-selection--single {
    height: 46px; border-radius: 12px; border: 1px solid var(--ht-border); background: var(--ht-surface);
    display: flex; align-items: center; transition: border-color .15s, box-shadow .15s;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--ht-text); line-height: normal; padding: 0 .9rem 0 2.4rem; width: 100%;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--ht-subtle); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 44px; width: 34px; left: 6px; right: auto; }
.select2-container--default .select2-selection--single .select2-selection__arrow b { border-color: var(--ht-subtle) transparent transparent transparent; }
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { border-color: transparent transparent var(--ht-subtle) transparent; }
.select2-container--default .select2-selection--single .select2-selection__clear { color: var(--ht-subtle); margin-left: 26px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: rgba(var(--ht-primary-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--ht-primary-rgb), .12);
}
.select2-container--default.select2-container--disabled .select2-selection--single { background: var(--ht-surface-2); opacity: .75; cursor: not-allowed; }
.select2-container.is-invalid .select2-selection--single { border-color: rgba(var(--ht-danger-rgb), .6); }
.select2-dropdown {
    background: var(--ht-surface); border: 1px solid var(--ht-border) !important; border-radius: 14px !important;
    box-shadow: var(--ht-shadow-lg); overflow: hidden; z-index: 2060;
}
.select2-container--open .select2-dropdown--below { margin-top: 6px; }
.select2-container--open .select2-dropdown--above { margin-top: -6px; }
.select2-search--dropdown { padding: 8px; }
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1px solid var(--ht-border); border-radius: 10px; background: var(--ht-surface-2); color: var(--ht-text);
    padding: 8px 12px; outline: none;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus { border-color: rgba(var(--ht-primary-rgb), .6); }
.select2-results__options { padding: 4px 6px 6px; }
.select2-container--default .select2-results > .select2-results__options { max-height: 280px; }
.select2-results__option { border-radius: 9px; padding: 8px 12px; color: var(--ht-text); margin: 1px 0; }
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: rgba(var(--ht-primary-rgb), .1); color: var(--ht-primary); }
.select2-container--default .select2-results__option--selected { background: rgba(var(--ht-primary-rgb), .16); color: var(--ht-primary); font-weight: 500; }
.select2-container--default .select2-results__option--disabled { color: var(--ht-subtle); }
.select2-results__message { color: var(--ht-subtle); }

/* ==========================================================================
   Persian date picker (persian-datepicker) — theme, dark mode, above modals
   ========================================================================== */
.datepicker-container { z-index: 2070 !important; }
.datepicker-plot-area {
    font-family: Vazirmatn, Tahoma, sans-serif !important; width: 272px !important; padding: 8px !important;
    background: var(--ht-surface) !important; color: var(--ht-text) !important;
    border: 1px solid var(--ht-border) !important; border-radius: 16px !important; box-shadow: var(--ht-shadow-lg) !important;
}
.datepicker-plot-area .datepicker-navigator { margin-bottom: 6px; }
.datepicker-plot-area .datepicker-navigator .pwt-btn-switch { font-weight: 700 !important; color: var(--ht-text) !important; border-radius: 10px !important; }
.datepicker-plot-area .datepicker-navigator .pwt-btn-next,
.datepicker-plot-area .datepicker-navigator .pwt-btn-prev { color: var(--ht-muted) !important; border-radius: 10px !important; }
.datepicker-plot-area .datepicker-navigator :is(.pwt-btn-next, .pwt-btn-prev, .pwt-btn-switch):hover { background: rgba(var(--ht-primary-rgb), .1) !important; color: var(--ht-primary) !important; }
.datepicker-plot-area .datepicker-day-view .month-grid-box .header .header-row-cell { color: var(--ht-subtle) !important; font-size: .74rem !important; }
.datepicker-plot-area .datepicker-navigator :is(.pwt-btn-next, .pwt-btn-prev, .pwt-btn-switch) { background: var(--ht-surface-2) !important; }
.datepicker-plot-area .datepicker-day-view .table-days td { background: transparent !important; }
/* The library paints every cell white (#fff) and disabled/other-month cells grey (#f1f1f1): reset to the theme. */
.datepicker-plot-area .datepicker-day-view .table-days td span,
.datepicker-plot-area :is(.month-item, .year-item, .month-item-disable, .year-item-disable) {
    background: transparent !important; border: 0 !important; text-shadow: none !important;
}
.datepicker-plot-area .datepicker-day-view .table-days td span {
    width: calc(100% - 4px) !important; height: 30px !important; line-height: 30px !important; margin: 2px auto !important;
    border-radius: 10px !important; color: var(--ht-text) !important; font-size: .82rem !important; transition: background .12s;
}
.datepicker-plot-area .datepicker-day-view .table-days td { height: 34px !important; }
.datepicker-plot-area .datepicker-day-view .table-days td span.other-month,
.datepicker-plot-area .datepicker-day-view .table-days td.disabled span,
.datepicker-plot-area :is(.month-item-disable, .year-item-disable) { color: var(--ht-subtle) !important; opacity: .55; }
.datepicker-plot-area .datepicker-day-view .table-days td .alter-calendar-day { color: var(--ht-subtle) !important; }
.datepicker-plot-area .datepicker-day-view .table-days td.disabled:hover span { background: transparent !important; color: var(--ht-subtle) !important; }
.datepicker-plot-area .datepicker-day-view .table-days td:hover span { background: rgba(var(--ht-primary-rgb), .1) !important; color: var(--ht-primary) !important; }
.datepicker-plot-area .datepicker-day-view .table-days td.today span { background: rgba(var(--ht-primary-rgb), .12) !important; color: var(--ht-primary) !important; font-weight: 700; }
.datepicker-plot-area .datepicker-day-view .table-days td.selected span { background: var(--ht-primary) !important; color: #fff !important; font-weight: 700; }
.datepicker-plot-area .datepicker-day-view .table-days td.disabled span { opacity: .35; }
.datepicker-plot-area :is(.datepicker-month-view, .datepicker-year-view) .month-item,
.datepicker-plot-area .datepicker-year-view .year-item { border-radius: 10px !important; color: var(--ht-text) !important; }
.datepicker-plot-area :is(.month-item, .year-item):hover { background: rgba(var(--ht-primary-rgb), .1) !important; color: var(--ht-primary) !important; }
.datepicker-plot-area :is(.month-item, .year-item).selected { background: var(--ht-primary) !important; color: #fff !important; }
.datepicker-plot-area .toolbox { border-top: 1px solid var(--ht-border) !important; margin-top: 6px; padding-top: 6px !important; }
.datepicker-plot-area .toolbox .pwt-btn-today { background: rgba(var(--ht-primary-rgb), .1) !important; color: var(--ht-primary) !important; border-radius: 10px !important; border: 0 !important; }
.err-fix { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(var(--ht-warning-rgb), .1); color: var(--ht-text); font-size: .82rem; }
.err-fix .ti { color: var(--ht-warning); font-size: 17px; flex-shrink: 0; }

/* ---- List and detail tables: titles start on the right, values centered under them ---- */
.table-x thead th { text-align: right !important; }
.table-x tbody td { text-align: center; }
.table-x tbody td .cell-user { justify-content: center; text-align: right; }

/* ---- Theme picker (top bar) ---- */
.theme-menu { width: 340px; max-width: calc(100vw - 24px); padding: 0 0 6px; }
.theme-menu .dropdown-header-x { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; }
.theme-menu .dropdown-header-x small { color: var(--ht-subtle); font-size: .72rem; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px 10px 10px; max-height: 340px; overflow-y: auto; scrollbar-width: thin; }
.theme-swatch { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ht-muted); font-size: .72rem; transition: background .15s, border-color .15s; }
.theme-swatch:hover { background: var(--ht-surface-2); color: var(--ht-text); }
.theme-swatch[aria-pressed="true"] { border-color: var(--ht-primary); background: var(--ht-surface-2); color: var(--ht-text); font-weight: 500; }
/* A small drawing of the page in a theme (_ThemeMini); its colors come from --sw1..3, not from the page's theme. */
.theme-mini { --mr: 4px; --mg: 4px; display: flex; gap: 0; aspect-ratio: 16 / 10; width: 100%; overflow: hidden; border-radius: 8px; background: #f3f5fa; border: 1px solid var(--ht-border); direction: rtl; }
.theme-mini[data-corners="sharp"] { --mr: 1px; }
.theme-mini[data-corners="round"] { --mr: 8px; }
.theme-mini[data-density="compact"] { --mg: 2px; }
.theme-mini .m-side { width: 28%; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--mg); padding: 6px var(--mg); background: radial-gradient(90% 60% at 100% 0, color-mix(in srgb, var(--sw1) 45%, transparent), transparent), var(--sw3); box-shadow: inset 1px 0 0 rgba(16, 24, 40, .08); }
.theme-mini[data-sidebar="solid"] .m-side { background: var(--sw3); }
.theme-mini .m-side i { height: 3px; border-radius: 3px; background: color-mix(in srgb, var(--sw3) 55%, #8a94a6); }
.theme-mini .m-side i:first-child { background: var(--sw1); }
.theme-mini .m-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--mg); padding: var(--mg); }
.theme-mini .m-card { flex: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; padding: 4px; background: #fff; border-radius: var(--mr); box-shadow: 0 3px 7px -3px rgba(16, 24, 40, .3); }
.theme-mini[data-surface="flat"] .m-card { box-shadow: 0 0 0 1px #e1e4ec; }
.theme-mini .m-card i { flex: 1; height: 3px; border-radius: 3px; background: #dfe3ec; }
.theme-mini .m-card b { width: 34%; height: 8px; border-radius: var(--mr); background: linear-gradient(90deg, var(--sw1), var(--sw2)); }
/* Theme management page */
.theme-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.theme-card { display: flex; flex-direction: column; padding: 12px; }
.theme-card.is-off .theme-mini { opacity: .5; }
.theme-card-body { flex: 1; padding: 10px 2px 8px; }
.theme-card-body p { margin: 4px 0 0; font-size: .78rem; color: var(--ht-muted); }
.theme-card-actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--ht-border); padding-top: 8px; }
.theme-form-preview { width: 200px; max-width: 100%; margin: 0 auto 16px; }
.theme-mode { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 10px; padding: 10px 4px 4px; border-top: 1px solid var(--ht-border); font-size: .8rem; color: var(--ht-muted); }
.seg-sm { padding: 3px; gap: 3px; border-radius: 10px; }
.seg-sm button { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ht-muted); font-size: .78rem; }
.seg-sm button .ti { font-size: 15px; }
.seg-sm button.active { background: var(--ht-surface); color: var(--ht-primary); font-weight: 500; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

/* ==========================================================================
   Theme shape (Admin > theme management): attributes on the html tag, set from the user's theme.
   Most corners are fixed sizes in the rules above, so the variants override the main components by name.
   ========================================================================== */
[data-ht-corners="sharp"] { --ht-radius: 6px; --ht-radius-lg: 8px; --bs-border-radius: 6px; --bs-border-radius-sm: 4px; --bs-border-radius-lg: 8px; }
[data-ht-corners="sharp"] :is(.btn, .btn-sm, .btn-icon, .icon-btn, .form-control, .form-select, .search-box input, .nav-link-x, .sidebar-card, .brand-mark, .user-chip, .avatar, .avatar-sm, .avatar-lg, .page-header, .page-header-icon, .stat-icon, .alert-x, .seg, .seg label, .seg button, .chip-filter, .chip-filter a, .pager a, .pager span, .perm-group, .role-pick label, .steps a, .feature-list div, .auth-card, .msg, .memory-row, .key-panel, .setup-step, .env-option, .grand, .dropdown-menu, .dropdown-item, .search-results, .search-results a, .modal-content, .select2-container--default .select2-selection--single, .theme-swatch, .welcome-card, .badge-soft, .crumbs) { border-radius: 6px; }
[data-ht-corners="sharp"] .nav-sub a { border-radius: 0 6px 6px 0; }

[data-ht-corners="round"] { --ht-radius: 20px; --ht-radius-lg: 26px; --bs-border-radius: 16px; --bs-border-radius-sm: 12px; --bs-border-radius-lg: 22px; }
[data-ht-corners="round"] :is(.btn, .btn-sm, .search-box input) { border-radius: 999px; }
[data-ht-corners="round"] :is(.btn-icon, .icon-btn, .brand-mark, .avatar, .avatar-sm) { border-radius: 50%; }
[data-ht-corners="round"] :is(.form-control, .form-select, .nav-link-x, .sidebar-card, .alert-x, .seg, .dropdown-menu, .search-results, .user-chip, .memory-row, .key-panel, .setup-step, .env-option, .select2-container--default .select2-selection--single) { border-radius: 18px; }
[data-ht-corners="round"] :is(.page-header, .welcome-card, .modal-content, .auth-card, .perm-group) { border-radius: 28px; }
[data-ht-corners="round"] .nav-sub a { border-radius: 0 18px 18px 0; }

[data-ht-surface="flat"] { --ht-shadow: none; }
[data-ht-surface="flat"] :is(.btn-primary, .page-header-icon, .brand-mark) { box-shadow: none; }
[data-ht-surface="flat"] .stat-card::after { display: none; }
[data-ht-surface="flat"] .auth-card, [data-bs-theme="dark"][data-ht-surface="flat"] .auth-card { box-shadow: none; }

[data-ht-sidebar="solid"] .sidebar { background-image: none; }
[data-ht-sidebar="solid"] .brand-mark { background: var(--ht-primary); box-shadow: none; }
[data-ht-sidebar="solid"] .nav-link-x.single.active { background: rgba(var(--ht-primary-rgb), .45); box-shadow: none; }

[data-ht-density="compact"] { --ht-topbar-height: 56px; --ht-sidebar-width: 244px; }
[data-ht-density="compact"] body { font-size: .86rem; }
[data-ht-density="compact"] .app-content { padding: 16px 20px 24px; }
[data-ht-density="compact"] .topbar { padding-inline: 20px; gap: 10px; }
[data-ht-density="compact"] .app-footer { min-height: 44px; padding-inline: 20px; }
[data-ht-density="compact"] .page-header { padding: 12px 16px; margin-bottom: 14px; }
[data-ht-density="compact"] .page-header-icon { width: 40px; height: 40px; font-size: 21px; }
[data-ht-density="compact"] .page-header h1 { font-size: 1.15rem; }
[data-ht-density="compact"] .card-x-header { padding: 10px 14px; }
[data-ht-density="compact"] .card-x-body { padding: 14px; }
[data-ht-density="compact"] .stat-card { padding: 12px; gap: 10px; }
[data-ht-density="compact"] .stat-card .value { font-size: 1.3rem; }
[data-ht-density="compact"] .table-x thead th { padding: 7px 12px; }
[data-ht-density="compact"] .table-x tbody td { padding: 6px 12px; font-size: .82rem; }
[data-ht-density="compact"] .btn { padding: .38rem .85rem; font-size: .82rem; }
[data-ht-density="compact"] .btn-sm { padding: .24rem .6rem; font-size: .76rem; }
[data-ht-density="compact"] .btn-icon { width: 30px; height: 30px; padding: 0; }
[data-ht-density="compact"] .icon-btn { width: 36px; height: 36px; }
[data-ht-density="compact"] .search-box input { height: 36px; }
[data-ht-density="compact"] :is(.form-control, .form-select) { padding-top: .36rem; padding-bottom: .36rem; font-size: .84rem; }
[data-ht-density="compact"] .nav-link-x { padding: 7px 10px; font-size: .84rem; }
[data-ht-density="compact"] .nav-sub a { padding-top: 5px; padding-bottom: 5px; font-size: .8rem; }
[data-ht-density="compact"] .sidebar-brand { padding: 10px 16px; }
[data-ht-density="compact"] .brand-mark { width: 34px; height: 34px; font-size: 19px; }
[data-ht-density="compact"] .auth-card { max-width: 380px; padding: 24px 24px 20px; }
[data-ht-density="compact"] .auth-card h1 { margin-top: 16px; }
[data-ht-density="compact"] .auth-card .lead-x { margin-bottom: 14px; }
[data-ht-density="compact"] .auth-card .btn-primary { height: 40px; }
@media (max-width: 991.98px) { [data-ht-density="compact"] .app-content { padding: 12px; } }

/* ---- AG Grid: ظاهر دقیق تصویر الگو ----
   رنگ‌ها عیناً از تصویر نمونه‌برداری شده‌اند و با انتخاب پوسته عوض نمی‌شوند (در حالت تیره از ترکیب همان آبی با زمینه):
   نوار و سرستون #f2f4fe (۷٪)، ردیف یک‌درمیان #f6f7fe، کارت جمع #f4f6fe، دکمه فعال #e8ecfd، انتخاب خانه #e4e9fd، قاب کارت جمع #c9d1f1.
   خطوط خاکستری #dbdcdf، عدد آبی #3651d4 (--ht-primary-hover) و آیکن اکسل #16a34a. */
.grid-host {
    /* رنگ پایه جدول‌ها ثابت و برابر تصویر الگوست و با انتخاب پوسته عوض نمی‌شود. */
    --g-primary: #4361ee;
    --g-primary-rgb: 67, 97, 238;
    --g-value: #3651d4;
    --g-panel: #f2f4fe;
    --g-stripe: #f6f7fe;
    --g-hover: #edf0fd;
    --g-stat: #f4f6fe;
    --g-stat-line: #c9d1f1;
    --g-stat-divider: #ccd3f1;
    --g-active: #e8ecfd;
    --g-select: #e4e9fd;
    --g-sidebar: #f8f8f9;
    --g-line: #dbdcdf;
    --g-row-line: #e6e9f2; /* خط جداکننده ردیف‌ها */
    --g-head-line: #dddee1;
    --g-input-line: #d6d8db;
    --g-icon: #52586a;
    --g-excel: #16a34a;
    --g-disabled: #cccfdb;
    display: flex; flex-direction: column; background: var(--ht-surface);
}
[data-bs-theme="dark"] .grid-host {
    --g-value: #8ea2ff;
    --g-hover: color-mix(in srgb, var(--g-primary) 12%, var(--ht-surface));
    --g-stat: color-mix(in srgb, var(--g-primary) 8%, var(--ht-surface));
    --g-stat-divider: color-mix(in srgb, var(--g-primary) 30%, var(--ht-border));
    --g-sidebar: var(--ht-surface-2);
    --g-panel: color-mix(in srgb, var(--g-primary) 9%, var(--ht-surface));
    --g-stripe: color-mix(in srgb, var(--g-primary) 4%, var(--ht-surface));
    --g-stat-line: color-mix(in srgb, var(--g-primary) 35%, var(--ht-border));
    --g-active: color-mix(in srgb, var(--g-primary) 22%, var(--ht-surface));
    --g-select: color-mix(in srgb, var(--g-primary) 24%, var(--ht-surface));
    --g-line: var(--ht-border); --g-row-line: var(--ht-border); --g-head-line: var(--ht-border); --g-input-line: var(--ht-border);
    --g-icon: var(--ht-muted); --g-disabled: var(--ht-subtle);
}

/* سربرگ: کارت‌های جمع در راست، ابزار و اکسل در چپ */
.grid-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 20px; background: var(--ht-surface); border-bottom: 1px solid var(--g-head-line); }
.grid-stats { display: flex; border: 1px solid var(--g-stat-line); border-radius: 10px; overflow: hidden; background: var(--g-stat); }
.grid-stat { padding: 7px 18px 8px; min-width: 100px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.grid-stat + .grid-stat { border-inline-start: 1px solid var(--g-stat-divider, var(--g-stat-line)); }
.grid-stat small { color: var(--ht-muted); font-size: .76rem; font-weight: 500; }
.grid-stat strong { color: var(--g-value); font-size: 1.12rem; font-weight: 800; display: flex; align-items: baseline; gap: 5px; line-height: 1.4; }
.grid-stat strong em { font-style: normal; font-size: .74rem; font-weight: 500; color: var(--ht-muted); }
.grid-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid-seg { display: inline-flex; border: 1px solid #e6e9f2; border-radius: 12px; overflow: hidden; background: var(--ht-surface); }
[data-bs-theme="dark"] .grid-seg, [data-bs-theme="dark"] .grid-excel { border-color: var(--ht-border); }
.grid-seg button, .grid-excel { display: inline-flex; align-items: center; gap: 7px; height: 38px; border: 0; background: transparent; color: var(--ht-text); font: inherit; font-size: .86rem; font-weight: 600; padding: 0 15px; transition: background-color .15s; }
.grid-seg button + button { border-inline-start: 1px solid #e6e9f2; }
[data-bs-theme="dark"] .grid-seg button + button { border-color: var(--ht-border); }
.grid-seg button:hover, .grid-excel:hover { background: var(--g-stripe); }
.grid-seg button.active { background: var(--g-active); color: var(--g-primary); }
.grid-seg .ti, .grid-excel .ti { font-size: 17px; color: var(--ht-muted); }
.grid-seg button.active .ti { color: var(--g-primary); }
.grid-excel { border: 1px solid #e6e9f2; border-radius: 12px; background: var(--ht-surface); }
.grid-excel .ti { color: var(--g-excel); }

/* نوار گروه‌بندی با کادر فیلتر در چپ */
.grid-body .ag-column-drop-wrapper { align-items: center; background: var(--g-panel); border-bottom: 1px solid var(--g-line); min-height: 44px; }
.grid-body .ag-column-drop-horizontal { background: transparent; border: 0; min-height: 44px; padding-inline: 18px; }
.grid-body .ag-column-drop-empty-message, .grid-body .ag-column-drop-horizontal .ag-column-drop-title-bar { color: var(--ht-text); opacity: 1; font-size: .86rem; font-weight: 500; }
.grid-body .ag-column-drop-horizontal .ag-icon { color: var(--ht-text); }
.grid-search { position: relative; flex: 0 0 240px; margin: 6px 14px; order: 99; }
.grid-search .ti { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--ht-subtle); font-size: 16px; pointer-events: none; }
.grid-search input { border-radius: 8px; border-color: var(--g-input-line); background: var(--ht-surface); padding-inline-start: 32px; height: 32px; font-size: .84rem; box-shadow: none; }
.grid-search input::placeholder { color: var(--ht-subtle); }

/* سرستون، فیلتر زیر سرستون، ردیف‌ها */
.grid-body .ag-header { background-color: var(--g-panel); border-bottom-color: var(--g-line); }
.grid-body .ag-header-cell-menu-button .ag-icon, .grid-body .ag-header-icon { color: var(--ht-text); }
.grid-body .ag-floating-filter-button .ag-icon, .grid-body .ag-floating-filter .ag-icon-filter { color: var(--g-icon); }
.grid-body .ag-floating-filter-input .ag-input-field-input { height: 30px; }
.grid-body .ag-cell.grid-cell { display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.5; }
/* محتوای خانه با ارتفاع طبیعی وسط ردیف می‌نشیند تا برچسب‌ها (badge) و دکمه‌ها بریده نشوند */
.grid-body .ag-cell.grid-cell .ag-cell-wrapper { height: 100%; align-items: center; }
.grid-body .ag-cell.grid-cell .ag-cell-value { line-height: 1.5; overflow: visible; }
.grid-body .ag-cell.grid-cell .badge-soft, .grid-body .ag-cell.grid-cell form.d-inline { vertical-align: middle; }
.grid-body .grid-ltr { unicode-bidi: isolate; white-space: nowrap; }
/* خانه چندخطی (عنوان و توضیح زیر آن): ردیف به اندازه محتوا بلند می‌شود */
/* AG Grid ارتفاع خودکار را از محتوا می‌سنجد، پس فاصله بالا و پایین روی خود محتواست نه روی خانه */
.grid-body .ag-cell.grid-multi { flex-direction: column; justify-content: center; align-items: flex-start; white-space: normal; text-overflow: clip; line-height: 1.55; }
.grid-body .ag-cell.grid-multi .ag-cell-wrapper { height: auto; }
.grid-body .ag-cell.grid-multi .grid-cell-content { display: block; white-space: normal; padding-block: 9px; }
.grid-body .ag-cell.grid-multi small.d-block { margin-top: 2px; line-height: 1.5; }
.grid-body .ag-cell.grid-rownum { color: var(--ht-text); font-weight: 600; justify-content: flex-start; display: flex; align-items: center; }
/* خط جداکننده بین ردیف‌ها (پارامتر rowBorder تم در این نسخه اعمال نمی‌شود) */
.grid-body .ag-row { border-bottom: 1px solid var(--g-row-line); }
.grid-body .ag-row-last:not(.ag-row-pinned) { border-bottom-color: transparent; }
.grid-body .ag-row.table-danger { background-color: rgba(var(--ht-danger-rgb), .08); }
.grid-body .ag-row.text-muted .ag-cell { color: var(--ht-muted); }
.grid-body .ag-row-pinned, .grid-body .ag-row.grid-total { font-weight: 700; }
.grid-body .btn-icon { width: 30px; height: 30px; border-radius: 8px; }
.grid-body .ag-cell .d-flex { flex-wrap: nowrap; }
.grid-body .ag-side-buttons { color: var(--ht-text); font-weight: 600; }

/* پانویس: اندازه صفحه، بازه ردیف و صفحه، با عددهای آبی */
.grid-body .ag-paging-panel { background: var(--g-panel); border-top: 1px solid var(--g-line); height: 48px; padding-inline: 18px; color: var(--ht-text); font-weight: 600; font-size: .86rem; gap: 6px; }
.grid-body .ag-paging-page-size .ag-picker-field-wrapper { background: var(--ht-surface); border-color: var(--g-line); border-radius: 8px; min-width: 64px; }
.grid-body .ag-paging-number, .grid-body .ag-paging-row-summary-panel-number { color: var(--g-value); font-weight: 800; }
.grid-body .ag-paging-button .ag-icon { color: var(--ht-text); }
.grid-body .ag-paging-button.ag-disabled .ag-icon { color: var(--g-disabled); opacity: 1; }

.grid-host.grid-hand .grid-body .ag-body { cursor: grab; }
.grid-host.grid-dragging, .grid-host.grid-dragging * { cursor: grabbing !important; user-select: none !important; }
@media (max-width: 767.98px) {
    .grid-search { flex-basis: 100%; }
    /* صفحه باریک: کارت‌ها و ابزار تمام‌عرض؛ گروه دکمه‌ها به‌جای بیرون‌زدن، افقی اسکرول می‌شود */
    .grid-head { padding: 14px; }
    .grid-stats, .grid-actions { width: 100%; }
    .grid-stat { flex: 1 1 0; }
    .grid-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .grid-seg::-webkit-scrollbar { display: none; }
    .grid-seg button { flex-shrink: 0; }
}
@media print { .grid-head, .grid-search, .grid-body .ag-column-drop-wrapper, .grid-body .ag-side-bar, .grid-body .ag-floating-filter, .grid-body .ag-paging-panel { display: none !important; } }
