:root {
  --app-shell-topbar-height: 48px;
  --app-shell-navigation-width: 248px;
  --app-shell-navigation-rail-width: 52px;
}

html[data-nav-collapsed="true"] {
  --app-shell-navigation-width: var(--app-shell-navigation-rail-width);
}

body { overflow: hidden; }

.app-shell {
  display: grid;
  grid-template-columns: var(--app-shell-navigation-width) minmax(0, 1fr);
  grid-template-rows: var(--app-shell-topbar-height) minmax(0, 1fr) auto;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--ui-color-canvas);
}

.app-shell__topbar {
  z-index: calc(var(--ui-z-sticky) + 2);
  grid-column: 1 / -1;
  grid-row: 1;
  display: grid;
  grid-template-areas: "brand toggle context search notification user";
  grid-template-columns:
    minmax(0, max(0px, calc(var(--app-shell-navigation-width) - var(--ui-control-height) - var(--ui-space-3) - var(--ui-space-4))))
    var(--ui-control-height)
    minmax(0, 1fr)
    minmax(240px, 520px)
    max-content
    max-content;
  gap: var(--ui-space-3);
  align-items: center;
  min-width: 0;
  padding: 0 var(--ui-space-4);
  border-block-end: 1px solid var(--ui-color-border);
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

.app-shell__nav-toggle { grid-area: toggle; border-radius: var(--ui-radius-compact); }

html[data-nav-collapsed="true"] .app-shell__brand { display: none; }
html[data-nav-collapsed="true"] .app-shell__nav-toggle { grid-column: 1 / 3; grid-row: 1; justify-self: center; }

.app-shell__brand {
  grid-area: brand;
  display: inline-flex;
  gap: var(--ui-space-3);
  align-items: center;
  min-width: 0;
  color: var(--ui-color-text);
  font-weight: 700;
  text-decoration: none;
}

.app-shell__brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: var(--ui-radius-control);
  color: var(--ui-color-on-accent);
  background: var(--ui-color-accent);
  font-size: var(--ui-font-size-200);
}

.app-shell__brand-name,
.app-user-menu__name,
.app-context-selector__value span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell__context { grid-area: context; width: 100%; max-width: 280px; min-width: 0; }

.app-context-selector {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: var(--ui-space-3);
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: var(--ui-space-2) var(--ui-space-4);
  border: 0;
  border-radius: var(--ui-radius-control);
  color: var(--ui-color-text);
  background: var(--ui-color-surface-2);
  text-align: start;
}

.app-context-selector:not(:disabled):hover { background: var(--ui-color-surface-hover); }
.app-context-selector:disabled { color: var(--ui-color-text); cursor: default; opacity: 1; }
.app-context-selector .ui-icon { grid-column: 2; grid-row: 1 / 3; width: 16px; height: 16px; color: var(--ui-color-text-secondary); }
.app-context-selector__label { color: var(--ui-color-text-secondary); font-size: 10px; line-height: 1; }
.app-context-selector__value { display: flex; gap: var(--ui-space-2); min-width: 0; font-size: var(--ui-font-size-200); line-height: 1.15; }
.app-context-selector--unavailable { display: grid; }

.app-shell__search {
  grid-area: search;
  display: flex;
  gap: var(--ui-space-3);
  align-items: center;
  justify-self: stretch;
  min-width: 0;
  height: var(--ui-control-height);
  padding-inline: var(--ui-space-4);
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-control);
  background: var(--ui-color-surface-1);
}

.app-shell__search:focus-within { border-color: var(--ui-color-focus); box-shadow: none; }
.app-shell__search .ui-icon { width: 16px; height: 16px; color: var(--ui-color-text-secondary); }
.app-shell__search input { min-width: 0; flex: 1 1 auto; border: 0; outline: 0; color: var(--ui-color-text); background: transparent; }
.app-shell__search input:focus-visible { box-shadow: none; }
.app-shell__search input:disabled { cursor: not-allowed; }
.app-shell__search kbd {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding-inline: var(--ui-space-3);
  border: var(--ui-border-width) solid var(--ui-color-border);
  border-radius: var(--ui-radius-control);
  color: var(--ui-color-text-secondary);
  background: var(--ui-color-surface-3);
  font-family: var(--ui-font-family);
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}

.app-shell__notification { grid-area: notification; }
.app-shell__notification:disabled { color: var(--ui-color-text-secondary); background: transparent; opacity: .7; }

