/* =====================================================================
   Velocity ERP — Premium UI Design System
   ---------------------------------------------------------------------
   Loaded LAST inside <head> so it wins the cascade over style.css and
   over per-page inline <style> blocks.

   Layout rules intentionally use `body > X` / `body.class > X` selectors
   so they beat the legacy theme regardless of source order.

   NOTHING here changes business logic, calculations or data — this file
   is presentation only.
   ===================================================================== */

/* =====================================================================
   1. DESIGN TOKENS
   ===================================================================== */

:root {
    /* --- Brand ------------------------------------------------------ */
    --erp-primary:        #4f46e5;
    --erp-primary-700:    #4338ca;
    --erp-primary-800:    #3730a3;
    --erp-primary-100:    #e0e7ff;
    --erp-primary-50:     #eef1ff;

    --erp-accent:         #f59e0b;
    --erp-accent-700:     #b45309;
    --erp-accent-100:     #fef0d3;
    --erp-accent-50:      #fff8ec;

    /* --- Surfaces --------------------------------------------------- */
    --erp-bg:             #f4f6fa;
    --erp-surface:        #ffffff;
    --erp-surface-2:      #fafbfd;
    --erp-surface-3:      #f1f3f8;

    --erp-sidebar:        #0f1218;
    --erp-sidebar-2:      #161a23;
    --erp-sidebar-3:      #1d222d;

    /* --- Borders ---------------------------------------------------- */
    --erp-border:         #e6e9f0;
    --erp-border-strong:  #d7dce6;

    /* --- Text ------------------------------------------------------- */
    --erp-text:           #14161c;
    --erp-text-2:         #4b5563;
    --erp-muted:          #7c8598;

    /* --- Semantic --------------------------------------------------- */
    --erp-success:        #0e9f6e;
    --erp-success-700:    #0a7a54;
    --erp-success-50:     #e8f8f1;
    --erp-warning:        #d97706;
    --erp-warning-700:    #b45309;
    --erp-warning-50:     #fdf3e3;
    --erp-danger:         #e02424;
    --erp-danger-700:     #b91c1c;
    --erp-danger-50:      #fdecec;
    --erp-info:           #0b84d4;
    --erp-info-700:       #0369a1;
    --erp-info-50:        #e8f3fc;

    /* --- Radius ----------------------------------------------------- */
    --erp-r-xs:  6px;
    --erp-r-sm:  8px;
    --erp-r:     12px;
    --erp-r-lg:  16px;
    --erp-r-xl:  20px;
    --erp-r-pill: 999px;

    /* --- Elevation -------------------------------------------------- */
    --erp-sh-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
    --erp-sh-2: 0 4px 14px -2px rgba(16, 24, 40, .08), 0 2px 6px -2px rgba(16, 24, 40, .04);
    --erp-sh-3: 0 16px 36px -12px rgba(16, 24, 40, .22);
    --erp-ring:  0 0 0 4px rgba(79, 70, 229, .14);

    /* --- Type ------------------------------------------------------- */
    --erp-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --erp-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* --- Space ------------------------------------------------------ */
    --erp-sp-1: 4px;
    --erp-sp-2: 8px;
    --erp-sp-3: 12px;
    --erp-sp-4: 16px;
    --erp-sp-5: 20px;
    --erp-sp-6: 24px;
    --erp-sp-8: 32px;
    --erp-sp-10: 40px;

    /* --- Shell metrics ---------------------------------------------- */
    --erp-header-h: 64px;
    --erp-sidebar-w: 262px;
    --erp-rail-w: 78px;
    --erp-content-max: 1680px;
}

/* =====================================================================
   2. BASE
   ===================================================================== */

body {
    background-color: var(--erp-bg);
    color: var(--erp-text);
    font-family: var(--erp-font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--erp-font);
    color: var(--erp-text);
    font-weight: 650;
    letter-spacing: -.012em;
}

h1 { font-size: 1.55rem; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.16rem; }
h4 { font-size: 1.02rem; }
h5 { font-size: .94rem; }
h6 { font-size: .85rem; }

a { color: var(--erp-primary); }
a:hover, a:focus { color: var(--erp-primary-700); }

hr {
    border-top: 1px solid var(--erp-border);
    margin: var(--erp-sp-5) 0;
}

.text-muted { color: var(--erp-muted) !important; }
.text-muted small, small.text-muted { color: var(--erp-muted) !important; }

/* Keyboard-friendly focus states everywhere (never on mouse click) */
:focus-visible {
    outline: 2px solid var(--erp-primary);
    outline-offset: 2px;
    border-radius: var(--erp-r-xs);
}

::selection { background: var(--erp-primary-100); color: var(--erp-primary-800); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c8cddb transparent; }
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: #ccd2e0;
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: var(--erp-r-pill);
}
*::-webkit-scrollbar-thumb:hover { background: #aeb6c9; background-clip: content-box; }

/* =====================================================================
   3. APP SHELL — HEADER
   ===================================================================== */

body > .header {
    align-items: center;
    background: rgba(255, 255, 255, .88);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--erp-border);
    box-shadow: none;
    display: flex;
    gap: var(--erp-sp-3);
    height: var(--erp-header-h);
    left: 0;
    padding: 0 var(--erp-sp-5);
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1030;
}

/* Hamburger (mobile) */
body > .header .erp-burger,
body > .header #mobile_btn {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--erp-r-sm);
    color: var(--erp-text-2);
    cursor: pointer;
    display: none;
    height: 40px;
    justify-content: center;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
    width: 40px;
}
body > .header .erp-burger:hover,
body > .header #mobile_btn:hover { background: var(--erp-surface-3); color: var(--erp-text); }
body > .header .erp-burger i,
body > .header #mobile_btn i { font-size: 17px; }

/* Desktop collapse control */
body > .header #toggle_btn {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--erp-r-sm);
    color: var(--erp-text-2);
    cursor: pointer;
    display: inline-flex;
    height: 40px;
    justify-content: center;
    margin: 0;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
    width: 40px;
}
body > .header #toggle_btn:hover { background: var(--erp-surface-3); color: var(--erp-text); }
body > .header #toggle_btn i { font-size: 17px; }

/* Brand lockup */
body > .header .header-left {
    align-items: center;
    display: flex;
    flex: 0 1 auto;
    float: none;
    gap: var(--erp-sp-3);
    height: auto;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    text-align: left;
    width: auto;
}
body > .header .header-left .logo {
    align-items: center;
    display: flex;
    gap: 10px;
    line-height: 1;
    text-decoration: none;
}
/* The logo asset is a wordmark, so no duplicate wordmark text sits beside it */
body > .header .header-left .logo img {
    display: block;
    height: 32px;
    max-height: 32px;
    max-width: 100%;
    object-fit: contain;
    width: auto;
}

/* Divider between brand and page context */
body > .header .erp-header-divider {
    background: var(--erp-border);
    height: 26px;
    width: 1px;
}

