/* ==========================================================================
   ESSA ERP - Design System ("erp-theme")
   --------------------------------------------------------------------------
   Loaded LAST in Views/Shared/_Layout.cshtml (end of <body>) so it wins over
   Nicepage / bootstrap / jsgrid / legacy Style{Ar,En}.css at equal specificity.

   Rules of thumb:
   - Only visual rules. Never hide/show things that JS toggles
     (display_none / hidden_Control stay authoritative).
   - Logical properties only (margin-inline-start, inset-inline-end ...) so
     the same rules work for RTL (Arabic, default) and LTR (English).
   - New components use the "erp-" prefix. Legacy overrides are scoped to
     .erp-main (the #carousel_47a3 content area) or to well known widgets.

   Sections
     0. Tokens            6. Buttons            12. Modals / search box
     1. Base / typography 7. Filter bar         13. Toasts / loader
     2. App shell         8. Data grids         14. Badges / empty state
     3. Page header       9. Tabs / steps       15. Tiles (home / menus)
     4. Cards / panels   10. Sticky action bar  16. Login
     5. Forms            11. Legacy overrides   17. Responsive / print
   ========================================================================== */

/* 0. TOKENS ================================================================ */
:root {
    --erp-font: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;

    /* Brand: deep navy / indigo */
    --erp-navy-950: #0b1430;
    --erp-navy-900: #101c42;
    --erp-navy-800: #172656;
    --erp-navy-700: #1f3170;
    --erp-primary: #2f4bb0;
    --erp-primary-hover: #263f98;
    --erp-primary-active: #1f3480;
    --erp-primary-400: #5b74d1;
    --erp-primary-200: #c3cdf2;
    --erp-primary-100: #e4e9fb;
    --erp-primary-50: #f2f5fe;

    /* Neutrals */
    --erp-gray-0: #ffffff;
    --erp-gray-25: #fafbfd;
    --erp-gray-50: #f4f6fa;
    --erp-gray-100: #eceff5;
    --erp-gray-200: #dfe3ec;
    --erp-gray-300: #c9cfdc;
    --erp-gray-400: #9aa3b6;
    --erp-gray-500: #636c81; /* AA (4.8:1) on --erp-bg too */
    --erp-gray-600: #4b5468;
    --erp-gray-700: #353c4e;
    --erp-gray-800: #222838;
    --erp-gray-900: #141824;

    /* Semantic */
    --erp-success: #137a39; /* text: 4.9:1 on --erp-success-bg */
    --erp-success-bg: #e6f6ec;
    --erp-warning: #b45309;
    --erp-warning-bg: #fdf3e2;
    --erp-danger: #c62828;
    --erp-danger-hover: #a91f1f;
    --erp-danger-bg: #fdecec;
    --erp-info: #0369a1;
    --erp-info-bg: #e3f2fb;

    /* Surfaces */
    --erp-bg: var(--erp-gray-50);
    --erp-surface: var(--erp-gray-0);
    --erp-border: var(--erp-gray-200);
    --erp-text: var(--erp-gray-800);
    --erp-text-muted: var(--erp-gray-500);

    /* Geometry */
    --erp-radius-sm: 6px;
    --erp-radius: 10px;
    --erp-radius-lg: 14px;
    --erp-sidebar-w: 268px;
    --erp-topbar-h: 64px;
    --erp-gutter: 24px;

    /* Elevation */
    --erp-shadow-xs: 0 1px 2px rgba(16, 24, 40, .06);
    --erp-shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --erp-shadow-md: 0 6px 16px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
    --erp-shadow-lg: 0 18px 40px rgba(16, 24, 40, .16);
    --erp-focus: 0 0 0 3px rgba(47, 75, 176, .22);

    --erp-transition: 160ms cubic-bezier(.4, 0, .2, 1);

    /* Solid fills for buttons (text on them is white) */
    --erp-on-primary: #ffffff;
    --erp-success-solid: #15803d;
    --erp-danger-solid: #c62828;
    --erp-danger-border: #f5c2c2;
    --erp-warning-solid: #b45309;
    --erp-info-solid: #0369a1;
    --erp-ease: cubic-bezier(.4, 0, .2, 1);
    --erp-transition-slow: 200ms cubic-bezier(.4, 0, .2, 1);

    /* Translucent surfaces / overlays (theme dependent) */
    --erp-topbar-bg: rgba(255, 255, 255, .92);
    --erp-actionbar-bg: rgba(255, 255, 255, .95);
    --erp-overlay: rgba(11, 20, 48, .45);
    --erp-loader-overlay: rgba(244, 246, 250, .55);
    --erp-toast-bg: #141824;
    --erp-toast-text: #ffffff;
    --erp-tile-icon-bg: var(--erp-primary-50);

    /* Primary used as TEXT (links, active tabs, icons). Equal to --erp-primary in the
       light themes; lighter in "night" so text on dark surfaces stays AA. */
    --erp-primary-text: #2f4bb0;
    --erp-primary-text-hover: #263f98;
    --erp-primary-shadow: rgba(47, 75, 176, .35);

    /* Sidebar (dark brand panel in every theme; background = --erp-navy-900/950) */
    --erp-sidebar-text: #c9d2ee;
    --erp-sidebar-text-2: #aab5dc;
    --erp-sidebar-muted: #8f9bc4;
    --erp-sidebar-label: #7d89b3;
    --erp-sidebar-tag: #c3cdf2;
    --erp-sidebar-danger: #f3b4b4;      /* sidebar Logout label (soft danger on the dark panel) */
    --erp-sidebar-danger-bg: rgba(198, 40, 40, .18);

    /* Login hero glows */
    --erp-hero-glow-1: rgba(91, 116, 209, .45);
    --erp-hero-glow-2: rgba(47, 75, 176, .5);

    /* Controls: ONE height for inputs, selects, select2, dates and buttons */
    --erp-control-h: 40px;
    --erp-control-h-sm: 32px;
    --erp-control-h-lg: 44px;
    --erp-control-radius: 8px;
    --erp-control-px: 12px;
    --erp-control-fs: 13.5px;
    --erp-label-fs: 12.5px;
    --erp-label-gap: 6px;
    --erp-field-gap-x: 16px;
    --erp-field-gap-y: 14px;

    color-scheme: light;
}

/* ---- COLOUR THEMES ---------------------------------------------------------
   <html data-theme="blue|green|orange|classic|night|sand|sage|mist"> plus two helper
   attributes, all set before first paint by the inline script in _Layout <head>
   and switched by the palette picker (ClientApp/Shell/Theme.ts):
     data-theme-mode="dark|light"       dark-surface rules (filters, text remaps)
     data-theme-surface="tinted|plain"  legacy white boxes/inputs/grids mapped to
                                        --erp-surface (night + sand/sage/mist: surface != #fff)
   :root above IS "classic" (white surfaces, navy/blue accents) = the default.
   data-theme="dark" (old saved value) is an alias of "night".
   Screen only: print always uses the classic tokens above. ---- */
@media screen {
    /* NIGHT (eye comfort, dark): soft navy-charcoal, never pure black */
    :root:is([data-theme="night"], [data-theme="dark"]) {
        --erp-navy-950: #060a18;
        --erp-navy-900: #0a1024;
        --erp-navy-800: #121b3a;
        --erp-navy-700: #1a2550;

        --erp-primary: #4762d4;       /* white label 5.3:1 */
        --erp-primary-hover: #3d56bd;
        --erp-primary-active: #a9b8f5;
        --erp-primary-text: #93a6f2;  /* 7.4:1 on surface */
        --erp-primary-text-hover: #b3c1f6;
        --erp-primary-shadow: rgba(0, 0, 0, .45);
        --erp-primary-400: #7489e6;
        --erp-primary-200: #34478f;
        --erp-primary-100: #24326a;
        --erp-primary-50: #1a2450;

        --erp-sidebar-danger: #f4abab;      /* sidebar Logout label */
        --erp-sidebar-danger-bg: rgba(248, 113, 113, .16);

        /* neutral scale is inverted: 0 = surface, 900 = strongest text */
        --erp-gray-0: #141a2b;
        --erp-gray-25: #171e31;
        --erp-gray-50: #1b2337;
        --erp-gray-100: #222b42;
        --erp-gray-200: #2c364f;
        --erp-gray-300: #3a4562;
        --erp-gray-400: #5d6987;
        --erp-gray-500: #8d97b2;
        --erp-gray-600: #a9b2c9;
        --erp-gray-700: #c3cadb;
        --erp-gray-800: #dde2ec;
        --erp-gray-900: #f2f4f9;

        --erp-success: #4ade80;
        --erp-success-bg: #12301f;
        --erp-warning: #fbbf24;
        --erp-warning-bg: #36280b;
        --erp-danger: #f87171;
        --erp-danger-hover: #ef4444;
        --erp-danger-bg: #3a1619;
        --erp-info: #38bdf8;
        --erp-info-bg: #0d2a3b;

        --erp-bg: #0e1322;
        --erp-surface: var(--erp-gray-0);
        --erp-border: var(--erp-gray-200);
        --erp-text: var(--erp-gray-800);
        --erp-text-muted: var(--erp-gray-500);

        --erp-shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
        --erp-shadow-sm: 0 1px 3px rgba(0, 0, 0, .4), 0 1px 2px rgba(0, 0, 0, .3);
        --erp-shadow-md: 0 6px 16px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .3);
        --erp-shadow-lg: 0 18px 40px rgba(0, 0, 0, .6);
        --erp-focus: 0 0 0 3px rgba(84, 112, 224, .4);

        /* solid fills keep white labels >= 5:1 */
        --erp-success-solid: #15803d;
        --erp-danger-solid: #c62828;
        --erp-danger-border: #6b2a2e;
        --erp-warning-solid: #b45309;
        --erp-info-solid: #0369a1;

        --erp-topbar-bg: rgba(20, 26, 43, .9);
        --erp-actionbar-bg: rgba(20, 26, 43, .95);
        --erp-overlay: rgba(0, 0, 0, .6);
        --erp-loader-overlay: rgba(14, 19, 34, .6);
        --erp-toast-bg: #f2f4f9;
        --erp-toast-text: #141824;
        --erp-tile-icon-bg: var(--erp-primary-50);

        color-scheme: dark;
    }

    /* BLUE: true blue primary, cool light-blue canvas, deep-blue sidebar */
    :root[data-theme="blue"] {
        --erp-navy-950: #081d42;
        --erp-navy-900: #0d2c5c;
        --erp-navy-800: #133a78;
        --erp-navy-700: #1a4a94;

        --erp-primary: #1a5fd0;       /* white label 5.9:1 */
        --erp-primary-hover: #164fae;
        --erp-primary-active: #123f8c;
        --erp-primary-400: #4f86e3;
        --erp-primary-200: #b9d0f5;
        --erp-primary-100: #dce8fb;
        --erp-primary-50: #eef4fd;
        --erp-primary-text: #1a5fd0;
        --erp-primary-text-hover: #164fae;
        --erp-primary-shadow: rgba(26, 95, 208, .35);

        --erp-gray-25: #f7faff;
        --erp-gray-50: #edf2f9;
        --erp-gray-100: #e3eaf4;
        --erp-gray-200: #d5dfec;
        --erp-gray-300: #bccadb;
        --erp-gray-400: #8593aa;
        --erp-gray-500: #5d6a80;
        --erp-gray-600: #435067;
        --erp-gray-700: #313c50;
        --erp-gray-800: #1d2737;
        --erp-gray-900: #111827;

        --erp-focus: 0 0 0 3px rgba(26, 95, 208, .24);
        --erp-overlay: rgba(8, 29, 66, .45);
        --erp-loader-overlay: rgba(237, 242, 249, .55);
        --erp-toast-bg: #111827;

        --erp-sidebar-text: #d3e2fa;
        --erp-sidebar-text-2: #b0c8ee;
        --erp-sidebar-muted: #93aedb;
        --erp-sidebar-label: #84a0cf;
        --erp-sidebar-tag: #b9d0f5;
        --erp-sidebar-danger: #f5b5b9;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(198, 40, 40, .2);
        --erp-hero-glow-1: rgba(79, 134, 227, .45);
        --erp-hero-glow-2: rgba(26, 95, 208, .5);
    }

    /* GREEN: calm emerald primary, faint green canvas, forest sidebar */
    :root[data-theme="green"] {
        --erp-navy-950: #06281f;
        --erp-navy-900: #0b3a2d;
        --erp-navy-800: #10493a;
        --erp-navy-700: #165a48;

        --erp-primary: #0f7a5a;       /* white label 5.3:1 */
        --erp-primary-hover: #0b664b;
        --erp-primary-active: #09513c;
        --erp-primary-400: #3d9c7e;
        --erp-primary-200: #b2dccb;
        --erp-primary-100: #d6efe4;
        --erp-primary-50: #ecf7f2;
        --erp-primary-text: #0f7a5a;
        --erp-primary-text-hover: #0b664b;
        --erp-primary-shadow: rgba(15, 122, 90, .35);

        --erp-gray-25: #f8fbfa;
        --erp-gray-50: #f0f5f3;
        --erp-gray-100: #e6eeeb;
        --erp-gray-200: #d7e2de;
        --erp-gray-300: #bfcec8;
        --erp-gray-400: #84978f;
        --erp-gray-500: #5c6e68;
        --erp-gray-600: #44554f;
        --erp-gray-700: #32403b;
        --erp-gray-800: #1e2a26;
        --erp-gray-900: #121a17;

        --erp-focus: 0 0 0 3px rgba(15, 122, 90, .24);
        --erp-overlay: rgba(6, 40, 31, .45);
        --erp-loader-overlay: rgba(240, 245, 243, .55);
        --erp-toast-bg: #121a17;

        --erp-sidebar-text: #cfe9df;
        --erp-sidebar-text-2: #aed3c5;
        --erp-sidebar-muted: #93bdae;
        --erp-sidebar-label: #82ae9e;
        --erp-sidebar-tag: #b2dccb;
        --erp-sidebar-danger: #f4b7b0;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(198, 40, 40, .2);
        --erp-hero-glow-1: rgba(61, 156, 126, .45);
        --erp-hero-glow-2: rgba(15, 122, 90, .5);
    }

    /* ORANGE: deep burnt orange fills (not neon), warm canvas, espresso sidebar.
       Warning moves to amber and danger to a deeper red so they stay distinct. */
    :root[data-theme="orange"] {
        --erp-navy-950: #1d130e;
        --erp-navy-900: #2b1d16;
        --erp-navy-800: #3b281d;
        --erp-navy-700: #4d3425;

        --erp-primary: #c2410c;       /* white label 5.2:1 */
        --erp-primary-hover: #a3360a;
        --erp-primary-active: #8a2d07;
        --erp-primary-400: #e8743a;
        --erp-primary-200: #f9c9ab;
        --erp-primary-100: #fee4d3;
        --erp-primary-50: #fff4ec;
        --erp-primary-text: #b93e0c;  /* 5.6:1 on white */
        --erp-primary-text-hover: #9a330a;
        --erp-primary-shadow: rgba(194, 65, 12, .35);

        --erp-gray-25: #fdfbfa;
        --erp-gray-50: #f8f4f1;
        --erp-gray-100: #f0ebe7;
        --erp-gray-200: #e4ddd7;
        --erp-gray-300: #cfc6be;
        --erp-gray-400: #978b80;
        --erp-gray-500: #6e655d;
        --erp-gray-600: #544b44;
        --erp-gray-700: #3e3731;
        --erp-gray-800: #2a2420;
        --erp-gray-900: #1a1613;

        --erp-warning: #a16207;
        --erp-warning-bg: #fdf6dd;
        --erp-warning-solid: #a16207;
        --erp-danger: #b91c1c;
        --erp-danger-hover: #991b1b;
        --erp-danger-solid: #b91c1c;

        --erp-focus: 0 0 0 3px rgba(194, 65, 12, .24);
        --erp-overlay: rgba(29, 19, 14, .45);
        --erp-loader-overlay: rgba(248, 244, 241, .55);
        --erp-toast-bg: #1a1613;

        --erp-sidebar-text: #f2dccd;
        --erp-sidebar-text-2: #dcc1ae;
        --erp-sidebar-muted: #c2a593;
        --erp-sidebar-label: #ad917f;
        --erp-sidebar-tag: #f9c9ab;
        --erp-sidebar-danger: #f8b4ad;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(220, 38, 38, .2);
        --erp-hero-glow-1: rgba(232, 116, 58, .4);
        --erp-hero-glow-2: rgba(194, 65, 12, .45);
    }

    /* SAND (eye comfort, light): warm paper surfaces (low blue light, like a sepia
       reading mode), muted brown accents, soft (never pure black) text. */
    :root[data-theme="sand"] {
        --erp-navy-950: #2c261f;
        --erp-navy-900: #3a3229;
        --erp-navy-800: #4a4035;
        --erp-navy-700: #5b4f41;

        --erp-primary: #7a5b39;       /* white label 6.2:1 */
        --erp-primary-hover: #654a2e;
        --erp-primary-active: #4f3a24;
        --erp-primary-400: #a3825c;
        --erp-primary-200: #dccab0;
        --erp-primary-100: #ebdfcb;
        --erp-primary-50: #f4ecdf;
        --erp-primary-text: #74563a;
        --erp-primary-text-hover: #5e4530;
        --erp-primary-shadow: rgba(58, 50, 41, .4);

        --erp-gray-0: #fcf8f1;
        --erp-gray-25: #f8f3ea;
        --erp-gray-50: #f2ebdf;
        --erp-gray-100: #ebe2d3;
        --erp-gray-200: #dfd3c0;
        --erp-gray-300: #cbbca5;
        --erp-gray-400: #94877a;
        --erp-gray-500: #6a5d4f;
        --erp-gray-600: #53483c;
        --erp-gray-700: #453a30;
        --erp-gray-800: #3b3229;
        --erp-gray-900: #2b241d;

        --erp-success: #3a7135;
        --erp-success-bg: #e5eedb;
        --erp-success-solid: #3f7a3a;
        --erp-warning: #9a5a12;
        --erp-warning-bg: #f6e9d2;
        --erp-warning-solid: #9a5a12;
        --erp-danger: #b23b2e;
        --erp-danger-hover: #962f24;
        --erp-danger-bg: #f7e3dc;
        --erp-danger-solid: #b23b2e;
        --erp-danger-border: #e9c3b8;
        --erp-info: #2f6a85;
        --erp-info-bg: #e0ebee;
        --erp-info-solid: #2f6a85;

        --erp-shadow-xs: 0 1px 2px rgba(60, 45, 25, .06);
        --erp-shadow-sm: 0 1px 3px rgba(60, 45, 25, .08), 0 1px 2px rgba(60, 45, 25, .04);
        --erp-shadow-md: 0 6px 16px rgba(60, 45, 25, .08), 0 2px 4px rgba(60, 45, 25, .04);
        --erp-shadow-lg: 0 18px 40px rgba(60, 45, 25, .16);
        --erp-focus: 0 0 0 3px rgba(122, 91, 57, .25);

        --erp-topbar-bg: rgba(252, 248, 241, .92);
        --erp-actionbar-bg: rgba(252, 248, 241, .95);
        --erp-overlay: rgba(44, 38, 31, .45);
        --erp-loader-overlay: rgba(242, 235, 223, .55);
        --erp-toast-bg: #3b3229;
        --erp-toast-text: #fcf8f1;

        --erp-sidebar-text: #ece2d0;
        --erp-sidebar-text-2: #d6c8b0;
        --erp-sidebar-muted: #bcae96;
        --erp-sidebar-label: #ab9d86;
        --erp-sidebar-tag: #dccab0;
        --erp-sidebar-danger: #f0b7aa;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(185, 60, 40, .22);
        --erp-hero-glow-1: rgba(163, 130, 92, .4);
        --erp-hero-glow-2: rgba(122, 91, 57, .45);
    }

    /* SAGE (eye comfort, light): muted green-grey paper surfaces, low glare, soft
       sage accents and soft (never pure black) text. */
    :root[data-theme="sage"] {
        --erp-navy-950: #1f2a24;
        --erp-navy-900: #2a3830;
        --erp-navy-800: #36463d;
        --erp-navy-700: #44564b;

        --erp-primary: #4a7360;       /* white label 5.3:1 */
        --erp-primary-hover: #3d6150;
        --erp-primary-active: #2f4d3f;
        --erp-primary-400: #79a08c;
        --erp-primary-200: #c5d8cc;
        --erp-primary-100: #dfeae2;
        --erp-primary-50: #eef4ef;
        --erp-primary-text: #436a57;
        --erp-primary-text-hover: #36574a;
        --erp-primary-shadow: rgba(42, 56, 48, .4);

        --erp-gray-0: #f8faf6;
        --erp-gray-25: #f3f6f1;
        --erp-gray-50: #eaefe8;
        --erp-gray-100: #e1e8de;
        --erp-gray-200: #d3dcd0;
        --erp-gray-300: #bccab8;
        --erp-gray-400: #87958a;
        --erp-gray-500: #5d6b61;
        --erp-gray-600: #4a564e;
        --erp-gray-700: #3d4841;
        --erp-gray-800: #333d37;
        --erp-gray-900: #252d28;

        --erp-success: #2f6e45;
        --erp-success-bg: #e0eedf;
        --erp-success-solid: #357a4c;
        --erp-warning: #8f5a12;
        --erp-warning-bg: #f3ead3;
        --erp-warning-solid: #8f5a12;
        --erp-danger: #a83a32;
        --erp-danger-hover: #8f2f28;
        --erp-danger-bg: #f5e1dc;
        --erp-danger-solid: #a83a32;
        --erp-danger-border: #e6c2bb;
        --erp-info: #2f6a85;
        --erp-info-bg: #dfeaee;
        --erp-info-solid: #2f6a85;

        --erp-shadow-xs: 0 1px 2px rgba(35, 50, 40, .06);
        --erp-shadow-sm: 0 1px 3px rgba(35, 50, 40, .08), 0 1px 2px rgba(35, 50, 40, .04);
        --erp-shadow-md: 0 6px 16px rgba(35, 50, 40, .08), 0 2px 4px rgba(35, 50, 40, .04);
        --erp-shadow-lg: 0 18px 40px rgba(35, 50, 40, .16);
        --erp-focus: 0 0 0 3px rgba(74, 115, 96, .25);

        --erp-topbar-bg: rgba(248, 250, 246, .92);
        --erp-actionbar-bg: rgba(248, 250, 246, .95);
        --erp-overlay: rgba(31, 42, 36, .45);
        --erp-loader-overlay: rgba(234, 239, 232, .55);
        --erp-toast-bg: #333d37;
        --erp-toast-text: #f8faf6;

        --erp-sidebar-text: #e3ece5;
        --erp-sidebar-text-2: #c9d6cc;
        --erp-sidebar-muted: #a9b9ad;
        --erp-sidebar-label: #98a99c;
        --erp-sidebar-tag: #c5d8cc;
        --erp-sidebar-danger: #f0b7aa;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(185, 60, 40, .22);
        --erp-hero-glow-1: rgba(121, 160, 140, .4);
        --erp-hero-glow-2: rgba(74, 115, 96, .45);
    }

    /* MIST (eye comfort, light): soft blue-grey paper surfaces, low glare, muted
       slate-blue accents and soft (never pure black) text. */
    :root[data-theme="mist"] {
        --erp-navy-950: #1c2430;
        --erp-navy-900: #263040;
        --erp-navy-800: #323d4f;
        --erp-navy-700: #404c60;

        --erp-primary: #46658a;       /* white label 5.9:1 */
        --erp-primary-hover: #3a5574;
        --erp-primary-active: #2e445e;
        --erp-primary-400: #7a95b5;
        --erp-primary-200: #c6d3e2;
        --erp-primary-100: #dfe6ef;
        --erp-primary-50: #eef2f7;
        --erp-primary-text: #40607f;
        --erp-primary-text-hover: #34506b;
        --erp-primary-shadow: rgba(38, 48, 64, .4);

        --erp-gray-0: #f7f9fb;
        --erp-gray-25: #f2f5f8;
        --erp-gray-50: #e9edf2;
        --erp-gray-100: #e0e5ec;
        --erp-gray-200: #d2d9e2;
        --erp-gray-300: #bac4d0;
        --erp-gray-400: #86909c;
        --erp-gray-500: #5c6673;
        --erp-gray-600: #49525d;
        --erp-gray-700: #3c444e;
        --erp-gray-800: #323942;
        --erp-gray-900: #242a31;

        --erp-success: #2f6e45;
        --erp-success-bg: #e1eee3;
        --erp-success-solid: #357a4c;
        --erp-warning: #8f5a12;
        --erp-warning-bg: #f3ead6;
        --erp-warning-solid: #8f5a12;
        --erp-danger: #a83a32;
        --erp-danger-hover: #8f2f28;
        --erp-danger-bg: #f5e2df;
        --erp-danger-solid: #a83a32;
        --erp-danger-border: #e6c4bf;
        --erp-info: #2f6a85;
        --erp-info-bg: #dfe9ef;
        --erp-info-solid: #2f6a85;

        --erp-shadow-xs: 0 1px 2px rgba(30, 40, 55, .06);
        --erp-shadow-sm: 0 1px 3px rgba(30, 40, 55, .08), 0 1px 2px rgba(30, 40, 55, .04);
        --erp-shadow-md: 0 6px 16px rgba(30, 40, 55, .08), 0 2px 4px rgba(30, 40, 55, .04);
        --erp-shadow-lg: 0 18px 40px rgba(30, 40, 55, .16);
        --erp-focus: 0 0 0 3px rgba(70, 101, 138, .25);

        --erp-topbar-bg: rgba(247, 249, 251, .92);
        --erp-actionbar-bg: rgba(247, 249, 251, .95);
        --erp-overlay: rgba(28, 36, 48, .45);
        --erp-loader-overlay: rgba(233, 237, 242, .55);
        --erp-toast-bg: #323942;
        --erp-toast-text: #f7f9fb;

        --erp-sidebar-text: #e2e8f0;
        --erp-sidebar-text-2: #c8d2de;
        --erp-sidebar-muted: #a8b4c3;
        --erp-sidebar-label: #97a4b4;
        --erp-sidebar-tag: #c6d3e2;
        --erp-sidebar-danger: #f0b7aa;      /* sidebar Logout label (soft danger on the dark panel) */
        --erp-sidebar-danger-bg: rgba(185, 60, 40, .22);
        --erp-hero-glow-1: rgba(122, 149, 181, .4);
        --erp-hero-glow-2: rgba(70, 101, 138, .45);
    }
}

