.module-mobile-nav, .module-menu-heading { display: none; }

@media screen and (max-width: 1024px) {
  body:not(.auth-screen) .shell {
    --module-bar-height: 64px;
    --module-safe-bottom: env(safe-area-inset-bottom, 0px);
    --module-bar-space: calc(var(--module-bar-height) + var(--module-safe-bottom));
    --module-nav-surface: var(--surface, var(--paper));
    --module-nav-accent: var(--accent-ink, var(--red-ink, #c00000));
    --module-nav-selected: var(--pale, var(--selected, #fbf1f1));
  }

  body:not(.auth-screen) .shell .module-mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 74;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0 max(4px, env(safe-area-inset-right)) var(--module-safe-bottom) max(4px, env(safe-area-inset-left));
    background: var(--module-nav-surface);
    border-top: 1px solid var(--line);
  }

  .shell .module-mobile-nav :is(.module-tab, [data-toggle-menu]) {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
    min-height: var(--module-bar-height);
    padding: 0 4px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
  }

  :is(.module-mobile-nav, .module-menu-heading) svg {
    width: 21px;
    height: 21px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .shell .module-mobile-nav .active,
  .shell:has(.nav-tools .active) .module-mobile-nav [data-toggle-menu] {
    background: var(--module-nav-selected);
    color: var(--module-nav-accent);
  }

  .module-mobile-nav .active::before,
  .shell:has(.nav-tools .active) .module-mobile-nav [data-toggle-menu]::before {
    position: absolute;
    inset: 0 calc(50% - 14px) auto;
    height: 2px;
    background: currentColor;
    content: "";
  }

  .shell .module-mobile-nav [aria-expanded="true"] {
    background: var(--ground);
    color: var(--ink);
  }

  .module-mobile-nav :focus-visible { outline-offset: -3px; }

  body:not(.auth-screen) .shell .workspace { padding-bottom: var(--module-bar-space); }
  body:not(.auth-screen) .shell .topbar-logo { display: inline; }
  body:not(.auth-screen) .shell .bottom-actions { bottom: var(--module-bar-space); }
  body:not(.auth-screen) .shell:has(.module-mobile-nav) ~ #toast {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  body.nav-open:not(.auth-screen)::after {
    position: fixed;
    inset: 0;
    z-index: 73;
    background: rgba(0, 0, 0, .24);
    content: "";
  }

  body.nav-open:not(.auth-screen) .shell .sidebar {
    inset: auto max(8px, env(safe-area-inset-right)) calc(var(--module-bar-space) + 8px) max(8px, env(safe-area-inset-left));
    z-index: 75;
    width: min(400px, calc(100% - 16px));
    height: auto;
    max-height: calc(100vh - var(--module-bar-space) - 16px);
    max-height: calc(100dvh - var(--module-bar-space) - 16px);
    margin: 0 auto;
    padding: 12px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--module-nav-surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
    overscroll-behavior: contain;
  }

  .shell .sidebar .brand,
  #mfg-sidebar > nav[aria-label="Manufacturing"],
  #distribution-sidebar .main-nav > a { display: none; }

  .module-menu-heading {
    order: -2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
  }

  .module-menu-heading button {
    display: grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    margin-right: -6px;
    border: 0;
    background: transparent;
    color: var(--muted);
  }

  .module-menu-heading button:hover { background: var(--ground); }
  .module-menu-heading button:focus-visible { outline-offset: -2px; }

  body.nav-open .shell .sidebar .sci-apps {
    order: -1;
    margin: 0;
    padding: 0 0 8px;
    border: 0;
  }

  .shell .sidebar .sci-app.is-current { background: var(--ground); }
  .shell .sidebar .nav-tools { margin: 0; }
}