/* Header page context (auto-filled by erp.js) */
body > .header .erp-header-context {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}
body > .header .erp-header-context .erp-header-title {
    color: var(--erp-text);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body > .header .erp-header-context .erp-header-crumbs {
    color: var(--erp-muted);
    font-size: 11.5px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body > .header .erp-header-context .erp-header-crumbs a { color: var(--erp-muted); }
body > .header .erp-header-context .erp-header-crumbs a:hover { color: var(--erp-primary); }
body > .header .erp-header-context .erp-header-crumbs .sep {
    margin: 0 6px;
    opacity: .55;
}

/* Right side cluster */
body > .header .user-menu {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    float: none;
    gap: 2px;
    margin: 0 0 0 auto;
    padding: 0;
    position: relative;
    z-index: 1;
}
body > .header .user-menu > li { flex: 0 0 auto; }
body > .header .erp-burger { flex: 0 0 auto; }
body > .header #toggle_btn { flex: 0 0 auto; }
body > .header .user-menu > li { list-style: none; }
body > .header .user-menu.nav > li > a {
    align-items: center;
    border-radius: var(--erp-r-sm);
    color: var(--erp-text-2);
    display: inline-flex;
    height: 40px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    transition: background .15s ease, color .15s ease;
    width: 40px;
}
body > .header .user-menu.nav > li > a:hover,
body > .header .user-menu.nav > li > a:focus {
    background: var(--erp-surface-3);
    color: var(--erp-text);
}
body > .header .user-menu.nav > li > a i,
body > .header .user-menu.nav > li > a .fe { font-size: 17px; }
body > .header .user-menu.nav > li > a:hover i { color: var(--erp-text); }

/* Global search trigger in header */
body > .header .erp-search-trigger {
    align-items: center;
    background: var(--erp-surface-2);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-sm);
    color: var(--erp-muted);
    cursor: pointer;
    display: flex;
    font-size: 13px;
    gap: 8px;
    height: 40px;
    min-width: 210px;
    padding: 0 10px 0 12px;
    transition: border-color .15s ease, background .15s ease;
}
body > .header .erp-search-trigger:hover { background: #fff; border-color: var(--erp-border-strong); }
body > .header .erp-search-trigger i { font-size: 14px; }
body > .header .erp-search-trigger .erp-kbd {
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-xs);
    color: var(--erp-muted);
    font-family: var(--erp-font);
    font-size: 10.5px;
    font-weight: 600;
    margin-left: auto;
    padding: 2px 6px;
}

/* Header title on the far left when the sidebar is a rail  */
body > .header .erp-header-overflow {
    background: linear-gradient(to right, rgba(255,255,255,.9), rgba(255,255,255,0));
    bottom: -8px;
    height: 8px;
    left: 0;
    position: absolute;
    right: 0;
}

/* User identity block */
body > .header .erp-user-chip {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--erp-r-pill);
    display: flex;
    gap: 9px;
    height: 42px;
    margin-left: 4px;
    padding: 0 8px 0 4px;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease;
}
body > .header .erp-user-chip:hover {
    background: var(--erp-surface-2);
    border-color: var(--erp-border);
    text-decoration: none;
}
body > .header .erp-user-chip .erp-user-avatar {
    background: linear-gradient(135deg, var(--erp-primary), #7c74ff);
    border-radius: var(--erp-r-pill);
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--erp-border);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    height: 32px;
    letter-spacing: .02em;
    line-height: 32px;
    text-align: center;
    text-transform: uppercase;
    width: 32px;
}
body > .header .erp-user-chip .erp-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    max-width: 150px;
    text-align: left;
}
body > .header .erp-user-chip .erp-user-name {
    color: var(--erp-text);
    font-size: 13px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body > .header .erp-user-chip .erp-user-role {
    color: var(--erp-muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body > .header .erp-user-chip .erp-caret { color: var(--erp-muted); font-size: 12px; }

/* Legacy header bits we no longer use */
body > .header .mobile_btn { display: none; }
body > .header h4 { margin: 0; }
body > .header .user-img img { border: 0; margin: 0; max-height: 34px; }
body > .header .nav-link { padding: 0; }

/* Header dropdown (profile / quick actions) */
body > .header .dropdown-menu {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-3);
    margin-top: 10px;
    min-width: 250px;
    padding: 6px;
}
body > .header .dropdown-menu.show { animation: erpPop .16s ease-out; }
body > .header .dropdown-menu::before { content: none; }
body > .header .dropdown-menu .dropdown-item {
    border-radius: var(--erp-r-sm);
    color: var(--erp-text-2);
    font-size: 13.5px;
    font-weight: 500;
    padding: 9px 11px;
    transition: background .12s ease, color .12s ease;
}
body > .header .dropdown-menu .dropdown-item i { color: var(--erp-muted); }
body > .header .dropdown-menu .dropdown-item:hover,
body > .header .dropdown-menu .dropdown-item:focus {
    background: var(--erp-primary-50);
    color: var(--erp-primary-800);
}
body > .header .dropdown-menu .dropdown-item:hover i { color: var(--erp-primary); }
body > .header .dropdown-menu .dropdown-divider { border-color: var(--erp-border); margin: 6px 4px; }
body > .header .dropdown-menu .user-header {
    align-items: center;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
    padding: 10px 12px 13px;
}
body > .header .dropdown-menu .user-header .avatar img {
    border-radius: var(--erp-r-pill);
    height: 38px;
    width: 38px;
}
body > .header .dropdown-menu .user-header h6 {
    font-size: 13.5px;
    font-weight: 650;
    margin: 0;
}
body > .header .dropdown-menu .user-header p { font-size: 12px; }

/* Badge on header icons */
body > .header .erp-dot {
    background: var(--erp-danger);
    border: 2px solid #fff;
    border-radius: var(--erp-r-pill);
    height: 9px;
    position: absolute;
    right: 8px;
    top: 8px;
    width: 9px;
}

@keyframes erpPop {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   4. APP SHELL — SIDEBAR
   ===================================================================== */

body > .sidebar {
    background: var(--erp-sidebar);
    border-right: 1px solid #05070b;
    bottom: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    left: 0;
    margin: 0;
    position: fixed;
    top: var(--erp-header-h);
    transition: width .2s cubic-bezier(.4, 0, .2, 1), transform .25s cubic-bezier(.4, 0, .2, 1);
    width: var(--erp-sidebar-w);
    z-index: 1040;
}
body > .sidebar::after {
    background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,0) 180px);
    content: "";
    inset: 0 0 auto 0;
    height: 180px;
    pointer-events: none;
    position: absolute;
}
body > .sidebar .sidebar-inner {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    height: auto !important;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}
/* Neutralise the legacy slimscroll plugin wrapper */
body > .sidebar .slimScrollDiv {
    height: auto !important;
    overflow: visible !important;
    width: 100% !important;
}
body > .sidebar .slimScrollBar,
body > .sidebar .slimScrollRail { display: none !important; opacity: 0 !important; }

body > .sidebar .sidebar-menu {
    flex: 1 1 auto;
    padding: var(--erp-sp-3) 12px var(--erp-sp-4);
}
body > .sidebar .sidebar-menu ul {
    font-size: 13.5px;
    list-style: none;
    margin: 0;
    padding: 0;
    position: static;
}
body > .sidebar .sidebar-menu > ul > li {
    margin-bottom: 2px;
    position: relative;
}

/* Group labels (inserted by header.php) */
body > .sidebar .erp-nav-label {
    color: #5b6478;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    margin: 18px 0 7px;
    padding: 0 10px;
    text-transform: uppercase;
    white-space: nowrap;
}
body > .sidebar .erp-nav-label:first-child { margin-top: 2px; }

/* Top level items */
body > .sidebar .sidebar-menu li > a {
    align-items: center;
    background: transparent;
    border-radius: var(--erp-r-sm);
    color: #aeb6c9;
    display: flex;
    font-size: 13.5px;
    font-weight: 500;
    gap: 11px;
    height: auto;
    min-height: 38px;
    padding: 8px 10px;
    position: relative;
    text-decoration: none;
    transition: background .14s ease, color .14s ease;
}
body > .sidebar .sidebar-menu li > a:hover {
    background: var(--erp-sidebar-3);
    color: #fff;
}
body > .sidebar .sidebar-menu li > a .fe,
body > .sidebar .sidebar-menu li > a > i {
    flex: 0 0 18px;
    font-size: 16px;
    line-height: 1;
    text-align: center;
    width: 18px;
}
body > .sidebar .sidebar-menu li > a span {
    display: inline-block;
    margin-left: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Section/parent rows */
body > .sidebar .sidebar-menu > ul > li.submenu > a { color: #c3cad9; }
body > .sidebar .sidebar-menu > ul > li > a.erp-parent-open {
    background: var(--erp-sidebar-2);
    color: #fff;
}

/* ACTIVE state — subtle indigo wash + amber indicator */
body > .sidebar .sidebar-menu li > a.active,
body > .sidebar .sidebar-menu > ul > li.active > a {
    background: rgba(79, 70, 229, .16);
    color: #fff;
    font-weight: 600;
}
body > .sidebar .sidebar-menu > ul > li > a.active::before {
    background: var(--erp-accent);
    border-radius: 0 var(--erp-r-pill) var(--erp-r-pill) 0;
    content: "";
    height: 20px;
    left: -12px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
}
body > .sidebar .sidebar-menu li > a.active .fe,
body > .sidebar .sidebar-menu li > a.active > i { color: #fff; }

/* Submenu */
body > .sidebar .sidebar-menu ul ul { display: none; }
body > .sidebar .sidebar-menu ul ul.erp-open { display: block; }
body > .sidebar .sidebar-menu ul ul > li > a {
    color: #8e97ab;
    font-size: 13px;
    font-weight: 500;
    min-height: 32px;
    padding: 6px 10px 6px 40px;
    position: relative;
}
body > .sidebar .sidebar-menu ul ul > li > a::before {
    background: #39404f;
    border-radius: var(--erp-r-pill);
    content: "";
    height: 4px;
    left: 24px;
    opacity: .75;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
}
body > .sidebar .sidebar-menu ul ul > li > a:hover {
    background: var(--erp-sidebar-2);
    color: #fff;
    text-decoration: none;
}
body > .sidebar .sidebar-menu ul ul > li > a.active,
body > .sidebar .sidebar-menu ul ul a.active {
    background: rgba(79, 70, 229, .14);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
body > .sidebar .sidebar-menu ul ul > li > a.active::before {
    background: var(--erp-accent);
    height: 6px;
    width: 6px;
}
body > .sidebar .sidebar-menu ul ul ul a {
    padding-left: 56px;
}

/* Chevron */
body > .sidebar .sidebar-menu .menu-arrow {
    color: #5b6478;
    font-family: 'FontAwesome', sans-serif;
    font-size: 13px;
    line-height: 1;
    margin-left: auto;
    position: static;
    right: auto;
    top: auto;
    transition: transform .18s ease;
}
body > .sidebar .sidebar-menu li > a.erp-parent-open .menu-arrow {
    color: #98a1b3;
    transform: rotate(90deg);
}

/* Sidebar footer (role chip + logout) */
body > .sidebar .erp-sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, .06);
    flex: 0 0 auto;
    padding: var(--erp-sp-3) 12px;
}
body > .sidebar .erp-sidebar-footer .erp-role-card {
    background: var(--erp-sidebar-2);
    border: 1px solid rgba(255, 255, 255, .05);
    border-radius: var(--erp-r-sm);
    padding: 10px 11px;
}
body > .sidebar .erp-sidebar-footer .erp-role-card .erp-role-label {
    color: #5b6478;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
body > .sidebar .erp-sidebar-footer .erp-role-card .erp-role-value {
    align-items: center;
    color: #e6eaf2;
    display: flex;
    font-size: 12.5px;
    font-weight: 600;
    gap: 6px;
    margin-top: 3px;
}
body > .sidebar .erp-sidebar-footer .erp-role-card .erp-role-value::before {
    background: var(--erp-accent);
    border-radius: var(--erp-r-pill);
    content: "";
    height: 6px;
    width: 6px;
}
body > .sidebar .erp-sidebar-footer .erp-logout {
    align-items: center;
    color: #8e97ab;
    display: flex;
    font-size: 13px;
    font-weight: 500;
    gap: 10px;
    margin-top: 6px;
    padding: 9px 10px;
    border-radius: var(--erp-r-sm);
    text-decoration: none;
}
body > .sidebar .erp-sidebar-footer .erp-logout:hover {
    background: rgba(224, 36, 36, .12);
    color: #ff9c9c;
}

/* Sidebar overlay (mobile backdrop) — legacy class neutralised */
body > .sidebar-overlay.opened { display: none !important; }
body > .sidebar-overlay.erp-open {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    background: rgba(10, 13, 20, .52);
    display: block;
    inset: 0;
    opacity: 1;
    position: fixed;
    top: 0;
    z-index: 1035;
}
html.menu-opened, html.menu-opened body { overflow: visible !important; }

/* =====================================================================
   5. APP SHELL — CONTENT AREA
   ===================================================================== */

body > .page-wrapper {
    margin-left: var(--erp-sidebar-w);
    min-height: 100vh;
    padding-top: var(--erp-header-h);
    transition: margin-left .2s cubic-bezier(.4, 0, .2, 1);
    width: auto;
}
body > .page-wrapper > .content,
body > .page-wrapper .content.container-fluid {
    margin: 0 auto;
    max-width: var(--erp-content-max);
    padding: var(--erp-sp-6);
    width: 100%;
}

/* =====================================================================
   6. COLLAPSED (RAIL) MODE — desktop
   ===================================================================== */

body.mini-sidebar > .sidebar { width: var(--erp-rail-w); }
body.mini-sidebar > .page-wrapper { margin-left: var(--erp-rail-w); }

body.mini-sidebar > .sidebar .sidebar-menu { padding: var(--erp-sp-3) 12px; }
body.mini-sidebar > .sidebar .erp-nav-label {
    height: 1px;
    margin: 12px 8px;
    overflow: hidden;
    padding: 0;
    text-indent: -999px;
    background: rgba(255,255,255,.07);
    border-radius: 1px;
}
body.mini-sidebar > .sidebar .sidebar-menu li > a {
    justify-content: center;
    padding: 10px;
}
body.mini-sidebar > .sidebar .sidebar-menu li > a span,
body.mini-sidebar > .sidebar .sidebar-menu .menu-arrow { display: none; }
body.mini-sidebar > .sidebar .sidebar-menu > ul > li > a.active::before { left: -12px; }
body.mini-sidebar > .sidebar .sidebar-menu ul ul { display: none !important; }
body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-role-card,
body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-logout span { display: none; }
body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-logout { justify-content: center; }

/* Hover-expand the rail (theme adds body.expand-menu on sidebar hover) */
body.mini-sidebar.expand-menu > .sidebar {
    box-shadow: var(--erp-sh-3);
    width: var(--erp-sidebar-w);
}
body.mini-sidebar.expand-menu > .sidebar .sidebar-menu li > a {
    justify-content: flex-start;
    padding: 8px 10px;
}
body.mini-sidebar.expand-menu > .sidebar .sidebar-menu li > a span,
body.mini-sidebar.expand-menu > .sidebar .sidebar-menu .menu-arrow { display: inline-block; }
body.mini-sidebar.expand-menu > .sidebar .sidebar-menu ul ul { display: none !important; }
body.mini-sidebar.expand-menu > .sidebar .sidebar-menu ul ul.erp-open { display: block !important; }
body.mini-sidebar.expand-menu > .sidebar .erp-nav-label {
    background: transparent;
    height: auto;
    margin: 18px 0 7px;
    overflow: visible;
    padding: 0 10px;
    text-indent: 0;
}
body.mini-sidebar.expand-menu > .sidebar .erp-sidebar-footer .erp-role-card,
body.mini-sidebar.expand-menu > .sidebar .erp-sidebar-footer .erp-logout span { display: block; }
body.mini-sidebar.expand-menu > .sidebar .erp-sidebar-footer .erp-logout { justify-content: flex-start; }
/* In rail mode the pointer must reach the sidebar from the page side */
body.mini-sidebar > .page-wrapper { pointer-events: auto; }

/* =====================================================================
   7. PAGE HEADER + BREADCRUMB
   ===================================================================== */

.page-header {
    margin-bottom: var(--erp-sp-5);
}
.page-header .page-title,
.page-header h3 {
    font-size: 1.28rem;
    font-weight: 700;
    letter-spacing: -.015em;
    margin: 0 0 4px;
}
.page-header .breadcrumb {
    align-items: center;
    background: transparent;
    display: flex;
    flex-wrap: wrap;
    font-size: 12.5px;
    gap: 2px;
    margin: 0;
    padding: 0;
}
.page-header .breadcrumb .breadcrumb-item { color: var(--erp-muted); font-weight: 500; }
.page-header .breadcrumb .breadcrumb-item a {
    color: var(--erp-muted);
    font-weight: 500;
    text-decoration: none;
}
.page-header .breadcrumb .breadcrumb-item a:hover { color: var(--erp-primary); }
.page-header .breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: #b6bdcc;
    content: "/";
    padding: 0 7px;
}
.page-header .breadcrumb .breadcrumb-item.active { color: var(--erp-text-2); }

/* Auto-generated page header (erp.js) */
.erp-auto-pageheader {
    align-items: flex-end;
    display: flex;
    flex-wrap: wrap;
    gap: var(--erp-sp-4);
    justify-content: space-between;
    margin-bottom: var(--erp-sp-5);
}
.erp-auto-pageheader .erp-aph-title {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1.2;
    margin: 0;
}
.erp-auto-pageheader .erp-aph-crumbs {
    color: var(--erp-muted);
    font-size: 12.5px;
    margin-top: 3px;
}
.erp-auto-pageheader .erp-aph-crumbs a { color: var(--erp-muted); text-decoration: none; }
.erp-auto-pageheader .erp-aph-crumbs a:hover { color: var(--erp-primary); }
.erp-auto-pageheader .erp-aph-crumbs .sep { margin: 0 7px; color: #b6bdcc; }

/* =====================================================================
   8. CARDS
   ===================================================================== */

.card {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    margin-bottom: var(--erp-sp-5);
    overflow: hidden;
}
.card > .card-header,
.card > .card-body:first-child,
.card > form > .card-body:first-child { border-top-left-radius: var(--erp-r); border-top-right-radius: var(--erp-r); }
.card > .card-body:last-child { border-bottom-left-radius: var(--erp-r); border-bottom-right-radius: var(--erp-r); }

.card-header {
    align-items: center;
    background: var(--erp-surface);
    border-bottom: 1px solid var(--erp-border);
    border-radius: 0;
    color: var(--erp-text);
    display: flex;
    flex-wrap: wrap;
    gap: var(--erp-sp-3);
    min-height: 56px;
    padding: 14px var(--erp-sp-5);
}
.card-header.bg-dark,
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-info,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-secondary {
    background: var(--erp-surface) !important;
    color: var(--erp-text) !important;
}
.card-header.bg-dark .card-title,
.card-header.bg-dark h5,
.card-header.bg-dark h4 { color: var(--erp-text) !important; }

.card-title,
.card-header h4,
.card-header h5 {
    color: var(--erp-text);
    font-size: 14.5px;
    font-weight: 650;
    letter-spacing: -.008em;
    margin: 0;
}
.card-header .card-subtitle {
    color: var(--erp-muted);
    font-size: 12.5px;
    margin: 2px 0 0;
}
.card-header .erp-header-actions { margin-left: auto; }
.card-body { padding: var(--erp-sp-5); }
.card-body.p-0 { padding: 0; }
.card-footer {
    background: var(--erp-surface-2);
    border-top: 1px solid var(--erp-border);
    padding: 14px var(--erp-sp-5);
}
.card.shadow-sm { box-shadow: var(--erp-sh-1); }

/* KPI / stat cards */
.erp-kpi {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    padding: var(--erp-sp-5);
    position: relative;
    transition: box-shadow .18s ease, transform .18s ease;
}
.erp-kpi:hover { box-shadow: var(--erp-sh-2); transform: translateY(-1px); }
.erp-kpi .erp-kpi-top {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}
.erp-kpi .erp-kpi-label {
    color: var(--erp-muted);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.erp-kpi .erp-kpi-icon {
    align-items: center;
    background: var(--erp-primary-50);
    border-radius: var(--erp-r-sm);
    color: var(--erp-primary);
    display: inline-flex;
    flex: 0 0 auto;
    height: 34px;
    justify-content: center;
    width: 34px;
}
.erp-kpi .erp-kpi-icon i { font-size: 16px; }
.erp-kpi.erp-kpi--success .erp-kpi-icon { background: var(--erp-success-50); color: var(--erp-success-700); }
.erp-kpi.erp-kpi--warning .erp-kpi-icon { background: var(--erp-warning-50); color: var(--erp-warning-700); }
.erp-kpi.erp-kpi--accent  .erp-kpi-icon { background: var(--erp-accent-50);  color: var(--erp-accent-700); }
.erp-kpi.erp-kpi--danger  .erp-kpi-icon { background: var(--erp-danger-50);  color: var(--erp-danger-700); }
.erp-kpi.erp-kpi--info    .erp-kpi-icon { background: var(--erp-info-50);    color: var(--erp-info-700); }
.erp-kpi .erp-kpi-value {
    color: var(--erp-text);
    font-size: 1.62rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -.025em;
    line-height: 1.1;
}
.erp-kpi .erp-kpi-value .erp-unit {
    color: var(--erp-muted);
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: 0;
    margin-left: 3px;
}
.erp-kpi .erp-kpi-foot {
    color: var(--erp-text-2);
    font-size: 12.5px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
}
.erp-kpi .erp-kpi-foot .erp-mini-stat { color: var(--erp-muted); }
.erp-kpi .erp-kpi-foot .erp-mini-stat b {
    color: var(--erp-text);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

/* Legacy dashboard gradient boxes → clean cards */
.card-box {
    background: var(--erp-surface) !important;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r) !important;
    box-shadow: var(--erp-sh-1) !important;
    color: var(--erp-text) !important;
    font-weight: 600;
    height: 100%;
    padding: var(--erp-sp-5) !important;
}
.card-box h4 {
    color: var(--erp-text);
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 6px 0;
}

/* Chart panel */
.erp-panel {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    height: 100%;
    padding: var(--erp-sp-5);
}
.erp-panel > .erp-panel-head {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: var(--erp-sp-4);
}
.erp-panel > .erp-panel-head h5 {
    font-size: 14.5px;
    font-weight: 650;
    margin: 0;
}
.erp-panel > .erp-panel-head .erp-panel-sub {
    color: var(--erp-muted);
    font-size: 12px;
}
.erp-panel .erp-chart-wrap { position: relative; width: 100%; }
.erp-panel .erp-chart-wrap > canvas { max-height: 300px; width: 100% !important; }

/* =====================================================================
   9. BUTTONS
   ===================================================================== */

.btn {
    align-items: center;
    border-radius: var(--erp-r-sm);
    border-width: 1px;
    display: inline-flex;
    font-family: var(--erp-font);
    font-size: 13.5px;
    font-weight: 600;
    gap: 7px;
    justify-content: center;
    line-height: 1.2;
    padding: 9px 15px;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
    white-space: nowrap;
}
.btn i, .btn .fe { font-size: 13px; }
.btn:focus, .btn.focus { box-shadow: none; outline: none; }
.btn:focus-visible { box-shadow: var(--erp-ring); }

.btn-primary {
    background: var(--erp-primary);
    border-color: var(--erp-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, .25);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--erp-primary-700);
    border-color: var(--erp-primary-700);
    color: #fff;
}
.btn-primary.disabled, .btn-primary:disabled { background: #a5a1ef; border-color: #a5a1ef; }

.btn-secondary, .btn-default {
    background: #fff;
    border-color: var(--erp-border-strong);
    color: var(--erp-text-2);
}
.btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active,
.btn-default:hover, .btn-default:focus,
.btn-secondary:not(:disabled):not(.disabled):active {
    background: var(--erp-surface-3);
    border-color: var(--erp-border-strong);
    color: var(--erp-text);
}

.btn-success {
    background: var(--erp-success-50);
    border-color: #c9ecdd;
    color: var(--erp-success-700);
}
.btn-success:hover, .btn-success:focus, .btn-success:active,
.btn-success:not(:disabled):not(.disabled):active {
    background: var(--erp-success);
    border-color: var(--erp-success);
    color: #fff;
}

.btn-info {
    background: var(--erp-info-50);
    border-color: #cbe6f8;
    color: var(--erp-info-700);
}
.btn-info:hover, .btn-info:focus, .btn-info:active,
.btn-info:not(:disabled):not(.disabled):active {
    background: var(--erp-info);
    border-color: var(--erp-info);
    color: #fff;
}

.btn-warning {
    background: var(--erp-warning-50);
    border-color: #f4dfb8;
    color: var(--erp-warning-700);
}
.btn-warning:hover, .btn-warning:focus, .btn-warning:active,
.btn-warning:not(:disabled):not(.disabled):active {
    background: var(--erp-warning);
    border-color: var(--erp-warning);
    color: #fff;
}

.btn-danger {
    background: var(--erp-danger-50);
    border-color: #f7cfcf;
    color: var(--erp-danger-700);
}
.btn-danger:hover, .btn-danger:focus, .btn-danger:active,
.btn-danger:not(:disabled):not(.disabled):active {
    background: var(--erp-danger);
    border-color: var(--erp-danger);
    color: #fff;
}

.btn-dark {
    background: var(--erp-text);
    border-color: var(--erp-text);
    color: #fff;
}
.btn-dark:hover, .btn-dark:focus { background: #000; border-color: #000; color: #fff; }

.btn-outline-primary { background: #fff; border-color: var(--erp-primary-100); color: var(--erp-primary-700); }
.btn-outline-primary:hover { background: var(--erp-primary); border-color: var(--erp-primary); color: #fff; }

.btn-link { color: var(--erp-primary); font-weight: 600; text-decoration: none; }
.btn-link:hover { color: var(--erp-primary-700); text-decoration: none; }

.btn-sm { border-radius: var(--erp-r-xs); font-size: 12.5px; padding: 6px 11px; }
.btn-sm i, .btn-sm .fe { font-size: 12px; }
.btn-lg { border-radius: var(--erp-r); font-size: 15px; padding: 12px 20px; }
.btn-block { width: 100%; }
.btn.btn-rounded { border-radius: var(--erp-r-pill); }

/* Icon-only action buttons produced by erp.js in table cells */
.erp-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}
.erp-actions .btn { padding: 6px 10px; }
.erp-actions .btn i:only-child, .erp-actions .btn .fe:only-child { margin: 0; }

/* =====================================================================
   10. FORMS
   ===================================================================== */

.form-group { margin-bottom: var(--erp-sp-4); }
.form-group > label,
label.col-form-label,
.form-group label {
    color: var(--erp-text-2);
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .005em;
    margin-bottom: 6px;
}
.form-text, .form-group small.text-muted { color: var(--erp-muted); font-size: 12px; }

.form-control, .custom-select {
    background: #fff;
    border: 1px solid var(--erp-border-strong);
    border-radius: var(--erp-r-sm);
    color: var(--erp-text);
    font-family: var(--erp-font);
    font-size: 13.5px;
    height: 42px;
    padding: 9px 12px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-control:focus, .custom-select:focus {
    background: #fff;
    border-color: var(--erp-primary);
    box-shadow: var(--erp-ring);
    color: var(--erp-text);
    outline: 0 none;
}
.form-control::placeholder { color: #a7aebe; }
.form-control:disabled, .form-control[readonly] {
    background: var(--erp-surface-3);
    color: var(--erp-muted);
}
textarea.form-control { height: auto; min-height: 92px; }
.form-control-sm { font-size: 12.5px; height: 34px; padding: 6px 10px; }
.form-control[type="color"] { padding: 4px; }
input[type="file"].form-control { height: auto; padding: 8px 12px; }
.custom-select { padding-right: 32px; }
.input-group-text {
    background: var(--erp-surface-3);
    border: 1px solid var(--erp-border-strong);
    color: var(--erp-text-2);
    font-size: 13px;
}
.form-check-input { height: 16px; margin-top: .22rem; width: 16px; }
.form-check-input:checked { background-color: var(--erp-primary); border-color: var(--erp-primary); }
.form-check-label { color: var(--erp-text-2); font-size: 13.5px; }
.form-row > [class*="col-"] { padding-left: 8px; padding-right: 8px; }
.form-row { margin-left: -8px; margin-right: -8px; }
.invalid-feedback, .erp-field-error {
    color: var(--erp-danger-700);
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-top: 5px;
}
.form-control.is-invalid, .was-validated .form-control:invalid {
    border-color: var(--erp-danger);
    box-shadow: none;
}

/* Filter / search bars */
.erp-filterbar {
    align-items: flex-end;
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    display: flex;
    flex-wrap: wrap;
    gap: var(--erp-sp-3);
    margin-bottom: var(--erp-sp-5);
    padding: var(--erp-sp-4);
}
.erp-filterbar.erp-bare {
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}
.erp-filterbar .erp-filter-field {
    flex: 1 1 190px;
    min-width: 0;
}
.erp-filterbar .erp-filter-field.erp-fixed { flex: 0 0 auto; }
.erp-filterbar .erp-filter-field > label {
    color: var(--erp-muted);
    display: block;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .05em;
    margin-bottom: 5px;
    text-transform: uppercase;
}
.erp-filterbar .erp-filter-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}
.erp-filterbar .form-control,
.erp-filterbar .custom-select { width: 100%; }

/* Mobile "Filters" disclosure */
.erp-filter-toggle { display: none; }
.erp-filters-collapsed { display: none !important; }

/* Auto-detected filter forms (erp.js adds .erp-filterbar to GET forms).
   Interactive elements stay natural-width; fields share the remaining space. */
form.erp-filterbar > *:not(script):not(br):not(.erp-filter-toggle):not(.btn):not(button):not(input[type="submit"]):not(input[type="button"]):not(input[type="reset"]):not(a.btn) {
    flex: 1 1 190px;
    min-width: 0;
}
form.erp-filterbar > label {
    color: var(--erp-muted);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .05em;
    margin: 0;
    text-transform: uppercase;
}
form.erp-filterbar > .btn,
form.erp-filterbar > button,
form.erp-filterbar > input[type="submit"],
form.erp-filterbar > input[type="button"],
form.erp-filterbar > a.btn {
    align-self: flex-end;
    flex: 0 0 auto;
}
form.erp-filterbar > .form-control,
form.erp-filterbar > .custom-select,
form.erp-filterbar > select,
form.erp-filterbar > input { width: 100%; }
form.erp-filterbar > [class*="col-"] { padding-left: 0; padding-right: 0; }
form.erp-filterbar > hr { display: none; }

/* Sortable headers added by erp.js */
.table thead th.erp-sortable { cursor: pointer; user-select: none; }
.table thead th.erp-sortable:hover { color: var(--erp-text); }
.table thead th.erp-sortable::after {
    color: #c3cad9;
    content: "\f0dc";
    font-family: 'FontAwesome', sans-serif;
    font-size: 10px;
    margin-left: 6px;
    opacity: .65;
}
.table thead th.erp-sort-asc::after { color: var(--erp-primary); content: "\f0d8"; opacity: 1; }
.table thead th.erp-sort-desc::after { color: var(--erp-primary); content: "\f0d7"; opacity: 1; }
.table thead th.erp-sortable:focus-visible { outline: 2px solid var(--erp-primary); outline-offset: -2px; }

/* Submit-in-flight feedback (button stays enabled so its name/value posts) */
.btn.erp-busy { cursor: progress; opacity: .85; }
/* The busy state spins whatever icon the button carries (erp.js swaps it to
   fe-sync on submit). The bundled icon font has no spinner glyph, so the
   rule must not name one. */
.btn.erp-busy i { animation: erpSpin 1s linear infinite; }
@keyframes erpSpin { to { transform: rotate(360deg); } }

/* Search input with icon */
.erp-searchbox { position: relative; }
.erp-searchbox > i,
.erp-searchbox > .fe {
    color: var(--erp-muted);
    font-size: 14px;
    left: 12px;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}
.erp-searchbox > input { padding-left: 34px; }

/* Sectioned forms */
.erp-form-section {
    border-bottom: 1px solid var(--erp-border);
    margin-bottom: var(--erp-sp-6);
    padding-bottom: var(--erp-sp-2);
}
.erp-form-section:last-of-type { border-bottom: 0; margin-bottom: 0; }
.erp-form-section-head {
    align-items: center;
    display: flex;
    gap: 10px;
    margin-bottom: var(--erp-sp-4);
}
.erp-form-section-head .erp-fs-icon {
    align-items: center;
    background: var(--erp-primary-50);
    border-radius: var(--erp-r-xs);
    color: var(--erp-primary);
    display: inline-flex;
    height: 28px;
    justify-content: center;
    width: 28px;
}
.erp-form-section-head h5 {
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .01em;
    margin: 0;
    text-transform: uppercase;
    color: var(--erp-text-2);
}
.erp-form-section-head .erp-fs-hint { color: var(--erp-muted); font-size: 12px; }

/* Sticky form action bar */
.erp-form-actions {
    align-items: center;
    background: var(--erp-surface-2);
    border-top: 1px solid var(--erp-border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px var(--erp-sp-5);
}
.erp-form-actions .erp-actions-right { margin-left: auto; display: flex; gap: 10px; }
@media (min-width: 768px) {
    .erp-form-actions.erp-sticky {
        bottom: 0;
        position: sticky;
        z-index: 5;
    }
}

/* =====================================================================
   11. TABLES
   ===================================================================== */

.erp-table-shell {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    margin-bottom: var(--erp-sp-5);
    overflow: hidden;
}
.erp-table-shell > .erp-table-shell-head {
    align-items: center;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--erp-sp-3);
    min-height: 56px;
    padding: 13px var(--erp-sp-5);
}
.erp-table-shell > .erp-table-shell-head h4,
.erp-table-shell > .erp-table-shell-head h5 {
    font-size: 14.5px;
    font-weight: 650;
    margin: 0;
}
.erp-table-shell > .erp-table-shell-head .erp-head-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.erp-table-shell > .table-responsive { border-radius: 0; }

.table {
    background: transparent;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--erp-text);
    margin-bottom: 0;
    width: 100%;
}
.table thead tr th,
.table > thead > tr > th,
.table > tbody > tr > th {
    background: var(--erp-surface-2);
    border-bottom: 1px solid var(--erp-border);
    border-top: 0;
    color: var(--erp-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 11px 14px;
    text-align: left;
    text-transform: uppercase;
    vertical-align: middle;
    white-space: nowrap;
}
.table tbody tr td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
    border-bottom: 1px solid #f1f3f8;
    border-top: 0;
    color: var(--erp-text-2);
    font-size: 13.5px;
    padding: 12px 14px;
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table tbody tr:hover,
.table-hover tbody tr:hover { background: #f8fafd; }
.table-hover tbody tr:hover td { background: transparent; }
.table td strong, .table td b { color: var(--erp-text); font-weight: 650; }
.table td.num, .table th.num, .table .erp-num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
.table td.text-start, .table td.text-left { text-align: left; }
.table th.text-right, .table td.text-right, .table th.text-center, .table td.text-center { white-space: nowrap; }

/* Legacy `.table-bordered` grid lines → modern dividers only */
.table-bordered { border: 0; }
.table-bordered th, .table-bordered td { border: 0; border-bottom: 1px solid #f1f3f8; }
.table-bordered thead th { border-bottom: 1px solid var(--erp-border); }
.table-sm tbody tr td, .table-sm thead tr th { padding: 9px 12px; }
.table-striped tbody tr:nth-of-type(odd) { background: var(--erp-surface-2); }
.table-striped tbody tr:nth-of-type(even) { background: transparent; }
.table-dark, .table thead.table-dark, .table thead.table-dark th {
    background: var(--erp-surface-2) !important;
    color: var(--erp-muted) !important;
}
.table thead.table-dark th { border-bottom: 1px solid var(--erp-border) !important; }
.table-responsive { -webkit-overflow-scrolling: touch; overflow-x: auto; }

/* Sticky header for long tables (erp.js adds .erp-sticky) */
.erp-sticky > thead > tr > th,
table.erp-sticky thead tr th {
    position: sticky;
    top: var(--erp-header-h);
    z-index: 3;
}
.erp-sticky-wrap > .table-responsive { max-height: 70vh; }
.erp-table-scroll { max-height: 72vh; overflow-y: auto; }

/* Empty state inside a table */
.erp-empty {
    align-items: center;
    color: var(--erp-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    padding: var(--erp-sp-10) var(--erp-sp-5);
    text-align: center;
}
.erp-empty .erp-empty-icon {
    align-items: center;
    background: var(--erp-surface-3);
    border-radius: var(--erp-r-pill);
    color: #9aa3b6;
    display: inline-flex;
    height: 52px;
    justify-content: center;
    margin-bottom: 8px;
    width: 52px;
}
.erp-empty .erp-empty-icon i { font-size: 22px; }
.erp-empty .erp-empty-title {
    color: var(--erp-text);
    font-size: 14.5px;
    font-weight: 650;
}
.erp-empty .erp-empty-text { font-size: 13px; max-width: 420px; }
.erp-empty td { border: 0 !important; }
td.erp-empty-cell {
    border-bottom: 0 !important;
    color: var(--erp-muted) !important;
    font-size: 13px;
    padding: 34px 14px !important;
    text-align: center;
}

/* Row status tint */
.table tr.erp-row-muted td { color: var(--erp-muted); }
.table tr.erp-row-danger td { background: #fffafa; }

/* =====================================================================
   12. BADGES / PILLS / STATUS
   ===================================================================== */

.badge {
    border-radius: var(--erp-r-pill);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    padding: 4px 9px;
    vertical-align: middle;
}
.badge-primary, .badge-info { background: var(--erp-info-50); color: var(--erp-info-700); }
.badge-success { background: var(--erp-success-50); color: var(--erp-success-700); }
.badge-warning { background: var(--erp-warning-50); color: var(--erp-warning-700); }
.badge-danger { background: var(--erp-danger-50); color: var(--erp-danger-700); }
.badge-secondary, .badge-dark { background: var(--erp-surface-3); color: var(--erp-text-2); }
.badge-light { background: #fff; border: 1px solid var(--erp-border); color: var(--erp-text-2); }
.badge-pill { border-radius: var(--erp-r-pill); padding: 4px 10px; }

/* Page-specific legacy status badges (production/stock/bundle lists) speak the
   same language as the system pills. Only the appearance is normalised — the
   classes the PHP prints, and the values behind them, are untouched. */
.badge-full, .badge-available, .badge-in, .badge-active, .badge-paid {
    background: var(--erp-success-50); color: var(--erp-success-700);
}
.badge-partial, .badge-con, .badge-pending {
    background: var(--erp-warning-50); color: var(--erp-warning-700);
}
.badge-sold, .badge-merged, .badge-consumed {
    background: var(--erp-danger-50); color: var(--erp-danger-700);
}
.badge-opening, .badge-custom {
    background: var(--erp-info-50); color: var(--erp-info-700);
}
.badge-full, .badge-partial, .badge-available, .badge-sold,
.badge-in, .badge-con, .badge-custom, .badge-opening {
    border-radius: var(--erp-r-pill);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    padding: 4px 9px;
}

/* Required-field marker (added by erp.js only where the markup already has a
   `required` attribute — no validation behaviour changes). */
.erp-required::after {
    color: var(--erp-danger);
    content: " *";
    font-weight: 700;
}
.erp-required { font-weight: 600; }

/* Status pill with dot — generic + semantic auto-detection */
.erp-pill,
.role-badge {
    align-items: center;
    border: 1px solid transparent;
    border-radius: var(--erp-r-pill);
    display: inline-flex;
    font-size: 11.5px;
    font-weight: 650;
    gap: 6px;
    letter-spacing: .01em;
    padding: 4px 10px;
    white-space: nowrap;
}
.erp-pill::before {
    background: currentColor;
    border-radius: var(--erp-r-pill);
    content: "";
    height: 6px;
    opacity: .85;
    width: 6px;
}
.erp-pill--neutral { background: var(--erp-surface-3); color: var(--erp-text-2); }
.erp-pill--success { background: var(--erp-success-50); color: var(--erp-success-700); }
.erp-pill--warning { background: var(--erp-warning-50); color: var(--erp-warning-700); }
.erp-pill--danger  { background: var(--erp-danger-50);  color: var(--erp-danger-700); }
.erp-pill--info    { background: var(--erp-info-50);    color: var(--erp-info-700); }
.erp-pill--brand   { background: var(--erp-primary-50); color: var(--erp-primary-800); }

/* Role badges (userlist.php) keep their colours, restyled */
.role-badge.role-admin     { background: var(--erp-danger-50);  color: var(--erp-danger-700); }
.role-badge.role-operator  { background: var(--erp-info-50);    color: var(--erp-info-700); }
.role-badge.role-accountant{ background: var(--erp-success-50); color: var(--erp-success-700); }
.role-badge.role-manager   { background: var(--erp-accent-50);  color: var(--erp-accent-700); }
.role-badge { padding: 4px 10px; }

/* =====================================================================
   13. ALERTS / TOASTS / EMPTY STATES
   ===================================================================== */

.alert {
    align-items: flex-start;
    border: 1px solid;
    border-radius: var(--erp-r-sm);
    box-shadow: none;
    display: flex;
    font-size: 13.5px;
    gap: 10px;
    margin-bottom: var(--erp-sp-4);
    padding: 12px 15px;
    position: relative;
}
.alert::before {
    content: "\f05a";
    font-family: 'FontAwesome', sans-serif;
    font-size: 15px;
    line-height: 1.4;
    opacity: .9;
}
.alert-success { background: var(--erp-success-50); border-color: #c9ecdd; color: var(--erp-success-700); }
.alert-success::before { content: "\f058"; }
.alert-warning { background: var(--erp-warning-50); border-color: #f4dfb8; color: var(--erp-warning-700); }
.alert-warning::before { content: "\f071"; }
.alert-danger, .alert-error { background: var(--erp-danger-50); border-color: #f7cfcf; color: var(--erp-danger-700); }
.alert-danger::before, .alert-error::before { content: "\f06a"; }
.alert-info { background: var(--erp-info-50); border-color: #cbe6f8; color: var(--erp-info-700); }
.alert-dark, .alert-secondary { background: var(--erp-surface-3); border-color: var(--erp-border); color: var(--erp-text-2); }
.alert p { margin: 0; }
.alert a { color: inherit; font-weight: 650; text-decoration: underline; }
.alert-dismissible .close {
    color: inherit;
    opacity: .6;
    padding: 10px;
    position: absolute;
    right: 6px;
    top: 4px;
}
.alert-dismissible .close:hover { opacity: 1; }

/* Floating toasts (erp.js toast()) */
#erp-toasts {
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
    position: fixed;
    right: 20px;
    width: 340px;
    z-index: 1090;
}
.erp-toast {
    align-items: flex-start;
    animation: erpToastIn .22s cubic-bezier(.2, .8, .2, 1);
    background: #fff;
    border: 1px solid var(--erp-border);
    border-left: 3px solid var(--erp-primary);
    border-radius: var(--erp-r-sm);
    box-shadow: var(--erp-sh-3);
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    pointer-events: auto;
}
.erp-toast.erp-toast--success { border-left-color: var(--erp-success); }
.erp-toast.erp-toast--error   { border-left-color: var(--erp-danger); }
.erp-toast.erp-toast--warning { border-left-color: var(--erp-warning); }
.erp-toast .erp-toast-icon { color: var(--erp-primary); font-size: 15px; line-height: 1.4; }
.erp-toast--success .erp-toast-icon { color: var(--erp-success); }
.erp-toast--error .erp-toast-icon { color: var(--erp-danger); }
.erp-toast--warning .erp-toast-icon { color: var(--erp-warning); }
.erp-toast .erp-toast-body { flex: 1; min-width: 0; }
.erp-toast .erp-toast-title { color: var(--erp-text); font-size: 13.5px; font-weight: 650; }
.erp-toast .erp-toast-text { color: var(--erp-text-2); font-size: 12.5px; }
.erp-toast .erp-toast-close {
    background: transparent;
    border: 0;
    color: var(--erp-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
}
.erp-toast .erp-toast-close:hover { color: var(--erp-text); }
.erp-toast.erp-toast--out { animation: erpToastOut .18s ease forwards; }
@keyframes erpToastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes erpToastOut { to { opacity: 0; transform: translateY(6px); } }

/* =====================================================================
   14. NAV TABS / PILL TABS
   ===================================================================== */

.nav-tabs {
    border-bottom: 1px solid var(--erp-border);
    gap: 4px;
}
.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--erp-muted);
    font-size: 13.5px;
    font-weight: 600;
    padding: 10px 14px;
}
.nav-tabs .nav-link:hover { border-color: transparent; color: var(--erp-text); }
.nav-tabs .nav-link.active {
    background: transparent;
    border-color: var(--erp-primary);
    color: var(--erp-primary-700);
}
.erp-tabs {
    background: var(--erp-surface-3);
    border: 0;
    border-radius: var(--erp-r-sm);
    display: inline-flex;
    gap: 2px;
    padding: 3px;
}
.erp-tabs .nav-link {
    border: 0;
    border-radius: var(--erp-r-xs);
    color: var(--erp-text-2);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 13px;
}
.erp-tabs .nav-link.active { background: #fff; box-shadow: var(--erp-sh-1); color: var(--erp-text); }

/* =====================================================================
   15. PAGINATION
   ===================================================================== */

.pagination { gap: 4px; margin: 0; }
.page-link {
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-xs);
    color: var(--erp-text-2);
    font-size: 13px;
    font-weight: 600;
    min-width: 34px;
    padding: 6px 9px;
    text-align: center;
}
.page-link:hover { background: var(--erp-surface-3); border-color: var(--erp-border-strong); color: var(--erp-text); }
.page-item.active .page-link { background: var(--erp-primary); border-color: var(--erp-primary); color: #fff; }
.page-item.disabled .page-link { color: #b9c0ce; }
.dataTables_wrapper .dataTables_paginate .pagination { justify-content: flex-end; }
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--erp-muted); font-size: 12.5px; }
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--erp-border-strong);
    border-radius: var(--erp-r-xs);
    height: 34px;
    margin-left: 6px;
    padding: 5px 10px;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--erp-border-strong);
    border-radius: var(--erp-r-xs);
    height: 34px;
    padding: 4px 6px;
}

/* =====================================================================
   16. DROPDOWNS / MODALS / TOOLTIPS / PROGRESS
   ===================================================================== */

.dropdown-menu {
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-3);
    font-size: 13.5px;
    padding: 6px;
}
.dropdown-item {
    border-radius: var(--erp-r-xs);
    color: var(--erp-text-2);
    font-weight: 500;
    padding: 8px 11px;
}
.dropdown-item:hover, .dropdown-item:focus {
    background: var(--erp-primary-50) !important;
    color: var(--erp-primary-800) !important;
    text-decoration: none;
}
.dropdown-item.text-danger:hover { background: var(--erp-danger-50) !important; color: var(--erp-danger-700) !important; }
.dropdown-divider { border-color: var(--erp-border); margin: 5px 4px; }
.dropdown-header {
    color: var(--erp-muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 8px 11px 4px;
    text-transform: uppercase;
}

.modal-content {
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-lg);
    box-shadow: var(--erp-sh-3);
    overflow: hidden;
}
.modal-header {
    align-items: center;
    border-bottom: 1px solid var(--erp-border);
    padding: 16px var(--erp-sp-5);
}
.modal-title { font-size: 15px; font-weight: 650; }
.modal-body { padding: var(--erp-sp-5); }
.modal-footer {
    border-top: 1px solid var(--erp-border);
    gap: 8px;
    padding: 14px var(--erp-sp-5);
}
.modal-backdrop.show { background: rgba(12, 15, 22, .55); opacity: 1; }
.modal-header .close { color: var(--erp-muted); opacity: 1; text-shadow: none; }
.modal-header .close:hover { color: var(--erp-text); }

.tooltip { font-family: var(--erp-font); font-size: 12px; }
.tooltip-inner {
    background: var(--erp-text);
    border-radius: var(--erp-r-xs);
    box-shadow: var(--erp-sh-2);
    color: #fff;
    padding: 5px 9px;
}
.bs-tooltip-top .arrow::before { border-top-color: var(--erp-text); }
.bs-tooltip-bottom .arrow::before { border-bottom-color: var(--erp-text); }
.bs-tooltip-left .arrow::before { border-left-color: var(--erp-text); }
.bs-tooltip-right .arrow::before { border-right-color: var(--erp-text); }

.progress { background: var(--erp-surface-3); border-radius: var(--erp-r-pill); height: 8px; }
.progress-bar { background: var(--erp-primary); border-radius: var(--erp-r-pill); }
.progress-bar.bg-success { background: var(--erp-success) !important; }
.progress-bar.bg-warning { background: var(--erp-warning) !important; }
.progress-bar.bg-danger { background: var(--erp-danger) !important; }

/* =====================================================================
   17. COMMAND PALETTE (Ctrl/⌘ + K)
   ===================================================================== */

#erp-palette {
    align-items: flex-start;
    background: rgba(12, 15, 22, .45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 11vh 16px 16px;
    position: fixed;
    z-index: 1095;
}
#erp-palette.erp-open { display: flex; }
#erp-palette .erp-palette-box {
    animation: erpPop .16s ease-out;
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-lg);
    box-shadow: var(--erp-sh-3);
    max-width: 560px;
    overflow: hidden;
    width: 100%;
}
#erp-palette .erp-palette-search {
    align-items: center;
    border-bottom: 1px solid var(--erp-border);
    display: flex;
    gap: 10px;
    padding: 13px 16px;
}
#erp-palette .erp-palette-search i { color: var(--erp-muted); font-size: 15px; }
#erp-palette .erp-palette-search input {
    border: 0;
    color: var(--erp-text);
    flex: 1;
    font-family: var(--erp-font);
    font-size: 14.5px;
    outline: 0;
    padding: 3px 0;
}
#erp-palette .erp-palette-list {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    padding: 8px;
}
#erp-palette .erp-palette-group {
    color: var(--erp-muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    padding: 10px 10px 5px;
    text-transform: uppercase;
}
#erp-palette .erp-palette-item {
    align-items: center;
    border-radius: var(--erp-r-sm);
    color: var(--erp-text-2);
    display: flex;
    gap: 10px;
    padding: 9px 11px;
    text-decoration: none;
}
#erp-palette .erp-palette-item i { color: var(--erp-muted); font-size: 14px; width: 16px; }
#erp-palette .erp-palette-item .erp-pi-hint {
    color: var(--erp-muted);
    font-size: 11.5px;
    margin-left: auto;
}
#erp-palette .erp-palette-item.erp-active,
#erp-palette .erp-palette-item:hover {
    background: var(--erp-primary-50);
    color: var(--erp-primary-800);
    text-decoration: none;
}
#erp-palette .erp-palette-item.erp-active i,
#erp-palette .erp-palette-item:hover i { color: var(--erp-primary); }
#erp-palette .erp-palette-empty {
    color: var(--erp-muted);
    font-size: 13px;
    padding: 26px 12px;
    text-align: center;
}
#erp-palette .erp-palette-foot {
    align-items: center;
    background: var(--erp-surface-2);
    border-top: 1px solid var(--erp-border);
    color: var(--erp-muted);
    display: flex;
    font-size: 11.5px;
    gap: 14px;
    padding: 9px 16px;
}
#erp-palette kbd {
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r-xs);
    color: var(--erp-text-2);
    font-family: var(--erp-font);
    font-size: 10.5px;
    padding: 1px 5px;
}

