/* Keep the signed-in app header on one row at every viewport width. */
html body .topbar #accountTrialStatus.account-trial-status,
html body .topbar #accountTrialStatus.fc-trial-strip {
  display: none !important;
}

.topbar {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  min-height: 64px !important;
  height: 64px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap !important;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.topbar::-webkit-scrollbar {
  display: none;
}

.topbar > *,
.topbar .top-actions,
.topbar #helpHeaderActions,
.topbar .switch {
  display: flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  flex-wrap: nowrap !important;
  min-width: max-content !important;
}

.topbar .top-actions,
.topbar #helpHeaderActions {
  gap: 6px !important;
}

.topbar button,
.topbar select,
.topbar a,
.topbar .chip {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

.portal-role-menu:not([hidden]) {
  display: grid !important;
  position: fixed !important;
  top: 62px !important;
  right: 10px !important;
  left: auto !important;
  width: min(238px, calc(100vw - 20px)) !important;
  z-index: 999999 !important;
}

@media (max-width: 760px) {
  .topbar,
  .topbar:has(#helpHeaderActions) {
    display: flex !important;
    grid-template-columns: none !important;
    grid-template-areas: none !important;
    padding: 0 8px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
  }

  .topbar .crumb {
    display: none !important;
  }

  .topbar > #headerHome {
    display: inline-flex !important;
    flex: 0 0 auto !important;
  }

  .topbar .top-actions {
    display: flex !important;
    box-sizing: border-box !important;
    width: calc(100vw - 78px) !important;
    flex: 0 0 calc(100vw - 78px) !important;
    min-width: 0 !important;
    max-width: calc(100vw - 78px) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    justify-content: flex-start !important;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .topbar #helpHeaderActions {
    grid-area: auto !important;
    justify-self: auto !important;
    display: flex !important;
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }

  .topbar .top-actions > * {
    flex: 0 0 auto !important;
  }

  .topbar .top-actions::-webkit-scrollbar {
    display: none;
  }

  .topbar .top-actions > .chip:not(#accountTrialStatus) {
    display: none !important;
  }

  .topbar button,
  .topbar select,
  .topbar a,
  .topbar .chip {
    font-size: 10px !important;
  }
}

/* Keep the compact header truly one row after the Help, notifications and
   team-access controls mount.  Older mobile rules made .top-actions wrap and
   pushed the whole header outside its 64px sticky area. */
@media (max-width: 760px) {
  .topbar,
  .topbar:has(#helpHeaderActions) {
    height:64px !important;
    min-height:64px !important;
    max-height:64px !important;
    padding:8px !important;
    align-items:center !important;
    flex-wrap:nowrap !important;
  }
  .topbar .top-actions {
    display:flex !important;
    flex:1 1 auto !important;
    width:auto !important;
    height:48px !important;
    min-height:0 !important;
    max-height:48px !important;
    align-items:center !important;
    align-self:center !important;
    flex-wrap:nowrap !important;
    overflow-x:auto !important;
    overflow-y:hidden !important;
  }
  .topbar .top-actions > *,
  .topbar #helpHeaderActions,
  .topbar .fc-language-bell,
  .topbar .switch {
    align-self:center !important;
    max-height:44px !important;
  }
}

/* Notification center uses a higher-specificity mobile layout. Keep every
   account control in the same scrollable row when that component is mounted. */
@media (max-width: 760px) {
  body.fc-app-refined .topbar:has(#fcNotificationBell) {
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    overflow: hidden !important;
    gap: 6px !important;
  }

  body.fc-app-refined .topbar:has(#fcNotificationBell) > #headerHome {
    flex: 0 0 auto !important;
  }

  body.fc-app-refined .topbar:has(#fcNotificationBell) > .top-actions {
    display: flex !important;
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
    touch-action: pan-x !important;
    -webkit-overflow-scrolling: touch;
  }

  body.fc-app-refined .topbar:has(#fcNotificationBell) .fc-language-bell,
  body.fc-app-refined .topbar:has(#fcNotificationBell) #helpHeaderActions {
    display: flex !important;
    flex: 0 0 auto !important;
    min-width: max-content !important;
    grid-area: auto !important;
  }

  body.fc-app-refined .topbar:has(#fcNotificationBell),
  body.fc-app-refined .topbar:has(#fcNotificationBell) > .top-actions,
  body.fc-app-refined .topbar:has(#fcNotificationBell) #helpHeaderActions,
  body.fc-app-refined .topbar:has(#fcNotificationBell) .switch {
    overflow: visible !important;
  }

  body.fc-app-refined .portal-role-menu {
    position: fixed !important;
    top: 58px !important;
    right: 8px !important;
    left: auto !important;
    width: min(250px, calc(100vw - 16px)) !important;
    z-index: 99999 !important;
  }
}
