/**
 * Two-level portal sidebar.
 *
 * Level 1 (.navbar-sidenav-rail) is the main nav, collapsed to icons and always
 * on screen — including inside Attendance / Access Control / Payment / Safety
 * Deposit Boxes, which used to replace it. It expands over the panel on demand.
 * Level 2 (.navbar-sidenav) is the page list for the current section.
 *
 * Loaded after sb-admin.css / portal-tablet-nav.css / portal-rtl.css, so it
 * restates the offsets those files pin to the old single 250px sidebar.
 */

:root {
    --bw-rail-width: 68px;
    /* Expanded = rail + panel, so the expanded main nav covers the page list
       cleanly instead of leaving a sliver of it showing. */
    --bw-rail-width-expanded: calc(68px + 250px);
    --bw-panel-width: 250px;
    --bw-nav-width: calc(var(--bw-rail-width) + var(--bw-panel-width));
    --bw-rail-border: var(--color-custom-1, #e5e7eb);
    --bw-rail-bg: #ffffff;
    --bw-rail-active: var(--color-primary, #193351);
}

/*
 * Specificity note: .navbar-expand-lg .navbar-nav sets flex-direction: row at
 * >= 992px, which lays the rail out horizontally. Outrank it with the
 * #mainNav .navbar-collapse prefix rather than relying on source order.
 */
#mainNav .navbar-collapse .navbar-sidenav-rail,
.navbar-sidenav-rail {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: var(--bw-rail-bg);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
}

/*
 * Both sidebars are flex columns, so once a long section overflows their rows
 * shrink to fit instead of the column scrolling — squashing the search band and
 * the heading, and pulling the list out of line with the rail. It only shows
 * once the content is taller than the viewport, which is why Attendance, Access
 * Control and Audits hit it first, and why browser zoom brings it on.
 * Rows keep their height; the columns scroll, which they already do.
 */
#mainNav .navbar-collapse .navbar-sidenav-rail > *,
#mainNav .navbar-collapse .navbar-sidenav > * {
    flex-shrink: 0;
}

/* Group separators: after the dashboard, after the workspace, after the modules. */
.navbar-sidenav-rail .nav-rail-divider {
    height: 1px;
    margin: 6px 12px;
    padding: 0;
    background-color: var(--bw-rail-border);
    list-style: none;
}

.navbar-sidenav-rail .nav-rail-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    margin-bottom: 6px;
    /* Same height as the top bar, so the logo, the handle, the search field and
       the breadcrumb all sit on one centre line. */
    height: 72px;
}

.navbar-sidenav-rail .nav-rail-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    height: 40px;
}

.navbar-sidenav-rail .nav-rail-brand__mark {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

/* Only the expanded rail is wide enough for the wordmark. */
.navbar-sidenav-rail .nav-rail-brand__full {
    display: none;
    width: 130px;
    height: auto;
    max-width: 100%;
}

.nav-rail-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    /* 24px is WCAG 2.2's minimum pointer target, so this is as small as the
       handle can go while staying clickable. */
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--bw-rail-border);
    border-radius: 8px;
    background: var(--bw-rail-bg);
    box-shadow: 0 2px 6px rgba(25, 51, 81, 0.12);
    color: var(--bw-rail-active);
    cursor: pointer;
}

.nav-rail-toggle:hover,
.nav-rail-toggle:focus-visible {
    background-color: var(--color-neutral-50, #f6f7f8);
}

.nav-rail-toggle .material-symbols-outlined {
    font-size: 16px;
    color: inherit;
}

/*
 * The chevron points the way the rail will move: outward to expand, back to
 * collapse — mirrored in RTL, where "outward" is the other direction.
 */
body.bw-rail-expanded .nav-rail-toggle-icon,
html[dir='rtl'] .nav-rail-toggle-icon {
    transform: rotate(180deg);
}

html[dir='rtl'] body.bw-rail-expanded .nav-rail-toggle-icon {
    transform: none;
}

.navbar-sidenav-rail > .nav-item {
    width: 100%;
    padding: 0 10px;
}

.navbar-sidenav-rail > .nav-item > .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 8px;
    border-radius: 10px;
    color: var(--bw-rail-active);
    overflow: visible;
    white-space: nowrap;
}