/* =====================================================================
   18. MISC COMPONENTS
   ===================================================================== */

.erp-mobile-fab { display: none; }

.erp-section-title {
    align-items: baseline;
    display: flex;
    gap: 10px;
    margin: 0 0 var(--erp-sp-4);
}
.erp-section-title h4 { font-size: 15px; font-weight: 650; margin: 0; }
.erp-section-title .erp-section-sub { color: var(--erp-muted); font-size: 12.5px; }

.erp-divider { border-top: 1px solid var(--erp-border); margin: var(--erp-sp-5) 0; }

.erp-skeleton {
    animation: erpShimmer 1.4s ease-in-out infinite;
    background: linear-gradient(90deg, #eef1f6 0%, #f7f9fc 50%, #eef1f6 100%);
    background-size: 200% 100%;
    border-radius: var(--erp-r-xs);
    min-height: 12px;
}
@keyframes erpShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Legacy dashboard / page helpers */
.chart-box {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: var(--erp-r);
    box-shadow: var(--erp-sh-1);
    height: 100%;
    padding: var(--erp-sp-5);
}
.chart-box h5 { font-size: 14.5px; font-weight: 650; margin-bottom: var(--erp-sp-3); }
.invoice-box { border: 1px solid var(--erp-border) !important; border-radius: var(--erp-r); padding: var(--erp-sp-6) !important; }
.mis-card-title { color: var(--erp-text); }
.mis-table th { background: var(--erp-surface-2); }
.mis-btn { border-radius: var(--erp-r-xs); font-size: 12.5px; padding: 6px 11px; }
.mis-badge { border-radius: var(--erp-r-pill); font-size: 11.5px; padding: 4px 10px; }
.skin-settings { display: none !important; }

/* Hide the template's demo customiser panel if injected late */
.skin-settings.active { display: none !important; }

/* Print helper buttons should not print */
.erp-no-print { }

/* =====================================================================
   19. RESPONSIVE — TABLET
   ===================================================================== */

@media (max-width: 1199.98px) {
    :root { --erp-content-max: 100%; }
    body > .page-wrapper > .content { padding: var(--erp-sp-5); }
}

@media (max-width: 991.98px) {
    /* The off-canvas drawer replaces the rail/expand behaviour entirely */
    body > .sidebar,
    body.mini-sidebar > .sidebar,
    body.mini-sidebar.expand-menu > .sidebar {
        bottom: 0;
        box-shadow: var(--erp-sh-3);
        left: 0;
        margin-left: 0;              /* legacy -225px offset */
        top: var(--erp-header-h);
        transform: translateX(-100%);
        transition: transform .26s cubic-bezier(.4, 0, .2, 1);
        width: min(88vw, 296px);
        z-index: 1041;
    }
    body.erp-nav-open > .sidebar { transform: translateX(0); }

    /* The legacy header-left goes full-width/absolute here — undo it */
    body > .header .header-left,
    body.mini-sidebar > .header .header-left,
    body.mini-sidebar.expand-menu > .header .header-left {
        padding: 0;
        position: static;
        text-align: left;
        width: auto;
    }
    body.mini-sidebar > .header .header-left .logo,
    body.mini-sidebar.expand-menu > .header .header-left .logo { display: flex; }

    body > .header #mobile_btn,
    body.mini-sidebar > .header #mobile_btn {
        color: var(--erp-text-2) !important;
        cursor: pointer;
        font-size: 17px !important;
        height: 40px;
        left: auto;
        line-height: 1;
        padding: 0;
        position: static;
        text-align: center;
        top: auto;
        z-index: auto;
    }

    /* Always show full labels inside the drawer */
    body.mini-sidebar > .sidebar .sidebar-menu li > a,
    body.mini-sidebar.expand-menu > .sidebar .sidebar-menu li > a {
        justify-content: flex-start;
        padding: 9px 10px;
    }
    body.mini-sidebar > .sidebar .sidebar-menu li > a span,
    body.mini-sidebar > .sidebar .sidebar-menu .menu-arrow,
    body.mini-sidebar.expand-menu > .sidebar .sidebar-menu li > a span,
    body.mini-sidebar.expand-menu > .sidebar .sidebar-menu .menu-arrow { display: inline-block; }
    body.mini-sidebar > .sidebar .erp-nav-label,
    body.mini-sidebar.expand-menu > .sidebar .erp-nav-label {
        background: transparent;
        height: auto;
        margin: 18px 0 7px;
        overflow: visible;
        padding: 0 10px;
        text-indent: 0;
    }
    body.mini-sidebar > .sidebar .sidebar-menu ul ul.erp-open,
    body.mini-sidebar.expand-menu > .sidebar .sidebar-menu ul ul.erp-open { display: block !important; }
    body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-role-card,
    body.mini-sidebar.expand-menu > .sidebar .erp-sidebar-footer .erp-role-card { display: block; }
    body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-logout,
    body.mini-sidebar.expand-menu > .sidebar .erp-sidebar-footer .erp-logout { justify-content: flex-start; }
    body.mini-sidebar > .sidebar .erp-sidebar-footer .erp-logout span { display: inline; }

    body > .page-wrapper,
    body.mini-sidebar > .page-wrapper { margin-left: 0; padding-left: 0; padding-right: 0; }

    body > .header #toggle_btn { display: none; }
    body > .header .erp-burger,
    body > .header #mobile_btn { display: inline-flex; }
    body > .header .erp-header-divider,
    body > .header .erp-header-context .erp-header-crumbs { display: none; }
    body > .header .erp-search-trigger { min-width: 0; width: 40px; justify-content: center; padding: 0; }
    body > .header .erp-search-trigger .erp-search-label,
    body > .header .erp-search-trigger .erp-kbd { display: none; }
    body > .header .erp-user-chip .erp-user-meta { display: none; }

    /* Tables: allow horizontal scroll inside the card instead of the page */
    .table-responsive { border: 0; }
    .erp-table-shell > .table-responsive { border-radius: 0; }

    .erp-form-actions { position: static; }
    .erp-form-actions .btn { flex: 1 1 auto; }
}

