/* One measured fit controller for desktop, browser zoom and landscape tablets.
   Bootstrap expands this navbar at 992px; all stages run in that same range.
   Secondary controls yield before any primary navigation link may clip. */

@media (min-width:992px){
  .navbar.nav-brand.cp-nav-fit-v2-hide-name .cp-desktop-account-dropdown .nav-user-name{
    display:none !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-hide-plan .navbar-right > .cp-nav-plan-badge{
    display:none !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-hide-search .navbar-actions--desktop .cp-gsearch-nav-trigger{
    display:none !important;
  }
  /* Search remains accessible from the Tools menu when its header icon yields. */
  .navbar.nav-brand.cp-nav-fit-v2-hide-search .cp-nav-search-fallback,
  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-nav-search-fallback{
    display:block !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-ready:not(.cp-nav-fit-v2-compact) .navbar-nav.nav-primary{
    overflow-x:visible !important;
    overflow-y:visible !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-ready:not(.cp-nav-fit-v2-compact) .navbar-nav.nav-primary > .nav-item{
    flex-shrink:0 !important;
  }
  /* Stage 1: keep the classic desktop row, but reclaim expendable width. */
  .navbar.nav-brand.cp-nav-fit-v2-tight{
    padding-left:.55rem !important;
    padding-right:.55rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-brand{
    margin-right:.28rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-nav.nav-primary{
    gap:0 !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-nav.nav-primary .nav-link,
  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-nav.nav-primary .btn{
    padding-left:.28rem !important;
    padding-right:.28rem !important;
    font-size:.79rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-right{
    gap:.28rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-right > .badge{
    padding:.34rem .46rem !important;
    font-size:.68rem !important;
    white-space:nowrap !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .nav-user-email{
    display:none !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-actions--desktop{
    gap:.28rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-tight .navbar-actions--desktop .nav-icon-btn{
    width:34px !important;
    height:34px !important;
    min-width:34px !important;
    min-height:34px !important;
    flex-basis:34px !important;
  }

  /* Stage 2: when the measured row still does not fit, use Bootstrap's collapse
     rather than letting tabs render under the right-hand controls. These rules
     intentionally beat the old cp-desktop-nav safety net. */
  .navbar.nav-brand.cp-nav-fit-v2-compact{
    flex-wrap:wrap !important;
    align-content:flex-start !important;
    overflow:visible !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact > .navbar-actions--mobile{
    display:flex !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact > .navbar-toggler{
    display:block !important;
    flex:0 0 auto !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-right{
    display:none !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapse{
    display:none !important;
    flex:0 0 100% !important;
    flex-basis:100% !important;
    width:100% !important;
    min-width:0 !important;
    max-height:min(72vh,720px) !important;
    margin-top:.35rem !important;
    padding:.75rem .75rem 1rem !important;
    position:static !important;
    overflow-x:hidden !important;
    overflow-y:auto !important;
    border-top:1px solid var(--border) !important;
    border-radius:0 0 18px 18px !important;
    background:var(--nav-bg) !important;
    box-shadow:none !important;
    -webkit-overflow-scrolling:touch;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapse.show,
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapsing{
    display:block !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary{
    display:flex !important;
    flex-direction:column !important;
    flex-wrap:nowrap !important;
    align-items:stretch !important;
    width:100% !important;
    max-width:none !important;
    min-width:0 !important;
    margin:0 !important;
    padding:.25rem !important;
    gap:0 !important;
    white-space:normal !important;
    text-align:center !important;
    overflow:visible !important;
    border:1px solid var(--border) !important;
    border-radius:18px !important;
    background:rgba(20,20,24,.78) !important;
    box-shadow:0 18px 45px rgba(0,0,0,.30) !important;
  }

  html[data-theme="light"] .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary{
    background:rgba(255,255,255,.92) !important;
    box-shadow:0 18px 45px rgba(0,0,0,.10) !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary > .nav-item{
    display:block !important;
    flex:0 0 auto !important;
    width:100% !important;
    min-width:0 !important;
    border-top:0 !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary > .nav-item + .nav-item{
    border-top:1px solid rgba(255,255,255,.07) !important;
  }

  html[data-theme="light"] .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary > .nav-item + .nav-item{
    border-top-color:rgba(0,0,0,.06) !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary .nav-link,
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary .btn{
    width:100% !important;
    max-width:100% !important;
    min-height:48px !important;
    padding:.8rem .9rem !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    text-align:center !important;
    white-space:normal !important;
    border-radius:14px !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav .d-lg-none,
  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-mobile-account-item{
    display:block !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav .social-nav.d-lg-none{
    display:flex !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .badge-wrap{
    display:inline-flex !important;
    justify-content:center !important;
    width:100% !important;
    white-space:normal !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-tools-nav{
    position:static !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-tools-menu,
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse .cp-tools-menu{
    position:static !important;
    inset:auto !important;
    transform:none !important;
    float:none !important;
    width:100% !important;
    min-width:0 !important;
    max-width:none !important;
    margin:.1rem 0 .42rem !important;
    padding:.36rem !important;
    border-radius:15px !important;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.035) !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-mobile-account-toggle{
    width:100% !important;
    min-height:54px !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    gap:.65rem !important;
  }

  .navbar.nav-brand.cp-nav-fit-v2-compact .cp-mobile-account-collapse{
    width:100% !important;
  }
}

/* Keep the launcher out of the menu in full desktop mode, yet keyboard and
   touch-accessible when search yields or the hamburger fallback is active. */
.navbar.nav-brand .cp-nav-search-fallback{display:none !important}
.navbar.nav-brand.cp-nav-fit-v2-compact .cp-nav-search-fallback{display:block !important}
.navbar.nav-brand .cp-nav-search-fallback .cp-tools-item{
  width:100%;border:0;text-align:left;cursor:pointer;font:inherit;
}

/* Defensive mobile boundary: even if a legacy header rule forces the
   desktop row at a zoomed width, never paint it over the mobile controls. */
@media (max-width:991.98px){
  .navbar.nav-brand .navbar-right{display:none!important}
  .navbar.nav-brand > .navbar-actions--mobile{display:flex!important}
  .navbar.nav-brand > .navbar-toggler{display:block!important}
  .navbar.nav-brand .navbar-collapse:not(.show):not(.collapsing){display:none!important}
}

/* The measured-fit compact presentation can now be enabled below 992px.
   Its original toggler/collapse rules were desktop-only: preserve identical
   access to all navigation links after device rotation or split view. */
@media (max-width:991.98px) {
  .navbar.nav-brand.cp-nav-fit-v2-compact{
    flex-wrap:wrap !important;
    overflow:visible !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact > .navbar-toggler{
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;
    flex:0 0 auto !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact > .navbar-actions--mobile{
    display:flex !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-right{
    display:none !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse{
    flex:0 0 100% !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapse:not(.show){
    display:none !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapse.show,
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-collapse.collapsing{
    display:block !important;
  }
  .navbar.nav-brand.cp-nav-fit-v2-compact .navbar-nav.nav-primary{
    flex-direction:column !important;
    flex-wrap:nowrap !important;
    align-items:stretch !important;
    min-width:0 !important;
    width:100% !important;
    overflow-x:hidden !important;
  }
}

/* Expanded Bootstrap hamburger menus must use a vertical list even when the
   navbar was previously in desktop mode (zoom, split view, iPad rotation).
   A leftover desktop row would overlap its icon controls below 992px. */
@media (max-width:991.98px) {
  .navbar.nav-brand .navbar-collapse.show .navbar-nav.nav-primary,
  .navbar.nav-brand .navbar-collapse.collapsing .navbar-nav.nav-primary{
    display:flex !important;
    flex-direction:column !important;
    flex-wrap:nowrap !important;
    align-items:stretch !important;
    width:100% !important;
    min-width:0 !important;
    max-width:100% !important;
    gap:0 !important;
    white-space:normal !important;
    overflow-x:hidden !important;
    overflow-y:visible !important;
  }
  .navbar.nav-brand .navbar-collapse.show .navbar-nav.nav-primary > .nav-item,
  .navbar.nav-brand .navbar-collapse.collapsing .navbar-nav.nav-primary > .nav-item{
    flex:0 0 auto !important;
    width:100% !important;
    min-width:0 !important;
  }
  .navbar.nav-brand .navbar-collapse.show .navbar-nav.nav-primary .nav-link,
  .navbar.nav-brand .navbar-collapse.collapsing .navbar-nav.nav-primary .nav-link{
    white-space:normal !important;
    overflow-wrap:anywhere !important;
  }
}

/* Both navigation and right actions participate in the same flex row.
   Do not let intrinsic min-content sizing push links under the icon buttons. */
@media (min-width:992px){
  .navbar.nav-brand:not(.cp-nav-fit-v2-compact) .navbar-collapse{
    min-width:0!important;
  }
  .navbar.nav-brand:not(.cp-nav-fit-v2-compact) .navbar-nav.nav-primary{
    flex:1 1 auto;
    min-width:0!important;
  }
}
