/* =========================================================
   CraftGrid UI Theme
   Modern enterprise shell
   Sidebar + application navigation
   ========================================================= */

:root {
    /* -----------------------------------------------------
       Brand
       ----------------------------------------------------- */
    --cg-blue-950: #102F44;
    --cg-blue-900: #143D54;
    --cg-blue-850: #17415A;
    --cg-blue-800: #1D4D66;
    --cg-blue-700: #1769C2;
    --cg-blue-600: #1769C2;
    --cg-blue-500: #3F86D0;
    --cg-blue-100: #EAF3FB;
    --cg-blue-050: #F5F8FB;
    /* -----------------------------------------------------
       Sidebar
       ----------------------------------------------------- */
    --cg-sidebar: #143D54;
    --cg-sidebar-deep: #102F44;
    --cg-sidebar-hover: #1D4D66;
    --cg-sidebar-active: #1769C2;
    --cg-sidebar-border: rgba(255,255,255,.09);
    --cg-sidebar-text: #f4f7fb;
    --cg-sidebar-muted: #b8c6d8;
    --cg-sidebar-section: #8fa9c6;
    /* -----------------------------------------------------
       Application
       ----------------------------------------------------- */
    --cg-page: #F5F7F7;
    --cg-surface: #ffffff;
    --cg-border: #DCE4E8;
    --cg-text: #17324D;
    --cg-text-muted: #66788A;
    /* -----------------------------------------------------
       Accent
       ----------------------------------------------------- */
    --cg-brand-green: #16845B;
}


/* =========================================================
   Application Page
   ========================================================= */

html,
body {
    min-height: 100%;
}

body {
    background: var(--cg-page);
    color: var(--cg-text);
}


/* =========================================================
   Desktop Sidebar Container
   ---------------------------------------------------------
   The sidebar must occupy the full available viewport
   height below the top navbar.
   ========================================================= */

.craftgrid-app-shell {
    min-height: 0;
    height: calc(100vh - 72px);
    height: calc(100dvh - 72px);
    overflow: hidden;
}

.craftgrid-main-row {
    height: 100%;
    min-height: 0;
    align-items: stretch;
}

.desktop-sidebar {
    height: 100%;
    min-height: 0;
    align-self: stretch;
    overflow: hidden;
    flex: 0 0 var(--sidebar-width);
}


/* =========================================================
   Collapsible desktop sidebar
   ---------------------------------------------------------
   The existing navigation stays intact. On desktop it is hidden
   by default and opens as an overlay from the left. This is a
   presentation-only change.
   ========================================================= */

@media (min-width: 992px) {
    .craftgrid-app-shell {
        width: 100%;
    }

    .desktop-sidebar {
        position: fixed;
        top: 76px;
        left: 0;
        bottom: 0;
        z-index: 1040;
        width: var(--sidebar-width) !important;
        max-width: var(--sidebar-width);
        flex: none !important;
        transform: translateX(-100%);
        transition: transform .22s ease, box-shadow .22s ease;
        box-shadow: none;
        background: transparent;
        pointer-events: none;
    }

    .desktop-sidebar > .erp-sidebar {
        pointer-events: auto;
        height: 100%;
        box-shadow: 6px 0 22px rgba(15, 31, 56, .16);
    }

    body.craftgrid-sidebar-open .desktop-sidebar {
        transform: translateX(0);
        box-shadow: 6px 0 22px rgba(15, 31, 56, .16);
    }

    .craftgrid-sidebar-backdrop {
        position: fixed;
        inset: 76px 0 0;
        z-index: 1035;
        background: rgba(16, 47, 68, .10);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .22s ease, visibility .22s ease;
    }

    body.craftgrid-sidebar-open .craftgrid-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

}

/* =========================================================
   Sidebar
   ========================================================= */

.erp-sidebar {
    height: 100%;
    min-height: 0;
    background: linear-gradient( 180deg, var(--cg-sidebar-deep) 0%, var(--cg-sidebar) 100% );
    color: var(--cg-sidebar-text);
    border-right: 1px solid rgba(0,0,0,.12);
    box-shadow: 4px 0 18px rgba(15,31,56,.10);
    padding: 18px 12px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.22) transparent;
}


    /* Chrome / Edge scrollbar */

    .erp-sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .erp-sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .erp-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.22);
        border-radius: 999px;
    }

        .erp-sidebar::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,.35);
        }


/* =========================================================
   Sidebar Brand
   ========================================================= */

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--cg-sidebar-border);
}

.sidebar-brand-mark {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255,255,255,.10);
    color: #ffffff;
}

.sidebar-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.01em;
}


/* =========================================================
   Section Label
   ========================================================= */

.sidebar-section-label {
    padding: 10px 12px 8px;
    color: var(--cg-sidebar-section);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}


/* =========================================================
   Details / Summary
   ========================================================= */

.erp-sidebar summary {
    list-style: none;
}

    .erp-sidebar summary::-webkit-details-marker {
        display: none;
    }


/* =========================================================
   Sidebar Groups
   ========================================================= */

.sidebar-group {
    margin: 2px 0;
}


/* =========================================================
   Menu Items
   ========================================================= */

.sidebar-group-toggle,
.sidebar-link {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 9px;
    color: var(--cg-sidebar-text);
    text-decoration: none;
    transition: background-color .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}


.sidebar-group-toggle {
    justify-content: space-between;
    padding: 9px 12px;
    cursor: pointer;
    user-select: none;
}


.sidebar-link {
    padding: 9px 12px;
}


/* Inner content */

.sidebar-link-content {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}


/* Icons */

.sidebar-link i,
.sidebar-group-toggle i {
    flex: 0 0 auto;
    font-size: 1rem;
}


/* Text */

.sidebar-group-toggle > .sidebar-link-content > span,
.sidebar-link > span {
    font-size: .92rem;
    font-weight: 500;
}

/* Attention/count badges on navigation items */
.sidebar-nav-badge {
    flex: 0 0 auto;
    margin-left: auto;
    min-width: 28px;
    padding: 3px 8px;
    text-align: center;
    line-height: 1.25;
    font-size: .72rem !important;
    font-weight: 700 !important;
    white-space: nowrap;
}


/* =========================================================
   Hover
   ========================================================= */

.sidebar-group-toggle:hover,
.sidebar-link:hover {
    background: var(--cg-sidebar-hover);
    color: #ffffff;
}


.sidebar-group-toggle:hover {
    transform: translateX(1px);
}


/* =========================================================
   Chevron
   ========================================================= */

.sidebar-chevron {
    color: #91a8c2;
    font-size: .78rem !important;
    transition: transform .18s ease, color .18s ease;
}


.sidebar-group[open] > .sidebar-group-toggle > .sidebar-chevron {
    transform: rotate(90deg);
    color: #ffffff;
}


/* =========================================================
   Top-Level Icons
   ---------------------------------------------------------
   Keep different functional colors but use them more
   subtly against the navy sidebar.
   ========================================================= */

.sidebar-icon-dashboard {
    color: #60a5fa;
}

.sidebar-icon-setup {
    color: #fbbf24;
}

.sidebar-icon-buy {
    color: #34d399;
}

.sidebar-icon-stock {
    color: #38bdf8;
}

.sidebar-icon-sell {
    color: #2dd4bf;
}

.sidebar-icon-accounts {
    color: #a78bfa;
}

.sidebar-icon-administration {
    color: #fb7185;
}


/* =========================================================
   Nested Menu
   ========================================================= */

.sidebar-submenu {
    margin: 2px 0 5px 14px;
    padding: 2px 0 2px 11px;
    border-left: 1px solid rgba(145,168,194,.22);
}


.sidebar-nested > .sidebar-group-toggle {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
    color: var(--cg-sidebar-muted);
}


    .sidebar-nested > .sidebar-group-toggle > .sidebar-link-content > span {
        font-size: .86rem;
        font-weight: 600;
    }


    .sidebar-nested > .sidebar-group-toggle:hover {
        color: #ffffff;
    }


/* =========================================================
   Nested Links
   ========================================================= */

.sidebar-submenu-link {
    min-height: 38px;
    color: #c5d1df;
    padding-top: 7px;
    padding-bottom: 7px;
}


    .sidebar-submenu-link > span {
        font-size: .86rem !important;
        font-weight: 500 !important;
    }


    .sidebar-submenu-link > i {
        color: #8ea5be;
        width: 17px;
        text-align: center;
    }


    .sidebar-submenu-link:hover > i,
    .sidebar-submenu-link.active > i {
        color: #ffffff;
    }


/* =========================================================
   Active Navigation
   ========================================================= */

.sidebar-link.active {
    background: linear-gradient( 90deg, #24558f 0%, #1f4f87 100% );
    color: #ffffff;
    box-shadow: inset 3px 0 0 #8ec5ff, 0 4px 12px rgba(0,0,0,.16);
}


.sidebar-submenu-link.active {
    background: rgba(37,99,235,.30);
    box-shadow: inset 2px 0 0 #8ec5ff;
}


.sidebar-link.active > span,
.sidebar-link.active > i {
    color: #ffffff;
}


/* =========================================================
   Disabled / Coming Soon
   ========================================================= */

.sidebar-link.disabled {
    color: rgba(197,209,223,.46);
    cursor: default;
}


    .sidebar-link.disabled:hover {
        background: transparent;
        transform: none;
    }


    .sidebar-link.disabled > i {
        color: rgba(142,165,190,.40);
    }


/* =========================================================
   Sidebar Badge
   ========================================================= */

.sidebar-badge {
    margin-left: auto;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.08);
    color: #aebed0;
    font-size: .64rem;
    font-weight: 600;
}


/* =========================================================
   Top Navbar
   ========================================================= */

.navbar {
    min-height: 72px;
    border-bottom: 1px solid var(--cg-border);
    box-shadow: 0 2px 12px rgba(15,31,56,.06) !important;
    background: #ffffff !important;
}


/* =========================================================
   Brand
   ========================================================= */

.navbar-brand {
    display: inline-flex;
    align-items: center;
    color: var(--cg-blue-950) !important;
    letter-spacing: -.02em;
}


    .navbar-brand .bi-grid-3x3-gap-fill {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 10px;
        /*
       Keep the green as a subtle CraftGrid
       brand identity.
    */
        background: var(--cg-brand-green);
        color: #ffffff;
        font-size: 1rem;
    }


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