/* =====================================================================
   20. RESPONSIVE — MOBILE (real re-layout, not just shrinking)
   ===================================================================== */

@media (max-width: 767.98px) {
    :root { --erp-header-h: 58px; }

    body { font-size: 14px; }
    body > .header { padding: 0 12px; gap: 6px; }
    body > .header .header-left .logo img { height: 27px; max-height: 27px; }
    /* The page's own title block carries the context on small screens */
    body > .header .erp-header-context { display: none; }
    body > .header .user-menu.nav > li > a,
    body > .header .erp-burger,
    body > .header #mobile_btn { height: 40px; width: 40px; }

    /* 16px sides so Bootstrap's -15px row gutters can never overflow the page */
    body > .page-wrapper > .content,
    body > .page-wrapper .content,
    body > .page-wrapper .content.container-fluid { padding: 14px 16px 28px; }
    body > .page-wrapper .content .row { margin-left: -8px; margin-right: -8px; }
    body > .page-wrapper .content .row > [class*="col-"],
    body > .page-wrapper .content .form-row > [class*="col-"] { padding-left: 8px; padding-right: 8px; }

    h1 { font-size: 1.3rem; }
    h3 { font-size: 1.12rem; }
    .page-header { margin-bottom: var(--erp-sp-4); }
    .page-title, .page-header h3 { font-size: 1.14rem; }

    /* Touch targets */
    .btn { min-height: 42px; padding: 10px 15px; }
    .btn-sm { font-size: 12.5px; min-height: 38px; padding: 8px 12px; }
    .form-control, .custom-select { font-size: 16px; height: 46px; }  /* 16px prevents iOS zoom */
    .form-control-sm { font-size: 15px; height: 40px; }

    /* Cards & panels breathe less */
    .card, .erp-panel, .chart-box, .erp-table-shell { border-radius: var(--erp-r); margin-bottom: var(--erp-sp-4); }
    .card-header { padding: 13px 15px; }
    .card-body { padding: 15px; }
    .erp-panel, .chart-box { padding: 15px; }

    /* Forms stack into one column */
    .form-group.row > label,
    .form-group.row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
    .form-group.row > label { margin-bottom: 6px; }
    .form-group.row { margin-left: 0; margin-right: 0; }
    .form-group.row > [class*="col-"] { padding-left: 0; padding-right: 0; }
    .form-group.row > label.col-form-label { padding-left: 0; text-align: left !important; }
    .col-form-label { padding-bottom: 2px; text-align: left !important; }

    /* Auto filter bars → stacked, collapsible */
    .erp-filterbar { align-items: stretch; flex-direction: column; padding: 14px; }
    .erp-filterbar .erp-filter-field,
    .erp-filterbar .erp-filter-field.erp-fixed { flex: 1 1 auto; width: 100%; }
    .erp-filterbar .erp-filter-actions { width: 100%; }
    .erp-filterbar .erp-filter-actions .btn { flex: 1 1 0; }
    form.erp-filterbar > .btn,
    form.erp-filterbar > button,
    form.erp-filterbar > input[type="submit"],
    form.erp-filterbar > a.btn { align-self: stretch; width: 100%; }
    .erp-filter-toggle { display: inline-flex; margin-bottom: var(--erp-sp-3); width: 100%; }
    .erp-filter-toggle .erp-ft-count { margin-left: auto; }
    .erp-filters-collapsed { display: none !important; }

    /* KPI cards */
    .erp-kpi { padding: 15px; }
    .erp-kpi .erp-kpi-value { font-size: 1.4rem; }

    /* Action clusters wrap instead of overflowing */
    .erp-actions { justify-content: flex-start; }
    .card-header .erp-header-actions { margin-left: 0; width: 100%; }
    .card-header .erp-header-actions .btn { width: 100%; }

    /* Modals become sheets */
    .modal-dialog { margin: 8px; max-width: calc(100vw - 16px); }
    .modal-content { border-radius: var(--erp-r); }
    .modal-body { max-height: 66vh; overflow-y: auto; padding: 15px; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 auto; }

    /* Prevent page-level horizontal overflow from wide content */
    img, canvas, svg, iframe, video { max-width: 100%; }
    .table-responsive, .erp-table-scroll { overflow-x: auto; }

    /* Long text wraps correctly */
    td, th, .card-title, .page-title, .erp-kpi-label { overflow-wrap: anywhere; }
    .table td .btn { white-space: nowrap; }

    #erp-toasts { bottom: 12px; left: 12px; right: 12px; width: auto; }

    #erp-palette { padding: 56px 10px 10px; }
    #erp-palette .erp-palette-list { max-height: 62vh; }

    /* ---- MOBILE TABLE → CARD TRANSFORMATION ------------------------- */
    .erp-cards > .table-responsive,
    .erp-cards.erp-table-shell > .table-responsive { overflow: visible; }

    table.erp-cards-table { border-collapse: collapse; display: block; width: 100%; }
    table.erp-cards-table > thead,
    table.erp-cards-table > tbody,
    table.erp-cards-table > tfoot { display: block; width: 100%; }
    table.erp-cards-table > thead { display: none !important; }
    table.erp-cards-table > tbody > tr {
        display: flex;
        flex-direction: column;
    }
    table.erp-cards-table > tbody > tr > td,
    table.erp-cards-table > tfoot > tr > td {
        align-items: flex-start;
        border-bottom: 1px solid #f2f4f9 !important;
        border-top: 0 !important;
        display: flex;
        gap: 12px;
        justify-content: space-between;
        padding: 10px 14px !important;
        text-align: right;
        white-space: normal !important;
        width: 100% !important;
    }
    table.erp-cards-table > tbody > tr > td::before {
        color: var(--erp-muted);
        content: attr(data-erp-label);
        flex: 0 0 42%;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: .05em;
        line-height: 1.5;
        max-width: 42%;
        text-align: left;
        text-transform: uppercase;
        word-break: break-word;
    }
    table.erp-cards-table > tbody > tr > td.erp-cell-block {
        display: block;
        text-align: left;
    }
    table.erp-cards-table > tbody > tr > td.erp-cell-block::before {
        display: block;
        margin-bottom: 3px;
        max-width: none;
    }
    table.erp-cards-table > tbody > tr > td[data-erp-label=""]::before,
    table.erp-cards-table > tbody > tr > td.erp-no-label::before { content: none; }
    table.erp-cards-table > tbody > tr > td.erp-no-label { display: block; }
    table.erp-cards-table > tbody > tr > td.erp-cell-actions { padding-top: 12px !important; order: 999; }
    table.erp-cards-table > tbody > tr > td.erp-cell-actions::before { flex-basis: 30%; max-width: 30%; }
    table.erp-cards-table > tbody > tr > td.erp-cell-actions .erp-actions { flex: 1; justify-content: flex-end; }

    /* Chosen title cell becomes the card header (order only, DOM untouched) */
    table.erp-cards-table > tbody > tr > td.erp-card-title {
        background: var(--erp-surface-2);
        border-bottom: 1px solid var(--erp-border) !important;
        color: var(--erp-text);
        font-size: 14px;
        font-weight: 650;
        order: -1;
    }
    table.erp-cards-table > tbody > tr > td.erp-card-title::before { content: none; }
    table.erp-cards-table > tbody > tr > td.erp-card-title a { color: var(--erp-primary-700); text-decoration: none; }

    /* One card per row */
    table.erp-cards-table > tbody > tr {
        background: var(--erp-surface) !important;
        border: 1px solid var(--erp-border);
        border-radius: var(--erp-r);
        box-shadow: var(--erp-sh-1);
        margin-bottom: 12px;
        overflow: hidden;
    }
    table.erp-cards-table > tbody > tr:hover { background: var(--erp-surface) !important; }
    table.erp-cards-table > tbody > tr > td:last-child { border-bottom: 0 !important; }

    /* Empty-state tables are not card-ified */
    table.erp-cards-table.erp-has-empty > tbody > tr {
        background: transparent !important;
        border: 0;
        box-shadow: none;
    }
    table.erp-cards-table.erp-has-empty > tbody > tr > td { display: block; text-align: center; }
    table.erp-cards-table td[colspan] { display: block !important; text-align: center; }
    table.erp-cards-table td[colspan]::before { content: none; }

    /* DataTables UI stacks */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate { text-align: left; width: 100%; }
    .dataTables_wrapper .dataTables_filter input { width: 100%; margin: 6px 0 0; }
    .dataTables_wrapper .dataTables_paginate .pagination { justify-content: flex-start; flex-wrap: wrap; }

    /* Sticky table headers make no sense once rows are cards */
    table.erp-cards-table.erp-sticky thead tr th { position: static; }

    /* Bottom safe area for the floating action button */
    body.erp-has-fab > .page-wrapper > .content { padding-bottom: 86px; }
}

