/* Navegação estável: impedir saltos de rolagem e mudanças de largura. */
html { scrollbar-gutter:stable; }
#sidebar { flex-shrink:0; }
#sidebar-menu {
  overflow-anchor:none;
  scrollbar-gutter:stable;
  overscroll-behavior-y:contain;
}
#sidebar-menu .menu-group,
#sidebar-menu .menu-group-submenu { overflow-anchor:none; }
@media (max-width:640px) { html { scrollbar-gutter:auto; } }


/* CG-SIDEBAR-SCROLL-20261021-V2
 * Permanent base navigation fix (owner and every SaaS tenant).
 * Limit the sidebar to the viewport and let the menu, not the entire page,
 * scroll.  Expanded accordion groups must never shrink or clip their items.
 */
@media screen {
  body:not(.pos-fullscreen-active) #sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
  }

  body:not(.pos-fullscreen-active) #sidebar > .sidebar-header {
    flex: 0 0 auto;
  }

  body:not(.pos-fullscreen-active) #sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  body:not(.pos-fullscreen-active) #sidebar-menu > * {
    flex-shrink: 0;
  }
}