/* 1. BASE / TYPOGRAPHY ===================================================== */
html { font-size: 16px; }

body.erp-body,
body.erp-body.u-body {
    font-family: var(--erp-font) !important;
    background: var(--erp-bg) !important;
    color: var(--erp-text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.erp-body h1, .erp-body h2, .erp-body h3, .erp-body h4, .erp-body h5, .erp-body h6,
.erp-body p, .erp-body label, .erp-body a, .erp-body input, .erp-body select,
.erp-body textarea, .erp-body button, .erp-body td, .erp-body th,
.erp-body .u-text, .erp-body .u-label, .erp-body .u-input, .erp-body .u-btn,
.erp-body .jsgrid, .erp-body .select2-container {
    font-family: var(--erp-font) !important;
}

/* Print previews rendered on screen keep their own font */
:is(#invoice, #invoiceJO, .invoiceBra, #ListBarCode, #Body_Print_Inv) :is(h1, h2, h3, h4, h5, h6, p, label, td, th, span, div) {
    font-family: inherit !important;
}

.erp-body a { color: var(--erp-primary-text); }
.erp-body a:hover { color: var(--erp-primary-text-hover); }

.erp-body ::selection { background: var(--erp-primary-100); }

.erp-text-muted { color: var(--erp-text-muted) !important; }
.erp-hidden { display: none !important; }

/* Scrollbars (WebKit) */
.erp-body ::-webkit-scrollbar { width: 10px; height: 10px; }
.erp-body ::-webkit-scrollbar-thumb { background: var(--erp-gray-300); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
.erp-body ::-webkit-scrollbar-track { background: transparent; }

/* 2. APP SHELL ============================================================= */

/* --- Sidebar --- */
.erp-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--erp-sidebar-w);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--erp-navy-900) 0%, var(--erp-navy-950) 100%);
    color: var(--erp-sidebar-text);
    box-shadow: var(--erp-shadow-md);
    transition: transform var(--erp-transition), width var(--erp-transition);
}

.erp-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--erp-topbar-h);
    padding-inline: 20px;
    border-block-end: 1px solid rgba(255, 255, 255, .07);
    flex-shrink: 0;
    cursor: pointer;
}

.erp-sidebar__logo {
    width: 38px;
    height: 38px;
    border-radius: 9px; /* the AE mark is its own rounded tile */
    object-fit: contain;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .28);
}

/* --- Brand mark (Acumen Development "AE"), themed ---
   One <symbol id="erpBrandMark"> sprite in _Layout, used by the sidebar, topbar and login
   (<svg class="erp-brand-mark"><use href="#erpBrandMark"/></svg>). Its tile, letters and accent
   stroke read these tokens per theme; Sidebar.ts (ErpBrand) builds a matching data: favicon on
   every theme change. Static files in images/brand stay as the pre-CSS / no-JS fallback. */
:root {
    --erp-brand-tile: #fff;      /* rounded tile behind the letters */
    --erp-brand-main: #134b7c;   /* A leg, E bars and blade (classic = the logo navy) */
    --erp-brand-accent: #17a2a7; /* A right stroke (classic = the logo teal) */
}
@media screen {
    :root[data-theme="blue"] { --erp-brand-main: #123f8c; --erp-brand-accent: #0ea5c6; }
    :root[data-theme="green"] { --erp-brand-main: #09513c; --erp-brand-accent: #22b07f; }
    :root[data-theme="orange"] { --erp-brand-main: #8a2d07; --erp-brand-accent: #f08a3c; }
    :root:is([data-theme="night"], [data-theme="dark"]) { --erp-brand-tile: #eef1fb; --erp-brand-main: #1f3480; --erp-brand-accent: #14b8a6; }
    :root[data-theme="sand"] { --erp-brand-main: #4f3a24; --erp-brand-accent: #b08a5a; }
    :root[data-theme="sage"] { --erp-brand-main: #2f4d3f; --erp-brand-accent: #3fa58a; }
    :root[data-theme="mist"] { --erp-brand-main: #2e445e; --erp-brand-accent: #4f9cbc; }
}

.erp-brand-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
svg.erp-brand-mark { display: block; flex-shrink: 0; overflow: visible; }
.erp-sidebar__brand svg.erp-sidebar__logo { object-fit: initial; }
.erp-topbar__logo svg.erp-brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.erp-login__brand svg.erp-brand-mark { width: 56px; height: 56px; border-radius: 13px; box-shadow: 0 8px 22px rgba(0, 0, 0, .3); }
/* the old <img> marks are kept in the markup (hidden) as a no-SVG fallback */
.erp-brand-fallback { display: none !important; }

/* --- Open in new tab (sidebar items, page tiles, topbar) --- */
.erp-nav-item { position: relative; }
.erp-nav-item > .erp-nav-link { padding-inline-end: 38px; }
.erp-nav-newtab {
    position: absolute;
    inset-block: 0;
    margin-block: auto;
    inset-inline-end: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    color: var(--erp-sidebar-muted) !important;
    font-size: 12px;
    text-decoration: none !important;
    opacity: 0;
    transition: opacity var(--erp-transition), background var(--erp-transition), color var(--erp-transition);
}
.erp-nav-item:hover > .erp-nav-newtab,
.erp-nav-item:focus-within > .erp-nav-newtab { opacity: 1; }
.erp-nav-newtab:hover,
.erp-nav-newtab:focus-visible { background: rgba(255, 255, 255, .12); color: #fff !important; outline: none; }
.erp-nav-item > .erp-nav-link.is-active + .erp-nav-newtab { color: rgba(255, 255, 255, .85) !important; }

.erp-tile__newtab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--erp-gray-500) !important;
    font-size: 13px;
    text-decoration: none !important;
    opacity: 0;
    transition: opacity var(--erp-transition), background var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition);
}
.erp-tile:hover .erp-tile__newtab,
.erp-tile:focus-within .erp-tile__newtab,
.erp-tile__newtab:focus-visible { opacity: 1; }
.erp-tile__newtab:hover,
.erp-tile__newtab:focus-visible { background: var(--erp-primary-50); border-color: var(--erp-primary-200); color: var(--erp-primary-text) !important; outline: none; }

/* touch screens have no hover: always show the new-tab buttons */
@media (hover: none) {
    .erp-nav-newtab, .erp-tile__newtab { opacity: 1; }
}

.erp-sidebar__brand-name {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    letter-spacing: .3px;
    line-height: 1.2;
    display: inline-block; /* Latin product name reads EA Pro + ERP in RTL too */
    direction: ltr;
}

.erp-sidebar__brand-tag,
.erp-login__brand-tag {
    display: inline-block;
    margin-inline-start: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: var(--erp-sidebar-tag);
    font-size: .62em;
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1.7;
    vertical-align: middle;
}

.erp-sidebar__brand-sub {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--erp-sidebar-muted);
}

.erp-sidebar__profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 14px 6px;
    padding: 12px;
    border-radius: var(--erp-radius);
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .06);
    cursor: pointer;
    transition: background var(--erp-transition);
}

.erp-sidebar__profile:hover { background: rgba(255, 255, 255, .09); }

.erp-avatar {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--erp-primary-400);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;
}

.erp-avatar img { width: 100%; height: 100%; object-fit: cover; }
.erp-avatar--sm { width: 32px; height: 32px; font-size: 13px; }

.erp-sidebar__user { min-width: 0; line-height: 1.35; }
.erp-sidebar__user-name { color: #fff; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erp-sidebar__user-meta { color: var(--erp-sidebar-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.erp-sidebar__search {
    margin: 8px 14px 4px;
    position: relative;
}

.erp-sidebar__search input {
    width: 100%;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .06);
    color: #fff;
    padding-inline: 34px 10px;
    font-size: 13px;
    outline: none;
}

.erp-sidebar__search input::placeholder { color: var(--erp-sidebar-muted); }
.erp-sidebar__search input:focus { border-color: var(--erp-primary-400); background: rgba(255, 255, 255, .1); }
.erp-sidebar__search .fa { position: absolute; inset-inline-start: 12px; top: 10px; color: var(--erp-sidebar-muted); font-size: 13px; }

.erp-sidebar, .erp-sidebar *, .erp-topbar, .erp-topbar *,
.erp-page, .erp-page *, .erp-login, .erp-login *, .erp-dashboard, .erp-dashboard * { box-sizing: border-box; }

.erp-sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px 16px;
}

.erp-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); }

.erp-nav-label {
    padding: 14px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--erp-sidebar-label);
}

.erp-nav-link,
.erp-nav-group__head {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--erp-sidebar-text) !important;
    font-size: 13.5px;
    font-weight: 600;
    text-align: start;
    text-decoration: none !important;
    cursor: pointer;
    transition: background var(--erp-transition), color var(--erp-transition);
}

.erp-nav-link:hover,
.erp-nav-group__head:hover { background: rgba(255, 255, 255, .07); color: #fff !important; }

.erp-nav-link.is-active { background: var(--erp-primary); color: #fff !important; box-shadow: 0 4px 12px var(--erp-primary-shadow); }

.erp-nav-icon {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
    font-size: 15px;
    opacity: .9;
}

.erp-nav-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.erp-nav-caret {
    flex-shrink: 0;
    font-size: 11px;
    opacity: .7;
    transition: transform var(--erp-transition);
}

.erp-nav-group.is-open > .erp-nav-group__head { color: #fff !important; }
.erp-nav-group.is-open > .erp-nav-group__head .erp-nav-caret { transform: rotate(180deg); }

.erp-nav-group__items {
    display: none;
    margin: 2px 0 6px;
    padding-inline-start: 22px;
    position: relative;
}

.erp-nav-group__items::before {
    content: "";
    position: absolute;
    inset-block: 4px;
    inset-inline-start: 22px;
    border-inline-start: 1px solid rgba(255, 255, 255, .1);
}

.erp-nav-group.is-open > .erp-nav-group__items { display: block; }

.erp-nav-group__items .erp-nav-link {
    min-height: 34px;
    padding-block: 6px;
    padding-inline: 18px 10px;
    font-weight: 500;
    font-size: 13px;
    color: var(--erp-sidebar-text-2) !important;
}

.erp-nav-group__items .erp-nav-link::before {
    content: "";
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
    opacity: .45;
}

.erp-nav-group__items .erp-nav-link.is-active::before { opacity: 1; }
.erp-nav-group__items .erp-nav-link.is-active { color: #fff !important; } /* white on primary, every theme */

.erp-nav-empty { padding: 10px 14px; color: var(--erp-sidebar-label); font-size: 12.5px; }

.erp-sidebar__footer {
    flex-shrink: 0;
    padding: 12px 14px;
    border-block-start: 1px solid rgba(255, 255, 255, .07);
}

.erp-sidebar__footer .erp-nav-link { color: var(--erp-sidebar-danger) !important; }
.erp-sidebar__footer .erp-nav-link:hover { background: var(--erp-sidebar-danger-bg); }

.erp-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: var(--erp-overlay);
    backdrop-filter: blur(1px);
}

/* --- Topbar (the legacy header #sec-06f8) --- */
.erp-topbar,
header#sec-06f8.erp-topbar {
    position: fixed !important;
    top: 0;
    inset-inline-start: var(--erp-sidebar-w);
    inset-inline-end: 0;
    height: var(--erp-topbar-h);
    min-height: 0 !important;
    z-index: 1030;
    background: var(--erp-topbar-bg) !important;
    background-image: none !important;
    backdrop-filter: saturate(180%) blur(8px);
    border-block-end: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow-xs);
    transition: inset-inline-start var(--erp-transition);
}

.erp-topbar__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
    padding-inline: 16px;
    padding-inline-end: 72px; /* room for the floating language button (#DivLang) */
}

.erp-topbar__logo { display: none; }
.erp-topbar__logo img { width: 34px; height: 34px; object-fit: contain; border-radius: 8px; }

.erp-topbar #_Btn_Back { display: contents; }

#Lab_NamePage.erp-topbar__title,
.erp-topbar .screen-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    text-align: start !important;
    text-shadow: none !important;
    color: var(--erp-gray-900) !important;
    background: none !important;
    -webkit-background-clip: border-box !important;
    -webkit-text-fill-color: currentColor !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: none !important;
}

.erp-topbar__actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.erp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--erp-border);
    background: var(--erp-surface);
    color: var(--erp-gray-700) !important;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none !important;
    transition: background var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition);
}

.erp-icon-btn:hover { background: var(--erp-primary-50); border-color: var(--erp-primary-200); color: var(--erp-primary-text) !important; }
.erp-icon-btn:focus-visible { outline: none; box-shadow: var(--erp-focus); }

/* Back arrow points "backwards" in reading direction */
.erp-dir-icon { display: inline-block; }
[dir="ltr"] .erp-dir-icon { transform: scaleX(-1); }

.erp-back-btn { color: var(--erp-primary-text) !important; }

.erp-user-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding-inline: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--erp-border);
    background: var(--erp-surface);
    cursor: pointer;
    color: var(--erp-gray-800);
}

.erp-user-chip:hover { border-color: var(--erp-primary-200); background: var(--erp-primary-50); }
.erp-user-chip__name { font-size: 13px; font-weight: 600; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erp-user-chip .fa-angle-down { font-size: 13px; color: var(--erp-gray-500); }

.erp-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    min-width: 210px;
    padding: 6px;
    border-radius: var(--erp-radius);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow-lg);
    z-index: 1100;
}

.erp-dropdown.is-open { display: block; }

.erp-dropdown__header { padding: 8px 10px 10px; border-block-end: 1px solid var(--erp-gray-100); margin-block-end: 4px; }
.erp-dropdown__title { font-weight: 700; font-size: 13.5px; color: var(--erp-gray-900); }
.erp-dropdown__sub { font-size: 12px; color: var(--erp-text-muted); }

.erp-dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--erp-gray-700);
    font-size: 13.5px;
    text-align: start;
    cursor: pointer;
}

.erp-dropdown__item:hover { background: var(--erp-gray-50); color: var(--erp-gray-900); }
.erp-dropdown__item .fa { width: 18px; text-align: center; color: var(--erp-gray-500); }
.erp-dropdown__item--danger, .erp-dropdown__item--danger .fa { color: var(--erp-danger); }
.erp-dropdown__item--danger:hover { background: var(--erp-danger-bg); color: var(--erp-danger); }

/* --- Content area (#carousel_47a3) --- */
.erp-main,
div#carousel_47a3.erp-main {
    min-height: 100vh;
    background: transparent !important;
    background-image: none !important;
    padding: 0;
    transition: margin var(--erp-transition);
}

/* Sidebar visible (= logged in): offset content + floating buttons */
#erpSidebar:not(.display_none) ~ #carousel_47a3 {
    margin-inline-start: var(--erp-sidebar-w);
    padding-top: var(--erp-topbar-h);
}

#erpSidebar:not(.display_none) ~ #carousel_47a3 > #htmlContainer,
#erpSidebar:not(.display_none) ~ #carousel_47a3 > .Page_Partial {
    padding: var(--erp-gutter);
    text-align: start;
}

/* Collapsed sidebar (desktop toggle). Desktop only: below 992px the sidebar is off-canvas
   (body.erp-sidebar-open), so a class left over from desktop must not block it there.
   The topbar selector repeats the id: "header#sec-06f8.erp-topbar" (1,1,1) used to win over
   the collapsed rule, so the topbar kept its 268px offset while the content went full width. */
@media (min-width: 992px) {
    body.erp-sidebar-collapsed .erp-sidebar { transform: translateX(-100%); box-shadow: none; }
    [dir="rtl"] body.erp-sidebar-collapsed .erp-sidebar { transform: translateX(100%); }
    body.erp-sidebar-collapsed .erp-topbar,
    body.erp-sidebar-collapsed header#sec-06f8.erp-topbar { inset-inline-start: 0; }
    body.erp-sidebar-collapsed #erpSidebar:not(.display_none) ~ #carousel_47a3 { margin-inline-start: 0; }
    body.erp-sidebar-collapsed .erp-topbar .erp-topbar__logo { display: inline-flex; } /* brand stays visible */
}

/* Language button (#DivLang). JS writes inline "position:absolute; top:15px !important"
   (top:70px on login). We keep its top and pin it to the inline-end corner. */
#DivLang.search-button-container {
    position: fixed !important;
    right: auto;
    left: auto;
    inset-inline-end: 16px;
    opacity: 1 !important;
    z-index: 1045;
}

#erpSidebar:not(.display_none) ~ #DivLang.search-button-container { top: 13px; }

#DivLang .search-button,
#GnrLang.search-button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--erp-surface) !important;
    border: 1px solid var(--erp-border);
    color: var(--erp-primary-text);
    font-size: 18px;
    box-shadow: none;
}

#GnrLang.search-button:hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200); }

/* Page actions in the topbar, right after the screen title (#erpPageActions):
   open-in-new-tab (#erpTopNewTab), quick search (#DivSearchBtnID + its panel #DivSearchID)
   and export to Excel (#DivDownload_Excel). The legacy floating containers were MOVED here
   (same ids / classes; App.ts still toggles display_none on them and GnrGridDownloadExcel()
   still rewrites the Excel button inside #DivDownload_Excel). The bottom inline-end corner
   of the screen is left free for the help button. */
.erp-topbar__page-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    margin-inline-end: auto; /* title + page actions start, user chip / theme at the end */
}

.erp-topbar #Lab_NamePage.erp-topbar__title,
.erp-topbar .screen-title { flex: 0 1 auto; }

.erp-topbar #DivSearchBtnID.search-button-container,
.erp-topbar #DivDownload_Excel.search-button-container,
.erp-topbar #DivSearchID.search-button-container {
    position: static !important;
    inset: auto !important;
    z-index: auto;
    opacity: 1 !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.erp-topbar #DivSearchBtnID.search-button-container.display_none,
.erp-topbar #DivDownload_Excel.search-button-container.display_none,
.erp-topbar #DivSearchID.search-button-container.display_none { display: none !important; }

/* quick-search number box drops down under the topbar (jQuery animates its width) */
.erp-topbar #DivSearchID.search-button-container {
    position: absolute !important;
    top: calc(100% + 12px) !important;
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
    z-index: 1031;
    overflow: hidden;
}

.erp-topbar .erp-topbar__page-actions .search-button,
.erp-topbar .erp-newtab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--erp-border) !important;
    background: var(--erp-surface) !important;
    color: var(--erp-gray-700) !important;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;
    box-shadow: none !important;
    filter: none;
    transform: none;
    cursor: pointer;
    transition: background var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition);
}

.erp-topbar .erp-topbar__page-actions .search-button:hover,
.erp-topbar .erp-newtab-btn:hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200) !important; color: var(--erp-primary-text) !important; }
.erp-topbar .erp-topbar__page-actions .search-button:focus-visible,
.erp-topbar .erp-newtab-btn:focus-visible { outline: none; box-shadow: var(--erp-focus) !important; }
.erp-topbar .erp-newtab-btn { width: 38px; padding: 0; font-size: 14px; }

/* Excel: outline button in the success tone of the current theme, icon + label */
.erp-topbar #DivDownload_Excel .search-button {
    border-color: color-mix(in srgb, var(--erp-success) 45%, transparent) !important;
    color: var(--erp-success) !important;
    background: var(--erp-surface) !important;
    font-size: 13px;
}
.erp-topbar #DivDownload_Excel .search-button .fa { font-size: 16px; }
.erp-topbar #DivDownload_Excel .search-button::after { content: "Excel"; font-family: var(--erp-font); }
[dir="rtl"] .erp-topbar #DivDownload_Excel .search-button::after { content: "تصدير Excel"; }
.erp-topbar #DivDownload_Excel .search-button:hover {
    background: var(--erp-success-bg) !important;
    border-color: var(--erp-success) !important;
    color: var(--erp-success) !important;
}

@media (max-width: 767.98px) {
    .erp-topbar #DivDownload_Excel .search-button { width: 38px; padding: 0; }
    .erp-topbar #DivDownload_Excel .search-button::after,
    [dir] .erp-topbar #DivDownload_Excel .search-button::after { content: none; }
}

@media (max-width: 479.98px) {
    .erp-topbar .erp-newtab-btn { display: none !important; } /* no room; tabs are rare on phones */
    .erp-topbar .erp-topbar__page-actions .search-button { width: 32px; min-width: 32px; height: 32px; }
}

/* Page primary action "Add" (#erpPageAdd, built by ClientApp/Shell/AddButtons.ts, only while a
   list screen is the top page). It is the LAST item of #erpPageActions and is pushed to the
   inline-end of that area, so it always sits at the same spot (just before the user chip),
   whatever the title length or which of the Excel / search buttons are shown.
   Under 576px it is icon-only (the title / aria-label keep the text). */
.erp-topbar .erp-topbar__page-actions { flex: 1 1 auto; justify-content: flex-start; }
.erp-topbar .erp-topbar__add { display: inline-flex; align-items: center; margin-inline-start: auto; }
.erp-topbar .erp-topbar__add:empty { display: none; }
.erp-topbar .erp-topbar__add > .erp-btn {
    height: 38px !important;
    min-height: 38px !important;
    padding-inline: 14px !important;
    border-radius: 10px !important;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    gap: 6px;
}
.erp-topbar .erp-topbar__add > .erp-btn > .fa { font-size: 14px; }
@media (max-width: 575.98px) {
    .erp-topbar .erp-topbar__add > .erp-btn { width: 38px !important; min-width: 38px; padding: 0 !important; justify-content: center; }
    .erp-topbar .erp-topbar__add-label { display: none; }
}
@media (max-width: 479.98px) {
    .erp-topbar .erp-topbar__add > .erp-btn { width: 32px !important; min-width: 32px; height: 32px !important; min-height: 32px !important; }
}

.Divsearch-TextID {
    height: 44px;
    border-radius: 12px;
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow-md);
    color: var(--erp-text);
}

/* 3. PAGE HEADER =========================================================== */
.erp-page { text-align: start; }

.erp-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-block-end: 18px;
}

.erp-page-header__titles { min-width: 0; }
.erp-page-header__title { margin: 0; font-size: 20px; font-weight: 700; color: var(--erp-gray-900); line-height: 1.3; }
.erp-page-header__subtitle { margin: 2px 0 0; font-size: 13px; color: var(--erp-text-muted); }

.erp-page-header__actions,
.erp-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.erp-breadcrumb { display: flex; gap: 6px; font-size: 12px; color: var(--erp-text-muted); margin-block-end: 4px; }

/* 4. CARDS / PANELS ======================================================== */
.erp-card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius-lg);
    box-shadow: var(--erp-shadow-sm);
    margin-block-end: 18px;
    text-align: start;
}

.erp-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-block-end: 1px solid var(--erp-gray-100);
}

.erp-card__title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--erp-gray-900) !important;
}

.erp-card__title .fa { color: var(--erp-primary-text); font-size: 15px; }
.erp-card__subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--erp-text-muted); }
.erp-card__body { padding: 18px 20px; }
.erp-card__body--flush { padding: 0; }
.erp-card__footer { padding: 12px 20px; border-block-start: 1px solid var(--erp-gray-100); background: var(--erp-gray-25); border-radius: 0 0 var(--erp-radius-lg) var(--erp-radius-lg); }

.erp-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 14px !important;
    padding-block-end: 8px;
    border-block-end: 1px dashed var(--erp-gray-200);
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--erp-primary-text) !important;
    text-transform: none;
}