.navbar-sidenav-rail .nav-rail-icon {
    flex: 0 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.navbar-sidenav-rail .nav-rail-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.navbar-sidenav-rail .nav-rail-icon .material-symbols-outlined {
    font-size: 22px;
    line-height: 1;
}

.navbar-sidenav-rail .nav-rail-label {
    display: none;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.navbar-sidenav-rail > .nav-item > .nav-link:hover,
.navbar-sidenav-rail > .nav-item > .nav-link:focus-visible {
    background-color: var(--color-neutral-50, #f6f7f8);
    text-decoration: none;
}

.navbar-sidenav-rail > .nav-item.active > .nav-link {
    background-color: var(--color-primary-50, #e8eefc);
}

.navbar-sidenav-rail > .nav-item.active > .nav-link .material-symbols-outlined,
.navbar-sidenav-rail > .nav-item.active > .nav-link .nav-rail-label {
    color: var(--bw-rail-active);
    font-weight: 600;
}

/*
 * Icon-only hover label. Positioned by portalNavRail.js rather than anchored to
 * the item: the rail is a scroll container (overflow-x: hidden), so anything
 * painted past its edge from the inside is clipped.
 */
.nav-rail-tip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1080;
    padding: 5px 10px;
    border-radius: 6px;
    background: #193351;
    color: #ffffff !important;
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    display: none;
}

.nav-rail-tip.is-visible {
    display: block;
}

/* ---------------------------------------------------------------- desktop */
@media (min-width: 992px) {
    /* Both levels sit above the top bar so they run the full viewport height. */
    #mainNav .navbar-collapse {
        z-index: 3;
    }

    .navbar-sidenav-rail {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        bottom: 0;
        width: var(--bw-rail-width);
        height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
        padding-bottom: 12px;
        border-inline-end: 1px solid var(--bw-rail-border);
        pointer-events: auto;
        transition: width 0.18s ease;
        z-index: 4;
    }

    /* Handle straddles the rail's outer border, level with the logo row. */
    .nav-rail-toggle {
        display: inline-flex;
        position: fixed;
        top: 24px;
        inset-inline-start: var(--bw-rail-width);
        transform: translateX(-50%);
        z-index: 6;
        pointer-events: auto;
        transition: inset-inline-start 0.18s ease;
    }

    html[dir='rtl'] .nav-rail-toggle {
        transform: translateX(50%);
    }

    body.bw-rail-expanded .nav-rail-toggle {
        inset-inline-start: var(--bw-rail-width-expanded);
    }

    #mainNav .navbar-collapse .navbar-sidenav {
        position: fixed;
        top: 0;
        inset-inline-start: var(--bw-rail-width);
        width: var(--bw-panel-width);
        height: 100vh;
        margin-top: 0;
        /* 8 here + .nav-search's own 10 puts the 36px field at 18..54 — centred
           on 36, the same line as the top bar. */
        padding-top: 8px;
        border-inline-end: 1px solid var(--bw-rail-border);
        z-index: 3;
    }

    /* portal-tablet-nav.css pins the panel to the edge with physical !important
       offsets; restate them so the panel sits beside the rail, not under it. */
    html[dir='ltr'] #mainNav .navbar-collapse .navbar-sidenav {
        left: var(--bw-rail-width) !important;
        right: auto !important;
    }

    html[dir='rtl'] #mainNav .navbar-collapse .navbar-sidenav {
        right: var(--bw-rail-width) !important;
        left: auto !important;
    }

    /* Collapsed rail: centre the icon in the strip. */
    body:not(.bw-rail-expanded) .navbar-sidenav-rail > .nav-item > .nav-link {
        justify-content: center;
        gap: 0;
        padding: 0;
    }

    #mainNav.fixed-top .navbar-sidenav {
        height: 100vh;
    }

    /* Expanded rail overlays the panel instead of reflowing the page. */
    body.bw-rail-expanded .navbar-sidenav-rail {
        width: var(--bw-rail-width-expanded);
        box-shadow: 6px 0 24px rgba(25, 51, 81, 0.12);
    }

    html[dir='rtl'] body.bw-rail-expanded .navbar-sidenav-rail {
        box-shadow: -6px 0 24px rgba(25, 51, 81, 0.12);
    }

    body.bw-rail-expanded .navbar-sidenav-rail .nav-rail-head {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    body.bw-rail-expanded .navbar-sidenav-rail .nav-rail-brand__mark {
        display: none;
    }

    body.bw-rail-expanded .navbar-sidenav-rail .nav-rail-brand__full {
        display: block;
    }

    body.bw-rail-expanded .navbar-sidenav-rail .nav-rail-label {
        display: block;
    }

    /* Content, breadcrumb, footer and toasts clear both levels. */
    .content-wrapper,
    html[dir='rtl'] .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: var(--bw-nav-width) !important;
    }

    #mainNav .nav-breadcrumb,
    html[dir='rtl'] #mainNav .nav-breadcrumb {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: calc(var(--bw-nav-width) + 10px) !important;
    }

    footer.sticky-footer {
        width: calc(100% - var(--bw-nav-width));
    }

    body.sticky-footer:has(.bw-ent-workspace) footer.sticky-footer,
    html[dir='rtl'] body.sticky-footer:has(.bw-ent-workspace) footer.sticky-footer {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: var(--bw-nav-width) !important;
        width: calc(100% - var(--bw-nav-width)) !important;
    }

    #toast-container.toast-portal-content-top {
        margin-inline-start: var(--bw-nav-width);
        width: calc(100% - var(--bw-nav-width));
    }
}