.app-user-menu { position: relative; grid-area: user; justify-self: end; min-width: 0; }
.app-user-menu > summary { max-width: 180px; list-style: none; cursor: pointer; }
.app-user-menu > summary::-webkit-details-marker { display: none; }
.app-user-menu__flyout {
  position: absolute;
  z-index: var(--ui-z-flyout);
  inset-block-start: calc(100% + var(--ui-space-3));
  inset-inline-end: 0;
  display: grid;
  width: 220px;
  padding: var(--ui-space-2);
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-surface);
  background: var(--ui-color-surface-1);
  box-shadow: var(--ui-shadow-flyout);
}

.app-user-menu__flyout a,
.app-user-menu__flyout button {
  display: flex;
  gap: var(--ui-space-3);
  align-items: center;
  width: 100%;
  min-height: var(--ui-control-height);
  padding-inline: var(--ui-space-4);
  border: 0;
  border-radius: var(--ui-radius-control);
  color: var(--ui-color-text);
  background: transparent;
  text-align: start;
  text-decoration: none;
}

.app-user-menu__flyout a:hover,
.app-user-menu__flyout button:hover { background: var(--ui-color-surface-hover); }
.app-user-menu__flyout form { margin: 0; }

.app-shell__navigation {
  z-index: calc(var(--ui-z-sticky) + 1);
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden auto;
  border-inline-end: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface-2);
}

.app-navigation { display: grid; gap: var(--ui-space-3); padding: var(--ui-space-4); }
.app-navigation__home,
.app-navigation__group a {
  display: flex;
  gap: var(--ui-space-3);
  align-items: center;
  min-height: var(--ui-control-height);
  padding-inline: var(--ui-space-4);
  border-radius: var(--ui-radius-control);
  color: var(--ui-color-text);
  text-decoration: none;
}

.app-navigation__home:hover,
.app-navigation__group a:hover { background: var(--ui-color-surface-hover); }
.app-navigation__home.is-active,
.app-navigation__group a.is-active { color: var(--ui-color-accent); background: var(--ui-color-accent-subtle); font-weight: 600; }
.app-navigation__home .ui-icon { width: 18px; height: 18px; }