/* 5. FORMS ================================================================= */
.erp-form-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 14px 18px;
    align-items: start;
}

.erp-col-12 { grid-column: span 12; }
.erp-col-9 { grid-column: span 9; }
.erp-col-8 { grid-column: span 8; }
.erp-col-6 { grid-column: span 6; }
.erp-col-4 { grid-column: span 4; }
.erp-col-3 { grid-column: span 3; }
.erp-col-2 { grid-column: span 2; }

.erp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.erp-field--inline { flex-direction: row; align-items: center; gap: 10px; }
.erp-field--end { justify-content: flex-end; align-self: end; }

.erp-label,
.erp-body .erp-field > label {
    margin: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--erp-gray-600);
    text-align: start;
}

.erp-label .erp-req,
.erp-req { color: var(--erp-danger); margin-inline-start: 2px; }
.erp-hint { font-size: 12px; color: var(--erp-text-muted); }

.erp-input,
.erp-select,
.erp-textarea,
.erp-main .u-input:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]),
.erp-main .form-control:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]),
.erp-main .form-select,
.erp-main select,
.erp-main textarea,
.erp-main input[type="text"],
.erp-main input[type="number"],
.erp-main input[type="email"],
.erp-main input[type="password"],
.erp-main input[type="date"],
.erp-main input[type="datetime-local"],
.erp-main input[type="time"],
.erp-main input[type="month"],
.erp-main input[type="search"],
.erp-main input[type="tel"] {
    width: 100%;
    min-height: var(--erp-control-h);
    height: auto;
    padding: 7px 12px !important;
    border: 1px solid var(--erp-gray-300) !important;
    border-radius: 8px !important;
    background-color: var(--erp-surface) !important;
    background-image: none;
    color: var(--erp-text) !important;
    font-size: 13.5px !important;
    line-height: 1.45;
    box-shadow: none !important;
    transition: border-color var(--erp-transition), box-shadow var(--erp-transition);
    text-align: start;
}

.erp-main select,
.erp-select,
.erp-main .form-select,
.erp-main select.u-input {
    appearance: auto;
    padding-block: 6px !important;
    cursor: pointer;
}

.erp-main textarea,
.erp-textarea { min-height: 84px; resize: vertical; }

.erp-input:hover, .erp-select:hover, .erp-textarea:hover,
.erp-main .u-input:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]):hover, .erp-main .form-control:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]):hover, .erp-main select:hover, .erp-main textarea:hover { border-color: var(--erp-gray-400) !important; }

.erp-input:focus, .erp-select:focus, .erp-textarea:focus,
.erp-main .u-input:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]):focus, .erp-main .form-control:not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]):focus, .erp-main .form-select:focus,
.erp-main select:focus, .erp-main textarea:focus, .erp-main input:focus {
    outline: none !important;
    border-color: var(--erp-primary) !important;
    box-shadow: var(--erp-focus) !important;
}

.erp-main input:disabled, .erp-main select:disabled, .erp-main textarea:disabled,
.erp-main .u-input:disabled, .erp-main .form-control:disabled,
.erp-main input[readonly], .erp-main .form-control[readonly] {
    background-color: var(--erp-gray-50) !important;
    color: var(--erp-gray-500) !important;
    cursor: not-allowed;
}

.erp-main input[type="color"] { padding: 3px !important; height: var(--erp-control-h); cursor: pointer; }
.erp-main input::placeholder, .erp-main textarea::placeholder { color: var(--erp-gray-400) !important; opacity: 1; }

/* Validation helper used by legacy Errorinput() */
.erp-main .text_Mandatory { border: 1px solid var(--erp-danger) !important; box-shadow: 0 0 0 3px rgba(198, 40, 40, .15) !important; }

/* Checkbox / radio */
.erp-main input[type="checkbox"],
.erp-main input[type="radio"],
.erp-check input {
    width: 18px !important;
    height: 18px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0;
    accent-color: var(--erp-primary);
    cursor: pointer;
    box-shadow: none !important;
    vertical-align: middle;
}

.erp-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--erp-control-h);
    padding: 6px 12px;
    border: 1px solid var(--erp-gray-200);
    border-radius: 8px;
    background: var(--erp-surface);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 500 !important;
    color: var(--erp-gray-700) !important;
}

.erp-check:hover { border-color: var(--erp-primary-200); background: var(--erp-primary-50); }

.erp-choice-group { display: flex; flex-wrap: wrap; gap: 10px; }

/* Image picker */
.erp-image-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: var(--erp-radius);
    border: 2px dashed var(--erp-gray-300);
    background: var(--erp-gray-25);
    overflow: hidden;
    cursor: pointer;
}

.erp-image-picker:hover { border-color: var(--erp-primary-400); }
.erp-image-picker img { width: 100% !important; height: 100% !important; object-fit: cover; border: 0 !important; border-radius: 0 !important; }

/* select2 */
.erp-body .select2-container { width: 100% !important; }
.erp-body .select2-container--default .select2-selection--single,
.erp-body .select2-container--default .select2-selection--multiple {
    min-height: var(--erp-control-h);
    border: 1px solid var(--erp-gray-300);
    border-radius: 8px;
    background: var(--erp-surface);
}

.erp-body .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: calc(var(--erp-control-h) - 2px);
    padding-inline: 12px 28px;
    color: var(--erp-text);
    text-align: start;
}

.erp-body .select2-container--default .select2-selection--single .select2-selection__arrow { height: calc(var(--erp-control-h) - 2px); }
.erp-body .select2-container--default.select2-container--focus .select2-selection--multiple,
.erp-body .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--erp-primary); box-shadow: var(--erp-focus); }
.erp-body .select2-dropdown { border: 1px solid var(--erp-gray-200); border-radius: 8px; box-shadow: var(--erp-shadow-md); overflow: hidden; z-index: 1300; }
.erp-body .select2-container--default .select2-results__option--highlighted[aria-selected],
.erp-body .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--erp-primary); color: #fff; }
.erp-body .select2-search--dropdown .select2-search__field { border-radius: 6px; border: 1px solid var(--erp-gray-300); }
.erp-body .select2-container--default .select2-selection--multiple .select2-selection__choice { background: var(--erp-primary-100); border: 0; border-radius: 6px; color: var(--erp-primary-active); }

/* 6. BUTTONS =============================================================== */
.erp-btn,
.erp-main .u-btn,
.erp-main .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--erp-control-h);
    height: auto;
    padding: 7px 16px !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: background-color var(--erp-transition), border-color var(--erp-transition), color var(--erp-transition), box-shadow var(--erp-transition);
    user-select: none;
}

.erp-btn:focus-visible,
.erp-main .u-btn:focus-visible,
.erp-main .btn:focus-visible { outline: none; box-shadow: var(--erp-focus) !important; }

.erp-btn:disabled, .erp-btn.is-disabled,
.erp-main .u-btn:disabled, .erp-main .btn:disabled,
.erp-main input.u-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Primary (default for legacy .u-btn / .Style_Add_Item without an inline color) */
.erp-btn--primary,
.erp-main .u-btn:not([style*="background"]),
.erp-main .Style_Add_Item:not([style*="background"]),
.erp-main .btn-primary:not([style*="background"]),
.erp-main .btn-success:not([style*="background"]) {
    background-color: var(--erp-primary) !important;
    color: #fff !important;
}

.erp-btn--primary:hover,
.erp-main .u-btn:not([style*="background"]):hover,
.erp-main .Style_Add_Item:not([style*="background"]):hover,
.erp-main .btn-primary:not([style*="background"]):hover,
.erp-main .btn-success:not([style*="background"]):hover { background-color: var(--erp-primary-hover) !important; }

/* Legacy buttons with an inline semantic color keep the color but get the new shape */
.erp-main .u-btn[style*="background"],
.erp-main .Style_Add_Item[style*="background"] { color: #fff !important; }

.erp-btn--secondary,
.erp-main .btn-secondary,
.erp-main .btn-default {
    background-color: var(--erp-surface) !important;
    border-color: var(--erp-gray-300) !important;
    color: var(--erp-gray-700) !important;
}

.erp-btn--secondary:hover,
.erp-main .btn-secondary:hover,
.erp-main .btn-default:hover { background-color: var(--erp-gray-50) !important; border-color: var(--erp-gray-400) !important; color: var(--erp-gray-900) !important; }

.erp-btn--success { background-color: var(--erp-success-solid) !important; color: #fff !important; }
.erp-btn--success:hover { filter: brightness(.94); }

.erp-btn--danger,
.erp-main .btn-danger:not([style*="background"]) { background-color: var(--erp-danger-solid) !important; color: #fff !important; }
.erp-btn--danger:hover,
.erp-main .btn-danger:not([style*="background"]):hover { background-color: var(--erp-danger-hover) !important; }

.erp-btn--ghost { background-color: transparent !important; color: var(--erp-primary-text) !important; }
.erp-btn--ghost:hover { background-color: var(--erp-primary-50) !important; }

.erp-btn--outline { background-color: transparent !important; border-color: var(--erp-primary) !important; color: var(--erp-primary-text) !important; }
.erp-btn--outline:hover { background-color: var(--erp-primary-50) !important; }

.erp-btn--sm { min-height: var(--erp-control-h-sm); padding: 4px 12px !important; font-size: 12.5px !important; }
.erp-btn--lg { min-height: 44px; padding: 10px 22px !important; font-size: 14.5px !important; }
.erp-btn--block { width: 100%; }

.erp-btn--icon {
    width: var(--erp-control-h);
    min-width: var(--erp-control-h);
    padding: 0 !important;
}

.erp-btn--icon.erp-btn--sm { width: var(--erp-control-h-sm); min-width: var(--erp-control-h-sm); }

/* Loading state used by legacy code (._Loding / .Btn_Loder) */
.erp-main .Btn_Loder { position: relative; color: transparent !important; pointer-events: none; }
.erp-main .Btn_Loder::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    animation: erp-spin .7s linear infinite;
}

/* 7. FILTER BAR ============================================================ */
.erp-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px 16px;
    align-items: end;
}

.erp-filter-bar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: end;
}

.erp-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding-inline: 10px;
    border-radius: 999px;
    background: var(--erp-primary-50);
    color: var(--erp-primary-text);
    font-size: 12px;
    font-weight: 600;
}

/* Clear-filter control used by most list screens (#btnDelete_Filter) */
.erp-clear-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto !important;
    min-height: var(--erp-control-h);
    margin: 0 !important;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--erp-gray-200);
    background: var(--erp-surface);
    color: var(--erp-danger) !important;
    font-size: 13px !important;
    font-weight: 600;
    cursor: pointer;
}

.erp-clear-filter:hover { background: var(--erp-danger-bg); border-color: var(--erp-danger-border); }

/* 8. DATA GRIDS ============================================================ */
.erp-grid { overflow-x: auto; }
.erp-grid-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-block-end: 1px solid var(--erp-gray-100); }

/* --- jsgrid (also used by StGrid / EsGrid) --- */
.erp-body .jsgrid { font-size: 13px; width: 100% !important; }

.erp-body .jsgrid-grid-header,
.erp-body .jsgrid-grid-body {
    border: 0 !important;
    background: var(--erp-surface);
}

.erp-body .jsgrid-grid-header {
    border-block-end: 1px solid var(--erp-gray-200) !important;
    border-radius: var(--erp-radius) var(--erp-radius) 0 0;
    overflow: hidden;
}

.erp-body .jsgrid-grid-body { max-height: 620px; overflow-y: auto !important; }

.erp-body .jsgrid-table { border-collapse: separate; border-spacing: 0; width: 100%; }

.erp-body .jsgrid-header-row > .jsgrid-header-cell,
.erp-body .jsgrid-header-row > th {
    padding: 10px 12px !important;
    background: var(--erp-gray-50) !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-200) !important;
    color: var(--erp-gray-600) !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: none;
    text-align: center;
    white-space: nowrap;
}

.erp-body .jsgrid-header-sort { color: var(--erp-primary-text) !important; }
.erp-body .jsgrid-header-sort::before { border-color: var(--erp-primary) transparent; }

.erp-body .jsgrid-filter-row > .jsgrid-cell,
.erp-body .jsgrid-insert-row > .jsgrid-cell,
.erp-body .jsgrid-edit-row > .jsgrid-cell { background: var(--erp-primary-50) !important; padding: 6px 8px !important; }

.erp-body .jsgrid-row > .jsgrid-cell,
.erp-body .jsgrid-alt-row > .jsgrid-cell {
    padding: 7px 10px !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-100) !important;
    color: var(--erp-gray-800);
    vertical-align: middle;
    text-align: center;
}

.erp-body .jsgrid-row > .jsgrid-cell { background: var(--erp-surface) !important; }
.erp-body .jsgrid-alt-row > .jsgrid-cell { background: var(--erp-gray-25) !important; }
.erp-body .jsgrid-row:hover > .jsgrid-cell,
.erp-body .jsgrid-alt-row:hover > .jsgrid-cell { background: var(--erp-primary-50) !important; }
.erp-body .jsgrid-selected-row > .jsgrid-cell { background: var(--erp-primary-100) !important; border-color: var(--erp-primary-100) !important; }

.erp-body .jsgrid-nodata-row > .jsgrid-cell {
    padding: 40px 12px !important;
    background: var(--erp-surface) !important;
    color: var(--erp-text-muted);
    font-size: 13.5px;
    text-align: center;
}

/* Controls rendered inside grid cells (legacy itemTemplates set inline styles) */
.erp-body .jsgrid-cell input[type="text"],
.erp-body .jsgrid-cell input[type="number"],
.erp-body .jsgrid-cell input[type="date"],
.erp-body .jsgrid-cell select {
    min-height: var(--erp-control-h-sm) !important;
    padding: 4px 8px !important;
    border-radius: 6px !important;
    background-color: var(--erp-surface) !important;
    border: 1px solid var(--erp-gray-300) !important;
    font-size: 13px !important;
    text-align: center;
}

.erp-body .jsgrid-cell input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    accent-color: var(--erp-primary);
}

.erp-body .jsgrid-cell .u-btn,
.erp-body .jsgrid-cell .Style_Add_Item,
.erp-body .jsgrid-cell input[type="button"],
.erp-body .jsgrid-cell button {
    min-height: var(--erp-control-h-sm) !important;
    width: auto !important;
    min-width: 34px;
    padding: 4px 12px !important;
    border-radius: 6px !important;
    border: 1px solid transparent !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    cursor: pointer;
}

.erp-body .jsgrid-cell input[type="button"]:not([style*="background"]),
.erp-body .jsgrid-cell button:not([style*="background"]):not(.jsgrid-button) {
    background-color: var(--erp-primary-50) !important;
    border-color: var(--erp-primary-200) !important;
    color: var(--erp-primary-text) !important;
}

.erp-body .jsgrid-cell input[type="button"]:not([style*="background"]):hover,
.erp-body .jsgrid-cell button:not([style*="background"]):not(.jsgrid-button):hover { background-color: var(--erp-primary) !important; color: #fff !important; }

/* Pager */
.erp-body .jsgrid-pager-container { padding: 12px 8px 4px; }
.erp-body .jsgrid-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; padding: 0; font-size: 13px; color: var(--erp-text-muted); }
.erp-body .jsgrid-pager-page,
.erp-body .jsgrid-pager-nav-button { padding: 0 !important; margin: 0; }
.erp-body .jsgrid-pager-page a,
.erp-body .jsgrid-pager-nav-button a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--erp-gray-200);
    background: var(--erp-surface);
    color: var(--erp-gray-700) !important;
    text-decoration: none !important;
}

.erp-body .jsgrid-pager-page a:hover,
.erp-body .jsgrid-pager-nav-button a:hover { border-color: var(--erp-primary-200); color: var(--erp-primary-text) !important; }
.erp-body .jsgrid-pager-current-page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px !important;
    border-radius: 8px;
    background: var(--erp-primary);
    color: #fff !important;
    font-weight: 700;
}

/* --- bootstrap-table / plain .table / DataTables --- */
.erp-body .bootstrap-table .fixed-table-container,
.erp-body .fixed-table-container { border: 1px solid var(--erp-gray-200) !important; border-radius: var(--erp-radius); overflow: hidden; }

.erp-main table.table,
.erp-main .bootstrap-table table,
.erp-main table.dataTable,
.erp-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate !important;
    border-spacing: 0;
    background: var(--erp-surface);
    font-size: 13px;
    color: var(--erp-gray-800);
}

.erp-main table.table > thead > tr > th,
.erp-main .bootstrap-table table > thead > tr > th,
.erp-main table.dataTable > thead > tr > th,
.erp-table > thead > tr > th {
    padding: 10px 12px !important;
    background: var(--erp-gray-50) !important;
    color: var(--erp-gray-600) !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-200) !important;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}

.erp-main table.table > tbody > tr > td,
.erp-main .bootstrap-table table > tbody > tr > td,
.erp-main table.dataTable > tbody > tr > td,
.erp-table > tbody > tr > td {
    padding: 8px 12px !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-100) !important;
    vertical-align: middle;
}

.erp-main table.table > tbody > tr:nth-child(even) > td,
.erp-main table.dataTable > tbody > tr.even > td,
.erp-table > tbody > tr:nth-child(even) > td { background: var(--erp-gray-25); }

.erp-main table.table > tbody > tr:hover > td,
.erp-main table.dataTable > tbody > tr:hover > td,
.erp-table > tbody > tr:hover > td { background: var(--erp-primary-50); }

.erp-main table.table > tfoot > tr > td,
.erp-main table.table > tfoot > tr > th { background: var(--erp-gray-50); font-weight: 700; border-block-start: 1px solid var(--erp-gray-200) !important; }

.erp-body .dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 8px !important; border: 1px solid var(--erp-gray-200) !important; background: var(--erp-surface) !important; color: var(--erp-gray-700) !important; }
.erp-body .dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--erp-primary) !important; color: #fff !important; border-color: var(--erp-primary) !important; }
.erp-body .dataTables_wrapper .dataTables_filter input,
.erp-body .dataTables_wrapper .dataTables_length select { border: 1px solid var(--erp-gray-300); border-radius: 8px; padding: 4px 10px; }

/* --- Infragistics igGrid --- */
.erp-body .ui-iggrid { border: 1px solid var(--erp-gray-200) !important; border-radius: var(--erp-radius); overflow: hidden; font-family: var(--erp-font); }
.erp-body .ui-iggrid .ui-iggrid-header,
.erp-body .ui-iggrid th.ui-widget-header { background: var(--erp-gray-50) !important; color: var(--erp-gray-600) !important; border-color: var(--erp-gray-200) !important; font-weight: 700; font-size: 12px; }
.erp-body .ui-iggrid td { border-color: var(--erp-gray-100) !important; font-size: 13px; padding: 7px 10px; }
.erp-body .ui-iggrid tr.ui-ig-altrecord td { background: var(--erp-gray-25); }
.erp-body .ui-iggrid tr:hover td { background: var(--erp-primary-50) !important; }
.erp-body .ui-iggrid .ui-state-active,
.erp-body .ui-iggrid .ui-iggrid-activecell { background: var(--erp-primary-100) !important; border-color: var(--erp-primary-200) !important; color: var(--erp-gray-900) !important; }

/* 9. TABS / STEPS ========================================================== */
.erp-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-block-end: 16px;
    border-radius: var(--erp-radius);
    background: var(--erp-gray-100);
    overflow-x: auto;
}

.erp-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--erp-gray-600);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.erp-tab:hover { color: var(--erp-gray-900); }
.erp-tab.is-active, .erp-tab.active { background: var(--erp-surface); color: var(--erp-primary-text); box-shadow: var(--erp-shadow-xs); }

.erp-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    counter-reset: erp-step;
}

.erp-step {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 0;
    min-width: 0;
    color: var(--erp-gray-500);
    font-size: 13px;
    font-weight: 600;
    counter-increment: erp-step;
}

.erp-step::before {
    content: counter(erp-step);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--erp-gray-300);
    background: var(--erp-surface);
    font-size: 12.5px;
}

.erp-step::after {
    content: "";
    flex: 1 1 auto;
    height: 2px;
    border-radius: 2px;
    background: var(--erp-gray-200);
}

.erp-step:last-child::after { display: none; }
.erp-step.is-active { color: var(--erp-primary-text); }
.erp-step.is-active::before { border-color: var(--erp-primary); background: var(--erp-primary); color: #fff; }
.erp-step.is-done { color: var(--erp-success); }
.erp-step.is-done::before { border-color: var(--erp-success); background: var(--erp-success-bg); }

/* Step state driven purely by which legacy panel is visible (no JS needed):
   .erp-wizard contains .erp-steps + panels; panel 2 visible => step 2 active */
.erp-wizard:has(> .erp-wizard__panel--2:not(.display_none)) .erp-step--1 { color: var(--erp-success); }
.erp-wizard:has(> .erp-wizard__panel--2:not(.display_none)) .erp-step--1::before { border-color: var(--erp-success); background: var(--erp-success-bg); color: var(--erp-success); }
.erp-wizard:has(> .erp-wizard__panel--2:not(.display_none)) .erp-step--2 { color: var(--erp-primary-text); }
.erp-wizard:has(> .erp-wizard__panel--2:not(.display_none)) .erp-step--2::before { border-color: var(--erp-primary); background: var(--erp-primary); color: #fff; }
.erp-wizard:has(> .erp-wizard__panel--1:not(.display_none)) .erp-step--1 { color: var(--erp-primary-text); }
.erp-wizard:has(> .erp-wizard__panel--1:not(.display_none)) .erp-step--1::before { border-color: var(--erp-primary); background: var(--erp-primary); color: #fff; }

/* 10. STICKY ACTION BAR ==================================================== */
.erp-action-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin: 8px calc(var(--erp-gutter) * -1) calc(var(--erp-gutter) * -1);
    padding: 12px var(--erp-gutter);
    background: var(--erp-actionbar-bg);
    backdrop-filter: blur(6px);
    border-block-start: 1px solid var(--erp-border);
    box-shadow: 0 -6px 16px rgba(16, 24, 40, .06);
}

.erp-action-bar__start { margin-inline-end: auto; display: flex; gap: 10px; align-items: center; }

/* 11. LEGACY (NICEPAGE / BOOTSTRAP 3) OVERRIDES ============================ */
/* Neutralize section backgrounds / gradients inside the content area */
.erp-main [class*="u-section-"],
.erp-main .u-gradient,
.erp-main .u-sheet,
.erp-main [class*="u-custom-color"],
.erp-main .u-grey-5,
.erp-main .u-grey-10,
.erp-main .u-body {
    background-color: transparent !important;
    background-image: none !important;
}

.erp-main .u-sheet {
    width: 100% !important;
    max-width: 100%;
    min-height: 0 !important;
    margin-inline: 0 !important;
}

.erp-main [class*="u-section-"] { min-height: 0 !important; }

/* Common legacy wrappers become cards */
.erp-main .sparkline8-graph,
.erp-main .sparkline8-list,
.erp-main .sparkline10-list,
.erp-main .sparkline12-list {
    background: var(--erp-surface) !important;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-radius-lg) !important;
    box-shadow: var(--erp-shadow-sm);
    padding: 18px 20px !important;
    margin-block-end: 18px;
    width: 100%;
    float: none;
    text-align: start;
}

.erp-main .inside-table { margin-block: 12px 0 !important; }

.erp-main .card {
    border: 1px solid var(--erp-border) !important;
    border-radius: var(--erp-radius-lg) !important;
    box-shadow: var(--erp-shadow-sm);
    background: var(--erp-surface);
}

.erp-main .card-header { background: var(--erp-gray-25); border-block-end: 1px solid var(--erp-gray-100); border-radius: var(--erp-radius-lg) var(--erp-radius-lg) 0 0 !important; }
.erp-main .card-title { font-size: 15px; font-weight: 700; color: var(--erp-gray-900); }
.erp-main .container { width: 100%; max-width: 100%; padding-inline: 0; margin-top: 0 !important; }

/* Nicepage form groups */
.erp-main .u-form .u-form-group,
.erp-main .u-form-group { text-align: start; }

.erp-main .u-label,
.erp-main .form-label,
.erp-main .u-form-group > label {
    display: block;
    margin-block-end: 6px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    color: var(--erp-gray-600) !important;
    text-align: start;
}

.erp-main .u-text-grey-40 { color: var(--erp-gray-600) !important; }

.erp-main .u-form-control-hidden { display: none !important; }

/* Legacy pill-shaped widgets -> regular radius */
.erp-main .u-radius-20,
.erp-main .u-radius-50:not(.u-image) { border-radius: var(--erp-radius) !important; }

/* Bootstrap 3 / legacy panels */
.erp-main .panel { border-radius: var(--erp-radius-lg); border-color: var(--erp-border); box-shadow: var(--erp-shadow-sm); }
.erp-main .panel-heading { border-radius: var(--erp-radius-lg) var(--erp-radius-lg) 0 0; background: var(--erp-gray-25) !important; color: var(--erp-gray-900) !important; }

/* Legacy step list (.multi-steps) */
.erp-main .multi-steps > li.is-active::before,
.erp-main .multi-steps > li.is-active ~ li::before { font-family: var(--erp-font); }

/* 12. MODALS / SEARCH BOX ================================================== */
.erp-body .modal { z-index: 1200 !important; }
.erp-body .modal:not(#myModalLoder) { background-color: var(--erp-overlay) !important; backdrop-filter: blur(2px); }

.erp-body .modal .card,
.erp-body .modal-content,
.erp-modal {
    border: 0 !important;
    border-radius: var(--erp-radius-lg) !important;
    box-shadow: var(--erp-shadow-lg) !important;
    background: var(--erp-surface);
    overflow: hidden;
    font-family: var(--erp-font);
}

.erp-body .modal .card-header,
.erp-body .modal-header,
.erp-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px !important;
    background: var(--erp-surface) !important;
    border-block-end: 1px solid var(--erp-gray-100) !important;
}

.erp-body .modal .card-header h4,
.erp-body .modal-title,
.erp-modal__title { margin: 0; font-size: 16px; font-weight: 700; color: var(--erp-gray-900); }

.erp-body .modal .card-body,
.erp-body .modal-body,
.erp-modal__body { padding: 18px 20px !important; }

.erp-body .modal-footer,
.erp-modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px !important; border-block-start: 1px solid var(--erp-gray-100); background: var(--erp-gray-25); }