/* --------------------------------------------------------- tablet / phone */
@media (max-width: 991.98px) {
    /* The drawer holds both levels side by side. Leave a strip of backdrop:
       at 94vw there was barely enough of it left to tap to dismiss. */
    #mainNav .navbar-collapse {
        display: flex !important;
        flex-direction: row;
        align-items: stretch;
        width: min(20rem, 86vw);
        padding: 0;
        overflow: hidden;
    }

    /* The top bar already shows the brand, centred; repeating it here only ate
       72px of a short screen. */
    #mainNav .navbar-collapse .navbar-sidenav-rail .nav-rail-head {
        display: none;
    }

    .navbar-sidenav-rail {
        flex: 0 0 60px;
        width: 60px;
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        padding-bottom: 12px;
        border-inline-end: 1px solid var(--bw-rail-border);
    }

    .navbar-sidenav-rail .nav-rail-head {
        justify-content: center;
        padding: 10px 6px 8px;
    }

    .navbar-sidenav-rail > .nav-item {
        padding: 0 8px;
    }

    .navbar-sidenav-rail > .nav-item > .nav-link {
        justify-content: center;
        gap: 0;
        padding: 0;
    }

    #mainNav .navbar-collapse .navbar-sidenav {
        flex: 1 1 auto;
        min-width: 0;
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 0 16px;
    }

    /*
     * The handle works in the drawer too, where it swaps which list you are
     * looking at: collapsed shows the page list beside the icons, expanded
     * gives the whole drawer to the named module list. Absolute rather than
     * fixed so it travels with the drawer as that slides in and out.
     */
    .nav-rail-toggle {
        display: inline-flex;
        position: absolute;
        top: 16px;
        inset-inline-start: 60px;
        transform: translateX(-50%);
        z-index: 6;
    }

    html[dir='rtl'] .nav-rail-toggle {
        transform: translateX(50%);
    }

    /* Nothing to swap to on the dashboard: it has no page list. */
    body.bw-nav-dashboard .nav-rail-toggle {
        display: none;
    }

    body.bw-rail-expanded #mainNav .navbar-collapse .navbar-sidenav-rail {
        flex: 1 1 auto;
        width: 100%;
        border-inline-end: 0;
    }

    body.bw-rail-expanded #mainNav .navbar-collapse .navbar-sidenav {
        display: none;
    }

    body.bw-rail-expanded .navbar-sidenav-rail .nav-rail-label {
        display: block;
    }

    body.bw-rail-expanded .navbar-sidenav-rail > .nav-item > .nav-link {
        justify-content: flex-start;
        gap: 12px;
        padding: 0 8px;
    }

    /* Expanded, the rail's edge is the drawer's edge — park it inside. */
    body.bw-rail-expanded .nav-rail-toggle {
        inset-inline-start: auto;
        inset-inline-end: 12px;
        transform: none;
    }
}

/* --------------------------------------------- phones: stray legacy margin */
/*
 * sb-admin.css has `@media (max-width: 480px) { .navbar-nav .nav-item {
 * margin-left: 15px; margin-right: 15px } }` — a spacing hack from when the top
 * bar was a plain Bootstrap navbar. It matches every row in both sidebars as
 * well as the top bar's controls: the right margin stopped the account group
 * 31px short of the edge, and the left one opened a 23px hole between the bell
 * and the avatar where every other width has 8px. Both sides have to go.
 */
