/* Navigation behavior layer, after page-specific styles. */
.ui-modern .topbar { height: auto !important; min-height: 56px !important; max-height: none !important; overflow: visible !important; }
.ui-modern .topbar .topbar-inner { height: auto !important; min-height: 56px !important; max-height: none !important; padding-block: 6px; flex-wrap: wrap !important; row-gap: 6px !important; }
.ui-modern .topbar :is(.topbar-left, .topbar-center, .topbar-right) { min-width: 0 !important; max-width: 100%; }
.ui-modern .topbar .topbar-left { flex: 0 1 auto !important; }
.ui-modern .topbar .topbar-center { flex: 1 1 180px !important; }
.ui-modern .topbar .topbar-right { height: auto !important; flex-wrap: wrap !important; justify-content: flex-end; row-gap: 4px !important; }
/* Desktop groups share one row; percentage heights must not feed back into
   the measured header height used to position the page below it. */
@media (min-width: 992px) {
    .ui-modern .topbar .topbar-inner { flex-wrap: nowrap !important; gap: 12px !important; }
    .ui-modern .topbar .topbar-left { flex: 0 1 350px !important; max-width: 350px !important; }
    .ui-modern .topbar .topbar-center { flex: 1 1 160px !important; max-width: 360px !important; }
    .ui-modern .topbar .topbar-right { flex: 0 0 auto !important; flex-wrap: nowrap !important; gap: 6px !important; margin-block: 0 !important; }
    .ui-modern .topbar #gmtTopbarBranchDropdownWrap { flex: 1 1 190px !important; min-width: 0 !important; width: auto !important; max-width: 240px !important; }
    .ui-modern .topbar .topbar-right .system-mode-toggle__label { display: none !important; }
    .ui-modern .topbar .topbar-right .system-mode-toggle__status { min-width: 0; font-size: 10px; }
    .ui-modern .topbar .topbar-right .topbar-divider { display: none !important; }
    .ui-modern .topbar .topbar-right .topbar-user-link { display: inline-flex !important; align-items: center; gap: 4px; padding: 0 2px !important; }
    .ui-modern .topbar .topbar-right .dropdown-toggle::after { display: none; }
    .ui-modern .topbar .topbar-right .topbar-icon-btn > span.d-lg-inline { display: none !important; }
}
@media (min-width: 992px) and (max-width: 1399.98px) {
    .ui-modern .topbar .topbar-center { display: none !important; }
    .ui-modern .topbar .topbar-mobile-search-trigger { display: block !important; }
    .ui-modern .topbar .topbar-left { flex: 1 1 260px !important; }
    .ui-modern .topbar .topbar-mobile-search { min-width: 320px; }
}
.ui-modern .topbar :is(.dropdown-menu, .topbar-mobile-search) { max-height: calc(100dvh - var(--header-height, 64px) - 16px); overflow-y: auto; overscroll-behavior: contain; }
.ui-modern .topbar #globalSearchResults { max-height: min(420px, 65dvh) !important; }
.ui-modern .topbar #globalSearchResultsSm { max-height: min(360px, 50dvh) !important; }
.ui-modern #sidebar-wrapper { overscroll-behavior: contain; }
.ui-modern #sidebar-wrapper [aria-current="page"] { box-shadow: inset 3px 0 var(--ui-accent); }
.ui-modern #sidebar-wrapper .mobile-close-btn { display: none; border-radius: 8px; min-width: 40px; min-height: 40px; }
@media (min-width: 992px) {
    body.ui-modern.sa-sidebar-collapsed { --sa-sidebar-width: 76px; }
    body.ui-modern:is(.sidebar-collapsed, .sa-sidebar-collapsed) #sidebar-wrapper .list-group-item { font-size: 0 !important; min-height: 44px; gap: 0 !important; justify-content: center; padding-inline: 8px !important; }
    body.ui-modern:is(.sidebar-collapsed, .sa-sidebar-collapsed) #sidebar-wrapper .list-group-item > i { font-size: 1.15rem !important; color: var(--sidebar-text, #dce6f5); margin: 0 !important; }
    body.ui-modern:is(.sidebar-collapsed, .sa-sidebar-collapsed) #sidebar-wrapper .list-group-item > :is(span, .badge) { display: none !important; }
    body.ui-modern.sa-sidebar-collapsed #sidebar-wrapper :is(.sidebar-heading, .sidebar-section-label) { font-size: 0; padding-inline: 8px; }
    body.ui-modern.sa-sidebar-collapsed #sidebar-wrapper .collapse { display: none !important; }
    body.ui-modern.sa-sidebar-collapsed #sidebar-wrapper .list-group > div:not(.collapse) { display: none; }
}
@media (max-width: 991.98px) {
    body.ui-modern.has-sidebar #sidebar-wrapper { position: fixed; inset: 0 auto 0 0; width: min(86vw, 288px) !important; height: 100dvh; transform: translateX(-100%); visibility: hidden; pointer-events: none; z-index: 3000; }
    body.ui-modern.has-sidebar.sidebar-open #sidebar-wrapper { transform: translateX(0) !important; visibility: visible !important; pointer-events: auto !important; opacity: 1 !important; }
    body.ui-modern.has-sidebar #sidebarOverlay { display: block !important; z-index: 2999; }
    body.ui-modern.ui-superadmin #sidebar-wrapper { visibility: hidden; pointer-events: none; z-index: 3000; }
    body.ui-modern.ui-superadmin.sa-sidebar-open #sidebar-wrapper { visibility: visible; pointer-events: auto; }
    body.ui-modern.ui-superadmin .sa-sidebar-overlay { z-index: 2999; }
    .ui-modern #sidebar-wrapper .mobile-close-btn { display: flex !important; align-items: center; justify-content: center; }
    body.ui-modern.has-sidebar .topbar { left: 0 !important; width: 100% !important; margin-left: 0 !important; }
    .ui-modern .topbar .topbar-center { display: none !important; }
    .ui-modern .topbar .topbar-mobile-search-trigger { display: block !important; }
    .ui-modern .topbar .topbar-right { flex: 1 1 auto; }
    .ui-modern .topbar :is(.btn, .nav-link) { min-height: 44px !important; }
    .ui-modern .topbar .dropdown-menu:not(#globalSearchResults):not(#globalSearchResultsSm) { position: fixed !important; inset: calc(var(--header-height, 64px) + 6px) 8px auto auto !important; transform: none !important; width: min(420px, calc(100vw - 16px)) !important; min-width: 0 !important; max-width: calc(100vw - 16px) !important; }
}
@media (max-width: 575.98px) {
    .ui-modern .topbar .topbar-left { flex: 1 1 100% !important; }
    .ui-modern .topbar .topbar-right { width: 100%; justify-content: space-between; margin-left: 0 !important; }
}
@media (prefers-reduced-motion: reduce) { .ui-modern #sidebar-wrapper, .ui-modern #sidebarOverlay { transition: none !important; } }