.erp-body .modal .form-control { min-height: var(--erp-control-h); border-radius: 8px; border-color: var(--erp-gray-300); }
.erp-body .modal .form-control:focus { border-color: var(--erp-primary); box-shadow: var(--erp-focus); }
.erp-body .modal label { font-size: 12.5px; font-weight: 600; color: var(--erp-gray-600); }
.erp-body .modal .btn { border-radius: 8px; font-weight: 600; min-height: var(--erp-control-h); }
.erp-body .modal .btn-primary { background: var(--erp-primary); border-color: var(--erp-primary); }
.erp-body .modal .btn-primary:hover { background: var(--erp-primary-hover); }

/* Forgot password modal: Close button had an inline maroon color */
.erp-body #Close_Email { background-color: var(--erp-gray-100) !important; border-color: var(--erp-gray-200) !important; color: var(--erp-gray-700) !important; }

/* Global search popups (#SearchBox / #NewSearch_Box_Pagination) */
.erp-body .search-box {
    z-index: 1210 !important;
    border-radius: var(--erp-radius-lg) !important;
    background: var(--erp-surface) !important;
    box-shadow: var(--erp-shadow-lg) !important;
    border: 1px solid var(--erp-border);
    overflow: hidden;
}

.erp-body .search-box .search-content { background: var(--erp-surface) !important; border-block-end: 1px solid var(--erp-gray-100); padding: 12px 16px !important; }
.erp-body .search-box .search-title { color: var(--erp-gray-900) !important; font-weight: 700; font-size: 16px; }
.erp-body .search-box .close-search-box { border-radius: 8px !important; background: var(--erp-gray-100) !important; color: var(--erp-gray-700) !important; border: 0 !important; width: 32px; height: 32px; }
.erp-body .search-box .dataTables_wrapper .dataTable thead th { background: var(--erp-gray-50) !important; color: var(--erp-gray-600) !important; }
.erp-body .search-box .dataTables_wrapper .dataTable tbody tr:hover td { background: var(--erp-primary-50) !important; }

/* 13. TOASTS / LOADER ====================================================== */
.erp-body .toast-container { z-index: 1400 !important; display: flex; flex-direction: column; gap: 8px; align-items: center; }

.erp-body .toast {
    background-color: var(--erp-toast-bg) !important;
    color: var(--erp-toast-text) !important;
    padding: 12px 18px !important;
    border-radius: 10px !important;
    box-shadow: var(--erp-shadow-lg) !important;
    font-size: 13.5px;
    font-weight: 600;
    max-width: min(92vw, 460px);
}

/* Loader overlay (#myModalLoder .loader). Show_Loder()/Close_Loder() only toggle
   #myModalLoder's inline display. The legacy Loder.css (coin glyph) is no longer
   loaded; the rules below also neutralize it if it is ever loaded again. */
.erp-body #myModalLoder {
    z-index: 1500 !important;
    background: var(--erp-loader-overlay) !important;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* slim indeterminate progress bar at the top of the viewport */
.erp-body #myModalLoder::before {
    content: "";
    position: fixed;
    top: 0;
    inset-inline: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--erp-primary) 35%, var(--erp-primary-400) 65%, transparent 100%);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: erp-progress 1.1s ease-in-out infinite;
}

/* the spinner card */
.erp-body #myModalLoder .loader {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
}

.erp-body .loader {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 72px !important;
    height: 72px !important;
    border-radius: 18px;
    background: var(--erp-surface);
    box-shadow: var(--erp-shadow-lg);
    border: 1px solid var(--erp-border);
    font-size: 0 !important;
    color: transparent !important;
    line-height: 0 !important;
    overflow: hidden;
}

.erp-body .loader::before { content: none !important; display: none !important; }

.erp-body .loader::after {
    content: "" !important;
    display: block !important;
    width: 34px !important;
    height: 34px !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 3px solid var(--erp-primary-100) !important;
    border-top-color: var(--erp-primary) !important;
    background: transparent !important;
    box-shadow: none !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    animation: erp-spin .75s linear infinite !important;
}

/* Deferred slim progress bar (#erpTopProgress, PERF_PLAN A3/A4). Toggled by Show_Loder_Deferred()
   / Close_Loder() via .is-active. No overlay: the page stays usable and nothing flashes for fast work. */
/* PERF_LOADER: the bar is revealed by the COMPOSITOR, not by a JS timer. Almost every data read is a
   synchronous XHR, and while it runs no timer fires and no style change is painted - a timer-based
   bar therefore never appeared for slow work. Now:
   .is-armed  = set on pointerdown of a button/link (or by Show_Loder_Deferred()). An opacity animation
                with a delay (--erp-bar-delay, default 250 ms) reveals the bar; once the frame with the
                class is committed, the compositor runs it even while the main thread is frozen.
                Work that finishes before the delay disarms it -> nothing is ever painted (no flash).
   .is-active = shown at once (no delay).
   The slider moves with transform only (compositor), never background-position (main thread). */
.erp-top-progress {
    display: none;
    position: fixed;
    top: 0;
    inset-inline: 0;
    height: 3px;
    z-index: 1600;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    contain: strict;
}
.erp-top-progress::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, var(--erp-primary) 35%, var(--erp-primary-400) 65%, transparent 100%);
    will-change: transform;
    animation: erp-progress-slide 1.1s ease-in-out infinite;
}
.erp-top-progress.is-armed,
.erp-top-progress.is-active { display: block; will-change: opacity; }
.erp-top-progress.is-armed { animation: erp-bar-reveal 140ms ease-out var(--erp-bar-delay, 250ms) forwards; }
.erp-top-progress.is-active { opacity: 1; animation: none; }
.erp-top-progress.is-leaving { opacity: 1; animation: erp-bar-hide 150ms ease-in forwards; }
@keyframes erp-bar-hide { from { opacity: 1; } to { opacity: 0; } }
/* the light loader (saves) has its own bar inside #myModalLoder: never show both */
#myModalLoder.erp-loder-light[style*="block"] ~ .erp-top-progress { display: none; }
@keyframes erp-bar-reveal { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .erp-top-progress::before { animation-duration: 2.2s; }
}

@keyframes erp-progress {
    0% { background-position: -40% 0; }
    100% { background-position: 140% 0; }
}
@keyframes erp-spin { to { transform: rotate(360deg); } }

/* Light loader (PERF_PLAN R2-1). Show_Loder() adds .erp-loder-light to #myModalLoder:
   0-600 ms : transparent click shield (still prevents double submits) + slim top bar + spinner on the
              pressed button (.erp-btn-busy). No blur, no tint, nothing flashes for fast saves.
   > 600 ms : a light tint + the spinner card fade in.
   Only opacity/transform are animated, so the bar, the spinners and the delayed fade-in keep running
   on the compositor even while a synchronous request blocks the main thread.
   .erp-loder-closing = invisible shield kept for a few ms after Close_Loder() (queued clicks). */
.erp-body #myModalLoder.erp-loder-light {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    cursor: progress;
    overflow: hidden;
}
.erp-body #myModalLoder.erp-loder-light::before {
    inset-inline: auto;
    left: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent 0%, var(--erp-primary) 35%, var(--erp-primary-400) 65%, transparent 100%);
    background-size: 100% 100%;
    will-change: transform, opacity;
    /* PERF_LOADER: fades in after 150 ms (compositor) - a fast save shows nothing at all */
    opacity: 0;
    animation: erp-progress-slide 1.1s ease-in-out infinite, erp-bar-reveal 140ms ease-out 150ms forwards;
}
.erp-body #myModalLoder.erp-loder-light .loader {
    opacity: 0;
    box-shadow: var(--erp-shadow-lg), 0 0 0 200vmax var(--erp-loader-overlay);
    will-change: opacity;
    animation: erp-loder-escalate 180ms ease-out 600ms forwards;
}
.erp-body #myModalLoder.erp-loder-closing::before,
.erp-body #myModalLoder.erp-loder-closing .loader {
    visibility: hidden !important;
    animation: none !important;
}
@keyframes erp-progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}
@keyframes erp-loder-escalate { to { opacity: 1; } }

/* inline busy state on the button that started a save / approval */
.erp-btn-busy {
    pointer-events: none !important;
    cursor: progress !important;
}
button.erp-btn-busy::after,
a.erp-btn-busy::after {
    content: "" !important;
    display: inline-block !important;
    position: static !important;
    width: .95em !important;
    height: .95em !important;
    margin: 0 !important;
    margin-inline-start: .45em !important;
    vertical-align: -.14em;
    border: 2px solid currentColor !important;
    border-inline-end-color: transparent !important;
    border-radius: 50% !important;
    background: none !important;
    /* PERF_LOADER: the spinner fades in after 150 ms (compositor) instead of flashing on fast saves */
    opacity: 0;
    will-change: transform, opacity;
    animation: erp-spin .7s linear infinite, erp-bar-reveal 140ms ease-out 150ms forwards !important;
}
@media (prefers-reduced-motion: reduce) {
    .erp-body #myModalLoder.erp-loder-light::before { animation-duration: 2.2s, 140ms; }
    button.erp-btn-busy::after, a.erp-btn-busy::after { animation-duration: 1.6s, 140ms !important; }
}

/* 14. BADGES / EMPTY STATE ================================================= */
.erp-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 24px;
    padding-inline: 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    background: var(--erp-gray-100);
    color: var(--erp-gray-700);
}

.erp-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.erp-badge--active, .erp-badge--success { background: var(--erp-success-bg); color: var(--erp-success); }
.erp-badge--inactive, .erp-badge--danger { background: var(--erp-danger-bg); color: var(--erp-danger); }
.erp-badge--warning { background: var(--erp-warning-bg); color: var(--erp-warning); }
.erp-badge--info { background: var(--erp-info-bg); color: var(--erp-info); }
.erp-badge--plain::before { display: none; }

.erp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 48px 16px;
    text-align: center;
    color: var(--erp-text-muted);
}

.erp-empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--erp-primary-50);
    color: var(--erp-primary-text);
    font-size: 24px;
}

.erp-empty__title { margin: 4px 0 0; font-size: 15px; font-weight: 700; color: var(--erp-gray-800); }
.erp-empty__text { margin: 0; font-size: 13px; max-width: 420px; }

/* 15. TILES (home dashboard + "pages in menu") ============================= */
.erp-dashboard { text-align: start; }

.erp-welcome {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    margin-block-end: 22px;
    padding: 22px 24px;
    border-radius: var(--erp-radius-lg);
    background: linear-gradient(120deg, var(--erp-navy-800) 0%, var(--erp-primary) 100%) !important;
    color: #fff;
    box-shadow: var(--erp-shadow-md);
    overflow: hidden;
}

.erp-welcome::after {
    content: "";
    position: absolute;
    inset-inline-end: -60px;
    top: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
    pointer-events: none;
}

.erp-welcome__avatar {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, .35);
    background: #fff;
    cursor: pointer;
}

.erp-welcome__avatar .u-image,
.erp-welcome__avatar img {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    object-fit: cover;
}

.erp-welcome__text { flex: 1 1 240px; min-width: 0; }
.erp-welcome__hello { margin: 0; font-size: 12.5px; font-weight: 600; color: rgba(255, 255, 255, .72); }
.erp-welcome .erp-welcome__name { margin: 2px 0 4px !important; font-size: 22px !important; font-weight: 700 !important; color: #fff !important; }
.erp-welcome .erp-welcome__meta { margin: 0 !important; font-size: 13px !important; color: rgba(255, 255, 255, .8) !important; }

.erp-welcome__logout {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding-inline: 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    color: #fff;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
}

.erp-welcome__logout:hover { background: rgba(255, 255, 255, .2); }

.erp-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.erp-section-head__title { margin: 0 !important; font-size: 16px !important; font-weight: 700 !important; color: var(--erp-gray-900) !important; }
.erp-section-head__sub { margin: 0; font-size: 12.5px; color: var(--erp-text-muted); }

.erp-tiles,
.erp-main .erp-tiles.u-repeater {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)) !important;
    gap: 16px !important;
    min-height: 0 !important;
    margin: 0 !important;
    width: 100%;
}

/* Tile markup emitted by Build_Menu() / Build_Tap_Page(): IMAGE-FREE icon tiles.
   <div id=CODE namescreen class="_MODULE_CODE erp-tile erp-tile--menu|--page">
     <span class="erp-tile__icon"><i class="fa fa-..."></i></span>
     <div class="erp-tile__body"><h6 class="erp-tile__title">Name</h6></div>
     <span class="erp-tile__arrow"><i class="fa fa-chevron-right"></i></span>
   </div> */
.erp-tile,
.erp-tiles > .u-repeater-item {
    position: relative;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    min-height: 76px !important;
    margin: 0 !important;
    width: auto !important;
    padding: 14px 16px !important;
    border-radius: var(--erp-radius-lg) !important;
    border: 1px solid var(--erp-border);
    background: var(--erp-surface) !important;
    box-shadow: var(--erp-shadow-xs);
    overflow: hidden;
    cursor: pointer;
    text-align: start;
    transition: transform var(--erp-transition), box-shadow var(--erp-transition), border-color var(--erp-transition), background var(--erp-transition);
}

.erp-tile:hover,
.erp-tiles > .u-repeater-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--erp-shadow-md);
    border-color: var(--erp-primary-200);
}

.erp-tile:focus-visible { outline: none; box-shadow: var(--erp-focus), var(--erp-shadow-md); }

/* No images in tiles anywhere (legacy static cards included) */
.erp-tiles img,
.erp-tile img,
.erp-tile__media { display: none !important; }
.erp-tiles > .u-repeater-item > .u-container-layout { padding: 0 !important; min-height: 0 !important; }

.erp-tile__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--erp-tile-icon-bg);
    color: var(--erp-primary-text);
    font-size: 20px;
    transition: background var(--erp-transition), color var(--erp-transition);
}

.erp-tile:hover .erp-tile__icon { background: var(--erp-primary); color: var(--erp-on-primary); }

.erp-tile__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.erp-tile .erp-tile__title,
.erp-tiles > .u-repeater-item h6 {
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--erp-gray-900) !important;
    line-height: 1.4;
    text-align: start;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-tile__arrow {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: var(--erp-gray-400);
    font-size: 11px;
    transition: color var(--erp-transition), transform var(--erp-transition);
}

[dir="rtl"] .erp-tile__arrow .fa { transform: scaleX(-1); }
.erp-tile:hover .erp-tile__arrow { color: var(--erp-primary-text); }

.erp-tile--menu { min-height: 84px !important; }
.erp-tile--menu .erp-tile__icon { width: 52px; height: 52px; font-size: 22px; }

/* Home dashboard extras */
.erp-welcome__date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-block-start: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: rgba(255, 255, 255, .9);
    font-size: 12px;
    font-weight: 600;
}

.erp-home-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 18px;
    align-items: start;
}

.erp-hint-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.erp-hint-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: var(--erp-text); }
.erp-hint-list .fa {
    flex-shrink: 0;
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px;
    background: var(--erp-primary-50);
    color: var(--erp-primary-text);
    font-size: 14px;
}
.erp-hint-list strong { display: block; color: var(--erp-gray-900); font-size: 13.5px; }
.erp-hint-list span { color: var(--erp-text-muted); }

@media (max-width: 1199.98px) { .erp-home-grid { grid-template-columns: 1fr; } }
/* 16. LOGIN ================================================================ */
.erp-login {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr);
    background: var(--erp-bg) !important;
    overflow: auto;
    text-align: start;
    font-family: var(--erp-font);
}

.erp-login__hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 56px;
    background: radial-gradient(circle at 15% 20%, var(--erp-hero-glow-1) 0, transparent 45%),
                radial-gradient(circle at 85% 80%, var(--erp-hero-glow-2) 0, transparent 40%),
                linear-gradient(140deg, var(--erp-navy-950) 0%, var(--erp-navy-800) 100%);
    color: #fff;
    overflow: hidden;
}

.erp-login__brand { display: flex; align-items: center; gap: 14px; }
.erp-login__brand img { width: 56px; height: 56px; border-radius: 13px; object-fit: contain; flex-shrink: 0; box-shadow: 0 8px 22px rgba(0, 0, 0, .3); }
.erp-login__brand-name { font-size: 20px; font-weight: 700; display: inline-block; direction: ltr; }
.erp-login__brand-sub { font-size: 12.5px; color: rgba(255, 255, 255, .65); }
.erp-login__headline { max-width: 460px; }
.erp-login__headline h1 { margin: 0 0 12px; font-size: 34px; line-height: 1.3; font-weight: 700; color: #fff; }
.erp-login__headline p { margin: 0; font-size: 15px; color: rgba(255, 255, 255, .75); }
.erp-login__features { display: grid; gap: 12px; margin: 28px 0 0; padding: 0; list-style: none; }
.erp-login__features li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255, 255, 255, .85); }
.erp-login__features .fa { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: rgba(255, 255, 255, .1); }
.erp-login__copy { font-size: 12px; color: rgba(255, 255, 255, .5); }

.erp-login__panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: var(--erp-surface);
}

.erp-login__card { width: 100%; max-width: 400px; }

.erp-login__switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-block-end: 26px;
    border-radius: 10px;
    background: var(--erp-gray-100);
}

.erp-login__switch .splits { flex: 1 1 0; margin: 0; width: auto !important; float: none !important; background: transparent !important; }
.erp-login__switch .splits p { display: none !important; }

.erp-login__switch .__button {
    width: 100%;
    height: 36px;
    border: 0;
    border-radius: 8px !important;
    background: transparent !important;
    opacity: 1 !important;
    color: var(--erp-gray-600) !important;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
}

.erp-login__switch .__button.active { background: var(--erp-surface) !important; color: var(--erp-primary-text) !important; box-shadow: var(--erp-shadow-xs); }
.erp-login .CompSelect { margin: 0 !important; width: 100% !important; font-weight: 500; }

.erp-login .erp-login__form { display: block; }
.erp-login .erp-login__form.display_none { display: none !important; }
.erp-login .erp-login__form h3 { margin: 0 0 6px; font-size: 24px; font-weight: 700; color: var(--erp-gray-900); }
.erp-login .erp-login__lead { margin: 0 0 22px; font-size: 13.5px; color: var(--erp-text-muted); }
/* REGISTER CODE: the company the typed code belongs to (Login.ts RegLookup) */
.erp-login .erp-login__company { margin: 0; font-size: 13px; font-weight: 600; min-height: 1.2em; }
.erp-login .erp-login__company.is-ok { color: var(--erp-success, #16a34a); }
.erp-login .erp-login__company.is-bad { color: var(--erp-danger, #dc2626); }

.erp-login .erp-login__field { display: flex; flex-direction: column; gap: 6px; margin-block-end: 14px; position: relative; }
.erp-login .erp-login__field.display_none { display: none !important; }
.erp-login .erp-login__field > label { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--erp-gray-600); position: static !important; transform: none !important; }

.erp-login input[type="text"],
.erp-login input[type="email"],
.erp-login input[type="password"],
.erp-login select {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--erp-gray-300) !important;
    border-radius: 8px !important;
    background: var(--erp-surface) !important;
    color: var(--erp-text) !important;
    font-size: 14px;
    box-shadow: none !important;
    outline: none;
}

.erp-login input:focus,
.erp-login select:focus { border-color: var(--erp-primary) !important; box-shadow: var(--erp-focus) !important; }

.erp-login .erp-login__submit { margin-block-start: 8px; }
.erp-login .erp-login__submit .__button,
.erp-login input.erp-btn {
    width: 100%;
    height: 44px;
    border: 0;
    border-radius: 8px;
    background: var(--erp-primary) !important;
    color: #fff !important;
    font-weight: 700;
    font-size: 14.5px;
    cursor: pointer;
    transition: background var(--erp-transition);
}

.erp-login .erp-login__submit .__button:hover { background: var(--erp-primary-hover) !important; }
.erp-login #LoginBack.__button { background: var(--erp-surface) !important; color: var(--erp-gray-700) !important; border: 1px solid var(--erp-gray-300); }
.erp-login #LoginBack.__button:hover { background: var(--erp-gray-50) !important; }

.erp-login .erp-login__link { display: inline-block; margin-block-start: 12px; color: var(--erp-primary-text) !important; font-size: 13px; font-weight: 600; cursor: pointer; }

.erp-login .erp-login__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-block-end: 14px; }
.erp-login .erp-login__row > .name { margin: 0 !important; width: auto !important; }
.erp-login .erp-login__row.display_none { display: none !important; }
.erp-login .erp-login__row input[type="button"] {
    width: 100%;
    height: 40px;
    border: 1px dashed var(--erp-gray-300);
    border-radius: 8px;
    background: var(--erp-gray-25) !important;
    color: var(--erp-gray-700);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.erp-login .erp-login__row input._backColor { border-color: var(--erp-success); color: var(--erp-success); background: var(--erp-success-bg) !important; }

/* Login: the legacy sliding ".veen .wrapper.move" register animation is replaced by a tab switch */
.erp-login .wrapper #register { display: none; }
.erp-login .wrapper.move #register { display: block; }
.erp-login .wrapper.move #login,
.erp-login .wrapper.move #DivCompany { display: none !important; }
.erp-login .wrapper { position: static !important; width: auto !important; height: auto !important; transform: none !important; box-shadow: none !important; background: transparent !important; padding: 0 !important; top: auto !important; left: auto !important; right: auto !important; }
.erp-login .wrapper > form { position: static !important; width: auto !important; padding: 0 !important; margin: 0 !important; opacity: 1 !important; transform: none !important; }
.erp-login.body { background: var(--erp-bg) !important; }

/* 18. CONTROL ALIGNMENT (one height for every control) ===================== */
/* Single-line text inputs, selects, dates: exact height so they line up with buttons */
.erp-input,
.erp-select,
.erp-main .u-input:not(textarea):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.erp-main .form-control:not(textarea):not([type="checkbox"]):not([type="radio"]),
.erp-main .form-select,
.erp-main select:not([multiple]):not([size]),
.erp-main input[type="text"],
.erp-main input[type="number"],
.erp-main input[type="email"],
.erp-main input[type="password"],
.erp-main input[type="date"],
.erp-main input[type="datetime-local"],
.erp-main input[type="time"],
.erp-main input[type="month"],
.erp-main input[type="search"],
.erp-main input[type="tel"],
.erp-body .modal .form-control:not(textarea) {
    height: var(--erp-control-h) !important;
    min-height: var(--erp-control-h) !important;
    padding-block: 0 !important;
    padding-inline: var(--erp-control-px) !important;
    border-radius: var(--erp-control-radius) !important;
    font-size: var(--erp-control-fs) !important;
    line-height: calc(var(--erp-control-h) - 2px);
    margin-block: 0 !important;
    vertical-align: middle;
}

.erp-main input[type="color"] { height: var(--erp-control-h) !important; border-radius: var(--erp-control-radius) !important; }

/* Every button-like control: same height/radius/font as inputs */
.erp-btn,
.erp-main .u-btn,
.erp-main .btn,
.erp-main .Style_Add_Item,
.erp-main input[type="button"]:not(.jsgrid-button),
.erp-main input[type="submit"],
.erp-main .u-btn.u-input,
.erp-main input[type="button"].u-input,
.erp-main input[type="button"].form-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--erp-control-h) !important;
    min-height: var(--erp-control-h) !important;
    padding-block: 0 !important;
    padding-inline: 16px !important;
    border-radius: var(--erp-control-radius) !important;
    font-size: var(--erp-control-fs) !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    margin-block: 0 !important;
    vertical-align: middle;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Legacy "u-btn u-input" / "Style_Add_Item u-input" combos: button look wins over input look */
.erp-main .u-btn.u-input:not([style*="background"]),
.erp-main .Style_Add_Item.u-input:not([style*="background"]),
.erp-main input[type="button"].u-input:not([style*="background"]):not(.jsgrid-button) {
    background-color: var(--erp-primary) !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
    cursor: pointer;
}

.erp-main .u-btn.u-input:not([style*="background"]):hover,
.erp-main .Style_Add_Item.u-input:not([style*="background"]):hover,
.erp-main input[type="button"].u-input:not([style*="background"]):not(.jsgrid-button):hover { background-color: var(--erp-primary-hover) !important; border-color: transparent !important; }

.erp-main input[type="button"][style*="background"],
.erp-main .u-btn[style*="background"] { border-color: transparent !important; color: #fff !important; }

.erp-btn--sm, .erp-main .erp-btn--sm { height: var(--erp-control-h-sm) !important; min-height: var(--erp-control-h-sm) !important; padding-inline: 12px !important; font-size: 12.5px !important; }
.erp-btn--lg, .erp-main .erp-btn--lg { height: var(--erp-control-h-lg) !important; min-height: var(--erp-control-h-lg) !important; padding-inline: 22px !important; }
.erp-btn--icon, .erp-main .erp-btn--icon { width: var(--erp-control-h) !important; min-width: var(--erp-control-h); padding-inline: 0 !important; }
.erp-btn--icon.erp-btn--sm { width: var(--erp-control-h-sm) !important; min-width: var(--erp-control-h-sm); }
.erp-icon-btn { width: var(--erp-control-h); height: var(--erp-control-h); }
.erp-main .erp-clear-filter { height: var(--erp-control-h) !important; min-height: var(--erp-control-h) !important; min-width: var(--erp-control-h); flex: 0 0 auto; }

/* select2 single: same height */
.erp-body .select2-container--default .select2-selection--single {
    height: var(--erp-control-h) !important;
    border-radius: var(--erp-control-radius) !important;
}
.erp-body .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: calc(var(--erp-control-h) - 2px) !important; font-size: var(--erp-control-fs); }
.erp-body .select2-container--default .select2-selection--single .select2-selection__arrow { height: calc(var(--erp-control-h) - 2px) !important; }

/* Labels: always above the field, fixed spacing; empty/whitespace labels keep their
   height so a button under an empty label lines up with neighbouring inputs */
.erp-label,
.erp-body .erp-field > label,
.erp-main .u-label,
.erp-main .form-label,
.erp-main .u-form-group > label {
    display: block;
    min-height: calc(var(--erp-label-fs) * 1.45);
    margin: 0 0 var(--erp-label-gap) !important;
    font-size: var(--erp-label-fs) !important;
    line-height: 1.45 !important;
}

.erp-field { gap: var(--erp-label-gap); }
.erp-field > .erp-label,
.erp-field > label { margin: 0 !important; }

/* Field whose content is a button placed beside inputs: sits on the field bottom line */
.erp-field--end {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-self: end;
}
.erp-field--end > .erp-btn,
.erp-field--end > input[type="button"],
.erp-field--end > button { width: 100%; }

/* Forms / grids align their cells to the bottom so buttons meet inputs */
.erp-form-grid { gap: var(--erp-field-gap-y) var(--erp-field-gap-x); align-items: end; }
.erp-form-grid > .erp-field:has(> textarea),
.erp-form-grid > .erp-field--top { align-self: start; }

/* --- Input group: input + lookup/search button(s), attached, same height ---
   <div class="erp-input-group">
     <input type="text" class="erp-input"> <button class="erp-btn erp-btn--outline erp-btn--icon">..</button>
   </div>  (keep hidden inputs OUTSIDE the group) */
.erp-input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.erp-input-group > * { margin: 0 !important; }
.erp-input-group > input,
.erp-input-group > select,
.erp-input-group > .erp-input,
.erp-input-group > .erp-select,
.erp-input-group > .select2-container { flex: 1 1 auto; min-width: 0; width: 1% !important; }
.erp-input-group > .erp-btn,
.erp-input-group > button,
.erp-input-group > input[type="button"],
.erp-input-group > .erp-input-group__addon { flex: 0 0 auto; width: auto !important; }

.erp-input-group > :not(:last-child),
.erp-input-group > :not(:last-child) .select2-selection {
    border-start-end-radius: 0 !important;
    border-end-end-radius: 0 !important;
}

.erp-input-group > :not(:first-child),
.erp-input-group > :not(:first-child) .select2-selection {
    border-start-start-radius: 0 !important;
    border-end-start-radius: 0 !important;
    margin-inline-start: -1px !important;
}

.erp-input-group > :focus,
.erp-input-group > :focus-within { position: relative; z-index: 1; }

.erp-input-group__addon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--erp-control-h);
    padding-inline: 12px;
    border: 1px solid var(--erp-gray-300);
    border-radius: var(--erp-control-radius);
    background: var(--erp-gray-50);
    color: var(--erp-text-muted);
    font-size: 13px;
    white-space: nowrap;
}