@media (max-width: 480px) {
    #mainNav .portal-top-nav-actions .nav-item,
    #mainNav .navbar-sidenav-rail .nav-item,
    #mainNav .navbar-sidenav .nav-item {
        margin-inline: 0;
    }
}

/* ----------------------------------------------------- top bar typography */
/*
 * The top bar, and the menus it opens, read at the same size as both sidebars.
 * Set on the containers: every icon in here carries an absolute px size
 * (.googleIconSideBar, .material-symbols-*), so none of them scale with it.
 * Buttons are listed explicitly — they only inherit font via Reboot.
 */
.portal-navbar-top,
#mainNav .portal-admin-dropdown-menu,
#mainNav .portal-admin-dropdown-menu .dropdown-item,
#mainNav .portal-locale-submenu .dropdown-item {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ------------------------------------------------------ top bar admin menu */
/*
 * One icon column for every row. The Change Language row is a flex row because
 * it carries a caret; the rest were block rows whose text started 11px further
 * left, so the labels did not line up.
 */
#mainNav .portal-admin-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#mainNav .portal-admin-dropdown-menu .dropdown-item > i,
#mainNav .portal-admin-dropdown-menu .dropdown-item > .material-symbols-outlined {
    flex: 0 0 1.125rem;
    width: 1.125rem;
    margin: 0;
    text-align: center;
}

/*
 * sb-admin.css has `.dropdown-item span { margin-left: 5px !important }` — a
 * physical margin that predates this row being a flex row. It stacked on top of
 * the gap (pushing the label 5px past the labels below it) and pushed the wrong
 * side in Arabic. The gap owns the spacing now.
 */
#mainNav .portal-admin-dropdown-menu .dropdown-item > span {
    margin: 0 !important;
}

/* Submenu caret: an icon, sized with the row, pointing toward the inline end —
   the same affordance the sidebar's collapse rows use. */
#mainNav .portal-admin-dropdown-menu .portal-locale-toggle__caret {
    font-size: 1.125rem;
    color: inherit;
}

html[dir='rtl'] #mainNav .portal-admin-dropdown-menu .portal-locale-toggle__caret {
    transform: rotate(180deg);
}

/* The bell and the account button carry their own padding; 1rem on top of it
   left a visible hole between the two circles. */
#mainNav .portal-top-nav-actions {
    gap: 0.5rem;
}

/*
 * Pin Quick Setup + bell + account to the trailing edge on every page
 * (dashboard included — empty breadcrumbs used to leave the cluster on the left).
 */
@media (min-width: 992px) {
    #mainNav.navbar {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
    }

    #mainNav .top-nav-bar {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        flex: 1 1 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    #mainNav .portal-top-nav-actions {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
        margin-inline-start: auto !important;
        margin-left: auto; /* LTR fallback when logical props ignored */
        flex: 0 0 auto;
        width: auto;
        max-width: max-content;
        justify-content: flex-end;
    }

    html[dir='rtl'] #mainNav .portal-top-nav-actions {
        margin-left: 0;
        margin-right: auto;
    }

    /* Dashboard: same trailing pin (no level-2 panel) */
    body.bw-nav-dashboard #mainNav .top-nav-bar,
    body.bw-nav-dashboard #mainNav .portal-top-nav-actions {
        /* inherit rules above; keep explicit so dashboard layout wins */
        display: flex !important;
    }
}

/*
 * Quick Setup ▾ — global chrome (must not depend on asw-setup-wizard.css /
 * enterprise-tier1-polished.css; those are missing on dashboard/home).
 * Label + Material expand_more only — hide Bootstrap's caret.
 */
#mainNav .asw-nav-quick-setup {
    align-self: center;
    margin-inline-end: 8px;
    list-style: none;
}

#mainNav .asw-nav-quick-setup .dropdown-toggle::after,
#mainNav .asw-nav-quick-setup > .nav-link.dropdown-toggle::after,
#mainNav .asw-nav-quick-setup .asw-nav-quick-setup__btn::after {
    display: none !important;
    content: none !important;
    border: 0 !important;
    margin: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

