/* Real mobile #topPrimaryMenu layout. It is not the desktop portal or the sidebar.
   Loaded last, after legacy sheets. No routing, state, accounting or print logic changed. */
@media screen and (max-width:980px) {
  .app-shell .company-header.mobile-reference-header.reference-header{
    box-sizing:border-box!important;
    height:auto!important;
    min-height:calc(76px + max(env(safe-area-inset-top,0px),var(--system-top,24px)))!important;
    padding:calc(8px + max(env(safe-area-inset-top,0px),var(--system-top,24px))) 12px 10px!important;
    grid-template-columns:56px minmax(0,1fr) minmax(0,108px)!important;
    gap:6px!important;
    align-items:center!important;
  }
  .app-shell .company-header .header-start{min-width:0!important;width:auto!important}
  .app-shell .company-header .header-end{min-width:0!important;width:auto!important;max-width:108px!important}
  .app-shell .company-header .reference-role-card{width:100%!important;min-width:0!important;max-width:108px!important;overflow:hidden!important}
  .app-shell .company-header .reference-role-card .role-user-copy{min-width:0!important}
  .app-shell .company-header .reference-role-card .role-user-copy b,
  .app-shell .company-header .reference-role-card .role-user-copy small{max-width:65px!important;overflow:hidden!important;text-overflow:ellipsis!important}
  body.nw-modern-erp #topPrimaryMenu.top-primary-menu.grouped-top-menu.erp-top-menu{
    position:relative!important;
    top:auto!important;
    left:auto!important;
    right:auto!important;
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    align-items:stretch!important;
    justify-items:stretch!important;
    gap:8px!important;
    box-sizing:border-box!important;
    width:calc(100% - 24px)!important;
    max-width:100%!important;
    min-width:0!important;
    height:auto!important;
    margin:10px 12px 12px!important;
    padding:12px!important;
    border:1px solid #e5ebf3!important;
    border-radius:20px!important;
    background:#fff!important;
    box-shadow:0 5px 20px rgba(18,40,70,.035)!important;
    overflow:visible!important;
    contain:none!important;
    touch-action:pan-y!important;
    z-index:115!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group{
    display:block!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
    flex:none!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group:last-child:nth-child(odd){grid-column:1/-1!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group.open{z-index:1350!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-group-trigger{
    box-sizing:border-box!important;
    display:flex!important;
    align-items:center!important;
    justify-content:flex-start!important;
    width:100%!important;
    min-width:0!important;
    min-height:58px!important;
    height:100%!important;
    margin:0!important;
    padding:9px 9px!important;
    gap:8px!important;
    background:#f8fafc!important;
    border:1px solid #e9eef5!important;
    border-radius:14px!important;
    color:#394b63!important;
    font-size:12px!important;
    font-weight:700!important;
    box-shadow:none!important;
    text-align:left!important;
    white-space:normal!important;
    touch-action:manipulation!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-group-trigger>b{
    min-width:0!important;
    flex:1 1 auto!important;
    font-size:12px!important;
    line-height:1.3!important;
    font-weight:750!important;
    letter-spacing:-.03em!important;
    white-space:normal!important;
    word-break:keep-all!important;
    overflow-wrap:anywhere!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-group-trigger .top-menu-chevron{
    flex:0 0 auto!important;
    font-size:10px!important;
    opacity:.52!important;
    color:#687991!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group.active>.top-primary-group-trigger,
  body.nw-modern-erp #topPrimaryMenu .top-primary-group.open>.top-primary-group-trigger{
    color:#155cbb!important;
    background:#edf5ff!important;
    border-color:#d6e6fb!important;
    box-shadow:none!important;
  }
  body.nw-modern-erp #topPrimaryMenu .nw-mobile-menu-icon{
    display:flex!important;
    flex:0 0 32px!important;
    align-items:center!important;
    justify-content:center!important;
    width:32px!important;height:32px!important;
    border-radius:10px!important;
    background:#e9f1fc!important;
    color:#3178c7!important;
    pointer-events:none!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group:nth-child(4n+2) .nw-mobile-menu-icon{background:#f8f2e5!important;color:#b18a38!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group:nth-child(4n+3) .nw-mobile-menu-icon{background:#e8f6ef!important;color:#21956b!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group:nth-child(4n) .nw-mobile-menu-icon{background:#f0edfb!important;color:#8463c4!important}
  body.nw-modern-erp #topPrimaryMenu .nw-mobile-menu-icon svg{display:block!important;width:18px!important;height:18px!important;stroke:currentColor!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-dropdown{
    position:absolute!important;
    top:calc(100% + 7px)!important;
    bottom:auto!important;
    left:0!important;
    right:auto!important;
    box-sizing:border-box!important;
    width:min(300px,calc(100vw - 36px))!important;
    min-width:0!important;
    max-width:calc(100vw - 36px)!important;
    max-height:55dvh!important;
    overflow-y:auto!important;
    border:1px solid #dce5f0!important;
    border-radius:14px!important;
    background:#fff!important;
    box-shadow:0 14px 35px rgba(20,37,65,.15)!important;
    z-index:1500!important;
  }
  body.nw-modern-erp #topPrimaryMenu .top-primary-group:nth-child(even) .top-primary-dropdown{
    left:auto!important;
    right:0!important;
  }
  body.nw-finance-mode.nw-modern-erp #topPrimaryMenu.top-primary-menu.grouped-top-menu.erp-top-menu{
    display:none!important;
  }
  body .app-shell main #content{
    box-sizing:border-box!important;
    padding-bottom:max(160px,calc(var(--nw-scroll-clearance,140px) + 28px))!important;
    scroll-padding-bottom:var(--nw-scroll-clearance,140px)!important;
  }
  .app-shell main{scroll-padding-bottom:var(--nw-scroll-clearance,140px)!important}
}
@media (max-width:370px){
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-group-trigger{gap:6px!important;padding:8px 7px!important}
  body.nw-modern-erp #topPrimaryMenu .nw-mobile-menu-icon{flex-basis:28px!important;width:28px!important;height:28px!important}
  body.nw-modern-erp #topPrimaryMenu .top-primary-group .top-primary-group-trigger>b{font-size:11px!important}
}
@media print{
  body.nw-modern-erp #topPrimaryMenu.top-primary-menu.grouped-top-menu.erp-top-menu{display:none!important}
  body .app-shell main #content{padding-bottom:0!important}
}