.erp-input-group > .erp-btn--outline { border-color: var(--erp-gray-300) !important; background: var(--erp-gray-25) !important; color: var(--erp-primary-text) !important; }
.erp-input-group > .erp-btn--outline:hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200) !important; }

/* --- Filter bar: responsive grid, actions grouped at the end of the last row --- */
.erp-filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--erp-field-gap-y) var(--erp-field-gap-x);
    align-items: end;
}

.erp-filter-bar > .erp-filter-bar__wide { grid-column: 1 / -1; }
.erp-filter-bar > .erp-filter-bar__span-2 { grid-column: span 2; }

.erp-filter-bar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    align-self: end;
    grid-column-end: -1;
    min-height: var(--erp-control-h);
}

.erp-filter-bar__actions--row { grid-column: 1 / -1; }

/* --- Action rows --- */
.erp-actions { gap: 8px; }
.erp-actions--end { justify-content: flex-end; }
.erp-actions--between { justify-content: space-between; }

/* Sticky action bar order: [start / danger] ........ [secondary] [primary/success] (reading direction) */
.erp-action-bar { gap: 10px; }
.erp-action-bar > .erp-action-bar__start { order: -2; }
.erp-action-bar > .erp-btn--danger { order: -1; margin-inline-end: auto; }
.erp-action-bar > .erp-btn--ghost,
.erp-action-bar > .erp-btn--secondary,
.erp-action-bar > .erp-btn--outline { order: 1; }
.erp-action-bar > .erp-btn--primary { order: 2; }
.erp-action-bar > .erp-btn--success { order: 3; }
.erp-action-bar:has(> .erp-btn--danger) > .erp-action-bar__start { margin-inline-end: 0; }

/* --- Legacy Nicepage forms (.u-inner-form) become a responsive grid --- */
.erp-main form.u-inner-form {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--erp-field-gap-y) var(--erp-field-gap-x);
    align-items: end;
    margin: 0 !important;
    padding: 4px 0 !important;
}

.erp-main form.u-inner-form > .u-form-group {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    min-width: 0;
}

/* empty spacer groups (no element children, no id) */
.erp-main form.u-inner-form > .u-form-group:not([id]):not(:has(> :not(input[type="hidden"]))) { display: none !important; }
/* wide content keeps a full row */
.erp-main form.u-inner-form > .u-form-partition-factor-1,
.erp-main form.u-inner-form > .u-form-group:has(table, .jsgrid, textarea, [id*="Grid"], [id*="grid"]) { grid-column: 1 / -1; }

.erp-main form.u-inner-form > .u-form-group > .u-btn,
.erp-main form.u-inner-form > .u-form-group > .Style_Add_Item,
.erp-main form.u-inner-form > .u-form-group > input[type="button"] { width: 100% !important; }

/* Grid cells keep compact controls */
.erp-body .erp-main .jsgrid-cell :is(input[type="text"], input[type="number"], input[type="date"], select, .u-input:not([type="checkbox"])),
.erp-body .erp-main .jsgrid-cell :is(input[type="button"], button, .u-btn, .Style_Add_Item),
.erp-body .erp-main :is(table.table, table.dataTable) td :is(input[type="text"], input[type="number"], select, input[type="button"], button) {
    height: var(--erp-control-h-sm) !important;
    min-height: var(--erp-control-h-sm) !important;
    line-height: 1.2 !important;
    padding-inline: 8px !important;
    font-size: 12.5px !important;
}

.erp-main .u-form-group [style*="margin-top"].u-btn,
.erp-main .u-form-group [style*="margin-top"].Style_Add_Item { margin-top: 0 !important; }

@media (max-width: 767.98px) {
    .erp-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .erp-filter-bar > .erp-filter-bar__span-2 { grid-column: 1 / -1; }
    .erp-filter-bar__actions { grid-column: 1 / -1; }
    .erp-main form.u-inner-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 479.98px) {
    .erp-filter-bar,
    .erp-main form.u-inner-form { grid-template-columns: minmax(0, 1fr); }
    .erp-filter-bar__actions > .erp-btn { flex: 1 1 auto; }
}

/* --- Legacy Nicepage tabs (App.ts ActiveTab() rewrites the link class attribute,
   so these rules target the legacy classes directly; no extra class needed) --- */
.erp-main .u-tabs { background: transparent !important; }

.erp-main .u-tab-list {
    display: inline-flex !important;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 18px !important;
    padding: 4px !important;
    list-style: none;
    background: var(--erp-gray-50) !important;
    border: 1px solid var(--erp-border) !important;
    border-radius: var(--erp-radius) !important;
    width: fit-content;
    max-width: 100%;
}

.erp-main .u-tab-list .u-tab-item { margin: 0 !important; padding: 0 !important; flex: 0 0 auto; width: auto !important; }

.erp-main .u-tab-list .u-tab-link {
    display: inline-flex !important;
    align-items: center;
    min-height: var(--erp-control-h-sm);
    padding: 6px 16px !important;
    border: 0 !important;
    border-radius: var(--erp-radius-sm) !important;
    background: transparent !important;
    color: var(--erp-gray-600) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    cursor: pointer;
}

.erp-main .u-tab-list .u-tab-link:hover { color: var(--erp-primary-text) !important; }

.erp-main .u-tab-list .u-tab-link.active,
.erp-main .u-tab-list .u-tab-link[aria-selected="true"] {
    background: var(--erp-surface) !important;
    color: var(--erp-primary-text) !important;
    box-shadow: var(--erp-shadow-xs) !important;
}

.erp-main .u-tab-content,
.erp-main .u-tab-pane { background: transparent !important; padding: 0 !important; border: 0 !important; min-height: 0 !important; }

/* 19. THEME PICKER ======================================================== */
/* The palette button (data-erp-action="theme") opens #erpThemeMenu, built by
   ClientApp/Shell/Theme.ts and positioned (fixed) under the button. */
.erp-theme-toggle svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.erp-theme-toggle[aria-expanded="true"] { background: var(--erp-primary-50); border-color: var(--erp-primary-200); color: var(--erp-primary-text) !important; }

.erp-theme-menu {
    position: fixed;
    z-index: 1200;
    width: 232px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    border-radius: var(--erp-radius);
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    box-shadow: var(--erp-shadow-lg);
    font-family: var(--erp-font);
    animation: erp-pop-in 140ms var(--erp-ease);
}
.erp-theme-menu[hidden] { display: none !important; }
.erp-theme-menu__title {
    padding: 6px 10px 8px;
    margin-block-end: 4px;
    border-block-end: 1px solid var(--erp-gray-100);
    font-size: 12px;
    font-weight: 700;
    color: var(--erp-text-muted);
}
.erp-theme-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--erp-gray-700);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background-color var(--erp-transition), color var(--erp-transition);
}
.erp-theme-menu__item:hover { background: var(--erp-gray-50); color: var(--erp-gray-900); }
.erp-theme-menu__item:focus { outline: none; }
.erp-theme-menu__item:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--erp-primary); background: var(--erp-gray-50); }
.erp-theme-menu__item[aria-checked="true"] { background: var(--erp-primary-50); color: var(--erp-primary-text); }
.erp-theme-menu__name { flex: 1 1 auto; min-width: 0; }
.erp-theme-menu__check { flex-shrink: 0; font-size: 13px; visibility: hidden; }
.erp-theme-menu__item[aria-checked="true"] .erp-theme-menu__check { visibility: visible; }