#mainNav .asw-nav-quick-setup__btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    height: 40px;
    padding: 0 12px !important;
    border: 1px solid var(--bw-form-border-color, #d4d8e3);
    border-radius: 8px;
    background: #fff;
    color: var(--bw-form-value-color, #454e65) !important;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    max-width: 100%;
}

#mainNav .asw-nav-quick-setup__btn:hover,
#mainNav .asw-nav-quick-setup__btn:focus {
    background: var(--bw-primary-soft, #e8ecf2);
    color: var(--bw-primary, #193351) !important;
    text-decoration: none;
}

#mainNav .asw-nav-quick-setup__btn .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
}

/* Desktop: label + caret only (no leading icon). */
#mainNav .asw-nav-quick-setup__icon {
    display: none;
}

#mainNav .asw-nav-quick-setup .dropdown-menu {
    min-width: 220px;
    border-radius: 8px;
    border-color: var(--bw-border, #e8eaed);
    box-shadow: 0 4px 16px rgba(7, 19, 35, 0.12);
}

#mainNav .asw-nav-quick-setup .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 14px;
}

#mainNav .asw-nav-quick-setup .dropdown-item .material-symbols-outlined {
    font-size: 18px;
    line-height: 1;
    color: var(--bw-form-label-color, #5e6882);
    flex: 0 0 auto;
}

#mainNav .asw-nav-quick-setup .dropdown-divider {
    margin: 4px 0;
    border-top-color: var(--bw-border, #e8eaed);
}

#mainNav .asw-nav-quick-setup .dropdown-item.disabled,
#mainNav .asw-nav-attendance-setup--disabled,
#mainNav [data-asw-attendance-setup-disabled="1"],
#mainNav [data-asw-wizards-disabled="1"] {
    opacity: 0.55;
    pointer-events: none;
    cursor: not-allowed;
}

/* Tablet / phone: keep button usable in the tight top-actions cluster.
   portal-tablet-nav zeroes padding on `.nav-item.dropdown > .nav-link` — override.
   Dropdown opens below the trigger (same as profile menu). */
@media (max-width: 991.98px) {
    #mainNav .asw-nav-quick-setup {
        flex: 0 0 auto;
        margin-inline-end: 4px;
        position: relative;
    }

    #mainNav .top-nav-bar .asw-nav-quick-setup.nav-item.dropdown > .nav-link.asw-nav-quick-setup__btn,
    #mainNav .portal-top-nav-actions .asw-nav-quick-setup.nav-item.dropdown > .nav-link.asw-nav-quick-setup__btn,
    #mainNav .asw-nav-quick-setup__btn {
        height: 36px;
        padding: 0 10px !important;
        font-size: 13px;
        max-width: min(42vw, 11rem);
    }

    #mainNav .asw-nav-quick-setup__label {
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    #mainNav .asw-nav-quick-setup .dropdown-menu {
        top: calc(100% + 10px);
        inset-inline-end: 0;
        inset-inline-start: auto;
        right: 0;
        left: auto;
        margin-top: 0;
        max-width: min(17.5rem, calc(100vw - 1rem));
    }

    html[dir='rtl'] #mainNav .asw-nav-quick-setup .dropdown-menu {
        right: auto;
        left: 0;
        inset-inline-end: auto;
        inset-inline-start: 0;
    }
}

@media (max-width: 575.98px) {
    #mainNav .asw-nav-quick-setup__label,
    #mainNav .asw-nav-quick-setup__caret {
        display: none;
    }

    #mainNav .asw-nav-quick-setup__icon {
        display: inline-flex;
    }

    #mainNav .top-nav-bar .asw-nav-quick-setup.nav-item.dropdown > .nav-link.asw-nav-quick-setup__btn,
    #mainNav .portal-top-nav-actions .asw-nav-quick-setup.nav-item.dropdown > .nav-link.asw-nav-quick-setup__btn,
    #mainNav .asw-nav-quick-setup__btn {
        width: 36px;
        height: 36px;
        padding: 0 !important;
        justify-content: center;
        gap: 0;
        max-width: none;
    }
}

/* ------------------------------------------------- level 2 item typography */
/*
 * The panel reads at the rail's label size, so expanding the main sidebar over
 * it is not a jump in type scale. Sidebar icons are pinned at 16px !important
 * in sb-admin.css, so they are unaffected; the collapse caret inherits from the
 * row and scales with it.
 */