.navbar .btn-light {
    width: 42px;
    height: 42px;
    border: 1px solid var(--cg-border);
    background: #ffffff;
    border-radius: 11px;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}


    .navbar .btn-light:hover {
        background: var(--cg-blue-050);
        border-color: #cbd9eb;
        color: var(--cg-blue-700);
    }


/* =========================================================
   Navbar User Area
   ========================================================= */

.navbar .fw-semibold {
    color: var(--cg-blue-950);
}


/* =========================================================
   Main Content
   ========================================================= */

main {
    min-width: 0;
    background: var(--cg-page);
}


/* =========================================================
   Footer
   ========================================================= */

footer {
    background: #ffffff !important;
    border-color: var(--cg-border) !important;
}


/* =========================================================
   Full-height application shell
   ========================================================= */

@media (min-width: 992px) {
    .craftgrid-app-shell {
        height: calc(100vh - 72px);
        height: calc(100dvh - 72px);
    }

    .craftgrid-main-row {
        height: 100%;
        min-height: 0;
    }

    .desktop-sidebar,
    .desktop-sidebar > nav {
        height: 100%;
        min-height: 0;
    }
}

.craftgrid-mobile-sidebar {
    height: 100dvh;
}

#mobileSidebar .offcanvas-body {
    height: calc(100dvh - 56px);
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
}

#mobileSidebar .offcanvas-body > nav.erp-sidebar {
    height: 100%;
    min-height: 0;
}

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

@media (max-width: 991.98px) {

    /*
       Desktop sidebar is hidden by Bootstrap/layout.
       Mobile offcanvas gets its own full-height behavior.
    */

    .erp-sidebar {
        min-height: 0;
        height: 100%;
    }
}


@media (max-width: 575.98px) {

    .erp-sidebar {
        padding-left: 9px;
        padding-right: 9px;
    }

    .sidebar-group-toggle,
    .sidebar-link {
        min-height: 44px;
    }
}


/* =========================================================
   CraftGrid Dashboard
   Clean enterprise workspace
   ========================================================= */

.cg-dashboard-header {
    margin-bottom: 28px;
}

.cg-dashboard-kicker {
    margin-bottom: 6px;
    color: var(--cg-blue-700);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .10em;
    text-transform: uppercase;
}

.cg-dashboard-title {
    margin: 0;
    color: var(--cg-blue-950);
    font-size: clamp(2rem, 2.8vw, 2.65rem);
    font-weight: 650;
    letter-spacing: -.035em;
    line-height: 1.12;
}

.cg-dashboard-subtitle {
    margin: 10px 0 0;
    color: var(--cg-text-muted);
    font-size: .98rem;
}

/* Dashboard sections */

.cg-dashboard-section {
    margin-top: 30px;
}

    .cg-dashboard-section:first-of-type {
        margin-top: 0;
    }

.cg-dashboard-section-heading {
    margin-bottom: 14px;
}

.cg-dashboard-section-title {
    margin: 0;
    color: var(--cg-blue-950);
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: -.015em;
}

.cg-dashboard-section-subtitle {
    margin: 4px 0 0;
    color: var(--cg-text-muted);
    font-size: .88rem;
}

/* Quick action cards */

.cg-dashboard-card {
    height: 100%;
    padding: 20px;
    background: var(--cg-surface);
    border: 1px solid var(--cg-border);
    border-radius: 12px;
    box-shadow: 0 2px 7px rgba(15,31,56,.045);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

    .cg-dashboard-card:hover {
        border-color: #cbd9eb;
        box-shadow: 0 7px 20px rgba(15,31,56,.08);
        transform: translateY(-1px);
    }

.cg-dashboard-card-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    border-radius: 10px;
    background: var(--cg-blue-050);
    color: var(--cg-blue-600);
    font-size: 1rem;
}

.cg-dashboard-card-title {
    margin: 0;
    color: var(--cg-blue-950);
    font-size: 1rem;
    font-weight: 650;
}

.cg-dashboard-card-text {
    min-height: 42px;
    margin: 7px 0 13px;
    color: var(--cg-text-muted);
    font-size: .86rem;
    line-height: 1.5;
}

.cg-dashboard-card-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--cg-blue-600);
    font-size: .84rem;
    font-weight: 600;
    text-decoration: none;
}

    .cg-dashboard-card-link::after {
        content: "→";
        transition: transform .16s ease;
    }

    .cg-dashboard-card-link:hover {
        color: var(--cg-blue-700);
    }

        .cg-dashboard-card-link:hover::after {
            transform: translateX(3px);
        }

/* Business area cards */

.cg-dashboard-area {
    height: 100%;
    padding: 18px 20px;
    background: var(--cg-surface);
    border: 1px solid var(--cg-border);
    border-radius: 12px;
    box-shadow: 0 2px 7px rgba(15,31,56,.04);
}

.cg-dashboard-area-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 9px;
    background: var(--cg-blue-050);
    color: var(--cg-blue-600);
}

.cg-dashboard-area-title {
    margin: 0;
    color: var(--cg-blue-950);
    font-size: 1.08rem;
    font-weight: 650;
}

.cg-dashboard-area-description {
    margin: 4px 0 11px;
    color: var(--cg-text-muted);
    font-size: .82rem;
}

.cg-dashboard-area-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    row-gap: 1px;
}

@media (max-width: 575.98px) {
    .cg-dashboard-area-links {
        grid-template-columns: 1fr;
    }
}

.cg-dashboard-area-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 32px;
    padding: 5px 9px;
    margin: 0 -9px;
    border-radius: 7px;
    color: var(--cg-text);
    font-size: .86rem;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

    .cg-dashboard-area-link::after {
        content: "→";
        color: #91a0b3;
        opacity: 0;
        transform: translateX(-3px);
        transition: opacity .15s ease, transform .15s ease;
    }

    .cg-dashboard-area-link:hover {
        background: var(--cg-blue-050);
        color: var(--cg-blue-700);
    }

        .cg-dashboard-area-link:hover::after {
            opacity: 1;
            transform: translateX(0);
        }

    .cg-dashboard-area-link strong {
        font-weight: 600;
    }

    /* Coming soon items */

    .cg-dashboard-area-link.disabled {
        color: var(--cg-text-muted);
        cursor: default;
    }

        .cg-dashboard-area-link.disabled:hover {
            background: transparent;
            color: var(--cg-text-muted);
        }

/* Responsive dashboard */

@media (max-width: 991.98px) {
    .cg-dashboard-header {
        margin-bottom: 24px;
    }

    .cg-dashboard-section {
        margin-top: 26px;
    }
}

@media (max-width: 575.98px) {
    .cg-dashboard-title {
        font-size: 1.9rem;
    }

    .cg-dashboard-card,
    .cg-dashboard-area {
        padding: 17px;
    }
}

/* ==========================================================
   Flexible Sidebar / Favorite Modules
   ========================================================== */

.sidebar-modules {
    display: flex;
    flex-direction: column;
}

.sidebar-favorite-button {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin-left: auto;
    margin-right: 6px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--cg-sidebar-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: .55;
    transition: background-color .15s ease, color .15s ease, opacity .15s ease;
}

    .sidebar-favorite-button:hover,
    .sidebar-favorite-button:focus-visible {
        background: rgba(255, 255, 255, .10);
        color: #ffd76a;
        opacity: 1;
        outline: none;
    }

    .sidebar-favorite-button.is-favorite {
        color: #ffd76a;
        opacity: 1;
    }

        .sidebar-favorite-button.is-favorite i::before {
            content: "\f586";
        }

.sidebar-group[data-cg-module].is-favorite > .sidebar-group-toggle {
    background: rgba(255, 255, 255, .035);
}

@media (max-width: 991.98px) {
    .sidebar-favorite-button {
        width: 36px;
        height: 36px;
        margin-right: 8px;
    }
}


/* =========================================================
   CraftGrid Login-Inspired Authenticated Workspace
   ---------------------------------------------------------
   Uses the same visual language as the login page:
   deep navy + CraftGrid green + warm gold, soft surfaces,
   rounded cards and restrained shadows.
   This layer is presentation-only and does not change
   application/business behavior.
   ========================================================= */

.craftgrid-authenticated-shell {
    --cg-login-navy: #15374d;
    --cg-login-navy-deep: #0f2940;
    --cg-login-green: #078a63;
    --cg-login-green-bright: #07976c;
    --cg-login-green-soft: #eaf8f2;
    --cg-login-gold: #f0b92d;
    --cg-login-page: #f5fbf8;
    --cg-login-border: #dbe7e2;
    --cg-login-muted: #74879a;
    background:
        radial-gradient(circle at 92% 8%, rgba(7,138,99,.055), transparent 24%),
        linear-gradient(135deg, #f8fcfa 0%, #f5faf8 55%, #f8fbfa 100%);
}

/* Top bar becomes the visual anchor, matching login branding. */
.craftgrid-authenticated-shell .craftgrid-topbar,
.craftgrid-authenticated-shell .navbar {
    min-height: 76px;
    background: linear-gradient(135deg, #102d44 0%, #15374d 62%, #17415a 100%) !important;
    border-bottom: 0 !important;
    box-shadow: 0 7px 24px rgba(15,41,64,.16) !important;
}

.craftgrid-authenticated-shell .craftgrid-topbar .container-fluid {
    min-height: 76px;
}

.craftgrid-authenticated-shell .navbar-brand {
    color: #fff !important;
    gap: 10px;
}

.craftgrid-authenticated-shell .cg-brand-grid-mark {
    width: 39px;
    height: 39px;
    display: grid !important;
    grid-template-columns: repeat(3,1fr);
    gap: 2.5px;
    padding: 6px;
    border-radius: 11px;
    background: rgba(255,255,255,.10) !important;
}

.craftgrid-authenticated-shell .cg-brand-grid-mark span {
    border-radius: 2.5px;
    background: var(--cg-login-gold);
}

.craftgrid-authenticated-shell .cg-brand-copy {
    display: inline-flex;
    flex-direction: column;
    line-height: 1;
}

.craftgrid-authenticated-shell .cg-brand-copy strong {
    font-size: 1.16rem;
    letter-spacing: -.035em;
    color: #fff;
}

.craftgrid-authenticated-shell .cg-brand-copy strong span {
    color: #55c99f;
}

.craftgrid-authenticated-shell .cg-brand-copy small {
    margin-top: 5px;
    color: rgba(255,255,255,.55);
    font-size: .50rem;
    font-weight: 700;
    letter-spacing: .16em;
}

.craftgrid-authenticated-shell .craftgrid-topbar .text-muted {
    color: rgba(255,255,255,.58) !important;
}

.craftgrid-authenticated-shell .craftgrid-topbar .vr {
    color: rgba(255,255,255,.18);
    opacity: 1;
}

.craftgrid-authenticated-shell .craftgrid-icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.14) !important;
    border-radius: 12px;
    background: rgba(255,255,255,.08) !important;
    color: #fff !important;
}

