/* ==========================================================================
   Cosdelmar ERP - design system
   One stylesheet for the whole app, loaded after Bootstrap 5.3 (RTL).
   Pages must not set sizes, radii, shadows or colours themselves (no inline
   style= for those, no <style> blocks): use Bootstrap classes and the classes
   below. `php spark ui:lint` reports violations.

   Rules
   - Controls (buttons, inputs, selects, input-group addons): ONE height, 40px.
     Inside tables they are automatically compact (32px). btn-sm/-lg,
     form-control-sm/-lg and input-group-sm/-lg do not change size.
   - Type scale: page title 22px, section title 17px, body 15px, small 13px,
     money total (.amount-lg) 28px.
   - Radius: 8px for controls and badges, 12px for cards, dialogs, dropdowns.
   - Colours by role: primary (blue) = the main action of an area, one per
     area; outline-secondary = other actions; danger = destructive;
     success = money received / done; warning = attention only.
   ========================================================================== */

/* ---------- Font (self-hosted Tajawal) ---------- */
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('../vendor/tajawal/tajawal-arabic-400.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 400; font-display: swap;
    src: url('../vendor/tajawal/tajawal-latin-400.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('../vendor/tajawal/tajawal-arabic-500.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 500; font-display: swap;
    src: url('../vendor/tajawal/tajawal-latin-500.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('../vendor/tajawal/tajawal-arabic-700.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 700; font-display: swap;
    src: url('../vendor/tajawal/tajawal-latin-700.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 800; font-display: swap;
    src: url('../vendor/tajawal/tajawal-arabic-800.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 800; font-display: swap;
    src: url('../vendor/tajawal/tajawal-latin-800.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

/* Tabular digits: Tajawal's own digits are proportional and it has no tnum feature, so a
   digits-only copy with equal widths (scripts/build_tabular_digits.py) is put first in the
   font stack of figures that are compared or summed: money, tables, stats, number inputs. */
@font-face { font-family: 'Tajawal Digits'; font-weight: 400; font-display: swap; src: url('../vendor/tajawal/tajawal-digits-400.woff2') format('woff2'); unicode-range: U+0030-0039; }
@font-face { font-family: 'Tajawal Digits'; font-weight: 500; font-display: swap; src: url('../vendor/tajawal/tajawal-digits-500.woff2') format('woff2'); unicode-range: U+0030-0039; }
@font-face { font-family: 'Tajawal Digits'; font-weight: 600 700; font-display: swap; src: url('../vendor/tajawal/tajawal-digits-700.woff2') format('woff2'); unicode-range: U+0030-0039; }
@font-face { font-family: 'Tajawal Digits'; font-weight: 800 900; font-display: swap; src: url('../vendor/tajawal/tajawal-digits-800.woff2') format('woff2'); unicode-range: U+0030-0039; }

/* ---------- Tokens ---------- */
:root {
    --app-control-h: 2.5rem;           /* 40px */
    --app-control-h-compact: 2rem;     /* 32px, tables */
    --app-radius: 8px;
    --app-radius-lg: 12px;

    --app-fs-title: 1.375rem;          /* 22px */
    --app-fs-section: 1.0625rem;       /* 17px */
    --app-fs-body: 0.9375rem;          /* 15px */
    --app-fs-small: 0.8125rem;         /* 13px */
    --app-fs-amount: 1.75rem;          /* 28px */

    --app-text: #0f172a;
    --app-text-muted: #64748b;
    --app-border: #e2e8f0;
    --app-surface: #ffffff;
    --app-bg: #f8fafc;
    --app-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);

    /* legacy names still used by some markup */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: var(--app-bg);
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --card-shadow: var(--app-shadow);

    /* Bootstrap */
    --bs-font-sans-serif: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-font-size: var(--app-fs-body);
    --bs-body-color: var(--app-text);
    --bs-body-bg: var(--app-bg);
    --bs-secondary-color: var(--app-text-muted);
    --bs-border-color: var(--app-border);
    --bs-border-radius: var(--app-radius);
    --bs-border-radius-sm: var(--app-radius);
    --bs-border-radius-lg: var(--app-radius-lg);
    --bs-border-radius-xl: var(--app-radius-lg);
    --bs-border-radius-xxl: var(--app-radius-lg);
    --bs-box-shadow-sm: var(--app-shadow);
    --bs-box-shadow: var(--app-shadow);
    --bs-box-shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.12);

    --bs-primary: #2563eb;   --bs-primary-rgb: 37, 99, 235;
    --bs-success: #16a34a;   --bs-success-rgb: 22, 163, 74;
    --bs-danger: #dc2626;    --bs-danger-rgb: 220, 38, 38;
    --bs-warning: #d97706;   --bs-warning-rgb: 217, 119, 6;
    --bs-info: #0284c7;      --bs-info-rgb: 2, 132, 199;
    --bs-secondary: #64748b; --bs-secondary-rgb: 100, 116, 139;
    --bs-dark: #0f172a;      --bs-dark-rgb: 15, 23, 42;
    --bs-link-color: #2563eb; --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color: #1d4ed8;
    --bs-primary-text-emphasis: #1d4ed8; --bs-primary-bg-subtle: #eff6ff; --bs-primary-border-subtle: #bfdbfe;
    --bs-success-text-emphasis: #15803d; --bs-success-bg-subtle: #f0fdf4; --bs-success-border-subtle: #bbf7d0;
    --bs-danger-text-emphasis: #b91c1c;  --bs-danger-bg-subtle: #fef2f2;  --bs-danger-border-subtle: #fecaca;
    --bs-warning-text-emphasis: #b45309; --bs-warning-bg-subtle: #fffbeb; --bs-warning-border-subtle: #fde68a;
    --bs-info-text-emphasis: #0369a1;    --bs-info-bg-subtle: #f0f9ff;    --bs-info-border-subtle: #bae6fd;
    --bs-secondary-bg-subtle: #f1f5f9;   --bs-secondary-text-emphasis: #334155;
}

html, body {
    font-family: var(--bs-body-font-family);
    font-size: 16px;
    background-color: var(--app-bg);
    color: var(--app-text);
    margin: 0;
    padding: 0;
    overflow-x: clip !important;
    max-width: 100vw !important;
    width: 100% !important;
}
body { font-size: var(--app-fs-body); }

/* ---------- Type scale ---------- */
h1, .h1, h2, .h2, h3, .h3 { font-size: var(--app-fs-title); font-weight: 700; }
h4, .h4 { font-size: var(--app-fs-title); font-weight: 700; }
h5, .h5, h6, .h6 { font-size: var(--app-fs-section); font-weight: 700; }
.fs-1, .fs-2, .amount-lg { font-size: var(--app-fs-amount) !important; }
.fs-3, .fs-4 { font-size: var(--app-fs-title) !important; }
.fs-5 { font-size: var(--app-fs-section) !important; }
.fs-6 { font-size: var(--app-fs-body) !important; }
.fs-7, small, .small { font-size: var(--app-fs-small) !important; }
.amount-lg { font-weight: 800; font-variant-numeric: tabular-nums; }
.font-monospace { font-family: var(--bs-body-font-family) !important; font-variant-numeric: tabular-nums; }
.text-muted, .text-secondary { color: var(--app-text-muted) !important; }
label, .form-label { font-size: var(--app-fs-small); font-weight: 600; color: #334155; margin-bottom: .35rem; }
.form-text { font-size: var(--app-fs-small); }

/* ---------- Buttons ---------- */
.btn {
    --bs-btn-padding-y: 0;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: var(--app-fs-body);
    --bs-btn-font-weight: 600;
    --bs-btn-line-height: 1.2;
    --bs-btn-border-radius: var(--app-radius);
    --bs-btn-box-shadow: none;
    min-height: var(--app-control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    white-space: nowrap;
    box-shadow: none !important;
}
.btn.d-none { display: none !important; }
.btn-sm, .btn-lg, .btn-xs, .btn-group-sm > .btn, .btn-group-lg > .btn {
    --bs-btn-padding-y: 0;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: var(--app-fs-body);
    --bs-btn-border-radius: var(--app-radius);
    min-height: var(--app-control-h);
}
.btn > i, .btn > .fa-solid, .btn > .fa-regular { font-size: 1em !important; margin: 0 !important; }
.btn-icon { width: var(--app-control-h); padding: 0 !important; }
.btn-link { min-height: 0; --bs-btn-padding-x: 0; font-weight: 600; }

/* compact controls: inside tables, list-group rows and explicit .compact zones */
.table .btn, .compact .btn, .list-group .btn, .btn-compact {
    --bs-btn-padding-x: .6rem;
    --bs-btn-font-size: var(--app-fs-small);
    min-height: var(--app-control-h-compact);
}
.table .btn-icon, .compact .btn-icon { width: var(--app-control-h-compact); }

/* role colours */
.btn-primary { --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb; --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1e40af; --bs-btn-active-border-color: #1e40af; --bs-btn-disabled-bg: #2563eb; --bs-btn-disabled-border-color: #2563eb; }
.btn-success { --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d; --bs-btn-active-bg: #166534; --bs-btn-active-border-color: #166534; --bs-btn-disabled-bg: #16a34a; --bs-btn-disabled-border-color: #16a34a; }
.btn-danger { --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; --bs-btn-active-bg: #991b1b; --bs-btn-active-border-color: #991b1b; }
.btn-warning { --bs-btn-color: #fff; --bs-btn-bg: #d97706; --bs-btn-border-color: #d97706; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #b45309; --bs-btn-hover-border-color: #b45309; --bs-btn-active-color: #fff; --bs-btn-active-bg: #92400e; --bs-btn-active-border-color: #92400e; }
.btn-info { --bs-btn-color: #fff; --bs-btn-bg: #0284c7; --bs-btn-border-color: #0284c7; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #0369a1; --bs-btn-hover-border-color: #0369a1; --bs-btn-active-color: #fff; --bs-btn-active-bg: #075985; }
.btn-dark { --bs-btn-bg: #0f172a; --bs-btn-border-color: #0f172a; --bs-btn-hover-bg: #1e293b; --bs-btn-hover-border-color: #1e293b; }
/* neutral secondary actions: grey outline on white */
.btn-secondary, .btn-light, .btn-white, .btn-outline-secondary, .btn-outline-dark {
    --bs-btn-color: #334155; --bs-btn-bg: #fff; --bs-btn-border-color: #cbd5e1;
    --bs-btn-hover-color: #0f172a; --bs-btn-hover-bg: #f1f5f9; --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-active-color: #0f172a; --bs-btn-active-bg: #e2e8f0; --bs-btn-active-border-color: #94a3b8;
    --bs-btn-disabled-color: #94a3b8; --bs-btn-disabled-bg: #fff; --bs-btn-disabled-border-color: #e2e8f0;
}
.btn-outline-primary { --bs-btn-color: #2563eb; --bs-btn-border-color: #bfdbfe; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #2563eb; --bs-btn-hover-border-color: #2563eb; --bs-btn-active-bg: #1d4ed8; --bs-btn-active-border-color: #1d4ed8; }
.btn-outline-success { --bs-btn-color: #15803d; --bs-btn-border-color: #bbf7d0; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #16a34a; --bs-btn-hover-border-color: #16a34a; --bs-btn-active-bg: #15803d; --bs-btn-active-border-color: #15803d; }
.btn-outline-danger { --bs-btn-color: #b91c1c; --bs-btn-border-color: #fecaca; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #dc2626; --bs-btn-hover-border-color: #dc2626; --bs-btn-active-bg: #b91c1c; --bs-btn-active-border-color: #b91c1c; }
.btn-outline-warning { --bs-btn-color: #b45309; --bs-btn-border-color: #fde68a; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706; --bs-btn-active-bg: #b45309; --bs-btn-active-border-color: #b45309; }
.btn-outline-info { --bs-btn-color: #0369a1; --bs-btn-border-color: #bae6fd; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #0284c7; --bs-btn-hover-border-color: #0284c7; --bs-btn-active-bg: #0369a1; --bs-btn-active-border-color: #0369a1; }
.btn-check:checked + .btn-outline-secondary, .btn-check:checked + .btn-outline-primary,
.btn-outline-secondary.active, .btn-outline-primary.active { color: #fff !important; background: #2563eb !important; border-color: #2563eb !important; }

/* ---------- Form controls ---------- */
.form-control, .form-select,
.form-control-sm, .form-control-lg, .form-select-sm, .form-select-lg {
    min-height: var(--app-control-h);
    font-size: var(--app-fs-body) !important;
    border-radius: var(--app-radius);
    border-color: #cbd5e1;
    padding-top: .375rem;
    padding-bottom: .375rem;
    color: var(--app-text);
    box-shadow: none;
}
.form-control, .form-control-sm, .form-control-lg { padding-left: .75rem; padding-right: .75rem; }
textarea.form-control { min-height: calc(var(--app-control-h) * 2); }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input-group-text {
    min-height: var(--app-control-h);
    font-size: var(--app-fs-body);
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--app-text-muted);
    padding: 0 .75rem;
}
.input-group > .btn { min-height: var(--app-control-h); }
.input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .input-group-text, .input-group-sm > .btn,
.input-group-lg > .form-control, .input-group-lg > .form-select, .input-group-lg > .input-group-text, .input-group-lg > .btn {
    min-height: var(--app-control-h);
    font-size: var(--app-fs-body);
    border-radius: var(--app-radius);
    padding-top: .375rem; padding-bottom: .375rem;
}
.input-group.shadow-sm, .input-group.shadow { box-shadow: none !important; }
.table .form-control, .table .form-select, .table .input-group-text, .table .input-group > .btn,
.compact .form-control, .compact .form-select, .compact .input-group-text {
    min-height: var(--app-control-h-compact);
    font-size: var(--app-fs-small) !important;
    padding-top: .2rem; padding-bottom: .2rem;
}
.form-check-input { margin-top: .2em; }

/* ---------- Cards, dialogs, dropdowns ---------- */
.card, .card-custom {
    border-radius: var(--app-radius-lg);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
}
.card.shadow, .card.shadow-sm, .card.shadow-lg, .card-custom.shadow, .card-custom.shadow-sm { box-shadow: var(--app-shadow) !important; }
.card.border-0, .card-custom.border-0 { border: 1px solid var(--app-border) !important; }
.card-header { background: transparent; border-bottom-color: var(--app-border); font-weight: 700; font-size: var(--app-fs-section); }
.modal-content { border-radius: var(--app-radius-lg); border: 0; box-shadow: var(--bs-box-shadow-lg); }
.modal-header { border-bottom-color: var(--app-border); }
.modal-header .modal-title { font-size: var(--app-fs-section); font-weight: 700; }
.modal-footer { border-top-color: var(--app-border); }
.dropdown-menu { border-radius: var(--app-radius-lg); border-color: var(--app-border); box-shadow: var(--bs-box-shadow-lg); font-size: var(--app-fs-body); }
.rounded, .rounded-1, .rounded-2 { border-radius: var(--app-radius) !important; }
.rounded-3, .rounded-4, .rounded-5 { border-radius: var(--app-radius-lg) !important; }

/* ---------- Badges ---------- */
.badge { font-size: var(--app-fs-small) !important; font-weight: 600; padding: .3em .6em; border-radius: 6px; }
.badge.rounded-pill { border-radius: 999px; }

/* ---------- Tables ---------- */
.table { --bs-table-color: var(--app-text); font-size: var(--app-fs-body); }
.table > thead th, .table > thead td {
    font-size: var(--app-fs-small);
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border-bottom: 1px solid var(--app-border);
    white-space: nowrap;
}
.table > :not(caption) > * > * { padding: .6rem .75rem; vertical-align: middle; }
.table-light { --bs-table-bg: #f8fafc; }

/* ---------- Building blocks (app/Views/components/ui) ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; font-size: var(--app-fs-title); display: flex; align-items: center; gap: .6rem; }
.page-header h1 > i { color: #2563eb; }
.page-header .page-subtitle { margin: .25rem 0 0; color: var(--app-text-muted); font-size: var(--app-fs-small); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.section-title { font-size: var(--app-fs-section); font-weight: 700; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; }
.section-title > i { color: #2563eb; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar .toolbar-sep { width: 1px; align-self: stretch; background: var(--app-border); margin: 0 .25rem; }
.empty-state { text-align: center; color: var(--app-text-muted); padding: 2.5rem 1rem; }
.empty-state > i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: .75rem; }
kbd { font-size: .75rem; padding: .1rem .35rem; border-radius: 4px; background: #e2e8f0; color: #0f172a; font-family: var(--bs-body-font-family); }

/* ---------- Shell: sidebar, navbar, content ---------- */
.wrapper { display: flex; min-height: 100vh; overflow-x: clip !important; max-width: 100vw !important; width: 100% !important; }
.sidebar {
    width: 260px; background-color: var(--sidebar-bg); color: #fff; flex-shrink: 0;
    transition: margin-right .3s cubic-bezier(.4, 0, .2, 1), opacity .25s ease, visibility .25s ease;
    display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; align-self: flex-start; z-index: 100;
}
body.sidebar-collapsed .sidebar:not(.offcanvas) { margin-right: -260px !important; opacity: 0; visibility: hidden; pointer-events: none; }
#btnToggleDesktopSidebar { transition: all .2s ease; }
body.sidebar-collapsed #btnToggleDesktopSidebar { background-color: #e2e8f0; color: #0f172a; }
.sidebar .brand {
    padding: 18px 20px; font-size: var(--app-fs-section); font-weight: 700; border-bottom: 1px solid #1e293b; color: #38bdf8;
    display: flex; align-items: center; gap: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex-shrink: 0;
}
.sidebar-scroll { overflow-y: auto; min-height: 0; flex-grow: 1; padding: 10px 0; }
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background-color: #334155; border-radius: 4px; }
.nav-group { margin-bottom: 4px; }
.nav-group-header {
    display: flex; align-items: center; justify-content: space-between; padding: 9px 16px; color: #94a3b8; text-decoration: none;
    font-size: var(--app-fs-small); font-weight: 600; border-radius: var(--app-radius); margin: 2px 8px; transition: all .2s ease;
}
.nav-group-header:hover { background-color: #1e293b; color: #38bdf8; }
.nav-group-header:not(.collapsed) { background-color: rgba(56, 189, 248, .08); color: #38bdf8; }
.nav-group-header .arrow-icon { font-size: .72rem; transition: transform .25s ease; }
.nav-group-header:not(.collapsed) .arrow-icon { transform: rotate(180deg); }
.nav-sub-list { list-style: none; padding: 3px 0; margin: 2px 8px 6px 8px; background-color: rgba(15, 23, 42, .5); border-radius: var(--app-radius); border-right: 2px solid rgba(56, 189, 248, .25); }
.nav-sub-link {
    display: flex; align-items: center; gap: 10px; padding: 7px 14px; color: #cbd5e1; text-decoration: none;
    font-size: var(--app-fs-small); font-weight: 500; border-radius: 6px; margin: 1px 4px; transition: all .15s ease;
}
.nav-sub-link:hover { color: #38bdf8; background-color: rgba(56, 189, 248, .12); }
.nav-sub-link.active { color: #38bdf8; background-color: rgba(56, 189, 248, .18); font-weight: 700; border-right: 3px solid #38bdf8; }
.nav-single-link {
    display: flex; align-items: center; gap: 10px; padding: 9px 16px; color: #94a3b8; text-decoration: none;
    font-size: var(--app-fs-small); font-weight: 600; border-radius: var(--app-radius); margin: 2px 8px; transition: all .2s ease;
}
.nav-single-link:hover, .nav-single-link.active { background-color: #1e293b; color: #38bdf8; border-right: 3px solid #38bdf8; }
.main-content { flex-grow: 1; display: flex; flex-direction: column; width: 100%; min-width: 0 !important; max-width: 100vw !important; overflow-x: hidden !important; }
.nav-wide-label { display: none !important; }
@media (min-width: 1600px) { .nav-wide-label { display: inline !important; } }
.top-navbar {
    background-color: #fff; padding: 10px 20px; border-bottom: 1px solid var(--app-border);
    display: flex; justify-content: space-between; align-items: center; max-width: 100% !important; box-sizing: border-box; gap: 8px;
    position: sticky; top: 0; z-index: 90;
}
.top-navbar .btn { --bs-btn-padding-x: .75rem; }
.top-navbar .nav-clock { font-size: var(--app-fs-body); color: var(--app-text-muted); white-space: nowrap; margin: 0; font-weight: 500; }
.content-body { padding: 24px; flex-grow: 1; max-width: 100% !important; overflow-x: hidden !important; box-sizing: border-box; }
.table-responsive { max-width: 100% !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
@media (max-width: 991.98px) {
    .sidebar:not(.offcanvas) { display: none !important; }
    .content-body { padding: 12px !important; }
    .top-navbar { padding: 8px 12px !important; }
}
.offcanvas.mobile-sidebar-drawer {
    background-color: var(--sidebar-bg) !important; color: #fff !important; width: 290px !important; max-width: 85vw !important; z-index: 1065 !important;
    display: flex; flex-direction: column; border: none; box-shadow: -5px 0 25px rgba(0, 0, 0, .5);
    position: fixed !important; top: 0 !important; bottom: 0 !important; right: 0 !important; left: auto !important;
    transform: translateX(100%); transition: transform .28s cubic-bezier(.4, 0, .2, 1), visibility .28s ease !important;
}
.offcanvas.mobile-sidebar-drawer.show { display: flex !important; transform: translateX(0) !important; visibility: visible !important; }
.offcanvas.mobile-sidebar-drawer .brand {
    padding: 16px 20px; font-size: var(--app-fs-section); font-weight: 700; border-bottom: 1px solid #1e293b; color: #38bdf8;
    display: flex; align-items: center; justify-content: space-between;
}
.mobile-search-overlay {
    position: fixed; inset: 0; width: 100vw; height: 100vh; background-color: var(--app-bg); z-index: 1080;
    display: flex; flex-direction: column; animation: mobileSearchFadeIn .2s ease-out;
}
@keyframes mobileSearchFadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.mobile-search-header { background: #fff; padding: 10px 14px; border-bottom: 1px solid var(--app-border); flex-shrink: 0; }
.mobile-search-results { flex-grow: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.mobile-result-card {
    background: #fff; border-radius: var(--app-radius-lg); padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--app-border);
    cursor: pointer; transition: all .15s ease;
}
.mobile-result-card:active { transform: scale(.98); background-color: #f1f5f9; }
.mobile-group-header { font-size: var(--app-fs-small); font-weight: 700; padding: 6px 12px; border-radius: var(--app-radius); margin: 10px 0 8px; }

/* ---------- DataTables ---------- */
div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select { min-height: 0; height: var(--app-control-h-compact); padding-top: 0; padding-bottom: 0; font-size: var(--app-fs-small) !important; }
div.dataTables_wrapper div.dataTables_info, div.dataTables_wrapper div.dataTables_paginate { font-size: var(--app-fs-small); }
.page-link { font-size: var(--app-fs-small); }

/* ==========================================================================
   Page widgets (moved here from per-page <style> blocks)
   ========================================================================== */
.cursor-pointer { cursor: pointer; }
.hover-item:hover, .hover-bg:hover { background-color: #f1f5f9; }

/* KPI / stat cards: reports, stats, stock valuation, cash drawer */
.kpi-card, .stat-kpi-card, .caja-kpi-card {
    background: var(--app-surface); border-radius: var(--app-radius-lg); padding: 1rem 1.25rem;
    border: 1px solid var(--app-border) !important; box-shadow: var(--app-shadow); position: relative; overflow: hidden;
}
.kpi-card .kpi-icon {
    width: 44px; height: 44px; border-radius: var(--app-radius); display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.kpi-card .kpi-value, .number-highlight, .number-display { font-size: var(--app-fs-title); font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--bs-body-font-family); }
.kpi-card .kpi-label { color: var(--app-text-muted); font-size: var(--app-fs-small); font-weight: 600; }
.stat-kpi-icon { position: absolute; bottom: -10px; left: -10px; font-size: 4rem; opacity: .1; }
.chart-card, .filter-bar {
    background: var(--app-surface); border-radius: var(--app-radius-lg); padding: 1.25rem; border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow); margin-bottom: 1.25rem;
}
.chart-container { position: relative; height: 340px; width: 100%; }

/* Underlined tabs (reports, stats) */
.nav-reports-tabs, .nav-tabs-custom { border-bottom: 1px solid var(--app-border); gap: .25rem; }
.nav-reports-tabs .nav-link, .nav-tabs-custom .nav-link {
    border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--app-text-muted);
    font-weight: 600; font-size: var(--app-fs-body); padding: .75rem 1rem; background: transparent;
}
.nav-reports-tabs .nav-link:hover, .nav-tabs-custom .nav-link:hover { color: #2563eb; }
.nav-reports-tabs .nav-link.active, .nav-tabs-custom .nav-link.active { color: #2563eb; border-bottom-color: #2563eb; background: transparent; }

/* Date-range presets (reports) */
.badge-preset {
    cursor: pointer; font-weight: 600; font-size: var(--app-fs-small) !important; padding: .4rem .8rem; border-radius: var(--app-radius);
    border: 1px solid #cbd5e1; background: #fff; color: #334155;
}
.badge-preset:hover, .badge-preset.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.report-hero {
    background: #0f172a; border-radius: var(--app-radius-lg); color: #fff; padding: 1.5rem 1.75rem; margin-bottom: 1.25rem;
}

/* Small counters and status pills */
.caja-badge, .perm-badge-counter { font-size: var(--app-fs-small); padding: .25rem .5rem; border-radius: 6px; }
.form-check-input:checked { background-color: #2563eb; border-color: #2563eb; }

/* Selectable cards (warehouse type) */
.type-card { border-width: 2px !important; }
.active-type { border-color: #2563eb !important; background-color: #eff6ff; }

/* ---------- POS ---------- */
.pos-item-card { cursor: pointer; }
.line-verified, .line-verified td { background-color: #fef2f2 !important; }
.line-verified { box-shadow: inset -4px 0 0 #dc2626; }
.autocomplete-dropdown {
    position: absolute; top: 100%; right: 0; left: 0; z-index: 1050; max-height: 380px; overflow-y: auto;
    background: #fff; border-radius: var(--app-radius-lg); box-shadow: var(--bs-box-shadow-lg); border: 1px solid var(--app-border); margin-top: 4px;
}
.autocomplete-item { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.autocomplete-item:hover, .autocomplete-item.active { background-color: #eff6ff; }
/* touch keypad: deliberately larger than the standard control */
.numpad-btn { height: 56px; font-size: var(--app-fs-title); font-weight: 700; }
.numpad-display {
    font-size: var(--app-fs-amount); font-weight: 800; height: 64px; background-color: #0f172a; color: #fff;
    text-align: center; border-radius: var(--app-radius); border: none; font-variant-numeric: tabular-nums;
}
.pos-qty-stepper { flex-wrap: nowrap; }
.pos-qty-stepper input { max-width: 64px; text-align: center; }

/* Camera scanner */
.scanner-laser-bar {
    width: 85%; margin: 0 auto; height: 3px; background: #dc2626; box-shadow: 0 0 10px #dc2626;
    position: relative; border-radius: 2px; animation: scanLaserAnim 2.2s infinite ease-in-out;
}
@keyframes scanLaserAnim {
    0% { transform: translateY(-75px); opacity: .2; }
    50% { transform: translateY(75px); opacity: 1; }
    100% { transform: translateY(-75px); opacity: .2; }
}
@keyframes laserScanAnim {
    0% { top: 15%; opacity: .4; }
    50% { top: 80%; opacity: 1; }
    100% { top: 15%; opacity: .4; }
}
#camera-reader video, #scannerReader video { object-fit: cover !important; border-radius: var(--app-radius); width: 100% !important; height: auto !important; }

@media (max-width: 1199.98px) {
    .pos-top-toolbar { overflow-x: auto; white-space: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 767.98px) {
    #cart-table thead { display: none !important; }
    .pos-desktop-col { display: none !important; }
    .pos-mobile-row { display: table-cell !important; width: 100% !important; }
    #cart-table tr:not(#empty-cart-msg) { display: table-row !important; }
    .pos-qty-stepper { max-width: 160px !important; }
    .mobile-bottom-checkout-bar {
        position: fixed; bottom: 0; left: 0; right: 0; background: #0f172a; color: #fff; padding: 10px 16px; z-index: 1040;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .25); display: flex; justify-content: space-between; align-items: center;
    }
}
@media (min-width: 768px) {
    .pos-mobile-row { display: none !important; }
    .pos-desktop-col { display: table-cell !important; }
}

/* ---------- Login ---------- */
body.login-page { background: #0f172a; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 420px; padding: 32px 28px; background: #fff; border-radius: var(--app-radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .4);
}
.caja-badge-saved { background-color: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; font-size: var(--app-fs-small); padding: 2px 8px; border-radius: 6px; }

/* Icons inside labels and field prefixes are decoration: one neutral colour */
.form-label i, label > i, .input-group-text i { color: var(--app-text-muted) !important; }
/* Page and section title icons: the brand colour */
.page-header h1 > i, .section-title > i, .card-header > i, .card h5 > i:first-child, .card h6 > i:first-child { color: #2563eb !important; }
/* Payment-method style choice groups wrap into an even grid */
#payment-methods-btn-group { display: grid !important; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
#payment-methods-btn-group > .btn { border-radius: var(--app-radius) !important; margin: 0 !important; }


/* ==========================================================================
   Consistency layer (v2)
   ========================================================================== */

/* ---------- Contrast: coloured text always uses the dark shade (>= 4.5:1 on white) ---------- */
.text-success { color: #15803d !important; }
.text-warning { color: #b45309 !important; }
.text-info { color: #0369a1 !important; }
.text-primary { color: #1d4ed8 !important; }
.text-danger { color: #b91c1c !important; }
.link-primary, a:not(.btn):not(.nav-sub-link):not(.nav-single-link):not(.dropdown-item):not(.page-link) { text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ---------- Badges: tinted, centred, never wrapping ---------- */
.badge {
    display: inline-flex; align-items: center; justify-content: center; gap: .3em;
    line-height: 1.25; vertical-align: middle; white-space: nowrap;
}
.badge > i { font-size: .9em; }
.badge.bg-primary, .badge.text-bg-primary { background: var(--bs-primary-bg-subtle) !important; color: var(--bs-primary-text-emphasis) !important; }
.badge.bg-success, .badge.text-bg-success { background: var(--bs-success-bg-subtle) !important; color: var(--bs-success-text-emphasis) !important; }
.badge.bg-danger, .badge.text-bg-danger { background: var(--bs-danger-bg-subtle) !important; color: var(--bs-danger-text-emphasis) !important; }
.badge.bg-warning, .badge.text-bg-warning { background: var(--bs-warning-bg-subtle) !important; color: #92400e !important; }
.badge.bg-info, .badge.text-bg-info { background: var(--bs-info-bg-subtle) !important; color: var(--bs-info-text-emphasis) !important; }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-dark, .badge.text-bg-dark,
.badge.bg-light, .badge.text-bg-light { background: var(--bs-secondary-bg-subtle) !important; color: var(--bs-secondary-text-emphasis) !important; }
.badge.bg-warning-subtle, .badge.bg-warning.bg-opacity-25 { color: #92400e !important; }
/* a badge next to text always keeps its distance */
.badge + *, * + .badge { margin-inline-start: .4rem; }
.d-flex > .badge + *, .d-flex > * + .badge, .page-actions > *, .toolbar > * { margin-inline-start: 0; }

/* ---------- Icons: one box per icon so rows of them line up ---------- */
.input-group-text { justify-content: center; min-width: var(--app-control-h); }
.input-group-text > i, .form-label > i, .btn > i, .nav-sub-link > i { width: 1.25em; text-align: center; flex-shrink: 0; }
/* Icon tile used by stat cards and info boxes: always a square, icon centred */
.icon-tile {
    width: 2.75rem; height: 2.75rem; flex: 0 0 2.75rem; border-radius: var(--app-radius);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
    background: var(--bs-primary-bg-subtle); color: #2563eb;
}
.icon-tile.tone-success { background: var(--bs-success-bg-subtle); color: #15803d; }
.icon-tile.tone-danger { background: var(--bs-danger-bg-subtle); color: #b91c1c; }
.icon-tile.tone-warning { background: var(--bs-warning-bg-subtle); color: #b45309; }
.icon-tile.tone-info { background: var(--bs-info-bg-subtle); color: #0369a1; }
.icon-tile.tone-neutral { background: var(--bs-secondary-bg-subtle); color: #475569; }

/* ---------- Money and numbers ---------- */
.money { white-space: nowrap; direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
/* numeric table cells (marked by the layout script): left-to-right so signs sit on the
   correct side, never wrapped, aligned with the column's other text */
.table td.cell-num, .table th.cell-num { direction: ltr; text-align: right; white-space: nowrap; unicode-bidi: plaintext; }
.table td.cell-num .badge { direction: ltr; }

/* ---------- Stat card (ui_stat_card) ---------- */
.stat-card {
    display: flex; align-items: center; gap: .9rem; padding: 1rem 1.15rem; height: 100%;
    background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-lg); box-shadow: var(--app-shadow);
    min-width: 0;
}
.stat-card .stat-body { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: .15rem; }
.stat-card .stat-label { font-size: var(--app-fs-small); color: var(--app-text-muted); font-weight: 600; line-height: 1.35; }
.stat-card .stat-value { font-size: var(--app-fs-title); font-weight: 800; line-height: 1.25; color: var(--app-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .stat-value .money, .stat-card .stat-value { font-variant-numeric: tabular-nums; }
.stat-card .stat-hint { font-size: var(--app-fs-small); color: var(--app-text-muted); line-height: 1.35; }
.stat-card.tone-success .stat-value { color: #15803d; }
.stat-card.tone-danger .stat-value { color: #b91c1c; }
.stat-card.tone-warning .stat-value { color: #b45309; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }

/* ---------- Filter bar: fields left to right, actions last, all on one baseline ---------- */
.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem;
    background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow); padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.filter-bar .filter-field { display: flex; flex-direction: column; gap: .35rem; flex: 1 1 11rem; min-width: 0; }
.filter-bar .filter-field.filter-search { flex: 2 1 16rem; }
.filter-bar .filter-field.filter-date { flex: 0 1 10.5rem; }
.filter-bar .filter-field.filter-period { flex: 0 0 auto; }
.filter-bar .filter-field > label, .filter-bar .filter-field > .form-label { margin: 0; }
.filter-bar .filter-actions { display: flex; gap: .5rem; flex: 0 0 auto; margin-inline-start: auto; }
@media (max-width: 575.98px) {
    .filter-bar .filter-field, .filter-bar .filter-field.filter-date { flex: 1 1 100%; }
    .filter-bar .filter-actions { flex: 1 1 100%; }
    .filter-bar .filter-actions > .btn:not(.btn-icon) { flex: 1 1 auto; }
    .filter-bar .filter-field.filter-period { flex: 1 1 100%; min-width: 0; }
}

/* ---------- Segmented control: one row, scrolls instead of wrapping ---------- */
.segmented { display: inline-flex; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented > .btn { flex: 0 0 auto; }
.btn-group { flex-wrap: nowrap; }

/* ---------- Tables ---------- */
.table > thead th, .table > thead td { text-align: start; }
.table-bordered > :not(caption) > * { border-width: 0; }
.table-bordered > :not(caption) > * > * { border-width: 0 0 1px; }
.table > tbody > tr:last-child > * { border-bottom-width: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8fafc; }
.table td .text-muted.small, .table td small { line-height: 1.4; }
/* list cell: main line + secondary line of meta badges */
.cell-title { font-weight: 700; color: var(--app-text); }
.cell-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.cell-meta .badge { margin: 0; }
.table td.cell-wrap { white-space: normal; min-width: 12rem; }

/* ---------- DataTables: one layout everywhere ---------- */
.dt-toolbar, .dt-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; }
.dt-toolbar { margin-bottom: .75rem; }
.dt-footer { margin-top: .75rem; }
div.dataTables_wrapper div.dataTables_filter { text-align: start; }
div.dataTables_wrapper div.dataTables_filter label, div.dataTables_wrapper div.dataTables_length label {
    display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 500; color: var(--app-text-muted); font-size: var(--app-fs-small);
}
div.dataTables_wrapper div.dataTables_filter input {
    margin: 0 !important; width: 16rem; max-width: 60vw; height: var(--app-control-h) !important; min-height: var(--app-control-h);
    font-size: var(--app-fs-body) !important; padding-inline-start: 2.25rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' fill='%2394a3b8'%3E%3Cpath d='M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z'/%3E%3C/svg%3E") no-repeat right .8rem center / 14px;
}
div.dataTables_wrapper div.dataTables_length select { width: auto; height: var(--app-control-h) !important; min-height: var(--app-control-h); font-size: var(--app-fs-body) !important; margin: 0 !important; }
div.dataTables_wrapper div.dataTables_info { padding: 0 !important; color: var(--app-text-muted); }
div.dataTables_wrapper div.dataTables_paginate { margin: 0 !important; }
div.dataTables_wrapper div.dataTables_paginate ul.pagination { margin: 0 !important; justify-content: flex-start; }

/* ---------- Pagination ---------- */
.pagination { --bs-pagination-border-radius: var(--app-radius); --bs-pagination-color: #334155; --bs-pagination-active-bg: #2563eb; --bs-pagination-active-border-color: #2563eb; gap: .25rem; }
.pagination .page-link { min-width: 2rem; height: 2rem; padding: 0 .55rem; display: flex; align-items: center; justify-content: center; border-radius: var(--app-radius) !important; font-variant-numeric: tabular-nums; }
.pagination .page-item:not(:first-child) .page-link { margin: 0; }

/* ---------- Section titles inside cards: one colour ---------- */
.card h5, .card h6, .card .card-title, .card-header { color: var(--app-text); }

/* Toggle buttons (on/off state, e.g. sidebar toggle): pressed = grey, never the primary blue */
.btn-outline-secondary[aria-pressed="true"] { background: #e2e8f0; border-color: #94a3b8; color: #0f172a; }
.mobile-search-trigger { min-width: 0; max-width: 220px; }
@media (max-width: 575.98px) { .top-navbar { gap: 6px; } .top-navbar .user-info .badge { max-width: 5rem; overflow: hidden; text-overflow: ellipsis; } }
.pos-view-switch > .btn { flex: 1 1 0; min-width: 0; }

/* stat grid with a fixed column count (e.g. 6 cards = 2 rows of 3) */
@media (min-width: 992px) { .stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } .stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
/* chart legend dot and fixed chart heights */
.legend-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--dot, #2563eb); flex: 0 0 auto; }
.chart-sm { position: relative; height: 240px; } .chart-md { position: relative; height: 320px; }

/* Stat values step down instead of being cut off when the card is narrow */
.stat-card .stat-body { container-type: inline-size; }
@container (max-width: 13rem) { .stat-card .stat-value { font-size: var(--app-fs-section); } }
@container (max-width: 10rem) { .stat-card .stat-value { font-size: var(--app-fs-body); } }

/* Group header row inside a table body (e.g. "in" / "out" sections) */
.table tr.row-group > th, .table tr.row-group > td {
    font-size: var(--app-fs-small); font-weight: 600; color: var(--app-text-muted); background: #f8fafc;
    border-top: 1px solid var(--app-border); padding-top: .45rem; padding-bottom: .45rem;
}

/* Dates and times: read left-to-right inside Arabic text, never wrap */
.date { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td.date, .table th.date { text-align: right; }

/* Figures that line up: money, tables, stat values, totals, number inputs, pagination */
.money, .table, .stat-value, .amount-lg, .kpi-value, .number-display, .number-highlight, .numpad-display,
input[type="number"], .pagination, .cell-num, .date {
    font-family: 'Tajawal Digits', var(--bs-font-sans-serif);
}
/* "+N" / count badges read left-to-right */
.badge-count { direction: ltr; unicode-bidi: isolate; }
/* Page header on phones: actions wrap as compact buttons in rows, not one per line */
@media (max-width: 575.98px) {
    .page-header { align-items: flex-start; }
    .page-actions { width: 100%; }
    .page-actions > .btn, .page-actions > a.btn, .page-actions > .dropdown { flex: 1 1 auto; }
}

/* A select in a filter bar takes a field's width, not a whole row */
@media (min-width: 768px) { .filter-bar .filter-field:has(> select) { flex: 0 1 14rem; } }
/* Compact stat cards (facts like client / date / warehouse on detail pages) */
.stat-grid.compact { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; }
.stat-grid.compact .stat-card { padding: .75rem .9rem; gap: .65rem; }
.stat-grid.compact .icon-tile { width: 2.25rem; height: 2.25rem; flex-basis: 2.25rem; font-size: 1rem; }
.stat-grid.compact .stat-value { font-size: var(--app-fs-body); }
@media (max-width: 575.98px) { .stat-grid.compact { grid-template-columns: 1fr 1fr; } }

/* DataTables Responsive: flat chevron instead of the glossy plus/minus circles */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    content: '\f104'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: .8rem;
    background: var(--bs-secondary-bg-subtle); color: #475569; border: 0; box-shadow: none; border-radius: 6px;
    width: 1.25rem; height: 1.25rem; line-height: 1.25rem; text-align: center; text-indent: 0; display: inline-block;
    transition: transform .15s ease;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control::before {
    background: var(--bs-primary-bg-subtle); color: #1d4ed8; transform: rotate(-90deg);
}

/* Segmented controls that do not fit: fade the cut-off edge so it reads as scrollable */
.segmented.is-scrollable { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 2.5rem); mask-image: linear-gradient(to right, transparent 0, #000 2.5rem); }
.segmented.is-scrollable.at-end { -webkit-mask-image: none; mask-image: none; }