#mainNav .navbar-collapse .navbar-sidenav .nav-link,
#mainNav .navbar-collapse .navbar-sidenav .nav-link-text {
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ------------------------------------------------- dashboard: one sidebar */
/*
 * The dashboard has no level-2 sidebar, so the main sidebar stands alone and
 * the page widens to meet it. The body also carries .bw-rail-expanded, which
 * supplies the labels and wordmark; these rules only resize it (the expanded
 * width elsewhere covers the panel, and there is no panel to cover here) and
 * take away the handle, since there is nothing to collapse into.
 */
@media (min-width: 992px) {
    body.bw-nav-dashboard .navbar-sidenav-rail {
        width: var(--bw-panel-width);
        box-shadow: none;
    }

    body.bw-nav-dashboard .nav-rail-toggle {
        display: none;
    }

    body.bw-nav-dashboard .content-wrapper,
    html[dir='rtl'] body.bw-nav-dashboard .content-wrapper {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: var(--bw-panel-width) !important;
    }

    body.bw-nav-dashboard #mainNav .nav-breadcrumb,
    html[dir='rtl'] body.bw-nav-dashboard #mainNav .nav-breadcrumb {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: calc(var(--bw-panel-width) + 10px) !important;
    }

    body.bw-nav-dashboard footer.sticky-footer {
        width: calc(100% - var(--bw-panel-width));
    }

    body.bw-nav-dashboard.sticky-footer:has(.bw-ent-workspace) footer.sticky-footer,
    html[dir='rtl'] body.bw-nav-dashboard.sticky-footer:has(.bw-ent-workspace) footer.sticky-footer {
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-inline-start: var(--bw-panel-width) !important;
        width: calc(100% - var(--bw-panel-width)) !important;
    }

    body.bw-nav-dashboard #toast-container.toast-portal-content-top {
        margin-inline-start: var(--bw-panel-width);
        width: calc(100% - var(--bw-panel-width));
    }
}

/* Tablet drawer: the rail is the whole drawer when there is no panel beside it. */
@media (max-width: 991.98px) {
    body.bw-nav-dashboard #mainNav .navbar-collapse .navbar-sidenav-rail {
        flex: 1 1 auto;
        width: 100%;
        border-inline-end: 0;
    }

    body.bw-nav-dashboard .navbar-sidenav-rail .nav-rail-label {
        display: block;
    }

    body.bw-nav-dashboard .navbar-sidenav-rail > .nav-item > .nav-link {
        justify-content: flex-start;
        gap: 12px;
        padding: 0 8px;
    }

    body.bw-nav-dashboard .navbar-sidenav-rail .nav-rail-head {
        justify-content: flex-start;
        padding: 12px 16px;
    }

    body.bw-nav-dashboard .navbar-sidenav-rail .nav-rail-brand__mark {
        display: none;
    }

    body.bw-nav-dashboard .navbar-sidenav-rail .nav-rail-brand__full {
        display: block;
    }
}

/* ----------------------------------------------- level 2 section page list */
/*
 * A section's pages render flat at the top of the panel, so the list must drop
 * the nested indent .sidenav-second-level carries when it sits inside a group.
 */
#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list {
    width: 100%;
    margin: 0;
    padding-inline-start: 0;
    list-style: none;
}

#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li {
    width: 100%;
}

#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a,
html[dir='rtl'] #mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a {
    display: block;
    padding: 1em;
}

/* Sub-group rows: the caret belongs at the inline end, not next to the label.
   float:right is unreliable here, so lay the row out and push the caret over. */
#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a.nav-link-collapse {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a.nav-link-collapse > .nav-link-text {
    flex: 1 1 auto;
    min-width: 0;
}

#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a.nav-link-collapse::after,
html[dir='rtl'] #mainNav .navbar-collapse .navbar-sidenav > .bw-section-list > li > a.nav-link-collapse::after {
    float: none;
    flex: 0 0 auto;
    margin-inline-start: auto;
}

/*
 * Nested collapse rows (People On Board under Reports, and friends): sb-admin
 * lays the caret out with margin-inline-start:auto, which needs a flex row —
 * but `.sidenav-second-level > li > a { display: block }` outranks the :has()
 * rule that would have supplied it, so the caret sat against the label instead
 * of the row's end. The gap replaces the .me-lg-2 wrapper the plain rows beside
 * them use, so all the labels in a group still line up.
 */