.craftgrid-authenticated-shell .craftgrid-icon-button:hover {
    background: rgba(255,255,255,.15) !important;
    border-color: rgba(255,255,255,.22) !important;
}

.craftgrid-authenticated-shell .craftgrid-user-button {
    min-height: 48px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 13px;
    padding: 4px 9px 4px 5px;
    color: #fff;
    background: rgba(255,255,255,.07);
}

.craftgrid-authenticated-shell .craftgrid-user-button:hover,
.craftgrid-authenticated-shell .craftgrid-user-button:focus {
    color: #fff;
    background: rgba(255,255,255,.13);
    border-color: rgba(255,255,255,.20);
}

.craftgrid-authenticated-shell .craftgrid-avatar {
    background: var(--cg-login-green) !important;
    border: 2px solid rgba(255,255,255,.25);
}

.craftgrid-authenticated-shell .craftgrid-user-name {
    color: #fff !important;
}

.craftgrid-authenticated-shell .craftgrid-user-role {
    color: rgba(255,255,255,.58) !important;
}

/* Sidebar carries the same navy family, with green active state. */
.craftgrid-authenticated-shell .erp-sidebar {
    background: linear-gradient(180deg, #102d44 0%, #15374d 58%, #122f46 100%);
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 5px 0 22px rgba(15,41,64,.13);
}

.craftgrid-authenticated-shell .sidebar-link.active {
    background: linear-gradient(90deg, #087f5b 0%, #07976c 100%);
    box-shadow: inset 3px 0 0 #f0b92d, 0 6px 16px rgba(7,143,103,.18);
}

.craftgrid-authenticated-shell .sidebar-submenu-link.active {
    background: rgba(7,151,108,.27);
    box-shadow: inset 2px 0 0 #55c99f;
}

/* Main workspace: airy, light and closer to the login background. */
.craftgrid-authenticated-shell .craftgrid-app-shell main {
    background: transparent;
}

.craftgrid-authenticated-shell .craftgrid-app-shell main > .container-fluid {
    padding-top: 30px !important;
    padding-bottom: 38px !important;
}

.craftgrid-authenticated-shell .card {
    border: 1px solid var(--cg-login-border);
    border-radius: 17px;
    box-shadow: 0 8px 26px rgba(27,66,59,.055);
}

.craftgrid-authenticated-shell .card-header {
    background: rgba(255,255,255,.72);
    border-bottom: 1px solid #e6eeea;
    color: var(--cg-login-navy);
    font-weight: 700;
}

.craftgrid-authenticated-shell .table-responsive {
    border-radius: 14px;
}

.craftgrid-authenticated-shell .table {
    --bs-table-border-color: #e7eeeb;
}

.craftgrid-authenticated-shell .table thead th {
    background: #f4faf7;
    color: #486476;
    font-size: .74rem;
    font-weight: 750;
    letter-spacing: .045em;
    text-transform: uppercase;
    border-bottom-color: #dce9e4;
}

.craftgrid-authenticated-shell .table tbody tr:hover {
    background: #f8fcfa;
}

/* Forms use the same soft controls as the login page. */
.craftgrid-authenticated-shell .form-control,
.craftgrid-authenticated-shell .form-select,
.craftgrid-authenticated-shell .input-group-text {
    border-color: #dbe6e2;
    border-radius: 11px;
    min-height: 42px;
}

.craftgrid-authenticated-shell .form-control:focus,
.craftgrid-authenticated-shell .form-select:focus {
    border-color: #38a981;
    box-shadow: 0 0 0 .2rem rgba(56,169,129,.12);
}

.craftgrid-authenticated-shell .form-label {
    color: #304b5e;
    font-size: .82rem;
    font-weight: 650;
}

/* Primary actions inherit CraftGrid green. */
.craftgrid-authenticated-shell .btn-primary {
    --bs-btn-bg: #078a63;
    --bs-btn-border-color: #078a63;
    --bs-btn-hover-bg: #067955;
    --bs-btn-hover-border-color: #067955;
    --bs-btn-active-bg: #066d4e;
    --bs-btn-active-border-color: #066d4e;
    border-radius: 10px;
    font-weight: 650;
    box-shadow: 0 6px 15px rgba(7,143,103,.13);
}

.craftgrid-authenticated-shell .btn-outline-primary {
    --bs-btn-color: #078a63;
    --bs-btn-border-color: #9bcdbb;
    --bs-btn-hover-bg: #078a63;
    --bs-btn-hover-border-color: #078a63;
    --bs-btn-hover-color: #fff;
    border-radius: 10px;
    font-weight: 650;
}

.craftgrid-authenticated-shell .badge.bg-primary {
    background-color: #078a63 !important;
}

/* Headings throughout the ERP pick up the login typography. */
.craftgrid-authenticated-shell h1,
.craftgrid-authenticated-shell h2,
.craftgrid-authenticated-shell h3,
.craftgrid-authenticated-shell h4,
.craftgrid-authenticated-shell h5 {
    color: var(--cg-login-navy);
    letter-spacing: -.025em;
}

.craftgrid-authenticated-shell a {
    color: #078a63;
}

.craftgrid-authenticated-shell a:hover {
    color: #066d4e;
}

/* Bootstrap buttons can also be anchors. Keep their label/icon color
   independent from the global authenticated-link color. */
.craftgrid-authenticated-shell .btn-primary,
.craftgrid-authenticated-shell .btn-primary:hover,
.craftgrid-authenticated-shell .btn-primary:focus,
.craftgrid-authenticated-shell .btn-primary:active,
.craftgrid-authenticated-shell .btn-primary:visited {
    color: #ffffff !important;
}

.craftgrid-authenticated-shell .btn-success,
.craftgrid-authenticated-shell .btn-success:hover,
.craftgrid-authenticated-shell .btn-success:focus,
.craftgrid-authenticated-shell .btn-success:active,
.craftgrid-authenticated-shell .btn-success:visited {
    color: #ffffff !important;
}

/* Alerts retain semantic colors but gain the softer visual language. */
.craftgrid-authenticated-shell .alert {
    border-radius: 13px;
    border-width: 1px;
}

/* Mobile header remains compact without changing navigation behavior. */
@media (max-width: 575.98px) {
    .craftgrid-authenticated-shell .craftgrid-topbar,
    .craftgrid-authenticated-shell .craftgrid-topbar .container-fluid {
        min-height: 64px;
    }

    .craftgrid-authenticated-shell .cg-brand-grid-mark {
        width: 34px;
        height: 34px;
    }

    .craftgrid-authenticated-shell .cg-brand-copy small {
        display: none;
    }

    .craftgrid-authenticated-shell .craftgrid-app-shell main > .container-fluid {
        padding-left: 14px !important;
        padding-right: 14px !important;
        /* Keep page titles/forms clear of the compact mobile topbar. */
        padding-top: 32px !important;
    }
}


/* =========================================================
   CraftGrid mobile navigation
   Keep the authenticated/login visual identity and make the
   navigation trigger clearly visible on small screens.
   ========================================================= */

.craftgrid-authenticated-shell .craftgrid-mobile-menu {
    display: inline-flex;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: 10px !important;
    border: 1px solid rgba(255,255,255,.18) !important;
    border-radius: 12px;
    background: rgba(255,255,255,.09) !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

.craftgrid-authenticated-shell .craftgrid-mobile-menu i {
    font-size: 1.25rem;
    line-height: 1;
}

.craftgrid-authenticated-shell .craftgrid-mobile-menu:hover,
.craftgrid-authenticated-shell .craftgrid-mobile-menu:focus,
.craftgrid-authenticated-shell .craftgrid-mobile-menu:active {
    background: rgba(255,255,255,.16) !important;
    border-color: rgba(255,255,255,.28) !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 .15rem rgba(255,255,255,.08) !important;
}

.craftgrid-authenticated-shell .craftgrid-mobile-menu:focus-visible {
    outline: 2px solid rgba(216,177,90,.9);
    outline-offset: 2px;
}

/* The off-canvas navigation should look like the same shell,
   rather than a generic Bootstrap dark panel. */
.craftgrid-authenticated-shell .craftgrid-mobile-sidebar {
    width: min(300px, 86vw);
    background: linear-gradient(180deg, #102d44 0%, #15374d 100%) !important;
    border-right: 1px solid rgba(255,255,255,.10);
}

.craftgrid-authenticated-shell .craftgrid-mobile-sidebar .offcanvas-header {
    min-height: 64px;
    padding: 12px 16px;
    background: rgba(0,0,0,.10);
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.craftgrid-authenticated-shell .craftgrid-mobile-sidebar .offcanvas-title {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -.02em;
}

@media (max-width: 575.98px) {
    .craftgrid-authenticated-shell .craftgrid-mobile-menu {
        width: 40px;
        height: 40px;
        margin-right: 8px !important;
    }

    .craftgrid-authenticated-shell .craftgrid-mobile-menu i {
        font-size: 1.18rem;
    }

    /* Give the brand enough room while keeping the notification
       and profile controls visible. */
    .craftgrid-authenticated-shell .craftgrid-topbar .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .craftgrid-authenticated-shell .craftgrid-brand-copy strong {
        font-size: 1.02rem;
    }

    .craftgrid-authenticated-shell .craftgrid-icon-button {
        width: 40px;
        height: 40px;
    }

    .craftgrid-authenticated-shell .craftgrid-user-button {
        min-height: 44px;
        padding-right: 7px;
    }
}


/* Delivery action menus: keep them above the table/card chrome. */
.craftgrid-authenticated-shell .dropdown-menu {
    z-index: 1080;
}


/* =========================================================
   Deliveries work-queue hierarchy
   Purple = Sales Orders that still need a Delivery document.
   Green = Delivery documents that can be processed/dispatched now.
   Keep the color treatment intentionally soft so it remains
   readable outdoors and does not turn the page into a dashboard of
   competing colors.
   ========================================================= */

.craftgrid-authenticated-shell .craftgrid-delivery-work-panel {
    overflow: hidden;
    border-radius: 16px;
    border-width: 1px;
    border-style: solid;
}

.craftgrid-authenticated-shell .craftgrid-delivery-work-panel .card-header {
    padding: 15px 18px 13px;
    background: transparent;
    border-bottom: 1px solid rgba(15, 43, 68, .08);
}

.craftgrid-authenticated-shell .craftgrid-work-panel-title {
    display: inline-flex;
    align-items: center;
    color: var(--cg-login-navy);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.015em;
}

.craftgrid-authenticated-shell .craftgrid-work-panel-title i {
    font-size: 1.05rem;
}

/* Sales Orders Ready to Create — planning/create stage */
.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel {
    border-color: rgba(124, 58, 237, .25);
    background: linear-gradient(135deg, rgba(124, 58, 237, .075), rgba(139, 92, 246, .025));
}

.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .card-header {
    border-left: 4px solid #7c3aed;
    padding-left: 14px;
}

.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .craftgrid-work-panel-title i {
    color: #7c3aed;
}

.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .badge.text-bg-light {
    color: #6d28d9 !important;
    background: rgba(124, 58, 237, .10) !important;
    border-color: rgba(124, 58, 237, .22) !important;
}

.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .list-group-item {
    background: rgba(255,255,255,.78);
    border-color: rgba(124, 58, 237, .10);
}

.craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .list-group-item:last-child {
    border-bottom: 0;
}

.craftgrid-authenticated-shell .craftgrid-ready-create-button {
    background: #7c3aed;
    border-color: #7c3aed;
}

.craftgrid-authenticated-shell .craftgrid-ready-create-button:hover,
.craftgrid-authenticated-shell .craftgrid-ready-create-button:focus {
    background: #6d28d9;
    border-color: #6d28d9;
    color: #fff !important;
}

/* Delivery documents — operational/dispatch stage */
.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel {
    border-color: rgba(5, 150, 105, .25);
    background: linear-gradient(135deg, rgba(5, 150, 105, .075), rgba(16, 185, 129, .025));
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .card-header {
    border-left: 4px solid #059669;
    padding-left: 14px;
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .craftgrid-work-panel-title i {
    color: #059669;
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .badge.text-bg-light {
    color: #047857 !important;
    background: rgba(5, 150, 105, .10) !important;
    border-color: rgba(5, 150, 105, .22) !important;
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .table {
    --bs-table-bg: transparent;
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .craftgrid-delivery-dispatch-thead th {
    background: rgba(5, 150, 105, .075);
    border-bottom-color: rgba(5, 150, 105, .14);
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel tbody tr {
    background: rgba(255,255,255,.84);
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel tbody tr:hover {
    background: rgba(5, 150, 105, .045);
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .btn-outline-primary {
    border-color: rgba(5, 150, 105, .45);
    color: #047857;
}

.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .btn-outline-primary:hover,
.craftgrid-authenticated-shell .craftgrid-delivery-dispatch-panel .btn-outline-primary:focus {
    background: #059669;
    border-color: #059669;
    color: #fff !important;
}


/* Compact Deliveries filter bar: keep all controls in one row on desktop. */
.craftgrid-authenticated-shell .craftgrid-delivery-filter-body {
    padding: 14px 18px !important;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 2.2fr) minmax(150px, 1.25fr) minmax(145px, 1.2fr) minmax(155px, 1.25fr) minmax(105px, .75fr) minmax(105px, .75fr) auto auto;
    gap: 10px;
    align-items: end;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-field {
    min-width: 0;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-field .form-label {
    margin-bottom: 5px;
    font-size: .78rem;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-grid .form-control,
.craftgrid-authenticated-shell .craftgrid-delivery-filter-grid .form-select {
    min-height: 42px;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-actions {
    display: contents;
}

.craftgrid-authenticated-shell .craftgrid-delivery-filter-actions .btn {
    min-height: 42px;
    white-space: nowrap;
    padding-inline: 15px;
}

@media (max-width: 1199.98px) {
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-grid > .craftgrid-delivery-filter-field:first-child {
        grid-column: span 2;
    }
}

@media (max-width: 767.98px) {
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-body {
        padding: 12px 14px !important;
    }
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-grid {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-grid > .craftgrid-delivery-filter-field:first-child {
        grid-column: 1 / -1;
    }
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-actions {
        display: flex;
        grid-column: 1 / -1;
        gap: 8px;
    }
    .craftgrid-authenticated-shell .craftgrid-delivery-filter-actions .btn {
        flex: 1;
    }
}

/* Keep the two panels visually distinct on small screens without
   increasing horizontal scrolling. */
@media (max-width: 767.98px) {
    .craftgrid-authenticated-shell .craftgrid-delivery-work-panel .card-header {
        padding: 13px 14px 11px;
    }

    .craftgrid-authenticated-shell .craftgrid-delivery-ready-panel .list-group-item {
        padding: 13px 14px !important;
    }
}


/* Compact delivery status selector: the KPI cards themselves are the tabs.
   This removes the duplicated tab-button row and gives the work queue more
   vertical space. */
.craftgrid-authenticated-shell .craftgrid-delivery-status-cards {
    margin-bottom: 8px !important;
}

.craftgrid-authenticated-shell .craftgrid-delivery-status-cards > div > a {
    display: block;
    height: 100%;
}

.craftgrid-authenticated-shell .craftgrid-delivery-status-cards .card {
    min-height: 62px;
    border-radius: 14px;
}

.craftgrid-authenticated-shell .craftgrid-delivery-status-cards .card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.craftgrid-authenticated-shell .craftgrid-delivery-status-cards .small {
    line-height: 1.15;
}

.craftgrid-authenticated-shell .craftgrid-delivery-status-cards .fs-5 {
    line-height: 1.05;
    margin-top: 2px;
}

@media (max-width: 767.98px) {
    .craftgrid-authenticated-shell .craftgrid-delivery-status-cards .card {
        min-height: 58px;
    }
}

/* =========================================================
   Items - mobile card layout
   Keeps the desktop table intact while making item records
   readable and actionable on narrow screens.
   ========================================================= */
@media (max-width: 767.98px) {
    .cg-items-table-wrap {
        overflow: visible !important;
    }

    .cg-items-table {
        display: block;
        width: 100%;
    }

    .cg-items-table thead {
        display: none;
    }

    .cg-items-table tbody,
    .cg-items-table tr {
        display: block;
        width: 100%;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) {
        margin: 0 0 12px;
        padding: 13px 14px;
        border: 1px solid var(--cg-border, #d9e5e1);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15, 55, 45, .07);
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        width: 100%;
        padding: 6px 0;
        border: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td::before {
        content: attr(data-label);
        font-size: .72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #617b76;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td:nth-child(2) strong {
        font-size: 1rem;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td:last-child {
        display: flex;
        justify-content: flex-end;
        gap: 7px;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid #e6eeeb !important;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td:last-child::before {
        display: none;
    }

    .cg-items-table tbody tr:not(.cg-items-empty) td:last-child .btn {
        min-width: 42px;
        min-height: 38px;
    }

    .cg-items-table tbody tr.cg-items-empty td {
        display: block;
        border: 0 !important;
    }

    .cg-items-table tbody tr.cg-items-empty td::before {
        display: none;
    }

    .cg-items-table tfoot,
    .cg-items-table + * {
        max-width: 100%;
    }

    .cg-items-filter .row {
        row-gap: 10px;
    }
}


/* BOM component rows: comfortable on mobile without changing desktop table layout. */
.bom-lines-table .bom-line-actions {
    text-align: center;
    white-space: nowrap;
}
.bom-lines-table .remove-bom-line {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bom-lines-footer .text-muted {
    line-height: 1.4;
}

@media (max-width: 767.98px) {
    .bom-lines-responsive {
        overflow: visible;
    }

    .bom-lines-table {
        display: block;
        border: 0;
    }

    .bom-lines-table thead {
        display: none;
    }

    .bom-lines-table tbody,
    .bom-lines-table tr {
        display: block;
        width: 100%;
    }

    .bom-lines-table tbody tr {
        margin: 0;
        padding: 12px 14px;
        border: 0;
        border-bottom: 1px solid #e4ece8;
        background: #fff;
    }

    .bom-lines-table tbody tr td {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
        gap: 10px;
        align-items: center;
        width: 100%;
        padding: 5px 0;
        border: 0 !important;
        white-space: normal !important;
    }

    /* Give the component selector the full phone width so item names remain readable. */
    .bom-lines-table tbody tr td[data-label="Component"] {
        display: block;
        padding-top: 2px;
    }

    .bom-lines-table tbody tr td[data-label="Component"]::before {
        display: block;
        margin-bottom: 6px;
    }

    .bom-lines-table tbody tr td[data-label="Component"] .form-select {
        width: 100%;
    }

    .bom-lines-table tbody tr td[data-label="Notes"] {
        align-items: start;
    }

    .bom-lines-table tbody tr td::before {
        content: attr(data-label);
        font-size: .70rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #617b76;
    }

    .bom-lines-table tbody tr td:first-child {
        padding-top: 0;
    }

    .bom-lines-table tbody tr td:first-child .bom-line-number {
        font-weight: 700;
    }

    .bom-lines-table tbody tr .form-control,
    .bom-lines-table tbody tr .form-select {
        min-width: 0;
    }

    .bom-lines-table tbody tr .bom-line-actions {
        display: flex;
        justify-content: flex-end;
        padding-top: 9px;
        margin-top: 5px;
        border-top: 1px solid #e8efec !important;
    }

    .bom-lines-table tbody tr .bom-line-actions::before {
        display: none;
    }

    .bom-lines-footer {
        align-items: stretch !important;
        flex-direction: column;
        padding: 12px 14px !important;
    }

    .bom-lines-footer .btn {
        width: 100%;
    }
}


/* BOM page header responsiveness */
.bom-page-header-actions,
.bom-detail-actions {
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .bom-page-header,
    .bom-detail-page-header {
        align-items: flex-start !important;
        gap: 12px;
    }

    .bom-page-header > div:first-child,
    .bom-detail-page-header > div:first-child {
        min-width: 0;
        flex: 1 1 auto;
    }

    .bom-page-header h2,
    .bom-detail-page-header h2 {
        font-size: 1.55rem;
        line-height: 1.2;
    }

    .bom-page-header-actions,
    .bom-detail-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px !important;
        justify-content: flex-end;
    }

    .bom-detail-actions .btn,
    .bom-detail-actions form {
        margin: 0;
    }

    .bom-detail-actions form .btn {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .bom-page-header,
    .bom-detail-page-header {
        display: block !important;
    }

    .bom-page-header-actions,
    .bom-detail-actions {
        margin-top: 10px;
        justify-content: flex-start;
    }

    .bom-page-header-actions .btn,
    .bom-detail-actions .btn {
        min-width: 82px;
    }
}


/* BOM Details: mobile component cards keep each component readable without horizontal scrolling. */
.bom-detail-components-mobile {
    display: none;
}

@media (max-width: 767.98px) {
    .bom-detail-components-card .card-header {
        padding: 12px 16px;
    }

    .bom-detail-components-desktop {
        display: none;
    }

    .bom-detail-components-mobile {
        display: block;
    }

    .bom-detail-component-card {
        padding: 14px 16px;
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
        background: #fff;
    }

    .bom-detail-component-card:last-child {
        border-bottom: 0;
    }

    .bom-detail-component-top {
        display: flex;
        align-items: flex-start;
        gap: 12px;
    }

    .bom-detail-component-number {
        flex: 0 0 28px;
        font-size: .82rem;
        font-weight: 600;
        color: #6c7a7d;
        padding-top: 2px;
    }

    .bom-detail-component-name {
        min-width: 0;
        display: flex;
        flex-direction: column;
        line-height: 1.25;
    }

    .bom-detail-component-name strong {
        font-size: .95rem;
        color: #163b4d;
        overflow-wrap: anywhere;
    }

    .bom-detail-component-name span {
        margin-top: 3px;
        font-size: .82rem;
        color: #68777b;
        overflow-wrap: anywhere;
    }

    .bom-detail-component-metrics {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin: 12px 0 0 40px;
    }

    .bom-detail-component-metrics > div {
        min-width: 0;
        padding: 8px 9px;
        border: 1px solid #e1e8e7;
        border-radius: 9px;
        background: #f8fbfa;
    }

    .bom-detail-component-metrics span,
    .bom-detail-component-notes > span {
        display: block;
        font-size: .68rem;
        line-height: 1.15;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: #6b7d80;
    }

    .bom-detail-component-metrics strong {
        display: block;
        margin-top: 3px;
        font-size: .86rem;
        color: #183f50;
        overflow-wrap: anywhere;
    }

    .bom-detail-component-notes {
        margin: 10px 0 0 40px;
        font-size: .82rem;
        color: #56686d;
    }

    .bom-detail-component-notes > div {
        margin-top: 3px;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 380px) {
    .bom-detail-component-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .bom-detail-component-metrics > div:last-child {
        grid-column: 1 / -1;
    }
}


/* =========================================================
   Manufacturing Operations - mobile card layout
   Desktop keeps the normal table; mobile prioritizes
   operation code/name and removes repeated company clutter.
   ========================================================= */
@media (max-width: 767.98px) {
    .cg-operations-table-wrap {
        overflow: visible !important;
        background: transparent;
        box-shadow: none !important;
        border: 0 !important;
    }

    .cg-operations-table {
        display: block;
        width: 100%;
    }

    .cg-operations-table thead {
        display: none;
    }

    .cg-operations-table tbody,
    .cg-operations-table tr {
        display: block;
        width: 100%;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) {
        margin: 0 0 12px;
        padding: 12px 14px;
        border: 1px solid var(--cg-border, #d9e5e1);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15, 55, 45, .07);
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td {
        display: grid;
        grid-template-columns: 86px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        width: 100%;
        padding: 6px 0;
        border: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td::before {
        content: attr(data-label);
        font-size: .70rem;
        line-height: 1.25;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .045em;
        color: #617b76;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:first-child strong {
        font-size: 1rem;
        color: #123f55;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:nth-child(2) {
        font-weight: 600;
        color: #203b4a;
    }

    /* Company is already selected/scoped in the page; avoid repeating it in every card. */
    .cg-operations-table tbody tr:not(.cg-operations-empty) td:nth-child(3) {
        display: none;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:nth-child(4) {
        color: #526b70;
        line-height: 1.45;
    }

    .cg-operation-status {
        display: inline-flex;
        width: fit-content;
        align-items: center;
        padding: 3px 9px;
        border-radius: 999px;
        font-size: .75rem;
        font-weight: 700;
    }

    .cg-operation-status.is-active {
        background: #e4f6ee;
        color: #087a5b;
    }

    .cg-operation-status.is-inactive {
        background: #edf0f1;
        color: #68757a;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:last-child {
        display: flex;
        justify-content: flex-end;
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid #e6eeeb !important;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:last-child::before {
        display: none;
    }

    .cg-operations-table tbody tr:not(.cg-operations-empty) td:last-child .btn {
        min-width: 72px;
        min-height: 38px;
    }

    .cg-operations-table tbody tr.cg-operations-empty td {
        display: block;
        border: 0 !important;
    }

    .cg-operations-table tbody tr.cg-operations-empty td::before {
        display: none;
    }
}


/* =========================================================
   Manufacturing Routing - Mobile Process Lines
   ---------------------------------------------------------
   Keep the desktop routing table intact. On phones, each
   process line becomes a comfortable form card so the
   Sequence, Operation and Notes inputs are not squeezed
   into narrow table columns.
   ========================================================= */

@media (max-width: 767.98px) {
    .routing-lines-card thead {
        display: none;
    }

    .routing-lines-card .table-responsive {
        overflow: visible;
    }

    #routingLinesBody {
        display: block;
        padding: 10px 12px 2px;
    }

    #routingLinesBody tr.routing-line-card {
        display: block;
        margin: 0 0 12px;
        padding: 12px;
        border: 1px solid var(--cg-border);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(15,31,56,.06);
    }

    #routingLinesBody tr.routing-line-card:last-child {
        margin-bottom: 0;
    }

    #routingLinesBody tr.routing-line-card > td {
        display: block;
        width: 100%;
        padding: 7px 0 9px;
        border: 0;
        background: transparent;
    }

    #routingLinesBody tr.routing-line-card > td::before {
        content: attr(data-label);
        display: block;
        margin: 0 0 6px;
        color: #50677d;
        font-size: .72rem;
        line-height: 1.2;
        font-weight: 800;
        letter-spacing: .05em;
        text-transform: uppercase;
    }

    #routingLinesBody tr.routing-line-card .form-control,
    #routingLinesBody tr.routing-line-card .form-select {
        display: block;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        color: #25313d;
        font-size: .95rem;
        background-color: #fff;
        border-color: #cfd9e2;
    }

    #routingLinesBody tr.routing-line-card .form-control::placeholder {
        color: #6f7d8a;
        opacity: 1;
    }

    #routingLinesBody tr.routing-line-card .form-select {
        padding-right: 2.35rem;
        font-weight: 500;
    }

    #routingLinesBody tr.routing-line-card > td.routing-line-remove-cell {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        padding-top: 9px;
        border-top: 1px solid #edf0f4;
        margin-top: 5px;
    }

    #routingLinesBody tr.routing-line-card > td.routing-line-remove-cell::before {
        margin-right: auto;
    }

    #routingLinesBody .remove-routing-line {
        min-height: 38px;
        padding-inline: 12px;
    }

    .routing-lines-card .card-header {
        gap: 10px;
        flex-wrap: wrap;
    }

    .routing-lines-card .card-header strong {
        font-size: .98rem;
    }

    .routing-lines-card .card-header #addRoutingLine {
        margin-left: auto;
        white-space: nowrap;
    }
}

/* Routing: keep an Add Operation action available after the process lines. */
.routing-lines-card .routing-add-bottom {
    min-height: 42px;
    white-space: nowrap;
}

@media (max-width: 767.98px) {
    .routing-lines-card .routing-add-bottom {
        width: 100%;
        min-height: 44px;
        font-weight: 700;
    }
}


/* =========================================================
   Manufacturing Work Centers - mobile card layout
   ---------------------------------------------------------
   Keep the desktop table intact. On phones, each work center
   becomes a readable card instead of forcing horizontal scroll.
   ========================================================= */
@media (max-width: 767.98px) {
    .cg-workcenters-page-head { align-items: stretch !important; gap: 12px; flex-direction: column; }
    .cg-workcenters-page-copy h2 { font-size: 1.45rem; }
    .cg-workcenters-page-copy .text-muted { line-height: 1.45; }
    .cg-workcenter-new-btn { width: 100%; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
    .cg-workcenters-table-wrap { overflow: visible !important; background: transparent; border: 0 !important; box-shadow: none !important; }
    .cg-workcenters-table-wrap .table-responsive { overflow: visible; }
    .cg-workcenters-table { display: block; width: 100%; }
    .cg-workcenters-table thead { display: none; }
    .cg-workcenters-table tbody, .cg-workcenters-table tr.cg-workcenter-row { display: block; width: 100%; }
    .cg-workcenters-table tr.cg-workcenter-row { margin: 0 0 12px; padding: 14px; border: 1px solid var(--cg-border, #d9e5e1); border-radius: 14px; background: #fff; box-shadow: 0 3px 12px rgba(15, 55, 45, .07); }
    .cg-workcenters-table tr.cg-workcenter-row:last-child { margin-bottom: 0; }
    .cg-workcenters-table tr.cg-workcenter-row > td { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; align-items: start; width: 100%; padding: 8px 0; border: 0; background: transparent; overflow-wrap: anywhere; }
    .cg-workcenters-table tr.cg-workcenter-row > td::before { content: attr(data-label); display: block; font-size: .68rem; line-height: 1.25; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #667b8d; }
    .cg-workcenter-code { font-weight: 600; color: #233f55; }
    .cg-workcenter-description { grid-column: 2; margin-top: 4px; line-height: 1.4; overflow-wrap: anywhere; min-width: 0; }
    .cg-workcenter-company { line-height: 1.35; overflow-wrap: anywhere; }
    .cg-workcenters-table td[data-label="Action"] { display: flex !important; justify-content: flex-end; padding-top: 10px; margin-top: 4px; border-top: 1px solid #edf1ef; }
    .cg-workcenters-table tr.cg-workcenter-row > td[data-label="Action"]::before { content: none !important; display: none !important; }
    .cg-workcenter-edit-btn { min-width: 86px; min-height: 40px; }
    .cg-workcenters-table tr.cg-workcenters-empty { display: block; }
    .cg-workcenters-table tr.cg-workcenters-empty td { display: block; border: 0; }
    .cg-workcenters-table tr.cg-workcenters-empty td::before { display: none; }
}

/* =========================================================
   Manufacturing Routing - Mobile Details
   ---------------------------------------------------------
   Keep the desktop detail table intact. On phones, the
   routing header/actions stack cleanly and each process row
   becomes a readable information card.
   ========================================================= */
@media (max-width: 767.98px) {
    .routing-details-header {
        align-items: stretch !important;
        flex-direction: column;
        gap: 12px;
    }

    .routing-details-title h2 {
        font-size: 1.45rem;
        line-height: 1.2;
    }

    .routing-details-title .text-muted {
        margin-top: 3px;
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .routing-details-actions {
        width: 100%;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px !important;
    }

    .routing-details-actions > a,
    .routing-details-actions > form,
    .routing-details-actions > form .btn {
        width: 100%;
        min-width: 0;
    }

    .routing-details-actions > form {
        margin: 0;
    }

    .routing-details-actions > a,
    .routing-details-actions > form .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .routing-details-process-card .card-header {
        padding: 12px 14px;
    }

    .routing-details-table-wrap {
        overflow: visible !important;
    }

    .routing-details-table {
        display: block;
        width: 100%;
    }

    .routing-details-table thead {
        display: none;
    }

    .routing-details-table tbody,
    .routing-details-table tr.routing-details-line {
        display: block;
        width: 100%;
    }

    .routing-details-table tr.routing-details-line {
        margin: 0 12px 12px;
        width: calc(100% - 24px);
        padding: 10px 12px;
        border: 1px solid var(--cg-border, #d9e5e1);
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 2px 8px rgba(15,31,56,.06);
    }

    .routing-details-table tr.routing-details-line:last-child {
        margin-bottom: 12px;
    }

    .routing-details-table tr.routing-details-line > td {
        display: grid;
        grid-template-columns: 92px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        width: 100%;
        padding: 8px 0;
        border: 0;
        background: transparent;
        overflow-wrap: anywhere;
        min-width: 0;
    }

    .routing-details-table tr.routing-details-line > td::before {
        content: attr(data-label);
        font-size: .68rem;
        line-height: 1.25;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: #5d7387;
    }

    .routing-details-table tr.routing-details-line > td + td {
        border-top: 1px solid #edf0f4;
    }

    .routing-details-table tr.routing-details-line .small {
        line-height: 1.35;
        overflow-wrap: anywhere;
    }
}


/* =========================================================
   Routing Details - Premium mobile process presentation
   ---------------------------------------------------------
   Mobile only: transform each routing line into a compact,
   readable process card with a sequence badge and stronger
   operation hierarchy. Desktop table remains unchanged.
   ========================================================= */
.routing-details-process-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.routing-details-process-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.routing-details-process-subtitle {
    margin-top: 3px;
    color: #667b8d;
    font-size: .82rem;
    font-weight: 500;
}

.routing-details-process-icon,
.routing-details-step-count,
.routing-details-value-icon,
.routing-details-sequence-badge {
    display: none;
}

@media (max-width: 767.98px) {
    .routing-details-process-card {
        border: 0;
        border-radius: 16px;
        overflow: hidden;
        background: #f4faf8;
        box-shadow: 0 3px 14px rgba(15,55,45,.07);
    }

    .routing-details-process-card .routing-details-process-header {
        padding: 16px 14px 14px;
        background: linear-gradient(135deg, #f1fbf7 0%, #eaf8f2 100%);
        border-bottom: 1px solid #e2eee9;
    }

    .routing-details-process-heading {
        gap: 11px;
        min-width: 0;
    }

    .routing-details-process-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 50%;
        background: #d7f4e7;
        color: #087f5b;
        font-size: 1.05rem;
    }

    .routing-details-process-heading strong {
        display: block;
        color: #173f58;
        font-size: 1.02rem;
        line-height: 1.2;
        font-weight: 800;
    }

    .routing-details-process-subtitle {
        margin-top: 4px;
        font-size: .78rem;
        line-height: 1.35;
    }

    .routing-details-step-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 34px;
        padding: 0 12px;
        flex: 0 0 auto;
        border-radius: 999px;
        background: #d7f4e7;
        color: #08704f;
        font-size: .76rem;
        font-weight: 800;
        white-space: nowrap;
    }

    .routing-details-table-wrap {
        padding: 12px 12px 4px;
        background: #f4faf8;
    }

    .routing-details-table {
        width: 100%;
    }

    .routing-details-table tbody {
        display: block;
        width: 100%;
    }

    .routing-details-table tr.routing-details-line {
        position: relative;
        display: block;
        width: 100%;
        margin: 0 0 12px;
        padding: 14px 14px 12px 17px;
        border: 1px solid #dcebe5;
        border-radius: 15px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15,55,45,.07);
        overflow: hidden;
    }

    .routing-details-table tr.routing-details-line::before {
        content: "";
        position: absolute;
        inset: 0 auto 0 0;
        width: 4px;
        background: #13a875;
    }

    .routing-details-table tr.routing-details-line > td {
        position: relative;
        display: grid;
        grid-template-columns: 94px minmax(0, 1fr);
        gap: 9px;
        align-items: start;
        width: 100%;
        min-width: 0;
        padding: 9px 0;
        border: 0;
        background: transparent;
        color: #26343e;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .routing-details-table tr.routing-details-line > td + td {
        border-top: 1px solid #edf2ef;
    }

    .routing-details-table tr.routing-details-line > td::before {
        content: attr(data-label);
        font-size: .65rem;
        line-height: 1.3;
        font-weight: 800;
        letter-spacing: .055em;
        text-transform: uppercase;
        color: #5b7388;
    }

    .routing-details-table tr.routing-details-line > td[data-label="Sequence"] {
        grid-template-columns: 94px minmax(0,1fr);
        align-items: center;
    }

    .routing-details-sequence-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: #d9f5e8;
        color: #08704f;
        font-size: 1.05rem;
        font-weight: 800;
        line-height: 1;
    }

    .routing-details-operation-value {
        min-width: 0;
    }

    .routing-details-operation-value strong {
        display: block;
        color: #173f58;
        font-size: .98rem;
        line-height: 1.35;
        font-weight: 800;
        overflow-wrap: anywhere;
    }

    .routing-details-value-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        margin-right: 7px;
        color: #0b9d70;
        font-size: .9rem;
        vertical-align: middle;
    }

    .routing-details-table tr.routing-details-line > td[data-label="Work Center"],
    .routing-details-table tr.routing-details-line > td[data-label="Notes"] {
        display: block;
        padding-left: 0;
    }

    .routing-details-table tr.routing-details-line > td[data-label="Work Center"]::before,
    .routing-details-table tr.routing-details-line > td[data-label="Notes"]::before {
        display: inline-block;
        width: 94px;
        vertical-align: top;
        margin-top: 3px;
    }

    .routing-details-table tr.routing-details-line > td[data-label="Work Center"] .routing-details-value-icon,
    .routing-details-table tr.routing-details-line > td[data-label="Notes"] .routing-details-value-icon {
        margin-left: 0;
    }

    .routing-details-table tr.routing-details-line:last-child {
        margin-bottom: 4px;
    }
}


/* =========================================================
   Manufacturing Routings - Mobile List
   ---------------------------------------------------------
   Convert the desktop routing list table into readable cards
   on phones. Desktop remains unchanged.
   ========================================================= */
@media (max-width: 767.98px) {
    .cg-routings-table {
        display: block;
        width: 100%;
    }

    .cg-routings-table thead {
        display: none;
    }

    .cg-routings-table tbody {
        display: block;
        width: 100%;
    }

    .cg-routings-table tbody tr {
        display: block;
        width: calc(100% - 24px);
        margin: 0 12px 12px;
        padding: 12px 14px;
        border: 1px solid var(--cg-border, #d9e5e1);
        border-radius: 15px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15,55,45,.07);
        overflow: hidden;
    }

    .cg-routings-table tbody tr:last-child {
        margin-bottom: 4px;
    }

    .cg-routings-table tbody td {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        width: 100%;
        min-width: 0;
        padding: 9px 0;
        border: 0;
        background: transparent;
        overflow-wrap: anywhere;
        line-height: 1.35;
    }

    .cg-routings-table tbody td + td {
        border-top: 1px solid #edf2ef;
    }

    .cg-routings-table tbody td::before {
        content: attr(data-label);
        font-size: .65rem;
        line-height: 1.3;
        font-weight: 800;
        letter-spacing: .055em;
        text-transform: uppercase;
        color: #5b7388;
    }

    .cg-routings-table tbody td[data-label="Code"] a {
        font-weight: 800;
        color: #087f5b !important;
        overflow-wrap: anywhere;
    }

    .cg-routings-table tbody td[data-label="Name"] {
        color: #26343e;
        font-weight: 600;
    }

    .cg-routings-table tbody td[data-label="Finished Item"] strong {
        color: #173f58;
        font-weight: 800;
    }

    .cg-routings-table tbody td[data-label="Finished Item"] .text-muted {
        margin-top: 2px;
        line-height: 1.3;
        overflow-wrap: anywhere;
    }

    .cg-routings-table tbody td[data-label="Action"] {
        display: flex !important;
        justify-content: flex-end;
        padding-top: 11px;
        margin-top: 2px;
        border-top: 1px solid #edf2ef;
    }

    .cg-routings-table tbody td[data-label="Action"]::before {
        display: none;
    }

    .cg-routings-table tbody td[data-label="Action"] .btn {
        min-width: 84px;
        min-height: 40px;
    }
}


/* =========================================================
   Routing Details - Desktop Premium Presentation
   ---------------------------------------------------------
   Keeps the mobile card treatment, while giving desktop
   a stronger process header and a readable table.
   ========================================================= */
@media (min-width: 768px) {
    .routing-details-process-card {
        border: 1px solid #dfece7;
        border-radius: 18px;
        overflow: hidden;
        background: #fff;
        box-shadow: 0 4px 18px rgba(15,55,45,.07);
    }

    .routing-details-process-card .routing-details-process-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
        padding: 17px 20px;
        background: linear-gradient(135deg, #f1fbf7 0%, #eaf8f2 100%);
        border-bottom: 1px solid #dfece7;
    }

    .routing-details-process-heading {
        display: flex;
        align-items: center;
        gap: 13px;
        min-width: 0;
    }

    .routing-details-process-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 50%;
        background: #d7f4e7;
        color: #087f5b;
        font-size: 1.05rem;
    }

    .routing-details-process-heading strong {
        display: block;
        color: #173f58;
        font-size: 1.05rem;
        line-height: 1.2;
        font-weight: 800;
    }

    .routing-details-process-subtitle {
        margin-top: 4px;
        color: #667b8d;
        font-size: .82rem;
        line-height: 1.35;
        font-weight: 500;
    }

    .routing-details-step-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 34px;
        padding: 0 13px;
        border-radius: 999px;
        background: #d7f4e7;
        color: #08704f;
        font-size: .78rem;
        font-weight: 800;
        white-space: nowrap;
    }

    .routing-details-table-wrap {
        padding: 0;
        overflow-x: auto;
    }

    .routing-details-table {
        width: 100%;
        margin: 0;
        table-layout: fixed;
    }

    .routing-details-table thead th {
        padding: 11px 14px;
        background: #f7fbf9;
        border-bottom: 1px solid #dfece7;
        color: #587085;
        font-size: .68rem;
        font-weight: 800;
        letter-spacing: .045em;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .routing-details-table thead th:nth-child(1) { width: 9%; }
    .routing-details-table thead th:nth-child(2) { width: 22%; }
    .routing-details-table thead th:nth-child(3) { width: 25%; }
    .routing-details-table thead th:nth-child(4) { width: 44%; }

    .routing-details-table tbody td {
        padding: 14px;
        border-bottom: 1px solid #edf2ef;
        color: #26343e;
        vertical-align: middle;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .routing-details-table tbody tr:last-child td {
        border-bottom: 0;
    }

    .routing-details-table tbody tr.routing-details-line:hover {
        background: #fbfefc;
    }

    /* The sequence badge is intentionally a mobile-only treatment.
       On desktop show the sequence as a clean numeric value. */
    .routing-details-table tbody td[data-label="Sequence"] {
        text-align: center;
        font-weight: 800;
        color: #173f58;
    }

    .routing-details-sequence-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 38px;
        height: 30px;
        padding: 0 9px;
        border-radius: 999px;
        background: #eef8f4;
        color: #087f5b;
        font-size: .86rem;
        font-weight: 800;
    }

    .routing-details-operation-value strong {
        color: #173f58;
        font-size: .95rem;
        font-weight: 800;
    }

    .routing-details-table tbody td[data-label="Work Center"] {
        white-space: normal;
    }

    .routing-details-table tbody td[data-label="Notes"] {
        color: #536777;
    }

    .routing-details-value-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        margin-right: 6px;
        color: #0b9d70;
        font-size: .88rem;
        vertical-align: middle;
    }
}


/* =========================================================
   CraftGrid - Global Back Button
   ---------------------------------------------------------
   One consistent neutral Back action across the ERP.
   Page-specific business/action buttons are not affected.
   ========================================================= */
.craftgrid-authenticated-shell .cg-back-btn {
    --bs-btn-color: #495057;
    --bs-btn-bg: #ffffff;
    --bs-btn-border-color: #adb5bd;
    --bs-btn-hover-color: #212529;
    --bs-btn-hover-bg: #f1f3f5;
    --bs-btn-hover-border-color: #868e96;
    --bs-btn-active-color: #212529;
    --bs-btn-active-bg: #e9ecef;
    --bs-btn-active-border-color: #868e96;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 42px;
    min-width: 82px;
    padding: .5rem .9rem;
    border: 1px solid var(--bs-btn-border-color);
    border-radius: 10px;
    background: var(--bs-btn-bg);
    color: var(--bs-btn-color);
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

.craftgrid-authenticated-shell .cg-back-btn:hover,
.craftgrid-authenticated-shell .cg-back-btn:focus-visible {
    background: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
    color: var(--bs-btn-hover-color);
    text-decoration: none;
    box-shadow: 0 2px 7px rgba(18, 42, 34, .08);
}

.craftgrid-authenticated-shell .cg-back-btn:active {
    background: var(--bs-btn-active-bg);
    border-color: var(--bs-btn-active-border-color);
    color: var(--bs-btn-active-color);
}

.craftgrid-authenticated-shell .cg-back-btn i {
    font-size: .95rem;
}

@media (max-width: 767.98px) {
    .craftgrid-authenticated-shell .cg-back-btn {
        min-height: 42px;
        min-width: 82px;
        padding-inline: .85rem;
    }
}

/* =========================================================
   Final mobile topbar layout correction
   UI-only: keep all primary header controls on one row.
   ========================================================= */
@media (max-width: 575.98px) {
    .craftgrid-authenticated-shell .craftgrid-topbar .container-fluid {
        flex-wrap: nowrap !important;
        overflow: visible !important;
    }

    .craftgrid-authenticated-shell .craftgrid-brand {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        max-width: 145px;
        margin-right: 0 !important;
        overflow: hidden;
    }

    .craftgrid-authenticated-shell .craftgrid-brand .cg-brand-copy {
        min-width: 0;
    }

    .craftgrid-authenticated-shell .craftgrid-brand .cg-brand-copy strong {
        font-size: 1rem !important;
        white-space: nowrap;
    }
}


/* =========================================================
   CraftGrid — Clean Sidebar Navigation
   ---------------------------------------------------------
   One viewport, one scroll owner:
       desktop-sidebar = fixed viewport
       .erp-sidebar    = scroll container
   No competing height/overflow rules.
   ========================================================= */

:root {
    --cg-sidebar-width: 292px;
    --cg-sidebar-top: 76px;
    --cg-sidebar-bottom-space: 28px;
}

/* Base navigation appearance */
.erp-sidebar {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background: linear-gradient(
        180deg,
        #102d44 0%,
        #15374d 58%,
        #122f46 100%
    );
    color: #d8e2ec;
    border-right: 1px solid rgba(255,255,255,.08);
}

/* Desktop: the ASIDE is the fixed viewport. */
@media (min-width: 992px) {

    .desktop-sidebar {
        position: fixed !important;
        top: var(--cg-sidebar-top) !important;
        left: 0 !important;
        bottom: 0 !important;

        width: var(--cg-sidebar-width) !important;
        max-width: var(--cg-sidebar-width) !important;

        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        padding: 0 !important;
        margin: 0 !important;

        box-sizing: border-box !important;
        overflow: hidden !important;

        flex: none !important;
        z-index: 1040;

        background: transparent;
        pointer-events: none;
    }

    /* The NAV is the ONLY desktop scrolling element. */
    .desktop-sidebar > .erp-sidebar {
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;

        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 20px 12px var(--cg-sidebar-bottom-space) !important;

        box-sizing: border-box !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;

        scrollbar-gutter: stable;
        scrollbar-width: auto;
        scrollbar-color: rgba(255,255,255,.42) rgba(255,255,255,.055);

        pointer-events: auto;
    }

    /* Chromium / Edge */
    .desktop-sidebar > .erp-sidebar::-webkit-scrollbar {
        width: 9px;
        display: block;
    }

    .desktop-sidebar > .erp-sidebar::-webkit-scrollbar-track {
        background: rgba(255,255,255,.055);
        border-radius: 8px;
    }

    .desktop-sidebar > .erp-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.42);
        border-radius: 8px;
        border: 2px solid transparent;
        background-clip: padding-box;
    }

    .desktop-sidebar > .erp-sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255,255,255,.64);
        background-clip: padding-box;
    }

    /* The content itself must remain natural height. */
    .desktop-sidebar > .erp-sidebar .sidebar-modules {
        overflow: visible;
        padding-bottom: 10px;
    }

    .desktop-sidebar > .erp-sidebar .sidebar-group,
    .desktop-sidebar > .erp-sidebar .sidebar-submenu {
        overflow: visible;
    }

    /* Deliberate breathing room between functional modules. */
    .desktop-sidebar > .erp-sidebar > .sidebar-modules > .sidebar-group {
        margin-bottom: 14px;
    }

    .desktop-sidebar > .erp-sidebar > .sidebar-modules > .sidebar-group:last-child {
        margin-bottom: 18px;
    }
}

/* ---------------------------------------------------------
   Module parent rows
   --------------------------------------------------------- */

.erp-sidebar .sidebar-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 45px;
    padding: 9px 10px;
    box-sizing: border-box;
    border-radius: 9px;
    gap: 0;
}

.erp-sidebar .sidebar-group-toggle .sidebar-link-content {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
}

.erp-sidebar .sidebar-group-toggle .sidebar-link-content > i {
    flex: 0 0 20px;
    width: 20px;
    margin-right: 10px;
    text-align: center;
}

.erp-sidebar .sidebar-group-toggle .sidebar-link-content > span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

/* Drag handle: visible, compact and aligned after the label. */
.erp-sidebar .sidebar-drag-handle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    flex: 0 0 24px;
    width: 24px;
    min-width: 24px;
    height: 30px;

    margin-left: 4px;
    padding: 0;

    color: rgba(255,255,255,.46);
    background: transparent;
    border: 0;
    border-radius: 6px;

    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.erp-sidebar .sidebar-drag-handle:hover {
    color: #dbe7f3;
    background: rgba(255,255,255,.07);
}

.erp-sidebar .sidebar-drag-handle:active {
    cursor: grabbing;
}

/* Favourite and chevron stay anchored at the far right. */
.erp-sidebar .sidebar-favorite-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 30px;
    width: 30px;
    min-width: 30px;
    height: 30px;

    margin-left: 3px;
    padding: 0;

    color: rgba(255,255,255,.42);
    background: transparent;
    border: 0;
    border-radius: 7px;
}

.erp-sidebar .sidebar-favorite-button:hover,
.erp-sidebar .sidebar-favorite-button:focus-visible {
    color: #f4c95d;
    background: rgba(255,255,255,.07);
}

.erp-sidebar .sidebar-chevron {
    flex: 0 0 18px;
    width: 18px;
    min-width: 18px;
    margin-left: 4px;
    text-align: center;
}

/* Open parent module: subtle elevation only. */
.erp-sidebar > .sidebar-modules > .sidebar-group[open] > .sidebar-group-toggle {
    background: rgba(255,255,255,.045);
    color: #ffffff;
}

/* Active dashboard/page treatment remains CraftGrid green. */
.craftgrid-authenticated-shell .sidebar-link.active {
    background: linear-gradient(90deg, #087f5b 0%, #07976c 100%);
    color: #ffffff;
    box-shadow: inset 3px 0 0 #f0b92d, 0 6px 16px rgba(7,143,103,.18);
}

/* Nested menu hierarchy. */
.erp-sidebar .sidebar-submenu {
    margin: 5px 0 7px 15px;
    padding: 3px 0 3px 12px;
    border-left: 1px solid rgba(145,168,194,.18);
}

.erp-sidebar .sidebar-submenu-link {
    min-height: 38px;
    margin: 1px 0;
    border-radius: 8px;
}

.craftgrid-authenticated-shell .sidebar-submenu-link.active {
    background: rgba(7,151,108,.27);
    box-shadow: inset 2px 0 0 #55c99f;
    color: #ffffff;
}

/* Parent containing the current page is subtly highlighted. */
.erp-sidebar > .sidebar-modules > .sidebar-group:has(.sidebar-submenu-link.active)
    > .sidebar-group-toggle {
    background: rgba(255,255,255,.055);
}

/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

@media (max-width: 991.98px) {

    .erp-sidebar {
        width: 100%;
        min-width: 0;
        height: 100%;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        box-sizing: border-box;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,.38) rgba(255,255,255,.05);
    }

    .erp-sidebar::-webkit-scrollbar {
        width: 7px;
    }

    .erp-sidebar::-webkit-scrollbar-track {
        background: rgba(255,255,255,.05);
    }

    .erp-sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,.38);
        border-radius: 8px;
    }

    .erp-sidebar .sidebar-submenu {
        margin-left: 12px;
        padding-left: 11px;
    }
}

/* =========================================================
   CraftGrid One Architecture Map
   ========================================================= */
.cg-architecture-shell { max-width: 1500px; margin: 0 auto; }
.cg-architecture-hero {
    display:flex; justify-content:space-between; align-items:flex-end; gap:24px;
    padding:28px; margin-bottom:18px; border-radius:18px; color:#fff;
    background:linear-gradient(135deg,#102a43 0%,#163d5c 55%,#1f5874 100%);
    box-shadow:0 12px 32px rgba(16,42,67,.16);
}
.cg-architecture-eyebrow { font-size:.72rem; font-weight:800; letter-spacing:.14em; opacity:.72; margin-bottom:7px; }
.cg-architecture-hero h1 { margin:0 0 8px; font-size:clamp(1.5rem,2.4vw,2.1rem); font-weight:750; color:#fff !important; }
.cg-architecture-hero p { margin:0; max-width:850px; color:rgba(255,255,255,.78); }
.cg-architecture-status-key { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:7px; min-width:260px; }
.cg-arch-status { display:inline-flex; align-items:center; border-radius:999px; padding:4px 9px; font-size:.68rem; font-weight:750; white-space:nowrap; border:1px solid transparent; }
.cg-arch-status.available { background:#e8f7ef; color:#146c43; border-color:#b9e5ca; }
.cg-arch-status.foundation { background:#eef4ff; color:#2456a6; border-color:#c9d9fb; }
.cg-arch-status.under-development { background:#fff4df; color:#8a5a00; border-color:#f2d49a; }
.cg-arch-status.coming-soon { background:#f2f4f7; color:#667085; border-color:#d9dee7; }
.cg-architecture-protection { border:1px solid #c9e8dc; background:#f1fbf7; color:#245b4a; border-radius:12px; }
.cg-architecture-card { height:100%; background:#fff; border:1px solid #e7ebf0; border-radius:16px; box-shadow:0 6px 20px rgba(15,23,42,.055); overflow:hidden; }
.cg-architecture-card-head { display:flex; gap:14px; padding:20px; border-bottom:1px solid #edf0f4; }
.cg-architecture-icon { flex:0 0 42px; width:42px; height:42px; display:grid; place-items:center; border-radius:12px; background:#eef8f4; color:#087f5b; font-size:1.15rem; }
.cg-architecture-card h2 { margin:0; font-size:1rem; font-weight:750; }
.cg-architecture-card-head p { margin:5px 0 0; color:#667085; font-size:.8rem; }
.cg-architecture-features { padding:8px 12px 12px; }
.cg-architecture-feature { display:flex; align-items:center; gap:10px; padding:11px 8px; border-radius:10px; text-decoration:none; color:inherit; transition:background .15s ease,transform .15s ease; }
.cg-architecture-feature:hover { background:#f7faf9; transform:translateX(2px); }
.cg-architecture-feature-icon { flex:0 0 27px; width:27px; height:27px; display:grid; place-items:center; border-radius:8px; background:#f3f5f7; color:#64748b; font-size:.7rem; }
.cg-architecture-feature strong { display:block; font-size:.82rem; color:#1f2937; }
.cg-architecture-feature small { display:block; margin-top:2px; color:#667085; font-size:.72rem; line-height:1.35; }
.cg-architecture-feature > .cg-arch-status { margin-left:8px; }
.cg-architecture-feature-page { max-width:1000px; margin:0 auto; }
.cg-architecture-feature-hero { padding:28px; border-radius:18px; color:#fff; background:linear-gradient(135deg,#102a43,#1f5874); box-shadow:0 12px 32px rgba(16,42,67,.16); }
.cg-architecture-feature-hero h1 { margin:0 0 8px; font-weight:750; }
.cg-architecture-feature-hero p { max-width:760px; color:rgba(255,255,255,.78); margin-bottom:14px; }
.cg-architecture-detail-card { margin-top:18px; border:0; border-radius:16px; box-shadow:0 6px 20px rgba(15,23,42,.06); }
@media (max-width: 767.98px) {
    .cg-architecture-hero { display:block; padding:20px; }
    .cg-architecture-status-key { justify-content:flex-start; min-width:0; margin-top:18px; }
    .cg-architecture-card-head { padding:16px; }
    .cg-architecture-feature { align-items:flex-start; flex-wrap:wrap; }
    .cg-architecture-feature > .cg-arch-status { margin-left:37px; }
    .cg-architecture-feature-page { width:100%; }
}

/* Small status marker used for architecture navigation without changing authorization. */
.erp-sidebar .cg-sidebar-status { margin-left:auto; padding:2px 6px; border-radius:999px; font-size:.58rem; font-weight:700; letter-spacing:.02em; color:#b9d8ca; background:rgba(255,255,255,.08); }


/* Item tracking policy */
.cg-item-tracking-badge {
    font-weight: 700;
    letter-spacing: .01em;
}

.cg-tracking-none {
    background: #eef2f1;
    color: #52635f;
}

.cg-tracking-batch {
    background: #e7f1ff;
    color: #245b9a;
}

.cg-tracking-serial {
    background: #f4eaff;
    color: #68429a;
}

@media (max-width: 767.98px) {
    .cg-items-table tbody tr:not(.cg-items-empty) td {
        grid-template-columns: 96px minmax(0, 1fr);
    }

    .cg-items-table .cg-item-tracking-badge {
        justify-self: start;
    }
}


/* =========================================================
   CraftGrid Navigation UX Corrections
   - Planning aligns with the other Inventory submenu links.
   - Long module names remain readable instead of being clipped.
   ========================================================= */

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle {
    min-height: 38px;
    margin: 1px 0;
    padding: 7px 12px;
    border-radius: 8px;
    color: #c5d1df;
}

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle > .sidebar-link-content {
    flex: 1 1 auto;
    min-width: 0;
    gap: 11px;
}

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle > .sidebar-link-content > i {
    width: 17px;
    min-width: 17px;
    text-align: center;
    color: #8ea5be;
}

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle > .sidebar-link-content > span {
    font-size: .86rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle:hover {
    background: rgba(255,255,255,.07);
    color: #ffffff;
    transform: none;
}

.erp-sidebar .sidebar-planning-group[open] > .sidebar-group-toggle {
    background: rgba(255,255,255,.055);
    color: #ffffff;
}

.erp-sidebar .sidebar-planning-group > .sidebar-group-toggle > .sidebar-chevron {
    flex: 0 0 18px;
    width: 18px;
    min-width: 18px;
}

/* Keep long top-level module labels readable on the available width. */
.erp-sidebar > .sidebar-modules > .sidebar-group > .sidebar-group-toggle
    > .sidebar-link-content {
    flex: 1 1 auto;
    min-width: 0;
}

.erp-sidebar > .sidebar-modules > .sidebar-group > .sidebar-group-toggle
    > .sidebar-link-content > span {
    min-width: 0;
}

/* The label is allowed to consume the available space, while the
   drag/favourite/chevron controls remain fixed and aligned. */
.erp-sidebar .sidebar-group-toggle > .sidebar-link-content > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 992px) {
    :root {
        --cg-sidebar-width: 310px;
    }
}

@media (max-width: 991.98px) {
    .craftgrid-authenticated-shell .craftgrid-mobile-sidebar {
        width: min(320px, 90vw);
    }
}

@media (max-width: 575.98px) {
    .erp-sidebar .sidebar-group-toggle > .sidebar-link-content > span {
        font-size: .88rem;
    }
}

/* CraftGrid Accounts submenu section labels */
.sidebar-subsection-label {
    margin: .45rem .55rem .2rem;
    padding: .38rem .55rem .3rem;
    color: #d9e8f7;
    background: rgba(143, 169, 198, .12);
    border-left: 3px solid #8fa9c6;
    border-radius: .25rem;
    font-size: .70rem;
    font-weight: 800;
    letter-spacing: .10em;
    text-transform: uppercase;
    line-height: 1.25;
}

.sidebar-subsection-label.mt-2 {
    margin-top: .5rem !important;
}