.app-navigation__groups { display: grid; gap: var(--ui-space-4); }
.app-navigation__group { min-width: 0; }
.app-navigation__group h2 {
  display: flex;
  gap: var(--ui-space-3);
  align-items: center;
  min-height: 28px;
  margin: 0;
  padding-inline: var(--ui-space-4);
  color: var(--ui-color-text-secondary);
  font-size: var(--ui-font-size-100);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.app-navigation__group h2 .ui-icon { width: 16px; height: 16px; }
.app-navigation__group ul { display: grid; gap: var(--ui-space-1); margin: 0; padding: 0; list-style: none; }
.app-navigation__group a { padding-inline-start: 34px; font-size: var(--ui-font-size-200); }
.app-navigation__state { display: flex; gap: var(--ui-space-3); align-items: flex-start; padding: var(--ui-space-4); color: var(--ui-color-warning); font-size: var(--ui-font-size-200); }
.app-navigation__empty { margin: var(--ui-space-4); color: var(--ui-color-text-secondary); font-size: var(--ui-font-size-200); }

html[data-nav-collapsed="true"] .app-navigation { padding-inline: var(--ui-space-3); }
html[data-nav-collapsed="true"] .app-navigation__home { justify-content: center; padding: 0; }
html[data-nav-collapsed="true"] .app-navigation__home span,
html[data-nav-collapsed="true"] .app-navigation__group h2 span,
html[data-nav-collapsed="true"] .app-navigation__group ul,
html[data-nav-collapsed="true"] .app-navigation__state span,
html[data-nav-collapsed="true"] .app-navigation__empty { display: none; }
html[data-nav-collapsed="true"] .app-navigation__group h2 { justify-content: center; padding: 0; }

.app-shell__main {
  grid-column: 2;
  grid-row: 2 / 4;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.app-page-header {
  inset-block-start: 0;
  display: flex;
  gap: var(--ui-space-6);
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: var(--ui-space-4) var(--ui-space-6);
  border-block-end: 1px solid var(--ui-color-border);
}

.app-page-header__identity { min-width: 0; }
.app-page-header h1 { margin: 0; overflow: hidden; font-size: var(--ui-font-size-500); text-overflow: ellipsis; white-space: nowrap; }
.app-breadcrumb { display: flex; gap: var(--ui-space-2); align-items: center; color: var(--ui-color-text-secondary); font-size: var(--ui-font-size-100); }
.app-breadcrumb a { color: inherit; text-decoration: none; }
.app-breadcrumb a:hover { color: var(--ui-color-accent); text-decoration: underline; }
.app-page-header__commands { display: flex; gap: var(--ui-space-2); align-items: center; }
.app-shell__workspace { width: min(100%, 1680px); margin-inline: auto; padding: var(--ui-space-6); }
.app-shell__main:focus { box-shadow: none; }

.app-shell__backdrop { display: none; }
.app-shell__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .app-shell__topbar {
    grid-template-areas: "brand toggle search search notification user";
    grid-template-columns:
      minmax(0, max(0px, calc(var(--app-shell-navigation-width) - var(--ui-control-height) - var(--ui-space-3) - var(--ui-space-4))))
      var(--ui-control-height)
      minmax(160px, 1fr)
      minmax(0, 320px)
      max-content
      max-content;
  }
  .app-shell__context { display: none; }
}

@media (max-width: 900px) {
  :root { --app-shell-navigation-width: 0px; }
  html[data-nav-collapsed="true"] { --app-shell-navigation-width: 0px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-shell__topbar {
    grid-column: 1;
    grid-template-areas: "brand search toggle notification";
    grid-template-columns: max-content minmax(120px, 1fr) var(--ui-control-height) max-content;
  }
  .app-shell__topbar:not(:has(.app-shell__notification)) {
    grid-template-areas: "brand search toggle";
    grid-template-columns: max-content minmax(120px, 1fr) var(--ui-control-height);
  }
  html[data-nav-collapsed="true"] .app-shell__brand { display: inline-flex; }
  html[data-nav-collapsed="true"] .app-shell__nav-toggle { grid-area: toggle; justify-self: stretch; }
  .app-shell__brand-mark { width: var(--ui-control-height); height: var(--ui-control-height); }
  .app-user-menu { display: none; }
  .app-shell__navigation {
    position: fixed;
    z-index: calc(var(--ui-z-flyout) + 1);
    inset-block: var(--app-shell-topbar-height) 0;
    inset-inline-start: 0;
    width: min(82vw, 288px);
    border-inline-end: 0;
    box-shadow: var(--ui-shadow-flyout);
    transform: translateX(-105%);
    transition: transform var(--ui-motion-normal);
  }
  html[dir="rtl"] .app-shell__navigation { transform: translateX(105%); }
  html[data-nav-open="true"] .app-shell__navigation { transform: translateX(0); }
  .app-shell__main { grid-column: 1; }
  .app-shell__backdrop {
    position: fixed;
    z-index: var(--ui-z-flyout);
    inset: var(--app-shell-topbar-height) 0 0;
    display: block;
    border: 0;
    background: var(--ui-color-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ui-motion-normal), visibility var(--ui-motion-normal);
  }
  html[data-nav-open="true"] .app-shell__backdrop { opacity: 1; visibility: visible; }
  html[data-nav-collapsed="true"] .app-navigation__home span,
  html[data-nav-collapsed="true"] .app-navigation__group h2 span { display: inline; }
  html[data-nav-collapsed="true"] .app-navigation__group ul { display: grid; }
  html[data-nav-collapsed="true"] .app-navigation__home,
  html[data-nav-collapsed="true"] .app-navigation__group h2 { justify-content: flex-start; padding-inline: var(--ui-space-4); }
}

@media (max-width: 620px) {
  .app-shell__topbar {
    grid-template-areas: "brand search toggle";
    grid-template-columns: max-content minmax(0, 1fr) var(--ui-control-height);
  }
  .app-shell__brand-name,
  .app-shell__notification,
  .app-user-menu__name,
  .app-shell__search kbd { display: none; }
  .app-page-header { align-items: flex-start; flex-direction: column; min-height: auto; }
  .app-shell__workspace { padding: var(--ui-space-4); }
}

@media (forced-colors: active) {
  .app-shell__topbar,
  .app-shell__navigation,
  .app-page-header { border-color: CanvasText; }
  .app-navigation__home.is-active,
  .app-navigation__group a.is-active { border: 1px solid Highlight; }
}


/* Nested ERPPlatform menu tree. Base layout, topbar and rail remain CleanMiniErp. */
.app-navigation__section { min-width: 0; }
.app-navigation__section[hidden] { display: none; }
.app-navigation__section > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ui-space-2);
    min-height: var(--ui-control-height);
    padding-inline: var(--ui-space-4);
    border-radius: var(--ui-radius-control);
    color: var(--ui-color-text-secondary);
    font-size: var(--ui-font-size-200);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.app-navigation__section > summary::-webkit-details-marker { display: none; }
.app-navigation__section > summary:hover { background: var(--ui-color-surface-hover); }
.app-navigation__section > summary:focus-visible { box-shadow: var(--ui-focus-ring); }
.app-navigation__section > summary .ui-icon { width: 16px; height: 16px; transition: transform var(--ui-motion-fast); }
.app-navigation__section[open] > summary .ui-icon { transform: rotate(180deg); }
.app-navigation__section ul { padding-block: var(--ui-space-2); }
.app-navigation__section a { padding-inline-start: 24px; }
.app-navigation__section [data-app-nav-item][hidden] { display: none; }
.app-user-menu__notice { display: block; padding: var(--ui-space-4); color: var(--ui-color-text-secondary); font-size: var(--ui-font-size-200); }
html[data-nav-collapsed="true"] .app-navigation__section { display: none; }
@media (max-width: 900px) {
    html[data-nav-open="true"] .app-navigation__section { display: block; }
}


/* Keep scrollbar geometry constant to prevent horizontal menu jitter.
   Only the thumb color changes on hover, not the scrollbar width. */
.app-shell__navigation {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
  overscroll-behavior-y: contain;
}
.app-shell__navigation::-webkit-scrollbar { width: 7px; height: 7px; }
.app-shell__navigation::-webkit-scrollbar-track { background: transparent; }
.app-shell__navigation::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
@media (hover: hover) and (pointer: fine) {
  .app-shell__navigation:hover { scrollbar-color: #aeb8c4 transparent; }
  .app-shell__navigation:hover::-webkit-scrollbar-thumb { background: #aeb8c4; }
  .app-shell__navigation::-webkit-scrollbar-thumb:hover { background: #7f90a3; }
}
@media (hover: none) {
  .app-shell__navigation { scrollbar-color: #aeb8c4 transparent; }
  .app-shell__navigation::-webkit-scrollbar-thumb { background: #aeb8c4; }
}
/* Compact, readable navigation with distinct focus, hover and active states. */
.app-navigation__home,
.app-navigation__group a,
.app-navigation__section > summary {
  transition: background-color 120ms ease, color 120ms ease;
}
.app-navigation__group a,
.app-navigation__section > summary {
  line-height: 1.35;
}
.app-navigation__section > summary:hover,
.app-navigation__group a:hover,
.app-navigation__home:hover {
  color: var(--ui-color-text);
  background: var(--ui-color-surface-hover);
}
.app-navigation__group a.is-active,
.app-navigation__home.is-active {
  color: var(--ui-color-accent);
  background: var(--ui-color-accent-subtle);
  font-weight: 650;
}
.app-navigation__section:has(a.is-active) > summary {
  color: var(--ui-color-text);
}
.app-navigation__home:focus-visible,
.app-navigation__group a:focus-visible,
.app-navigation__section > summary:focus-visible {
  outline: 2px solid var(--ui-color-focus);
  outline-offset: -2px;
}
.app-navigation__group h2 { line-height: 1.3; }
@media (prefers-reduced-motion: reduce) {
  .app-navigation__home,
  .app-navigation__group a,
  .app-navigation__section > summary { transition: none; }
}

/* Pinned account control: outside the menu's independent scroll area. */
.app-shell__user-footer {
  position: relative;
  z-index: calc(var(--ui-z-sticky) + 2);
  grid-column: 1;
  grid-row: 3;
  min-width: 0;
  padding: 8px;
  border-top: 1px solid var(--ui-color-border);
  border-right: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface-2);
}
.app-user-trigger {
  width: 100%;
  min-height: 48px;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border: 0;
  border-radius: 9px;
  text-align: left;
  background: transparent;
  color: var(--ui-color-text);
  cursor: pointer;
}
.app-user-trigger:hover, .app-user-trigger[aria-expanded="true"] { background: var(--ui-color-surface-hover); }
.app-user-trigger:focus-visible { outline: 2px solid var(--ui-color-focus); outline-offset: -2px; }
.app-user-avatar { flex: 0 0 32px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ui-color-accent); color: white; font-weight: 700; }
.app-user-identity { flex: 1; min-width: 0; display: grid; gap: 2px; }
.app-user-identity__name { font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-identity__sub { font-size: 10px; color: var(--ui-color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-trigger > .ui-icon { width: 15px; height: 15px; color: var(--ui-color-text-secondary); }
.app-user-popover {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 6px);
  width: max(238px, calc(100% - 16px));
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(480px, calc(100vh - 100px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--ui-color-border);
  border-radius: 12px;
  background: var(--ui-color-surface-1);
  box-shadow: 0 10px 35px rgb(0 0 0 / 15%);
}
.app-user-popover[hidden] { display: none !important; }
.app-user-popover__heading { padding: 11px 10px; font-size: 12px; font-weight: 650; }
.app-user-popover__heading small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; color: var(--ui-color-text-secondary); }
.app-user-popover__group { display: grid; gap: 2px; padding: 7px 0; border-top: 1px solid var(--ui-color-border); }
.app-user-popover__label { padding: 3px 10px 6px; font-size: 10px; color: var(--ui-color-text-secondary); }
.app-user-popover__group a, .app-user-popover__group button {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px;
  padding: 7px 10px; border: 0; border-radius: 7px;
  color: var(--ui-color-text); background: transparent; text-align: left;
  font: inherit; font-size: 12px; text-decoration: none; cursor: pointer;
}
.app-user-popover__group a:hover, .app-user-popover__group button:not(:disabled):hover { background: var(--ui-color-surface-hover); }
.app-user-popover__group button[aria-pressed="true"] { color: var(--ui-color-accent); background: var(--ui-color-accent-subtle); }
.app-user-popover__group button:disabled { opacity: .55; cursor: not-allowed; }
.app-user-popover__group small { margin-left: auto; font-size: 10px; }
.app-user-popover__group .ui-icon { flex-shrink: 0; width: 16px; height: 16px; }
html[data-nav-collapsed="true"] .app-user-identity,
html[data-nav-collapsed="true"] .app-user-trigger > .ui-icon { display: none; }
html[data-nav-collapsed="true"] .app-user-trigger { justify-content: center; padding-inline: 0; }
html[data-nav-collapsed="true"] .app-user-popover { width: 250px; }
@media (max-width: 900px) {
  .app-shell__user-footer {
    position: fixed; z-index: calc(var(--ui-z-flyout) + 2);
    bottom: 0; left: 0; width: min(82vw, 288px);
    transform: translateX(-105%); transition: transform var(--ui-motion-normal);
  }
  html[data-nav-open="true"] .app-shell__user-footer { transform: translateX(0); }
  .app-shell__navigation { padding-bottom: 70px; }
  html[data-nav-collapsed="true"] .app-user-identity { display: grid; }
  html[data-nav-collapsed="true"] .app-user-trigger > .ui-icon { display: inline-flex; }
  html[data-nav-collapsed="true"] .app-user-trigger { justify-content: flex-start; padding: 6px 8px; }
}

/* Navigation search belongs to the left sidebar, not the global topbar. */
.app-shell__topbar {
  grid-template-areas: "brand toggle context notification";
  grid-template-columns:
    minmax(0, max(0px, calc(var(--app-shell-navigation-width) - var(--ui-control-height) - var(--ui-space-3) - var(--ui-space-4))))
    var(--ui-control-height) minmax(0, 1fr) max-content;
}
.app-navigation__search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-control);
  background: var(--ui-color-surface-1);
}
.app-navigation__search:focus-within { border-color: var(--ui-color-focus); }
.app-navigation__search input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: var(--ui-font-size-200);
}
.app-navigation__search .ui-icon { width: 15px; height: 15px; color: var(--ui-color-text-secondary); }
.app-navigation__search kbd { font-size: 10px; color: var(--ui-color-text-secondary); white-space: nowrap; }
html[data-nav-collapsed="true"] .app-navigation__search { padding-inline: 0; justify-content: center; }
html[data-nav-collapsed="true"] .app-navigation__search input,
html[data-nav-collapsed="true"] .app-navigation__search kbd { display: none; }
@media (max-width: 1100px) {
  .app-shell__topbar {
    grid-template-areas: "brand toggle context notification";
    grid-template-columns: minmax(0, 1fr) var(--ui-control-height) minmax(0, 1fr) max-content;
  }
}
@media (max-width: 900px) {
  .app-shell__topbar {
    grid-template-areas: "brand toggle notification";
    grid-template-columns: minmax(0, 1fr) var(--ui-control-height) max-content;
  }
  html[data-nav-collapsed="true"] .app-navigation__search { padding: 0 9px; justify-content: flex-start; }
  html[data-nav-collapsed="true"] .app-navigation__search input,
  html[data-nav-collapsed="true"] .app-navigation__search kbd { display: block; }
}
@media (max-width: 620px) {
  .app-shell__topbar {
    grid-template-areas: "brand toggle";
    grid-template-columns: minmax(0, 1fr) var(--ui-control-height);
  }
}

/* One topbar: the current page is rendered in its former workspace slot. */
.app-shell__topbar { grid-template-areas: "brand toggle filler notification"; }
.app-shell__page-title {
  position: relative;
  z-index: calc(var(--ui-z-sticky) + 3);
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: start;
  min-width: 0;
  max-width: calc(100% - 70px);
  margin-inline-start: 18px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
  pointer-events: none;
}
.app-shell__page-label { color: var(--ui-color-text-secondary); font-size: 11px; }
.app-shell__page-title strong { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.app-shell__workspace { padding-top: var(--ui-space-5); }
.app-shell__user-footer { padding: 0; }
.app-user-trigger { min-height: 60px; padding: 9px 12px; border-radius: 0; }
.app-user-identity__name { font-size: 14px; }
.app-user-identity__sub { font-size: 11px; }
.app-user-popover__heading { font-size: 14px; }
.app-user-popover__group a, .app-user-popover__group button { font-size: 13px; min-height: 38px; }
.app-user-settings { display: grid; padding: 4px 0 8px 12px; }
.app-user-settings[hidden] { display: none !important; }
.app-user-settings__title { font-size: 11px; color: var(--ui-color-text-secondary); padding: 9px 10px 4px; }
[data-user-settings-toggle] > .ui-icon:last-child { margin-left: auto; }
[data-user-settings-toggle][aria-expanded="true"] > .ui-icon:last-child { transform: rotate(180deg); }
@media(max-width:900px) {
  .app-shell__page-title { margin-inline-start: 12px; }
  .app-shell__page-label { display: none; }
}
@media(max-width:620px) {
  .app-shell__page-title strong { font-size: 12px; }
  .app-shell__page-title { max-width: calc(100% - 55px); }
}

/* Account popover: same compact Fluent/ERP visual density as the navigation. */
.app-user-popover {
  left: 4px;
  bottom: calc(100% + 3px);
  width: max(226px, calc(100% - 8px));
  padding: 3px;
  border: 1px solid var(--ui-color-border);
  border-radius: var(--ui-radius-surface);
  background: var(--ui-color-surface-1);
  box-shadow: 0 3px 12px rgb(0 0 0 / 10%);
}
.app-user-popover__heading {
  padding: 7px 8px;
  font-size: var(--ui-font-size-200);
  line-height: 1.3;
}
.app-user-popover__heading small { margin-top: 2px; font-size: 11px; }
.app-user-popover__group { gap: 1px; padding: 3px 0; }
.app-user-popover__group a,
.app-user-popover__group button {
  min-height: 30px;
  padding: 5px 8px;
  gap: 7px;
  border-radius: var(--ui-radius-control);
  font-size: var(--ui-font-size-200);
  line-height: 1.3;
}
.app-user-popover__group .ui-icon { width: 15px; height: 15px; }
.app-user-popover__label,
.app-user-settings__title { padding: 5px 8px 3px; font-size: 10px; }
.app-user-settings { padding: 2px 0 4px 8px; }
.app-user-popover__group small { font-size: 10px; }
html[data-nav-collapsed="true"] .app-user-popover { width: 240px; }

/* Sidebar search: one 1px focus border, no inherited input glow/ring. */
.app-navigation__search,
.app-navigation__search:focus-within {
  box-sizing: border-box;
  outline: none;
  box-shadow: none;
}
.app-navigation__search:focus-within {
  border-color: var(--ui-color-focus);
}
.app-navigation__search input,
.app-navigation__search input:focus,
.app-navigation__search input:focus-visible {
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  outline: none;
  outline-offset: 0;
  box-shadow: none;
  background: transparent;
}

/* Header: preserve the original brand/hamburger grid positions. */
.app-shell__topbar {
  grid-template-areas: "brand toggle context notification";
  grid-template-columns:
    minmax(0, max(0px, calc(var(--app-shell-navigation-width) - var(--ui-control-height) - var(--ui-space-3) - var(--ui-space-4))))
    var(--ui-control-height) minmax(0, 1fr) max-content;
  gap: var(--ui-space-3);
}
.app-shell__nav-toggle {
  grid-area: toggle;
  width: var(--ui-control-height);
  height: var(--ui-control-height);
  justify-self: center;
}
.app-shell__page-title {
  grid-area: context;
  grid-column: auto;
  grid-row: auto;
  position: static;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  max-width: none;
  margin: 0 0 0 8px;
  padding: 0 0 0 14px;
  min-height: 36px;
  border-left: 1px solid var(--ui-color-border);
  white-space: nowrap;
  pointer-events: auto;
}
.app-shell__page-label { display: block; font-size: 10px; line-height: 1.2; font-weight: 400; color: var(--ui-color-text-secondary); }
.app-shell__breadcrumb-chevron { display: none; }
.app-shell__page-current {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ui-color-text);
  font-size: 15px;
  line-height: 1.2;
  font-weight: 650;
}
html[data-nav-collapsed="true"] .app-shell__topbar {
  grid-template-columns: 0 var(--ui-control-height) minmax(0,1fr) max-content;
}
@media (max-width: 900px) {
  .app-shell__topbar { grid-template-areas: "brand toggle context notification"; grid-template-columns: minmax(0, 1fr) var(--ui-control-height) minmax(0,1fr) max-content; }
}
@media (max-width: 620px) {
  .app-shell__topbar { grid-template-areas: "brand toggle context"; grid-template-columns: minmax(0,1fr) var(--ui-control-height) minmax(90px,1fr); }
  .app-shell__page-title { margin-left: 0; padding-left: var(--ui-space-4); }
  .app-shell__page-current { font-size: 13px; }
}


/* Align the breadcrumb divider with the content edge, without moving the toggle. */
@media (min-width: 621px) {
  .app-shell__page-title { margin-left: 0; padding-left: 8px; }
}

/* The viewport owns the shell; only the main pane scrolls. */
.app-shell { height: 100vh; height: 100dvh; min-height: 0; }
.app-shell__main {
  min-height: 0;
  max-height: calc(100vh - var(--app-shell-topbar-height));
  max-height: calc(100dvh - var(--app-shell-topbar-height));
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
}
.app-shell__main::-webkit-scrollbar { width: 7px; height: 7px; }
.app-shell__main::-webkit-scrollbar-track { background: transparent; }
.app-shell__main::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; }
@media (hover: hover) and (pointer: fine) {
  .app-shell__main:hover { scrollbar-color: #aeb8c4 transparent; }
  .app-shell__main:hover::-webkit-scrollbar-thumb { background: #aeb8c4; }
  .app-shell__main::-webkit-scrollbar-thumb:hover { background: #7f90a3; }
}
@media (hover: none) {
  .app-shell__main { scrollbar-color: #aeb8c4 transparent; }
  .app-shell__main::-webkit-scrollbar-thumb { background: #aeb8c4; }
}

/* Indent section/group headings slightly, without shifting their child links. */
.app-navigation__section > summary {
  padding-inline-start: calc(var(--ui-space-4) + var(--ui-space-2));
}


/* Account Settings: accessible, compact six-color theme picker. Scoped to the
   existing user popover; no global input or component styling is changed. */
.app-user-settings__theme-palette {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 3px 7px 7px;
}

.app-user-popover__group .app-user-settings__theme-palette button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 5px 2px;
    border: 1px solid transparent;
    border-radius: var(--ui-radius-control);
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
}

.app-user-popover__group .app-user-settings__theme-palette button[aria-pressed="true"] {
    border-color: var(--ui-color-accent);
    background: var(--ui-color-accent-subtle);
    color: var(--ui-color-accent);
}

.app-user-popover__group .app-user-settings__theme-palette button:focus-visible {
    outline: 2px solid var(--ui-color-focus);
    outline-offset: 1px;
}

.app-user-settings__swatch {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border-radius: 50%;
    background-color: var(--user-theme-swatch);
    border: 1px solid rgb(0 0 0 / 12%);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 22%);
}

/* The Dashboard participates in the same navigation search as grouped links. */
.app-navigation__home[hidden] { display: none; }