#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level > li > a.nav-link-collapse {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level > li > a.nav-link-collapse > .nav-link-text {
    flex: 1 1 auto;
    min-width: 0;
}

#mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level > li > a.nav-link-collapse::after,
html[dir='rtl'] #mainNav .navbar-collapse .navbar-sidenav .sidenav-second-level > li > a.nav-link-collapse::after {
    float: none;
    flex: 0 0 auto;
    margin-inline-start: auto;
}

/* Sub-groups inside a section (Reports, Policies, Biometrics…) keep their indent. */
#mainNav .navbar-collapse .navbar-sidenav > .bw-section-list .sidenav-second-level > li > a,
html[dir='rtl'] #mainNav .navbar-collapse .navbar-sidenav > .bw-section-list .sidenav-second-level > li > a {
    padding: 1em;
    padding-inline-start: 2.25em;
}

/* ------------------------------------------------------------ nav search */
.nav-search {
    position: relative;
    list-style: none;
    padding: 10px 12px 4px;
}

/*
 * In the panel the search occupies a band the height of the rail's logo band,
 * so the list below it starts level with the rail's first item (8px panel
 * padding + 72 = 80; rail head 72 + its 6px margin + the list's 2px gap = 80).
 */
#mainNav .navbar-collapse .navbar-sidenav > .nav-search {
    height: 72px;
    padding-bottom: 0;
}

.nav-search__field {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-search__icon {
    position: absolute;
    inset-inline-start: 10px;
    font-size: 18px;
    color: var(--color-grey-600, #6b7280);
    pointer-events: none;
}

.nav-search__input {
    width: 100%;
    height: 36px;
    padding-block: 0;
    padding-inline: 34px 10px;
    border: 1px solid var(--bw-rail-border);
    border-radius: 8px;
    background: #ffffff;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-link, #414346);
}

.nav-search__input::placeholder {
    color: var(--color-grey-600, #6b7280);
}

.nav-search__input:focus {
    outline: none;
    border-color: var(--bw-rail-active);
    box-shadow: 0 0 0 3px rgba(25, 51, 81, 0.1);
}

/* Search clears its own field; the browser's extra button crowds the box. */
.nav-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/*
 * Fixed, and reparented to <body> by portalNavSearch.js. Both sidebars are
 * scroll containers (overflow-y: auto), so a dropdown positioned inside one is
 * clipped at its edge — and sb-admin.min.js binds a legacy mousewheel handler
 * to .navbar-sidenav / .navbar-collapse that calls preventDefault on every
 * wheel event inside them, which stops an inner list scrolling at all.
 * Out here it is clipped by nothing and reachable by the wheel.
 */
.nav-search__results {
    position: fixed;
    z-index: 1085;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 0;
    border: 1px solid var(--bw-rail-border);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(25, 51, 81, 0.16);
}

.nav-search__group {
    margin: 6px 0 2px;
    padding: 0 12px;
    /* A rule between modules; the first heading needs none. */
    border-top: 1px solid var(--bw-rail-border);
    padding-top: 8px;
    margin-top: 8px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-grey-600, #6b7280);
}

.nav-search__group:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

.nav-search__hit {
    display: block;
    padding: 7px 12px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-link, #414346) !important;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-search__hit.is-active,
.nav-search__hit:hover {
    background-color: var(--color-primary-50, #e8eefc);
    text-decoration: none;
}

.nav-search__empty {
    margin: 0;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--color-grey-600, #6b7280);
}

/* Collapsed rail is 68px wide — no room for a field, and the panel beside it
   already carries one. Only the dashboard's expanded sidebar shows it there. */
.navbar-sidenav-rail .nav-search {
    display: none;
}

body.bw-nav-dashboard .navbar-sidenav-rail .nav-search {
    display: block;
    /* Clear the top bar's edge by the same 8px the second sidebar gives its
       first item. 6 here + the list's own 2px row gap = 8. */
    margin-top: 6px;
    padding-top: 0;
}

body.bw-nav-dashboard .navbar-sidenav-rail .nav-rail-head {
    margin-bottom: 0;
}

/* ------------------------------------------------- level 2 section heading */
.navbar-sidenav-section {
    list-style: none;
    /* A rail row's height, text centred: the heading then sits on the same line
       as the first rail icon rather than floating above it. */
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-grey-600, #6b7280);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