/* Swatch: the theme's primary over its surface (fixed colours, not tokens) */
.erp-theme-swatch {
    --sw-surface: #ffffff;
    --sw-primary: #2f4bb0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--sw-surface);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.erp-theme-swatch::after {
    content: "";
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--sw-primary);
}
.erp-theme-swatch--blue    { --sw-surface: #edf2f9; --sw-primary: #1a5fd0; }
.erp-theme-swatch--green   { --sw-surface: #f0f5f3; --sw-primary: #0f7a5a; }
.erp-theme-swatch--orange  { --sw-surface: #f8f4f1; --sw-primary: #c2410c; }
.erp-theme-swatch--classic { --sw-surface: #ffffff; --sw-primary: #2f4bb0; }
.erp-theme-swatch--night   { --sw-surface: #141a2b; --sw-primary: #5b74e0; }
.erp-theme-swatch--sand    { --sw-surface: #f2ebdf; --sw-primary: #7a5b39; }
.erp-theme-swatch--sage    { --sw-surface: #eaefe8; --sw-primary: #4a7360; }
.erp-theme-swatch--mist    { --sw-surface: #e9edf2; --sw-primary: #46658a; }
:root[data-theme-mode="dark"] .erp-theme-swatch { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }
@media (prefers-reduced-motion: reduce) { .erp-theme-menu { animation: none; } }
@media print { .erp-theme-menu { display: none !important; } }

/* Login page: floating toggle under the language button */
.erp-login__panel { position: relative; }
.erp-login__theme { position: absolute; top: 16px; inset-inline-start: 16px; z-index: 5; }

/* 20. DARK MODE: legacy & third-party overrides (screen only) ============== */
@media screen {
    :root[data-theme-surface="tinted"] body,
    :root[data-theme-surface="tinted"] body.erp-body { background: var(--erp-bg) !important; color: var(--erp-text) !important; }

    /* Nicepage / bootstrap white boxes and fixed text colours */
    :root[data-theme-surface="tinted"] .erp-main :is(.u-white, .u-grey-5, .u-grey-10, .u-grey-15, .u-grey-25, .u-palette-5-light-3, .bg-white, .bg-light, .well, .panel, .panel-body, .panel-footer, .list-group-item, .dropdown-menu, .popover, .tab-content, .nav-tabs > li.active > a, .u-container-style, .u-form, .u-inner-form, .container-fluid) {
        background-color: var(--erp-surface) !important;
        color: var(--erp-text) !important;
        border-color: var(--erp-border) !important;
    }

    :root[data-theme-surface="tinted"] .erp-main :is(.u-section-1, .u-section-2, .u-section-3, .u-body, .u-sheet, .u-layout-cell, .u-container-layout) { background-color: transparent !important; }

    :root[data-theme-mode="dark"] .erp-main :is(h1, h2, h3, h4, h5, h6, p, label, li, legend, dt, dd, .u-text, .u-label, .form-label, .card-title, .card-text):not([style*="color"]) { color: var(--erp-text); }
    :root[data-theme-mode="dark"] .erp-main :is(.u-text-black, .u-text-grey-90, .u-text-grey-80, .u-text-grey-70, .u-text-grey-60, .u-text-grey-50, .u-text-grey-40, .text-dark, .text-muted, .text-black-50) { color: var(--erp-text-muted) !important; }
    :root[data-theme-mode="dark"] .erp-main .u-text-grey-90,
    :root[data-theme-mode="dark"] .erp-main .text-dark { color: var(--erp-text) !important; }

    /* inline white backgrounds written in legacy markup */
    :root[data-theme-surface="tinted"] .erp-main [style*="background-color: white"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background-color:white"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background: white"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background:white"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background-color: #fff"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background-color:#fff"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background: #fff"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background:#fff"],
    :root[data-theme-surface="tinted"] .erp-main [style*="background-color: rgb(255, 255, 255)"] { background-color: var(--erp-surface) !important; color: var(--erp-text) !important; }

    :root[data-theme-surface="tinted"] .erp-main hr { border-color: var(--erp-border); }
    :root[data-theme-surface="tinted"] .erp-main .card-footer { background: var(--erp-gray-25) !important; border-color: var(--erp-border) !important; }

    /* Form controls (bootstrap/nicepage set #fff backgrounds) */
    :root[data-theme-surface="tinted"] .erp-body :is(.form-control, .form-select, .u-input, select, textarea, input[type="text"], input[type="number"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], input[type="tel"], input[type="time"], input[type="datetime-local"], input[type="month"]):not([style*="background"]):not(.u-btn):not(.Style_Add_Item):not([type="button"]):not([type="submit"]) {
        background-color: var(--erp-surface) !important;
        color: var(--erp-text) !important;
        border-color: var(--erp-gray-300) !important;
    }
    :root[data-theme-surface="tinted"] .erp-body :is(input, select, textarea):disabled,
    :root[data-theme-surface="tinted"] .erp-body :is(input, textarea)[readonly] { background-color: var(--erp-gray-50) !important; color: var(--erp-gray-500) !important; }
    :root[data-theme-surface="tinted"] .erp-body option { background: var(--erp-surface); color: var(--erp-text); }
    :root[data-theme-surface="tinted"] .erp-body input:-webkit-autofill,
    :root[data-theme-surface="tinted"] .erp-body textarea:-webkit-autofill,
    :root[data-theme-surface="tinted"] .erp-body select:-webkit-autofill {
        -webkit-text-fill-color: var(--erp-text) !important;
        box-shadow: inset 0 0 0 50px var(--erp-surface) !important;
        caret-color: var(--erp-text);
    }
    :root[data-theme-mode="dark"] .erp-body input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.85); }

    /* select2 */
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-selection--single,
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-selection--multiple { background: var(--erp-surface) !important; border-color: var(--erp-gray-300) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--erp-text) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-selection__placeholder { color: var(--erp-gray-400) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: var(--erp-gray-500) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-dropdown { background: var(--erp-surface) !important; color: var(--erp-text) !important; border-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-results__option { color: var(--erp-text); }
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-results__option[aria-selected="true"],
    :root[data-theme-surface="tinted"] .erp-body .select2-container--default .select2-results__option--selected { background: var(--erp-primary-100) !important; color: var(--erp-text) !important; }
    :root[data-theme-surface="tinted"] .erp-body .select2-search--dropdown .select2-search__field { background: var(--erp-gray-25) !important; color: var(--erp-text) !important; border-color: var(--erp-gray-300) !important; }

    /* jsgrid / StGrid / EsGrid */
    :root[data-theme-surface="tinted"] .erp-body .jsgrid,
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-grid-header,
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-grid-body,
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-table { background: var(--erp-surface) !important; color: var(--erp-text) !important; border-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-cell,
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-header-cell { color: var(--erp-text) !important; border-color: var(--erp-gray-100) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-header-cell { color: var(--erp-gray-600) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-cell input[type="text"],
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-cell input[type="number"],
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-cell input[type="date"],
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-cell select { background-color: var(--erp-gray-25) !important; color: var(--erp-text) !important; border-color: var(--erp-gray-300) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-pager { color: var(--erp-text-muted) !important; }

    /* bootstrap-table / .table / DataTables (stripes are set on <tr>) */
    :root[data-theme-surface="tinted"] .erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tbody > tr { background-color: var(--erp-surface) !important; color: var(--erp-text) !important; }
    :root[data-theme-surface="tinted"] .erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tbody > tr:nth-child(even) > td { background-color: var(--erp-gray-25) !important; }
    :root[data-theme-surface="tinted"] .erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tbody > tr:hover > td { background-color: var(--erp-primary-50) !important; }
    :root[data-theme-surface="tinted"] .erp-body :is(table.table, table.dataTable) td,
    :root[data-theme-surface="tinted"] .erp-body :is(table.table, table.dataTable) th { border-color: var(--erp-gray-100) !important; color: inherit; }
    :root[data-theme-surface="tinted"] .erp-body .table-striped > tbody > tr:nth-of-type(odd),
    :root[data-theme-surface="tinted"] .erp-body .table-hover > tbody > tr:hover { background-color: var(--erp-gray-25) !important; }
    :root[data-theme-surface="tinted"] .erp-body .fixed-table-toolbar,
    :root[data-theme-surface="tinted"] .erp-body .fixed-table-pagination,
    :root[data-theme-surface="tinted"] .erp-body .dataTables_wrapper,
    :root[data-theme-surface="tinted"] .erp-body .dataTables_wrapper :is(.dataTables_info, .dataTables_length, .dataTables_filter) { color: var(--erp-text-muted) !important; }
    :root[data-theme-surface="tinted"] .erp-body .pagination > li > a,
    :root[data-theme-surface="tinted"] .erp-body .pagination > li > span { background: var(--erp-surface) !important; border-color: var(--erp-border) !important; color: var(--erp-text) !important; }
    :root[data-theme-surface="tinted"] .erp-body .pagination > .active > a { background: var(--erp-primary) !important; border-color: var(--erp-primary) !important; color: #fff !important; }

    /* Infragistics igGrid / jQuery UI widgets */
    :root[data-theme-surface="tinted"] .erp-body :is(.ui-widget-content, .ui-iggrid, .ui-iggrid-table, .ui-iggrid td, .ui-iggrid-footer, .ui-iggrid-pager) { background: var(--erp-surface) !important; color: var(--erp-text) !important; border-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body :is(.ui-widget-header, .ui-iggrid-header, .ui-iggrid th) { background: var(--erp-gray-50) !important; color: var(--erp-gray-600) !important; border-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body .ui-iggrid tr.ui-ig-altrecord td { background: var(--erp-gray-25) !important; }
    :root[data-theme-surface="tinted"] .erp-body .ui-state-default { background: var(--erp-gray-50) !important; color: var(--erp-text) !important; border-color: var(--erp-border) !important; }

    /* Modals / search boxes / bootstrap cards loaded inside modals */
    :root[data-theme-surface="tinted"] .erp-body :is(.modal .card, .modal-content, .modal .card-body, .search-box, .search-box .search-content, .archive-footer) { background: var(--erp-surface) !important; color: var(--erp-text) !important; }
    :root[data-theme-mode="dark"] .erp-body .modal :is(h1, h2, h3, h4, h5, label) { color: var(--erp-text) !important; }
    :root[data-theme-surface="tinted"] .erp-body .archive-file-list { border-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body .file-item:hover { background: var(--erp-gray-50) !important; }
    :root[data-theme-surface="tinted"] .erp-body .file-name { color: var(--erp-text) !important; }
    :root[data-theme-mode="dark"] .erp-body .close,
    :root[data-theme-mode="dark"] .erp-body .btn-close { color: var(--erp-text) !important; filter: invert(.9); }

    /* Login page leftovers (Login_Style.css) */
    :root[data-theme-surface="tinted"] .erp-login .CompSelect { background-color: var(--erp-surface) !important; color: var(--erp-text) !important; }

    /* POS (StylePos.css: fixed light colours) */
    :root[data-theme-surface="tinted"] .erp-body .products-grid { background: transparent !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-card { background: var(--erp-surface) !important; border-color: var(--erp-border) !important; box-shadow: var(--erp-shadow-sm) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-image { background: linear-gradient(135deg, var(--erp-gray-50) 0%, var(--erp-gray-100) 100%) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-quantity { background: var(--erp-surface) !important; color: var(--erp-text) !important; border-color: var(--erp-surface) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-name { color: var(--erp-gray-900) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-desc { color: var(--erp-text-muted) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-footer { border-top-color: var(--erp-border) !important; }
    :root[data-theme-surface="tinted"] .erp-body .product-price { color: var(--erp-success) !important; }
    :root[data-theme-surface="tinted"] .erp-body .btn-add-product { background: var(--erp-primary) !important; color: var(--erp-on-primary) !important; }
    :root[data-theme-surface="tinted"] .erp-body .btn-add-product:hover { background: var(--erp-primary-hover) !important; }
    :root[data-theme-surface="tinted"] .erp-body .empty-state { background: var(--erp-surface) !important; }
    :root[data-theme-surface="tinted"] .erp-body .empty-state h3 { color: var(--erp-gray-900) !important; }
    :root[data-theme-surface="tinted"] .erp-body .empty-state p { color: var(--erp-text-muted) !important; }

    /* The sidebar search stays a dark-panel input (the input mapping above is for content) */
    :root[data-theme-surface="tinted"] .erp-body #erpSidebar .erp-sidebar__search input {
        background-color: rgba(255, 255, 255, .06) !important;
        color: #fff !important;
        border-color: rgba(255, 255, 255, .08) !important;
    }
    :root[data-theme-surface="tinted"] .erp-body #erpSidebar .erp-sidebar__search input:focus { border-color: var(--erp-primary-400) !important; background-color: rgba(255, 255, 255, .1) !important; }

    /* Misc shell bits */
    :root[data-theme-mode="dark"] .erp-body .toast-container .toast { color: var(--erp-toast-text) !important; }
    :root[data-theme-mode="dark"] .erp-image-picker img[src*="AddImage"] { filter: invert(.85) hue-rotate(180deg); }
}
/* 17. RESPONSIVE / PRINT =================================================== */
@media (max-width: 1199.98px) {
    .erp-col-3 { grid-column: span 6; }
    .erp-col-4 { grid-column: span 6; }
    .erp-col-2 { grid-column: span 4; }
}

@media (max-width: 991.98px) {
    :root { --erp-gutter: 16px; }

    .erp-sidebar { transform: translateX(-100%); box-shadow: none; }
    [dir="rtl"] .erp-sidebar { transform: translateX(100%); }
    body.erp-sidebar-open .erp-sidebar,
    [dir="rtl"] body.erp-sidebar-open .erp-sidebar { transform: none; box-shadow: var(--erp-shadow-lg); }
    body.erp-sidebar-open .erp-backdrop { display: block; }

    .erp-topbar, header#sec-06f8.erp-topbar { inset-inline-start: 0; }
    #erpSidebar:not(.display_none) ~ #carousel_47a3 { margin-inline-start: 0; }

    .erp-user-chip__name { display: none; }
    .erp-topbar__logo { display: inline-flex; }
    .erp-login { grid-template-columns: 1fr; }
    .erp-login__hero { display: none; }
}

@media (max-width: 767.98px) {
    .erp-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .erp-form-grid > [class*="erp-col-"] { grid-column: span 2; }
    .erp-form-grid > .erp-col-sm-half { grid-column: span 1; }
    .erp-filter-bar { grid-template-columns: 1fr 1fr; }
    .erp-page-header__title { font-size: 18px; }
    #Lab_NamePage.erp-topbar__title { font-size: 16px !important; }
    .erp-tiles, .erp-main .erp-tiles.u-repeater { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important; gap: 12px !important; }
    .erp-card__body { padding: 14px; }
    .erp-card__header { padding: 12px 14px; }
    .erp-action-bar { justify-content: stretch; }
    .erp-action-bar > .erp-btn { flex: 1 1 auto; }
    .erp-main .u-form-group[class*="u-form-partition-factor-"] { width: 100% !important; margin-inline: 0 !important; }
}

@media (max-width: 479.98px) {
    .erp-filter-bar { grid-template-columns: 1fr; }
    .erp-welcome { padding: 18px; }
    .erp-welcome__logout span { display: none; }
}

@media print {
    .erp-sidebar, .erp-topbar, .erp-backdrop, #DivLang, #DivSearchBtnID, #DivDownload_Excel, .erp-action-bar { display: none !important; }
    #carousel_47a3 { margin: 0 !important; padding: 0 !important; }
    body.erp-body { background: #fff !important; }
}

@media (prefers-reduced-motion: reduce) {
    .erp-body *, .erp-body *::before, .erp-body *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
    .erp-body #myModalLoder .loader::after { animation-duration: .8s !important; }
}

/* 21. SHELL FIXES (tester round 1) ======================================== */
/* B) (removed) The quick-search / Excel buttons no longer float in the bottom corner:
   they are page actions in the topbar (section 2, .erp-topbar__page-actions). */

/* D) Toasts: readable pill at the bottom centre, both themes */
.erp-body #toastContainer.toast-container {
    position: fixed !important;
    top: auto !important;
    bottom: 24px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: max-content;
    max-width: min(92vw, 520px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.erp-body #toastContainer .toast {
    display: block !important;
    width: auto !important;
    min-width: 220px;
    max-width: 100% !important;
    flex-basis: auto !important;
    height: auto !important;
    padding: 12px 20px !important;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    background-color: var(--erp-toast-bg) !important;
    color: var(--erp-toast-text) !important;
    font-size: 13.5px !important;
    font-weight: 600;
    line-height: 1.5 !important;
    text-align: center;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
    box-shadow: var(--erp-shadow-lg) !important;
    pointer-events: auto;
}

/* E) Grids scroll horizontally inside their card; header and body scroll together */
.erp-card .erp-grid,
.erp-card__body > .jsgrid,
.erp-main .erp-grid { max-width: 100%; overflow-x: auto !important; }

/* width:auto (NOT max-content): jsgrid's tables are width:100% + table-layout:fixed, so a
   max-content wrapper resolved to ~666,000px and every grid rendered blank. The tables size
   themselves from the column widths; .erp-grid (the card) scrolls horizontally when wider. */
.erp-main .erp-grid.jsgrid .jsgrid-grid-header,
.erp-main .erp-grid.jsgrid .jsgrid-grid-body,
.erp-main .erp-grid > .jsgrid .jsgrid-grid-header,
.erp-main .erp-grid > .jsgrid .jsgrid-grid-body {
    overflow: visible !important;
    max-height: none !important;
    width: auto !important;
    min-width: 100%;
}

/* width:1px keeps table-layout:fixed active (auto width would switch to auto layout and
   misalign header vs body); a fixed table grows to the sum of its column widths. */
.erp-main .erp-grid .jsgrid-table { width: 1px !important; min-width: 100%; }

.erp-main .erp-grid .jsgrid-header-scrollbar { padding-inline-end: 0 !important; }

/* jsgrid's own sprite buttons (search / clear filter / insert / edit / delete) = icon buttons */
.erp-body .jsgrid .jsgrid-cell input.jsgrid-button[type="button"],
.erp-body .jsgrid .jsgrid-header-cell input.jsgrid-button[type="button"],
.erp-body .jsgrid input.jsgrid-button {
    display: inline-block !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 7px !important;
    margin: 0 2px !important;
    border: 1px solid var(--erp-gray-200) !important;
    border-radius: 8px !important;
    background-color: transparent !important;
    background-origin: content-box !important;
    background-clip: content-box !important;
    box-shadow: 0 0 0 0 transparent;
    font-size: 0 !important;
    color: transparent !important;
    vertical-align: middle;
    cursor: pointer;
}

.erp-body .jsgrid input.jsgrid-button:hover { border-color: var(--erp-primary-200) !important; box-shadow: 0 0 0 3px var(--erp-primary-50); }
:root[data-theme-mode="dark"] .erp-body .jsgrid input.jsgrid-button { filter: invert(.85) hue-rotate(180deg); }

/* G) Mobile off-canvas: the language button must stay below the backdrop */
body.erp-sidebar-open #DivLang.search-button-container,
body.erp-sidebar-open #DivSearchBtnID,
body.erp-sidebar-open #DivDownload_Excel { z-index: 1030 !important; }

/* H) Home: inner gutter + avatar never clipped */
.erp-dashboard .erp-home-menus { margin: 0 !important; width: auto !important; direction: inherit; }
.erp-dashboard .erp-card__header,
.erp-dashboard .erp-card__body { padding-inline: 20px; }
.erp-welcome { padding-inline: 24px; }
.erp-welcome__avatar { min-width: 72px; }
@media (max-width: 479.98px) {
    .erp-welcome { gap: 12px; }
    .erp-welcome__avatar { width: 56px; height: 56px; min-width: 56px; }
    .erp-dashboard .erp-card__header,
    .erp-dashboard .erp-card__body { padding-inline: 14px; }
}

/* 22. LEGACY COLOUR UNIFICATION (style-unification pass) ===================
   One palette everywhere. Legacy colours that still reach the screen come from
   (a) inline colours written by .ts itemTemplates / markup strings
       (txt.style.backgroundColor = "#c78816", style="background-color: sandybrown"),
   (b) StyleAr/StyleEn.css (old brand #ab4f4f / #a93f3f, tomato steps, aqua),
   (c) Nicepage palette-1 coral (#c95b56) on active/hover states.
   Inline colours are serialised by the browser ("#c78816" -> "rgb(199, 136, 22)"),
   so they are matched here by value and mapped to a semantic TONE:
     --erp-tone (text/icon), --erp-tone-bg (soft fill), --erp-tone-solid (filled).
   Unknown inline colours fall back to the primary tone. Data-driven colours are
   left alone: POS item cards (.erp-pos, colours from the DB) and colour pickers.
   ========================================================================== */

/* --- 22.1 Tone variables (set by legacy colour value) --- */
.erp-body [style*="darkred" i],
.erp-body [style*="crimson" i],
.erp-body [style*="brown" i],
.erp-body [style*="rgb(134, 0, 0)"],
.erp-body [style*="rgb(131, 2, 2)"],
.erp-body [style*="#830202" i],
.erp-body [style*="#860000" i],
.erp-body [style*="rgb(220, 53, 69)"],
.erp-body [style*="rgb(167, 29, 42)"],
.erp-body [style*="color: red" i],
.erp-body [style*="color:red" i] {
    --erp-tone: var(--erp-danger);
    --erp-tone-bg: var(--erp-danger-bg);
    --erp-tone-solid: var(--erp-danger-solid);
}

.erp-body [style*="rgb(199, 136, 22)"],
.erp-body [style*="#c78816" i],
.erp-body [style*="chocolate" i],
.erp-body [style*="sandybrown" i],
.erp-body [style*="rgb(253, 127, 53)"],
.erp-body [style*="rgb(0, 142, 112)"],
.erp-body [style*="rgb(48, 238, 198)"],
.erp-body [style*="color: orange" i] {
    --erp-tone: var(--erp-warning);
    --erp-tone-bg: var(--erp-warning-bg);
    --erp-tone-solid: var(--erp-warning-solid);
}

.erp-body [style*="green" i],
.erp-body [style*="rgb(22, 199, 109)"],
.erp-body [style*="#16c76d" i],
.erp-body [style*="rgb(3, 187, 16)"],
.erp-body [style*="rgb(0, 128, 15)"],
.erp-body [style*="rgb(40, 167, 69)"],
.erp-body [style*="rgb(30, 126, 52)"],
.erp-body [style*="rgb(6, 179, 11)"],
.erp-body [style*="rgb(0, 243, 0)"],
.erp-body [style*="rgb(255, 162, 11)"],
.erp-body [style*="rgb(255 162 11)"],
.erp-body [style*="rgb(2 141 31)"] {
    --erp-tone: var(--erp-success);
    --erp-tone-bg: var(--erp-success-bg);
    --erp-tone-solid: var(--erp-success-solid);
}

.erp-body [style*="rgb(0, 176, 32)"],
.erp-body [style*="rgb(255, 0, 188)"],
.erp-body [style*="rgb(0, 55, 255)"],
.erp-body [style*="#46b8da" i],
.erp-body [style*="rgb(70, 184, 218)"] {
    --erp-tone: var(--erp-info);
    --erp-tone-bg: var(--erp-info-bg);
    --erp-tone-solid: var(--erp-info-solid);
}
/* cornflowerblue, cadetblue, #003ba5, #147fed, #126bb1, #1a2fc9, #0a0fa9, #25229c,
   #007bff ... = primary (the fallback, no list needed) */

/* --- 22.2 Buttons carrying an inline legacy colour ---
   Outside grids: solid tone fill. Inside grid/table cells: soft tonal button that
   fills on hover (calmer for rows full of actions). */
.erp-body .erp-main :is(input[type="button"], input[type="submit"], button, a.u-btn, a.btn, .Style_Add_Item, .btn)[style*="background"]:not([style*="transparent"]):not([style*="background: none"]):not([style*="background:none"]):not(.jsgrid-button):not(.erp-pos *):not(.erp-sidebar *),
.erp-body .modal :is(input[type="button"], button, .btn, .Style_Add_Item)[style*="background"]:not([style*="transparent"]):not([style*="background: none"]):not([style*="background:none"]):not(.jsgrid-button):not(.close),
.erp-body #Upload_Excel_Data :is(input[type="button"], button)[style*="background"] {
    background-color: var(--erp-tone-solid, var(--erp-primary)) !important;
    background-image: none !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
    box-shadow: none !important;
}

.erp-body .erp-main :is(input[type="button"], input[type="submit"], button, a.u-btn, a.btn, .Style_Add_Item, .btn)[style*="background"]:not([style*="transparent"]):not([style*="background: none"]):not([style*="background:none"]):not(.jsgrid-button):not(.erp-pos *):not(.erp-sidebar *):not(:disabled):hover {
    filter: brightness(.93);
}

.erp-body .erp-main :is(.jsgrid-cell, td) :is(input[type="button"], input[type="submit"], button, a.u-btn, a.btn, .Style_Add_Item, .btn):not(.jsgrid-button):not(.erp-pos *)[style*="background"]:not([style*="transparent"]):not([style*="background: none"]):not([style*="background:none"]) {
    background-color: var(--erp-tone-bg, var(--erp-primary-50)) !important;
    border: 1px solid color-mix(in srgb, var(--erp-tone, var(--erp-primary)) 24%, transparent) !important;
    color: var(--erp-tone, var(--erp-primary-text)) !important;
    border-radius: var(--erp-radius-sm) !important;
    filter: none !important;
}

.erp-body .erp-main :is(.jsgrid-cell, td) :is(input[type="button"], input[type="submit"], button, a.u-btn, a.btn, .Style_Add_Item, .btn):not(.jsgrid-button):not(.erp-pos *)[style*="background"]:not([style*="transparent"]):not([style*="background: none"]):not([style*="background:none"]):not(:disabled):hover {
    background-color: var(--erp-tone-solid, var(--erp-primary)) !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
}

/* Action buttons never spill into the neighbouring column (fixed column widths) */
.erp-body .jsgrid-cell :is(input[type="button"], button:not(.jsgrid-button), .u-btn, .Style_Add_Item) { max-width: 100%; text-overflow: ellipsis; overflow: hidden; }

/* Legacy class-coloured buttons in cells (btn-info / btn-warning / btn-success / btn-danger) */
.erp-body .erp-main :is(.jsgrid-cell, td) :is(.btn-info, .btn-primary, .btn-success, .u-btn-info):not([style*="background"]) { --erp-tone: var(--erp-primary-text); --erp-tone-bg: var(--erp-primary-50); --erp-tone-solid: var(--erp-primary); }
.erp-body .erp-main :is(.jsgrid-cell, td) .btn-warning:not([style*="background"]) { --erp-tone: var(--erp-warning); --erp-tone-bg: var(--erp-warning-bg); --erp-tone-solid: var(--erp-warning-solid); }
.erp-body .erp-main :is(.jsgrid-cell, td) .btn-danger:not([style*="background"]) { --erp-tone: var(--erp-danger); --erp-tone-bg: var(--erp-danger-bg); --erp-tone-solid: var(--erp-danger-solid); }
.erp-body .erp-main :is(.jsgrid-cell, td) :is(.btn-info, .btn-primary, .btn-success, .btn-warning, .btn-danger, .u-btn-info):not([style*="background"]):not(.jsgrid-button) {
    background-color: var(--erp-tone-bg) !important;
    border: 1px solid color-mix(in srgb, var(--erp-tone) 24%, transparent) !important;
    color: var(--erp-tone) !important;
}
.erp-body .erp-main :is(.jsgrid-cell, td) :is(.btn-info, .btn-primary, .btn-success, .btn-warning, .btn-danger, .u-btn-info):not([style*="background"]):not(.jsgrid-button):not(:disabled):hover {
    background-color: var(--erp-tone-solid) !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
}

/* Same buttons outside cells */
.erp-body .erp-main .btn-info:not([style*="background"]) { background-color: var(--erp-primary) !important; border-color: transparent !important; color: var(--erp-on-primary) !important; }
.erp-body .erp-main .btn-warning:not([style*="background"]) { background-color: var(--erp-warning-solid) !important; border-color: transparent !important; color: var(--erp-on-primary) !important; }

.erp-body .erp-main :is(input[type="button"], button, .btn, .u-btn, .Style_Add_Item):disabled { opacity: .45 !important; cursor: not-allowed !important; filter: none !important; }

/* StGrid round emoji actions (inline 50% radius / scale hover) -> same icon button shape */
.erp-body .erp-main .jsgrid-cell > div > button[title][style*="border-radius: 50%"] {
    width: var(--erp-control-h-sm) !important;
    min-width: var(--erp-control-h-sm) !important;
    padding: 0 !important;
    font-size: 14px !important;
    transform: none !important;
}

/* EsGrid message strip (inline brown pill) */
.erp-body [id^="DivMassage_"] {
    width: auto !important;
    padding: 8px 14px !important;
    border-radius: var(--erp-radius) !important;
    background: var(--erp-tone-bg, var(--erp-info-bg)) !important;
    color: var(--erp-tone, var(--erp-info)) !important;
    border: 1px solid color-mix(in srgb, var(--erp-tone, var(--erp-info)) 25%, transparent);
}
.erp-body [id^="DivMassage_"] h3 { margin: 0; font-size: 13.5px !important; font-weight: 600; color: inherit !important; }
.erp-body [id^="btnAdd_"][style*="width: 300px"] { width: auto !important; }

/* --- 22.3 Status / amount text coloured inline (Green/Red, status labels) --- */
.erp-body :is(.erp-main, .modal) :is(label, span, b, strong, small, p, h5, h6, td, div):not(.erp-pos *):is(
    [style*="color: green" i], [style*="color: red" i], [style*="color: orange" i],
    [style*="color: rgb(0, 176, 32)"], [style*="color: rgb(255, 162, 11)"], [style*="color: rgb(0, 142, 112)"],
    [style*="color: rgb(48, 238, 198)"], [style*="color: rgb(255, 0, 188)"], [style*="color: rgb(0, 55, 255)"],
    [style*="color: rgb(253, 127, 53)"], [style*="color: rgb(6, 179, 11)"], [style*="color: rgb(0, 243, 0)"]):not([style*="background"]) {
    color: var(--erp-tone) !important;
    font-weight: 600;
}

/* Validation borders written inline by App.ts (red / orange) */
.erp-body .erp-main :is(input, select, textarea)[style*="border-color: red" i] { border-color: var(--erp-danger) !important; box-shadow: 0 0 0 3px var(--erp-danger-bg) !important; }
.erp-body .erp-main :is(input, select, textarea)[style*="border-color: orange" i] { border-color: var(--erp-warning) !important; box-shadow: 0 0 0 3px var(--erp-warning-bg) !important; }

/* --- 22.4 Legacy StyleAr/StyleEn components --- */
/* App.ts custom pager (.paginationContainer: was #ab4f4f on white) */
.erp-body .paginationContainer { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; padding: 12px 0 4px !important; margin: 0 !important; }
.erp-body .paginationContainer button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px !important;
    border: 1px solid var(--erp-gray-200) !important;
    border-radius: 8px !important;
    background: var(--erp-surface) !important;
    color: var(--erp-gray-700) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background-color var(--erp-transition), border-color var(--erp-transition), color var(--erp-transition);
}
.erp-body .paginationContainer button:not(.active):not(.disabled):not(.dots):hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200) !important; color: var(--erp-primary-text) !important; }
.erp-body .paginationContainer button.active { background: var(--erp-primary) !important; border-color: var(--erp-primary) !important; color: var(--erp-on-primary) !important; }
.erp-body .paginationContainer button.disabled { opacity: .45; cursor: not-allowed; }
.erp-body .paginationContainer button.dots { border-color: transparent !important; background: transparent !important; color: var(--erp-text-muted) !important; }

/* Grid quick search (App.ts / SystemTools.ts: form#Div_Search_Grid_<grid>) = input group */
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0 !important;
    width: 100%;
    max-width: 420px;
    padding: 0 0 12px !important;
    margin: 0 !important;
}
/* .u-clearfix ::before/::after became empty grid/flex items (an empty first cell in every legacy form grid) */
.erp-body .erp-main form.u-inner-form.u-clearfix::before,
.erp-body .erp-main form.u-inner-form.u-clearfix::after,
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"]::before,
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"]::after { content: none !important; display: none !important; }
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] > .u-form-group { width: auto !important; flex: 0 0 auto; grid-column: auto !important; margin: 0 !important; padding: 0 !important; }
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] > .u-form-group:has(input[type="text"]) { flex: 1 1 auto; min-width: 0; }
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] > .u-form-group:has(.Grid-search_Pages) > label { display: block; visibility: hidden; }
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] input[type="text"] {
    width: 100% !important;
    border-start-end-radius: 0 !important;
    border-end-end-radius: 0 !important;
}
.erp-body :is(.erp-main, .search-box) .Grid-search_Pages,
.erp-body :is(.erp-main, .search-box) form.u-inner-form[id^="Div_Search_Grid_"] .Grid-search_Pages {
    width: var(--erp-control-h) !important;
    min-width: var(--erp-control-h) !important;
    height: var(--erp-control-h) !important;
    padding: 0 !important;
    margin: 0 !important;
    margin-inline-start: -1px !important;
    border: 1px solid var(--erp-gray-300) !important;
    border-radius: var(--erp-control-radius) !important;
    border-start-start-radius: 0 !important;
    border-end-start-radius: 0 !important;
    background: var(--erp-gray-25) !important;
    color: var(--erp-primary-text) !important;
    font-size: 15px !important;
}
.erp-body .search-box form.u-inner-form[id^="Div_Search_Grid_"] { padding-inline: 16px !important; }
.erp-body .search-box .close-search-box { filter: none !important; color: var(--erp-gray-700) !important; transition: background-color var(--erp-transition), color var(--erp-transition); }
.erp-body .search-box .close-search-box:hover { background: var(--erp-danger-bg) !important; color: var(--erp-danger) !important; }
.erp-body .search-box form.u-inner-form[id^="Div_Search_Grid_"] input[type="text"] {
    height: var(--erp-control-h) !important;
    padding-inline: var(--erp-control-px) !important;
    border: 1px solid var(--erp-gray-300) !important;
    border-radius: var(--erp-control-radius) !important;
    border-start-end-radius: 0 !important;
    border-end-end-radius: 0 !important;
    background: var(--erp-surface) !important;
    color: var(--erp-text) !important;
    font-size: var(--erp-control-fs) !important;
}
.erp-body .search-box .Grid-search_Pages { display: inline-flex !important; align-items: center; justify-content: center; text-decoration: none !important; }
.erp-body :is(.erp-main, .search-box) .Grid-search_Pages:hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200) !important; }

/* Global search popups: DataTables rows were maroon (#a93f3f) / mint, header #232323 */
.erp-body .search-box .dataTables_wrapper .dataTable thead { background: transparent !important; color: var(--erp-gray-600) !important; border-color: var(--erp-border) !important; }
.erp-body .search-box .dataTables_wrapper .dataTable tbody :is(tr, tr.odd, tr.even) { height: auto; background: var(--erp-surface) !important; color: var(--erp-text) !important; cursor: pointer; transition: background-color var(--erp-transition); }
.erp-body .search-box .dataTables_wrapper .dataTable tbody tr.even { background: var(--erp-gray-25) !important; }
.erp-body .search-box .dataTables_wrapper .dataTable tbody tr:hover { background: var(--erp-primary-50) !important; color: var(--erp-gray-900) !important; }
.erp-body .search-box .dataTables_wrapper .dataTable tbody tr:is(.selected, .active) { background: var(--erp-primary-100) !important; }
.erp-body .search-box .dataTables_wrapper .dataTable tbody td { border-color: var(--erp-gray-100) !important; color: inherit !important; }
.erp-body .search-box .dataTables_wrapper .dataTables_paginate .paginate_button:not(.current):not(.disabled):hover { background: var(--erp-primary-50) !important; border-color: var(--erp-primary-200) !important; color: var(--erp-primary-text) !important; }
.erp-body .search-box .dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .45; }
.erp-body .dataTables_wrapper .dataTables_filter input[type="search"] { background-color: var(--erp-surface); color: var(--erp-text); border-color: var(--erp-gray-300); }

/* Step list (.multi-steps: tomato / #098300) */
.erp-body .multi-steps > li { color: var(--erp-primary-text) !important; }
.erp-body .multi-steps > li::before { background-color: var(--erp-surface) !important; border-color: var(--erp-primary) !important; color: var(--erp-primary-text) !important; }
.erp-body .multi-steps > li::after { background-color: var(--erp-primary) !important; }
.erp-body .multi-steps > li.is-active::before { background-color: var(--erp-primary) !important; border-color: var(--erp-primary) !important; color: var(--erp-on-primary) !important; }
.erp-body .multi-steps > li.is-active ~ li { color: var(--erp-text-muted) !important; }
.erp-body .multi-steps > li.is-active ~ li::before,
.erp-body .multi-steps > li.is-active ~ li::after,
.erp-body .multi-steps > li.is-active::after { background-color: var(--erp-gray-100) !important; border-color: var(--erp-gray-200) !important; color: var(--erp-text-muted) !important; }

/* "uploaded" marker on image pickers (was aqua) */
.erp-body .erp-main ._backColor { background-color: var(--erp-success-bg) !important; border-color: var(--erp-success) !important; color: var(--erp-success) !important; }
/* yellow back button / black hover invoice buttons */
.erp-body .erp-main .Style_Back { background-color: var(--erp-surface) !important; border: 1px solid var(--erp-gray-300) !important; color: var(--erp-gray-700) !important; }
.erp-body .erp-main .But_Inv:is(:hover, :active) { background-color: var(--erp-primary-hover) !important; }

/* Legacy floating "search-button" outside the shell ids (#a93f3f circle) */
.erp-body .search-button:not(#GnrLang) { background-color: var(--erp-primary); color: var(--erp-on-primary); box-shadow: var(--erp-shadow-md); transition: filter var(--erp-transition), transform var(--erp-transition); }

/* bootstrap "bg-*" toasts (DisplayMassage) -> tokens */
.erp-body .alert-message.bg-success { background-color: var(--erp-success-solid) !important; }
.erp-body .alert-message.bg-danger { background-color: var(--erp-danger-solid) !important; }
.erp-body .alert-message.bg-orange { background-color: var(--erp-warning-solid) !important; }

/* --- 22.5 Nicepage palette-1 coral (#c95b56) on interactive states --- */
.erp-body .erp-main .u-tab-list a.u-tab-link.u-tab-link:is(.active, [aria-selected="true"]),
.erp-body .erp-main .u-tab-list li.active > a.u-tab-link.u-tab-link {
    background: var(--erp-surface) !important;
    background-color: var(--erp-surface) !important;
    color: var(--erp-primary-text) !important;
    box-shadow: var(--erp-shadow-xs) !important;
}
.erp-body .erp-main .u-tab-list a.u-tab-link.u-tab-link:not(.active):hover,
.erp-body .erp-main .u-tab-list a.u-tab-link.u-tab-link:not(.active):focus { background: transparent !important; background-color: transparent !important; color: var(--erp-primary-text) !important; }

.erp-body .erp-main a.u-button-style.u-button-style:is([class*="u-hover-palette"], [class*="u-active-palette"]):not(.u-tab-link):is(:hover, :focus, :active, .active) { background-color: var(--erp-primary-hover) !important; color: var(--erp-on-primary) !important; }
.erp-body .erp-main :is([class*="u-text-palette-1"], [class*="u-text-custom-color"]) { color: var(--erp-primary-text) !important; }
.erp-body .erp-main [class*="u-border-palette-"] { border-color: var(--erp-border) !important; }
.erp-body .erp-main a.u-link:hover { color: var(--erp-primary-text-hover) !important; }

/* --- 22.6 Grids: rows, lookup tables, row states --- */
/* tr backgrounds (jsgrid-theme paints rows white; showed as white lines in dark) */
.erp-body .jsgrid :is(.jsgrid-row, .jsgrid-alt-row, .jsgrid-header-row, .jsgrid-filter-row, .jsgrid-insert-row, .jsgrid-edit-row, .jsgrid-nodata-row) { background: transparent !important; }
.erp-body .jsgrid-row > .jsgrid-cell,
.erp-body .jsgrid-alt-row > .jsgrid-cell { transition: background-color var(--erp-transition); }
@media screen {
    :root[data-theme-surface="tinted"] .erp-body .jsgrid :is(.jsgrid-row, .jsgrid-alt-row, .jsgrid-header-row) { background: var(--erp-surface) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid :is(.jsgrid-cell, .jsgrid-header-cell) { border-inline-color: transparent !important; border-block-start-color: transparent !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-alt-row > .jsgrid-cell { background: var(--erp-gray-25) !important; }
    :root[data-theme-surface="tinted"] .erp-body :is(.jsgrid-row, .jsgrid-alt-row):hover > .jsgrid-cell { background: var(--erp-primary-50) !important; }
    :root[data-theme-surface="tinted"] .erp-body .jsgrid-selected-row > .jsgrid-cell { background: var(--erp-primary-100) !important; }
}

/* EsGrid / bootstrap-table lookups (table#table_div_Grid ...) without the .table class */
.erp-main table[id^="table_"],
.erp-main .erp-grid table:not(.jsgrid-table):not(.table):not(.dataTable) {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0;
    background: var(--erp-surface);
    color: var(--erp-gray-800);
    font-size: 13px;
}
.erp-main table[id^="table_"] > thead > tr > th,
.erp-main .erp-grid table:not(.jsgrid-table):not(.table):not(.dataTable) > thead > tr > th {
    padding: 10px 12px !important;
    background: var(--erp-gray-50) !important;
    color: var(--erp-gray-600) !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-200) !important;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}
.erp-main table[id^="table_"] > tbody > tr > td,
.erp-main .erp-grid table:not(.jsgrid-table):not(.table):not(.dataTable) > tbody > tr > td {
    padding: 6px 10px !important;
    border: 0 !important;
    border-block-end: 1px solid var(--erp-gray-100) !important;
    background: var(--erp-surface);
    vertical-align: middle;
    transition: background-color var(--erp-transition);
}
.erp-main table[id^="table_"] > tbody > tr:nth-child(even) > td,
.erp-main .erp-grid table:not(.jsgrid-table):not(.table):not(.dataTable) > tbody > tr:nth-child(even) > td { background: var(--erp-gray-25); }
.erp-main table[id^="table_"] > tbody > tr:hover > td,
.erp-main .erp-grid table:not(.jsgrid-table):not(.table):not(.dataTable) > tbody > tr:hover > td { background: var(--erp-primary-50); }
.erp-main table.table > tbody > tr > td { transition: background-color var(--erp-transition); }

/* bootstrap / DataTables selected row */
.erp-body :is(table.table, table.dataTable) > tbody > tr:is(.selected, .active, .info) > td { background: var(--erp-primary-100) !important; color: var(--erp-gray-900) !important; }
.erp-body :is(table.table, table.dataTable) > tbody > tr.success > td { background: var(--erp-success-bg) !important; }
.erp-body :is(table.table, table.dataTable) > tbody > tr.danger > td { background: var(--erp-danger-bg) !important; }
.erp-body :is(table.table, table.dataTable) > tbody > tr.warning > td { background: var(--erp-warning-bg) !important; }

/* bootstrap-table pagination (light) */
.erp-body .fixed-table-pagination .pagination > li > a,
.erp-body .fixed-table-pagination .pagination > li > span { border-radius: 8px !important; margin-inline: 2px; border-color: var(--erp-gray-200) !important; background: var(--erp-surface) !important; color: var(--erp-gray-700) !important; }
.erp-body .fixed-table-pagination .pagination > .active > a { background: var(--erp-primary) !important; border-color: var(--erp-primary) !important; color: var(--erp-on-primary) !important; }

/* --- 22.7 Focus, links, selection, scrollbars --- */
.erp-body :is(a, button, [role="button"], [tabindex]:not([tabindex="-1"]), summary):focus-visible { outline: none !important; box-shadow: var(--erp-focus) !important; }
.erp-body :is(a, button, [role="button"], [tabindex]):focus:not(:focus-visible),
.erp-body .erp-main .u-tab-link:focus { outline: none !important; }
.erp-body :is(.btn, .u-btn, .Style_Add_Item, input[type="button"]):focus:not(:focus-visible) { box-shadow: none !important; outline: none !important; }
.erp-body :is(input, select, textarea):focus-visible { outline: none; }
.erp-body .erp-main a:not([class]) { text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; transition: color var(--erp-transition); }
.erp-body ::selection { background: var(--erp-primary-100); color: var(--erp-gray-900); }
html { scrollbar-color: var(--erp-gray-300) transparent; }
.erp-body ::-webkit-scrollbar-thumb:hover { background-color: var(--erp-gray-400); }
.erp-body ::-webkit-scrollbar-corner { background: transparent; }

/* --- 22.8 SMOOTH: consistent motion (150-200ms, ease) --- */
.erp-body .erp-main :is(.u-btn, .btn, .Style_Add_Item, input[type="button"], input[type="submit"], button):not(.jsgrid-button) {
    transition: background-color var(--erp-transition), border-color var(--erp-transition), color var(--erp-transition), box-shadow var(--erp-transition), opacity var(--erp-transition), filter var(--erp-transition) !important;
}
.erp-body :is(.erp-input, .erp-select, .erp-textarea, .erp-main input, .erp-main select, .erp-main textarea, .select2-selection) {
    transition: border-color var(--erp-transition), box-shadow var(--erp-transition), background-color var(--erp-transition);
}
.erp-body :is(.erp-nav-link, .erp-sidebar a, .erp-dropdown__item, .erp-tab, .erp-card, .erp-clear-filter, .jsgrid input.jsgrid-button, .erp-user-chip) {
    transition: background-color var(--erp-transition), color var(--erp-transition), border-color var(--erp-transition), box-shadow var(--erp-transition);
}
.erp-body .erp-btn:not(:disabled):active,
.erp-body .erp-main :is(.u-btn, .btn, .Style_Add_Item):not(:disabled):active { transform: translateY(1px); }

/* Page switch: a short fade when a partial / container becomes visible. Opacity only
   (no transform: it would re-anchor position:fixed modals while it runs). */
@keyframes erp-page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes erp-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.erp-body #carousel_47a3 > #htmlContainer:not(.display_none),
.erp-body #carousel_47a3 > .Page_Partial:not(.display_none) { animation: erp-page-in 140ms var(--erp-ease); } /* no fill-mode: a filled opacity animation would keep a stacking context and trap modals under the topbar */
.erp-body .erp-dropdown.is-open,
.erp-body .select2-dropdown { animation: erp-pop-in 140ms var(--erp-ease); }
.erp-body .modal:not(#myModalLoder)[style*="display: block"] > * { animation: erp-pop-in 160ms var(--erp-ease); }

/* Theme switch: colour cross-fade only while html.erp-theme-switching (set by Theme.ts on toggle) */
html.erp-theme-switching,
html.erp-theme-switching body,
html.erp-theme-switching body *:not(.jsgrid-button),
html.erp-theme-switching body *::before,
html.erp-theme-switching body *::after {
    transition: background-color 200ms var(--erp-ease), color 200ms var(--erp-ease), border-color 200ms var(--erp-ease), fill 200ms var(--erp-ease) !important;
}

/* Sidebar collapse: content and topbar follow the sidebar with the same curve */
.erp-sidebar { transition: transform var(--erp-transition-slow), width var(--erp-transition-slow), box-shadow var(--erp-transition-slow); }
#carousel_47a3.erp-main,
div#carousel_47a3.erp-main { transition: margin var(--erp-transition-slow); } /* div# beats the 160ms rule in section 2 */
.erp-topbar, header#sec-06f8.erp-topbar { transition: inset-inline-start var(--erp-transition-slow), left var(--erp-transition-slow), right var(--erp-transition-slow); }

@media (prefers-reduced-motion: reduce) {
    .erp-body #carousel_47a3 > #htmlContainer,
    .erp-body #carousel_47a3 > .Page_Partial,
    .erp-body .erp-dropdown,
    .erp-body .select2-dropdown,
    .erp-body .modal > * { animation: none !important; }
    html.erp-theme-switching *,
    html.erp-theme-switching *::before,
    html.erp-theme-switching *::after { transition: none !important; }
    .erp-body .erp-btn:active,
    .erp-body .erp-main :is(.u-btn, .btn, .Style_Add_Item):active { transform: none; }
}

/* POS cards (StylePos.css): same radius / elevation / text tokens as the rest, both themes.
   The add-to-cart button colour comes from the item (DB) and is left alone. */
.erp-body .erp-pos .product-card { border-radius: var(--erp-radius-lg) !important; border: 1px solid var(--erp-border) !important; box-shadow: var(--erp-shadow-xs) !important; background: var(--erp-surface) !important; transition: transform var(--erp-transition), box-shadow var(--erp-transition), border-color var(--erp-transition) !important; }
.erp-body .erp-pos .product-card:hover { box-shadow: var(--erp-shadow-md) !important; border-color: var(--erp-primary-200) !important; }
.erp-body .erp-pos .product-image { background: var(--erp-gray-50) !important; }
.erp-body .erp-pos .product-name { color: var(--erp-gray-900) !important; }
.erp-body .erp-pos .product-desc { color: var(--erp-text-muted) !important; }
.erp-body .erp-pos .product-price { color: var(--erp-success) !important; }
.erp-body .erp-pos .product-footer { border-top-color: var(--erp-border) !important; }
.erp-body .erp-pos .product-quantity { background: var(--erp-surface) !important; color: var(--erp-text) !important; border-color: var(--erp-surface) !important; box-shadow: var(--erp-shadow-sm) !important; }
.erp-body .erp-pos .btn-add-product { border-radius: var(--erp-control-radius) !important; box-shadow: none !important; }

/* --- 22.9 Tester round 2 (layout polish) --- */
/* Home / menu tiles: wider, names wrap to two lines instead of being cut */
.erp-tiles,
.erp-main .erp-tiles.u-repeater { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; }
.erp-tile .erp-tile__title,
.erp-tiles > .u-repeater-item h6 {
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35 !important;
}
.erp-tile { gap: 12px; }

/* Profile / user definition: the name heading is a card title, not a page title */
.erp-main h1#Profile_UserName,
.erp-main #Profile_UserName:is(.erp-profile__name, .erp-userdef__name) {
    margin: 0 !important;
    font-size: 18px !important;
    line-height: 1.35 !important;
    font-weight: 700 !important;
    color: var(--erp-gray-900) !important;
    overflow-wrap: anywhere;
}

/* Small phones: give the page title the room (chip keeps the avatar only) */
@media (max-width: 479.98px) {
    .erp-topbar__inner { gap: 6px; padding-inline: 10px; padding-inline-end: 58px; }
    .erp-topbar .erp-user-chip { padding-inline: 3px; gap: 0; height: 38px; }
    .erp-topbar .erp-user-chip .fa-angle-down,
    .erp-topbar .erp-user-chip__name { display: none !important; }
    .erp-topbar .erp-icon-btn { width: 32px; height: 32px; }
    .erp-topbar .erp-topbar__logo { display: none !important; } /* Home stays in the sidebar */
    .erp-topbar .erp-topbar__actions { gap: 4px; }
    .erp-topbar .erp-avatar--sm { width: 30px; height: 30px; }
    #Lab_NamePage.erp-topbar__title { font-size: 15px !important; }
    .erp-tiles,
    .erp-main .erp-tiles.u-repeater { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; }
}

/* 23. BUTTON CONSISTENCY (buttons pass) =====================================
   One look for the key actions on every screen (see docs/redesign/BUTTONS.md).
   Everything here uses erp-theme tokens only, so it does not depend on legacy
   stylesheets (nicepage / bootstrap / StyleAr|En) and follows all 6 themes.
   23.1 filter-bar actions order   23.2 clear-filter icon button
   23.3 icons on <input type=button> (data-erp-icon)   23.4 grid row actions
   23.5 report print buttons   23.6 legacy class looks (btn-custon-*, u-btn-*)
   ========================================================================== */

/* --- 23.1 Filter bar actions: ONE row at the bottom inline-end of every filter card,
   in reading order [Clear (secondary)] [View data / Filter (primary)]. The Add button
   is NOT here any more: it is the page action in the topbar (#erpPageAdd, 23.7).
   The group always takes its own full row of the filter grid, so its place does not
   depend on how many filter fields the screen has. --- */
.erp-filter-bar__actions,
.erp-card__header > .erp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.erp-main .erp-filter-bar__actions {
    grid-column: 1 / -1 !important;
    justify-content: flex-end;
    flex-wrap: nowrap;
    width: 100%;
}
.erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > * { flex: 0 0 auto; margin: 0 !important; }
.erp-filter-bar__actions > .erp-clear-filter,
.erp-card__header > .erp-actions > .erp-clear-filter { order: 1; }
.erp-filter-bar__actions > :is([id^="Filter_View"], #btnShow),
.erp-card__header > .erp-actions > [id^="Filter_View"] { order: 2; }

/* --- 23.2 Clear filter (#btnDelete_Filter, an h6): secondary button, icon + label
   ("مسح" / "Clear", drawn by CSS so the h6 markup and its title stay as they are),
   same 40px height as the inputs and the View button; turns danger on hover --- */
.erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > .erp-clear-filter {
    width: auto !important;
    min-width: var(--erp-control-h) !important;
    height: var(--erp-control-h) !important;
    gap: 6px;
    padding: 0 14px !important;
    border-radius: var(--erp-control-radius) !important;
    border: 1px solid var(--erp-gray-300) !important;
    background: var(--erp-surface) !important;
    color: var(--erp-gray-700) !important;
    font-family: var(--erp-font);
    font-size: 13.5px !important;
    font-weight: 600;
    line-height: 1 !important;
    white-space: nowrap;
}
.erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > .erp-clear-filter > .fa { font-size: 14px; }
.erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > .erp-clear-filter::after { content: "Clear"; }
[dir="rtl"] .erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > .erp-clear-filter::after { content: "مسح"; }
.erp-main :is(.erp-filter-bar__actions, .erp-card__header > .erp-actions) > .erp-clear-filter:hover {
    background: var(--erp-danger-bg) !important;
    border-color: var(--erp-danger-border) !important;
    color: var(--erp-danger) !important;
}
.erp-main .erp-clear-filter.display_none { display: none !important; }

/* Icons inside every erp-btn: one size, one gap */
.erp-btn > .fa,
.erp-main .u-btn > .fa { font-size: 14px; line-height: 1; flex: 0 0 auto; }
.erp-btn { gap: 8px; }

/* --- 23.3 Icons on <input type="button"> (value is read/written by .val(), and
   inputs cannot have ::before) -> SVG background icon chosen by data-erp-icon.
   White on solid fills (success / danger / primary); tinted on secondary/outline. --- */
/* a background icon sits at the button edge, so icon inputs keep their natural
   width instead of stretching across the mobile action bar (icon stays by the label) */
.erp-main .erp-action-bar > input[data-erp-icon] { flex: 0 0 auto !important; padding-inline-end: 20px !important; }
.erp-body .erp-main input[data-erp-icon] {
    background-repeat: no-repeat !important;
    background-size: 16px 16px !important;
    background-position: right 14px center !important;     /* RTL (default) */
    padding-inline-start: 38px !important;
}
.erp-body #carousel_47a3.erp-main[style*="ltr"] input[data-erp-icon],
.erp-body [dir="ltr"] .erp-main input[data-erp-icon] { background-position: left 14px center !important; }

.erp-body .erp-main input[data-erp-icon="save"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z'/%3E%3Cpath d='M17 21v-8H7v8M7 3v5h8'/%3E%3C/svg%3E") !important; }
.erp-body .erp-main input[data-erp-icon="delete"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E") !important; }
.erp-body .erp-main input[data-erp-icon="add"].erp-btn--success,
.erp-body .erp-main input[data-erp-icon="add"].erp-btn--primary { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E") !important; }

/* Tinted icons: the url lives in a token so each theme can recolour it */
:root {
    --erp-ico-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475066' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
    --erp-ico-back-ltr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475066' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E");
    --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232f4bb0' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}
:root:is([data-theme="night"], [data-theme="dark"]) {
    --erp-ico-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c3cadb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
    --erp-ico-back-ltr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c3cadb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M11 6l-6 6 6 6'/%3E%3C/svg%3E");
    --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a6f2' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
}
:root[data-theme="blue"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a5fd0' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
:root[data-theme="green"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f7a5a' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
:root[data-theme="orange"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b93e0c' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
:root[data-theme="sand"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2374563a' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
:root[data-theme="sage"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23436a57' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
:root[data-theme="mist"] { --erp-ico-add-tint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2340607f' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }

.erp-body .erp-main input[data-erp-icon="back"] { background-image: var(--erp-ico-back) !important; }
.erp-body #carousel_47a3.erp-main[style*="ltr"] input[data-erp-icon="back"],
.erp-body [dir="ltr"] .erp-main input[data-erp-icon="back"] { background-image: var(--erp-ico-back-ltr) !important; }
.erp-body .erp-main input[data-erp-icon="add"]:is(.erp-btn--outline, .erp-btn--secondary) { background-image: var(--erp-ico-add-tint) !important; }

/* --- 23.4 Grid row actions (jsgrid / table cells, created by .ts itemTemplates).
   One size (--erp-control-h-sm), one radius, soft tonal look that fills on hover:
     edit (no inline colour, cornflowerblue, #1a2fc9 ...)  -> primary soft
     view / print / detail / slip / balance                 -> neutral
     delete / return (#860000, darkred)                     -> danger soft
     approve / archive (butSend*, #16c76d, #03bb10)          -> success soft  --- */
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(input[type="button"], .u-btn, .Style_Add_Item, a.btn, button.btn):not(.jsgrid-button):not(.erp-pos *) {
    height: var(--erp-control-h-sm) !important;
    min-height: var(--erp-control-h-sm) !important;
    padding-inline: 8px !important;
    border-radius: var(--erp-radius-sm) !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    background-image: none !important;
}

/* edit: legacy buttons without an inline colour were a solid primary fill in cells */
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(input[type="button"], .u-btn, .Style_Add_Item):not([style*="background"]):not(.jsgrid-button):not(.erp-pos *):not(:is(.btn-info, .btn-warning, .btn-danger, .btn-success, .btn-primary, .erp-btn)) {
    background-color: var(--erp-primary-50) !important;
    border: 1px solid color-mix(in srgb, var(--erp-primary) 24%, transparent) !important;
    color: var(--erp-primary-text) !important;
}
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(input[type="button"], .u-btn, .Style_Add_Item):not([style*="background"]):not(.jsgrid-button):not(.erp-pos *):not(:is(.btn-info, .btn-warning, .btn-danger, .btn-success, .btn-primary, .erp-btn)):not(:disabled):hover {
    background-color: var(--erp-primary) !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
}

/* approve (Tax_ViewSales butSend / butSendSA carry no colour) -> success soft */
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) input[type="button"]:is([id^="butSend"]):not([style*="background"]) {
    background-color: var(--erp-success-bg) !important;
    border-color: color-mix(in srgb, var(--erp-success) 24%, transparent) !important;
    color: var(--erp-success) !important;
}
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) input[type="button"]:is([id^="butSend"]):not([style*="background"]):not(:disabled):hover {
    background-color: var(--erp-success-solid) !important;
    border-color: transparent !important;
    color: var(--erp-on-primary) !important;
}

/* view / print / detail / slip / balance / profile -> neutral */
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(input[type="button"], button, .u-btn, .Style_Add_Item, .btn):not(.jsgrid-button):not(.erp-pos *):is(
    [style*="rgb(199, 136, 22)"], [style*="#c78816" i], [style*="chocolate" i], [style*="crimson" i],
    [style*="rgb(10, 15, 169)"], [style*="rgb(37, 34, 156)"], [style*="rgb(0, 59, 165)"],
    [style*="rgb(18, 107, 177)"], [style*="rgb(0, 128, 15)"]) {
    background-color: var(--erp-surface) !important;
    border: 1px solid var(--erp-gray-300) !important;
    color: var(--erp-gray-700) !important;
}
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(input[type="button"], button, .u-btn, .Style_Add_Item, .btn):not(.jsgrid-button):not(.erp-pos *):is(
    [style*="rgb(199, 136, 22)"], [style*="#c78816" i], [style*="chocolate" i], [style*="crimson" i],
    [style*="rgb(10, 15, 169)"], [style*="rgb(37, 34, 156)"], [style*="rgb(0, 59, 165)"],
    [style*="rgb(18, 107, 177)"], [style*="rgb(0, 128, 15)"]):not(:disabled):hover {
    background-color: var(--erp-gray-100) !important;
    border-color: var(--erp-gray-400) !important;
    color: var(--erp-gray-900) !important;
}

/* icon-only round actions (archive "📩": inline border-radius 50% + width 50px) -> square icon button */
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) input[type="button"][style*="border-radius: 50%"] {
    width: var(--erp-control-h-sm) !important;
    min-width: var(--erp-control-h-sm) !important;
    padding-inline: 0 !important;
    border-radius: var(--erp-radius-sm) !important;
    font-size: 14px !important;
}

/* --- 23.5 Report print buttons: Excel (secondary) then PDF (primary) at the end;
   the file icons carry their meaning colour on the neutral button --- */
.erp-main .erp-btn--secondary > .fa-file-excel-o { color: var(--erp-success); }
.erp-main .erp-btn--secondary > .fa-file-pdf-o { color: var(--erp-danger); }
.erp-main .erp-btn--secondary:hover > :is(.fa-file-excel-o, .fa-file-pdf-o) { color: inherit; }

/* --- 23.6 Legacy class looks that still reach the screen: shape comes from
   erp tokens, colour from the tone mapping (section 22) --- */
.erp-body .erp-main :is(.btn-custon-four, .btn-custon-three, .btn-custon-two, .btn-custon-one, .btn-custon-rounded-four, .btn-custon-rounded-three) {
    border-radius: var(--erp-control-radius) !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
.erp-body #carousel_47a3 :is(.jsgrid-cell, td) :is(.btn-custon-four, .btn-custon-three, .btn-custon-two, .btn-custon-one) { border-radius: var(--erp-radius-sm) !important; }
.erp-body .erp-main .u-btn:is(.u-btn-1, .u-btn-2, .u-btn-3, .u-btn-submit) { text-transform: none !important; letter-spacing: 0 !important; }

/* 24. QA ROUND 3 (components: grids, popups, POS, fields) ==================
   Found by the 6-theme x 66-screen sweep (docs/redesign/QA_ROUND3.md).
   Tokens only; nothing here depends on legacy stylesheets. */

/* --- 24.1 EsGrid toolbar (EsGrid.ts markup: .datatable-dashv1-list with <br>s,
   empty .project-list-action groups and margin-top:-7% on the quick search).
   Becomes one wrapping row: action buttons at the start, search at the end. --- */
.erp-body .erp-main .datatable-dashv1-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
}
.erp-body .erp-main .datatable-dashv1-list > br { display: none; }
.erp-body .erp-main .datatable-dashv1-list > :is(.button-ap-list, .project-list-action) {
    margin: 0 !important;
    top: auto !important;
    width: auto !important;
    float: none !important;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}
.erp-body .erp-main .datatable-dashv1-list > .project-list-action:not(:has(> :not([style*="display:none"]):not([style*="display: none"]))) { display: none !important; }
.erp-body .erp-main .datatable-dashv1-list > .project-list-action:has(.Search_grid) { margin-inline-start: auto !important; }
.erp-body .erp-main .datatable-dashv1-list .Search_grid { width: 260px !important; max-width: 100%; }
.erp-body .erp-main .datatable-dashv1-list > [id^="DivMassage_"]:not(.display_hidden) { flex: 1 1 100%; }
.erp-body .erp-main .datatable-dashv1-list > :is(table, .jsgrid) { flex: 1 1 100%; }
@media (max-width: 767.98px) {
    .erp-body .erp-main .datatable-dashv1-list > .project-list-action:has(.Search_grid) { flex: 1 1 100%; margin-inline-start: 0 !important; }
    .erp-body .erp-main .datatable-dashv1-list .Search_grid { width: 100% !important; }
}

/* --- 24.2 Legacy card wrappers inside a converted card: no card-in-card --- */
.erp-body .erp-main :is(.erp-card__body, .erp-grid) > :is(.sparkline8-graph, .sparkline8-list, .sparkline10-list, .sparkline12-list) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

/* --- 24.3 POS product card footer: price and add-to-cart never squeeze into
   2-3 broken lines (long currency strings, narrow cards, Arabic labels) --- */
.erp-body .erp-pos .product-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.erp-body .erp-pos .product-price { font-size: 17px !important; line-height: 1.3; white-space: nowrap; }
.erp-body .erp-pos .btn-add-product {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--erp-control-h);
    padding: 6px 14px !important;
    font-size: 13px !important;
    white-space: nowrap;
    flex: 1 0 auto;
    max-width: 100%;
}

/* --- 24.4 POS slide panels (#invoice / #invoiceCNT, on screen only; printing
   copies the markup into its own window with its own CSS). Paper follows the
   theme so night/sand do not show a white panel with light text. --- */
@media screen {
    .erp-body .erp-pos :is(#invoice, #invoiceCNT).invoice {
        background: var(--erp-surface) !important;
        color: var(--erp-text) !important;
        box-shadow: var(--erp-shadow-lg) !important;
        border-inline-end: 1px solid var(--erp-border);
    }
    .erp-body .erp-pos .invoice :is(h1, h2, h3, h6, p, span, div) { color: inherit; }
    .erp-body .erp-pos .invoice :is(h2, #invoice-title, .total-per-item, #invoice-cart-total, #invoice-total) { color: var(--erp-primary-text) !important; }
    .erp-body .erp-pos .invoice :is(#invoice-details, .item-details, #creator-name, #customer-greeting, #company-contact) { color: var(--erp-text-muted) !important; }
    .erp-body .erp-pos .invoice :is(.item-details span, .invoice-item.total) { color: var(--erp-text) !important; }
    .erp-body .erp-pos .invoice :is(.invoice-item, #company-contact) { border-color: var(--erp-border) !important; }
}

/* --- 24.5 jsgrid header labels: jsgrid uses table-layout:fixed with config widths, so a
   nowrap label longer than its column ran into the next header (search popups, RTL).
   Labels now wrap inside their own cell. --- */
.erp-body .jsgrid-header-row > :is(.jsgrid-header-cell, th) {
    white-space: normal !important;
    overflow-wrap: anywhere;
    overflow: hidden;
    line-height: 1.35;
    vertical-align: middle;
}

/* --- 24.6 Search popups (App.ts NewSearch_Box_*): muted label on tokens --- */
.erp-body :is(.erp-main, .search-box, .modal) .u-text-grey-40 { color: var(--erp-text-muted) !important; }

/* --- 25. BRANCH chip in the topbar (year | branch, ClientApp/Shell/BranchBar.ts) --- */
.erp-branch-chip { gap: 6px; padding-inline: 12px; font-size: 13px; }
.erp-branch-chip .fa-calendar-o,
.erp-branch-chip .fa-building-o { color: var(--erp-primary-text, var(--erp-gray-600)); font-size: 13px; }
.erp-branch-chip__year { font-weight: 700; font-variant-numeric: tabular-nums; }
.erp-branch-chip__sep { color: var(--erp-gray-300); }
.erp-branch-chip__name { font-weight: 600; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.erp-branch-chip.is-fixed { cursor: default; }
.erp-branch-chip.is-fixed .erp-branch-chip__caret { display: none; }
.erp-branch-chip.is-fixed:hover { border-color: var(--erp-border); background: var(--erp-surface); }
.erp-branch-chip.is-all .erp-branch-chip__name { color: var(--erp-warning-text, #9a5b00); }
.erp-dropdown__item.is-current { background: var(--erp-primary-50); color: var(--erp-gray-900); font-weight: 700; }
.erp-dropdown__item.is-current::after { content: "\f00c"; font-family: FontAwesome; margin-inline-start: auto; color: var(--erp-primary-text, inherit); }
@media (max-width: 767.98px) {
    .erp-branch-chip .fa-calendar-o, .erp-branch-chip__year, .erp-branch-chip__sep { display: none; }
    .erp-branch-chip__name { max-width: 90px; }
}
@media (max-width: 479.98px) {
    .erp-topbar .erp-branch-chip { padding-inline: 8px; height: 38px; }
    .erp-topbar .erp-branch-chip__name { max-width: 64px; }
}
.erp-dropdown__divider { height: 1px; margin: 4px 6px; background: var(--erp-gray-100); }

/* BRANCH: branches and users editor (developer), companies screen: ClientApp/Shell/BranchBar.ts ErpBranchAdmin */
.erp-branch-admin__hint { margin: 0 0 8px; font-size: 12.5px; color: var(--erp-text-muted); }
.erp-branch-admin__table { width: 100%; border-collapse: collapse; margin-block-end: 8px; }
.erp-branch-admin__table th, .erp-branch-admin__table td { padding: 6px 8px; border-block-end: 1px solid var(--erp-gray-100); text-align: start; vertical-align: middle; }
.erp-branch-admin__table th { font-size: 12.5px; font-weight: 700; color: var(--erp-text-muted); white-space: nowrap; }
.erp-branch-admin__code { width: 64px; font-variant-numeric: tabular-nums; font-weight: 700; }
.erp-branch-admin__check { text-align: center !important; }
.erp-branch-admin__check input { width: 18px; height: 18px; cursor: pointer; }
.erp-branch-admin__scroll { overflow-x: auto; }

/* Deep link (screen opened in a new tab): Home initialises invisibly (layout kept, so its
   widgets size correctly) until the requested screen opens on top - Sidebar.HoldHome(). */
#htmlContainer.erp-deeplink-hold { visibility: hidden; position: relative; min-height: 240px; }
#htmlContainer.erp-deeplink-hold::before {
    content: ""; visibility: visible; position: absolute; top: 120px; inset-inline-start: 50%;
    width: 32px; height: 32px; margin-inline-start: -16px; border-radius: 50%;
    border: 3px solid var(--erp-border, #dfe3ea); border-top-color: var(--erp-primary, #2f4bb0);
    animation: erp-spin .8s linear infinite;
}

/* 26. GRIDS: RESPONSIVE + ONE LOOK ==========================================
   Grid types in use (docs: side-session note "grids"):
   - jsgrid      ClientApp/JsGrid.ts + StGrid: every View* list screen (sales, purchases,
                 journals, items, customers, cash box, reports, ...). The .erp-grid is
                 the jsgrid itself or wraps it.
   - EsGrid      ClientApp/EsGrid.ts: editable detail lines (sales/tax invoice, purchases,
                 journal, orders, price offers, setup lists). bootstrap-table wraps
                 table.erp-esgrid (.bootstrap-table > .fixed-table-container > .fixed-table-body).
   - DataTables  ClientApp/DataTable.ts: the search popup (#SearchBox #SearchDataTable).
   - table.table / .erp-table: account statement, roles, audit log, popups.
   - igGrid      IgGrid.ts only, no live screen (section 8 rules kept).
   Rules: a wide grid scrolls inside its own frame (never the page); the header row
   stays visible; one header / row height / stripe / hover / footer / row-action look;
   EsGrid lines become labelled cards on phones. Tokens only: all 8 themes follow. */

.erp-body {
    --erp-grid-max-h: min(70vh, 640px);
    --erp-grid-frame: var(--erp-gray-200);
    --erp-grid-line: var(--erp-gray-100);
    --erp-grid-head-bg: var(--erp-gray-50);
    --erp-grid-head-fg: var(--erp-gray-700);
    --erp-grid-row-h: 42px;
}

/* --- 26.1 Nothing pushes the page sideways: grid hosts may shrink below their content --- */
.erp-main :is(.erp-card, .erp-card__body, .erp-grid, .datatable-dashv1-list, .bootstrap-table, .fixed-table-container, .dataTables_wrapper) { min-width: 0; max-width: 100%; }
.erp-main :is(.erp-form-grid, form.u-inner-form, .u-layout-row, .row) > :has(table, .jsgrid) { min-width: 0; }
.erp-main .datatable-dashv1-list > .bootstrap-table { flex: 1 1 100%; }

/* --- 26.2 One header / row / stripe look for every grid type --- */
.erp-body :is(.jsgrid-header-row > .jsgrid-header-cell, .jsgrid-header-row > th, table.table > thead > tr > th, .bootstrap-table table > thead > tr > th, table.dataTable > thead > tr > th, .erp-table > thead > tr > th) {
    background: var(--erp-grid-head-bg) !important;
    color: var(--erp-grid-head-fg) !important;
    font-size: 12.5px !important;
    font-weight: 700 !important;
    line-height: 1.35;
    letter-spacing: 0;
    border-block-end: 1px solid var(--erp-grid-frame) !important;
}
.erp-body :is(.jsgrid-row, .jsgrid-alt-row) > .jsgrid-cell,
.erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tbody > tr > td {
    height: var(--erp-grid-row-h);
    font-variant-numeric: tabular-nums;
    border-block-end: 1px solid var(--erp-grid-line) !important;
}
.erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tbody > tr:last-child > td,
.erp-body .jsgrid-grid-body tr:last-child > .jsgrid-cell { border-block-end-color: transparent !important; }
/* bootstrap-table's own .table-hover / striped colours -> tokens (EsGrid had grey Bootstrap hovers) */
.erp-body .bootstrap-table table > tbody > tr:nth-child(even) > td { background: var(--erp-gray-25); }
.erp-body .bootstrap-table table > tbody > tr:hover > td { background: var(--erp-primary-50); }
.erp-body .bootstrap-table .fixed-table-container thead th .th-inner { padding: 0 !important; white-space: normal; line-height: 1.35; }

/* --- 26.3 Totals / footers stand out --- */
.erp-body :is(table.table, .bootstrap-table table, table.dataTable, .erp-table) > tfoot > tr > :is(td, th),
.erp-body .bootstrap-table .fixed-table-footer td,
.erp-body .jsgrid :is(.jsgrid-footer-row, .jsgrid-total-row) > .jsgrid-cell {
    background: var(--erp-primary-50) !important;
    color: var(--erp-primary-text) !important;
    font-weight: 700 !important;
    font-variant-numeric: tabular-nums;
    border: 0 !important;
    border-block-start: 2px solid var(--erp-primary-200) !important;
    padding: 10px 12px !important;
}
/* invoice / purchase totals card: the net amount is the number people look for */
.erp-body .erp-main .erp-field:has(> #NetAmount) .erp-label { color: var(--erp-primary-text); font-weight: 700; }
.erp-body .erp-main .erp-field > input#NetAmount {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--erp-primary-text) !important;
    -webkit-text-fill-color: var(--erp-primary-text);
    background-color: var(--erp-primary-50) !important;
    border-color: var(--erp-primary-200) !important;
    opacity: 1;
}

/* --- 26.4 Row action buttons: one size, icon-only ones square --- */
.erp-body .erp-main :is(.jsgrid-cell, td) > :is(button, .btn, input[type="button"]):not(.jsgrid-button) { white-space: nowrap; }
.erp-body .erp-main :is(.jsgrid-cell, td) > :is(button, .btn):not(.jsgrid-button):has(> i:only-child):not(:has(> :not(i))) {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 15px !important;
    border-radius: 8px !important;
    line-height: 1 !important;
}

/* --- 26.5 jsgrid: the .erp-grid is the frame; it scrolls both ways, header sticks to
   its top and the pager to its bottom (jsgrid's own body scroller is off there, 21.E) --- */
.erp-main .erp-grid:is(.jsgrid, :has(> .jsgrid)) {
    max-height: var(--erp-grid-max-h);
    overflow: auto !important;
    overscroll-behavior-x: contain;
    border: 1px solid var(--erp-grid-frame);
    border-radius: var(--erp-radius);
    background: var(--erp-surface);
}
.erp-main .erp-grid:is(.jsgrid, :has(> .jsgrid)) .jsgrid-grid-header {
    position: sticky;
    top: 0;
    z-index: 3;
    border-radius: 0 !important;
    border-block-end: 0 !important;
}
.erp-main .erp-grid:is(.jsgrid, :has(> .jsgrid)) .jsgrid-pager-container {
    position: sticky;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 2;
    padding: 8px !important;
    background: var(--erp-surface);
    border-block-start: 1px solid var(--erp-grid-line);
}
.erp-main .erp-grid:is(.jsgrid, :has(> .jsgrid)) .jsgrid-pager-container:not(:has(.jsgrid-pager > *)) { display: none !important; }
/* jsgrid outside an .erp-grid (popups, older screens) keeps its own body scroller:
   reserve the scrollbar width in the header too, so header and body columns line up */
.erp-body .jsgrid :is(.jsgrid-grid-header, .jsgrid-grid-body) { scrollbar-gutter: stable; }
.erp-main .erp-grid:is(.jsgrid, :has(> .jsgrid)) :is(.jsgrid-grid-header, .jsgrid-grid-body) { scrollbar-gutter: auto; }

/* --- 26.6 EsGrid (bootstrap-table): its body is the scroller. EsGrid.ts sets it to
   height:460px + overflow:scroll inline (an empty block under short invoices, two
   scrollbars); it now grows with its lines up to the max height. --- */
.erp-main .bootstrap-table .fixed-table-container {
    padding-bottom: 0 !important;
    background: var(--erp-surface);
    border-color: var(--erp-grid-frame) !important;
}
.erp-main .bootstrap-table .fixed-table-body {
    height: auto !important;
    max-height: var(--erp-grid-max-h);
    overflow: auto !important;
    overscroll-behavior-x: contain;
}
.erp-main .bootstrap-table .fixed-table-body > table > thead > tr > th { position: sticky; top: 0; z-index: 2; }
.erp-main .bootstrap-table .fixed-table-toolbar:not(:has(.columns, .search, .bs-bars > *)) { display: none; }
.erp-main .bootstrap-table .fixed-table-loading { display: none !important; }

.erp-main table.erp-esgrid { width: 100% !important; margin: 0 !important; }
.erp-main table.erp-esgrid > thead > tr > th { text-align: center !important; white-space: normal !important; vertical-align: middle; padding: 10px 8px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td { padding: 6px !important; text-align: center; vertical-align: middle; }
/* every control keeps a usable minimum width, so the table grows and the frame scrolls
   instead of squeezing inputs to a few pixels */
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > :is(input, select, textarea):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]) {
    width: 100% !important;
    min-width: 96px;
    margin: 0 !important;
}
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > input[type="number"] { min-width: 84px; text-align: end; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > input[type="number"]::-webkit-inner-spin-button,
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > select { min-width: 120px; }
/* column widths come from these minimums only: contain:inline-size stops a field's own
   content (textarea cols, longest option, item name) from widening its column.
   Category, item family (type) and the item picker share one wider width (user request). */
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > :is(input, select, textarea, button):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]) { contain: inline-size; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > :is(input, textarea):not([type="number"]):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]) { min-width: 120px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > input[type="number"]:not(#_) { min-width: 90px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > select:not(#_) { min-width: 120px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td:is([id*="_CatID"], [id*="_ItemFamilyID"]) > select:not(#_),
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td:not([id^="td_btn_"]) > button:not(#_) { min-width: 200px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td[id*="_Ser"] > input:not(#_) { min-width: 56px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > textarea { min-width: 150px; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td:not([id^="td_btn_"]) > button { width: 100% !important; min-width: 150px; justify-content: center; overflow: hidden; text-overflow: ellipsis; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td[id*="_Ser"] > input { min-width: 52px; text-align: center; }
/* one height for every field in a line. Cairo needs ~25px of line box: a select with
   7px block padding in 32px clipped its text ("قطعة" cut at the bottom), and the text
   columns are <textarea>s (EsGrid.ts) that showed a resize grip and top-aligned text. */
.erp-body { --erp-esgrid-ctl-h: 36px; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > :is(input, select, textarea, button):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]) {
    height: var(--erp-esgrid-ctl-h) !important;
    min-height: var(--erp-esgrid-ctl-h) !important;
}
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > select {
    padding-block: 0 !important;
    line-height: normal !important;
}
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td > textarea {
    resize: none !important;
    overflow: hidden !important;
    white-space: nowrap;
    line-height: 20px !important;
    padding-block: calc((var(--erp-esgrid-ctl-h) - 22px) / 2) !important;
}
/* computed / locked cells read as text, editable ones keep their field look */
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td:not(#_) > :is(input, textarea, select):disabled {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--erp-text) !important;
    -webkit-text-fill-color: var(--erp-text);
    opacity: 1;
}
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td:not(#_) > select:disabled { appearance: none; -webkit-appearance: none; background-image: none !important; text-align: center; }
/* row actions (delete / copy): first column, square icon buttons */
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > tbody > tr > td[id^="td_btn_"] { width: 44px; padding-inline: 4px !important; }
:root .erp-body .erp-main .datatable-dashv1-list table.erp-esgrid[id] > thead > tr > th:is([class$="_Delete"], [class$="_Copy"]) { width: 44px !important; }

/* --- 26.7 DataTables (search popup) and plain tables: wide ones scroll in their frame --- */
/* DataTables CSS is not loaded: lay its controls out here (length + search on one line,
   info + pager under the table); the wrapper scrolls, its controls stay in view */
.erp-body .dataTables_wrapper { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; overflow-x: auto; overscroll-behavior-x: contain; }
.erp-body .dataTables_wrapper > table.dataTable { flex: 1 0 100%; margin: 0 !important; }
.erp-body .search-box .dataTables_wrapper > table.dataTable > tbody > tr > td { white-space: nowrap; }
.erp-body .dataTables_wrapper > :is(.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate) { position: sticky; inset-inline-start: 0; float: none !important; padding: 0 !important; font-size: 13px; color: var(--erp-text-muted); }
.erp-body .dataTables_wrapper > :is(.dataTables_filter, .dataTables_paginate) { margin-inline-start: auto; }
.erp-body .dataTables_wrapper :is(.dataTables_length, .dataTables_filter) label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; white-space: nowrap; }
.erp-body .dataTables_wrapper .dataTables_length select { width: auto; min-width: 72px; }
.erp-body .dataTables_wrapper .dataTables_filter input { width: 220px; max-width: 100%; margin: 0 !important; }
.erp-body .dataTables_wrapper .dataTables_paginate { display: flex; flex-wrap: wrap; gap: 4px; }
.erp-body .dataTables_wrapper .dataTables_paginate :is(.paginate_button, span > .paginate_button) { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px !important; margin: 0 !important; cursor: pointer; text-decoration: none !important; }
.erp-body .dataTables_wrapper .dataTables_paginate > span { display: inline-flex; gap: 4px; }
@media (max-width: 575.98px) {
    .erp-body .dataTables_wrapper > .dataTables_filter { flex: 1 1 100%; margin-inline-start: 0; }
    .erp-body .dataTables_wrapper .dataTables_filter label { display: flex; }
    .erp-body .dataTables_wrapper .dataTables_filter input { flex: 1 1 auto; width: auto; }
}
/* plain tables with 5+ columns keep readable columns and scroll in their frame on phones */
.erp-main .erp-grid > :is(table.table, .erp-table):has(> thead > tr > :nth-child(5)) { min-width: 640px; }
.erp-main .erp-grid > :is(table.table, .erp-table) > tbody > tr > td { overflow-wrap: normal; }
.erp-main .erp-grid:has(> :is(table.table, table.erp-table, .erp-table)) {
    max-height: var(--erp-grid-max-h);
    overflow: auto !important;
    overscroll-behavior-x: contain;
    border: 1px solid var(--erp-grid-frame);
    border-radius: var(--erp-radius);
    background: var(--erp-surface);
}
.erp-main .erp-grid > :is(table.table, .erp-table) > thead > tr > th { position: sticky; top: 0; z-index: 2; }
.erp-main .erp-grid > :is(table.table, .erp-table) > tfoot > tr > :is(td, th) { position: sticky; bottom: 0; z-index: 1; }

/* --- 26.8 Touch: controls inside rows reach a finger-sized target; 16px text stops iOS zoom --- */
@media (pointer: coarse) {
    .erp-body { --erp-esgrid-ctl-h: 40px; }
    .erp-body .erp-main :is(table.erp-esgrid, table.table, .erp-table) > tbody > tr > td > :is(input, select, textarea):not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    .erp-body .erp-main .jsgrid :is(.jsgrid-edit-row, .jsgrid-insert-row, .jsgrid-filter-row) .jsgrid-cell :is(input, select) {
        min-height: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    .erp-body .erp-main :is(.jsgrid-cell, td) > :is(button, .btn):not(.jsgrid-button):has(> i:only-child):not(:has(> :not(i))) { width: 40px !important; min-width: 40px !important; height: 40px !important; }
    .erp-body .erp-main :is(.jsgrid-cell, td) input[type="checkbox"] { width: 22px !important; height: 22px !important; }
}

@media (max-width: 767.98px) {
    .erp-body { --erp-grid-max-h: 72vh; --erp-grid-row-h: 40px; }
    .erp-body :is(.jsgrid-row, .jsgrid-alt-row) > .jsgrid-cell { padding: 6px 8px !important; }
    .erp-body :is(.jsgrid-header-row > .jsgrid-header-cell, table.table > thead > tr > th, .erp-table > thead > tr > th) { padding: 8px !important; font-size: 12px !important; }
    .erp-body :is(table.table, .erp-table) > tbody > tr > td { padding: 6px 8px !important; }
}

/* --- 26.9 Phones: EsGrid lines become cards (label = column title, from EsGrid.ts
   data-label). Hidden columns keep their inline display:none (not overridden here). --- */
@media (max-width: 575.98px) {
    :root .erp-body .erp-main .bootstrap-table .fixed-table-body:has(> table.erp-esgrid td[data-label]) { max-height: none; overflow: visible !important; }
    :root .erp-body .erp-main .bootstrap-table .fixed-table-container:has(table.erp-esgrid td[data-label]) { border: 0 !important; background: transparent; }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) { display: block; background: transparent; }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > thead { display: none; }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody { display: grid; gap: 10px; }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 12px;
        border: 1px solid var(--erp-grid-frame);
        border-radius: var(--erp-radius);
        background: var(--erp-surface) !important;
        box-shadow: var(--erp-shadow-xs);
    }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr:nth-child(n) > td {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        gap: 4px;
        min-width: 0;
        height: auto;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        text-align: start;
    }
    :root .erp-body .erp-main table.erp-esgrid > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        font-size: 11.5px;
        font-weight: 600;
        color: var(--erp-text-muted);
        line-height: 1.3;
    }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr > td:not(#_) > :is(input, select, textarea, button):not([type="hidden"]):not([type="checkbox"]) { min-width: 0 !important; width: 100% !important; text-align: start; }
    /* item picker / description span the card; row actions sit on their own line at the end */
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr > td:has(> button):not([id^="td_btn_"]) { grid-column: 1 / -1; }
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr > td[id^="td_btn_"] { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; width: auto; order: -1; }
    /* the editable cells on a coarse phone are full-height fields */
    :root .erp-body .erp-main table.erp-esgrid:has(td[data-label]) > tbody > tr > td:not(#_) > :is(input, select):disabled { padding-inline: 0 !important; text-align: start; font-weight: 600; }
}