@media (max-width: 575.98px) {
    .erp-kpi .erp-kpi-value { font-size: 1.3rem; }
    .card-header { align-items: flex-start; flex-direction: column; }
    .card-header .erp-header-actions,
    .card-header .btn { width: 100%; }
    .erp-auto-pageheader { align-items: stretch; }
    .erp-auto-pageheader .erp-aph-actions { width: 100%; }
    .erp-auto-pageheader .erp-aph-actions .btn { width: 100%; }
}

/* =====================================================================
   21. LARGE DESKTOP
   ===================================================================== */

@media (min-width: 1600px) {
    body > .page-wrapper > .content { padding: var(--erp-sp-8); }
}

/* =====================================================================
   22. REDUCED MOTION
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* =====================================================================
   23. PRINT — print only the document, never the chrome
   ===================================================================== */

@media print {
    body { background: #fff !important; }
    body > .header,
    body > .sidebar,
    body > .sidebar-overlay,
    #erp-toasts,
    #erp-palette,
    .erp-mobile-fab,
    .erp-filter-toggle,
    .erp-no-print,
    .erp-actions,
    .btn { display: none !important; }
    body > .page-wrapper { margin: 0 !important; padding: 0 !important; }
    body > .page-wrapper > .content { max-width: none !important; padding: 0 !important; }
    .card, .erp-panel, .erp-table-shell, .chart-box {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        break-inside: avoid;
    }
    .table thead tr th {
        background: #f2f2f2 !important;
        color: #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    .table tbody tr { break-inside: avoid; }
    a[href]::after { content: none !important; }
    table.erp-cards-table { display: table !important; }
    table.erp-cards-table > thead { display: table-header-group !important; }
    table.erp-cards-table > tbody > tr { display: table-row !important; border: 0 !important; box-shadow: none !important; }
    table.erp-cards-table > tbody > tr > td { display: table-cell !important; border-bottom: 1px solid #e5e5e5 !important; text-align: left !important; }
    table.erp-cards-table > tbody > tr > td::before { content: none !important; display: none !important; }
    .col, [class*="col-"] { float: none !important; width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }
}
