/* Stitch v2 navigation chrome; scoped to the application shell.
   Business panel and table styles remain in their existing components. */
#appView,
body.density-compact #appView {
  --nav-ink: #0f172a;
  --nav-muted: #64748b;
  --nav-line: #e2e8f0;
  --nav-blue: #1e40af;
  --nav-selected: #fff;
  --nav-selected-line: #bfdbfe;
  --nav-header-height: 52px;
  --nav-tab-height: 44px;
  --nav-control-height: 32px;
}
body.density-dense #appView {
  --nav-header-height: 48px;
  --nav-tab-height: 40px;
  --nav-control-height: 30px;
}
#appView > .topbar {
  padding: 8px 16px !important;
  gap: 16px;
  background: radial-gradient(120% 180% at 18% -20%, rgba(37,99,235,.08) 0%, rgba(79,70,229,.05) 32%, rgba(124,58,237,.02) 68%, transparent 100%), linear-gradient(90deg,#f8faff 0%,#f1f5fd 28%,#eef2ff 58%,#f8fafc 100%);
  box-shadow: 0 1px 3px rgba(15,23,42,.04),0 1px 12px -2px rgba(37,99,235,.06);
}
#appView > .topbar .brandBlock { gap: 14px; }
#appView > .topbar .brandLockup { gap: 9px; }
#appView > .topbar h1 { font-size: 12px !important; font-weight: 700 !important; letter-spacing: -.2px; }
#appView > .topbar .stitchBrandMark {
  display: block;
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 7px;
  object-fit: contain;
}
#appView > .topbar .stitchBrandBadge {
  padding: 0 5px; border: 1px solid #bfdbfe; border-radius: 3px;
  background: #eff6ff; color: #1d4ed8; font: 500 10px/16px 'JetBrains Mono',monospace;
  white-space: nowrap;
}
#appView > .topbar .brandBlock .stitchWorkspaceName {
  border-left: 0; padding: 0; display: flex; align-items: center;
  gap: 14px; color: #334155; font-size: 12px !important; font-weight: 600;
}
#appView > .topbar .stitchWorkspaceName::before { content: '/'; color: #94a3b8; font-size: 14px; font-weight: 300; }
#appView > .topbar .topActions { gap: 8px; }
#appView > .topbar .stitchSlogan {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px;
  border-radius: 999px; border: 1px solid #e2e8f0; background: #fff;
  color: #64748b; font-size: 10px; line-height: 16px; white-space: nowrap;
}
#appView > .topbar .stitchSlogan::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #2563eb; }
#appView > .topbar .currentUser {
  padding: 4px 9px; border-radius: 999px; border: 1px solid #d7def7;
  background: rgba(255,255,255,.95); font-size: 11px; line-height: 16px;
}
#appView > .topbar .topActions > button,
#appView > .topbar .userMenu > summary { font-size: 11px !important; padding: 0 9px !important; border-radius: 6px; background: rgba(255,255,255,.9); box-shadow: 0 1px 2px rgba(15,23,42,.03); }
#appView > .topbar .topActions > .languageToggle { border-color: transparent; background: transparent; box-shadow: none; }
#appView > .tabbar {
  padding: 5px 16px; gap: 4px;
  background: radial-gradient(100% 160% at 12% 0%,rgba(37,99,235,.06) 0%,rgba(99,102,241,.04) 35%,rgba(124,58,237,.015) 70%,transparent 100%),linear-gradient(90deg,#fff 0%,#f9fbff 30%,#f4f6fc 70%,#f8fafc 100%);
  box-shadow: 0 1px 2px rgba(15,23,42,.03);
  scrollbar-width: thin;
}
#appView > .tabbar .navButton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px !important; font-size: 12px !important; color: #334155;
}
#appView > .tabbar .navButton:hover { background: rgba(255,255,255,.8); color: #0f172a; }
#appView > .tabbar .navButton.active {
  background: #fff; border-color: #cbd5e1; color: #1e40af;
  font-weight: 700 !important;
  box-shadow: 0 1px 4px rgba(37,99,235,.14),0 2px 8px -2px rgba(79,70,229,.1),0 1px 2px rgba(0,0,0,.04);
}
#appView > .tabbar .navButton.active::before { content: ''; flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%; background: #2563eb; }
#appView > .layout > .sidebar {
  padding: 0 !important;
  gap: 0;
  background: linear-gradient(180deg,#f8fafc 0%,#f1f5f9 50%,#eff6ff 100%);
  border-right: 1px solid #e2e8f0;
}
#appView > .layout > .sidebar .stitchTreeHeading {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; min-height: 38px; background: rgba(255,255,255,.8);
  color: #0f172a; font-size: 11px; font-weight: 700;
}
#appView > .layout > .sidebar .stitchTreeHeading > span { display: flex; align-items: center; gap: 6px; }
#appView > .layout > .sidebar .stitchTreeHeading svg { width: 14px; height: 14px; color: #4f46e5; }
#appView > .layout > .sidebar .stitchTreeHeading small {
  padding: 0 5px; border-radius: 3px; border: 1px solid #a5b4fc; background: #fff;
  color: #3730a3; font: 600 9px/16px 'JetBrains Mono',monospace; letter-spacing: .35px; white-space: nowrap;
}
#appView > .layout > .sidebar .workerNav { padding: 8px; gap: 4px; }
#appView > .layout > .sidebar .projectNavGroup { gap: 4px; }
#appView > .layout > .sidebar .projectNavButton {
  display: flex; align-items: center; gap: 8px; min-height: 34px !important;
  padding: 6px 10px !important; color: #0f172a; font-weight: 700 !important;
}
#appView > .layout > .sidebar .projectChevron {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 20px;
  width: 20px; height: 20px; border-radius: 5px; border: 1px solid transparent;
  color: #4f46e5; font-size: 12px; line-height: 1;
}
#appView > .layout > .sidebar .projectChevron:empty { display: none; }
#appView > .layout > .sidebar .projectNavButton:hover .projectChevron { background: rgba(37,99,235,.08); border-color: #bfdbfe; }
#appView > .layout > .sidebar .projectNavChildren {
  border-left: 0; margin-left: 14px; padding: 2px 0 6px 14px; gap: 4px;
}
#appView > .layout > .sidebar .assetActionList { border-left: 0; margin-left: 8px; padding-left: 10px; gap: 3px; }
#appView > .layout > .sidebar .workerNavItem {
  display: flex; align-items: center; gap: 8px !important;
  min-height: 32px !important; padding: 6px 10px !important; color: #475569;
}
#appView > .layout > .sidebar .workerNavItem::before {
  content: ''; position: static; flex: 0 0 5px; width: 5px; height: 5px;
  border-radius: 50%; background: #cbd5e1;
}
#appView > .layout > .sidebar .workerNavItem.active::before { position: static; width: 5px; height: 5px; border-radius: 50%; background: #2563eb; }
#appView > .layout > .sidebar .workerNavItem:hover,
#appView > .layout > .sidebar .assetActionItem:hover,
#appView > .layout > .sidebar .projectNavButton:hover {
  background: linear-gradient(90deg,rgba(238,242,255,.7),rgba(240,249,255,.5)) !important;
  border-color: #e0e7ff !important;
}
/* A single selected destination; ancestors describe its project/Worker context. */
#appView > .layout > .sidebar :is(.workerNavItem,.assetActionItem,.projectNavButton).active {
  background: linear-gradient(110deg,#fff 0%,#edf3ff 100%) !important;
  border: 1px solid #c7d8f4 !important;
  color: #2449a4 !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(37,70,125,.06),inset 0 1px 0 rgba(255,255,255,.9) !important;
}
#appView > .layout > .sidebar .workerNavItem.active span { font-weight: 600 !important; color: inherit !important; }
#appView > .layout > .sidebar .projectNavGroup:has(.workerNavItem.active,.assetActionItem.active) > .projectNavButton.active {
  background: transparent !important;
  border-color: transparent !important;
  color: #334155 !important;
  box-shadow: none !important;
}
#appView > .layout > .sidebar .workerNavCluster:has(.assetActionItem.active) > .workerNavItem.active {
  background: rgba(226,234,249,.42) !important;
  border-color: transparent !important;
  color: #526581 !important;
  box-shadow: none !important;
}
#appView > .layout > .sidebar :is(.workerNavItem,.assetActionItem,.projectNavButton):focus-visible {
  outline: 2px solid #6086d2;
  outline-offset: 2px;
}
@media (min-width: 981px) {
  body:not([data-current-page="opening"]) #appView > .layout {
    grid-template-columns: 192px minmax(0,1fr) !important;
    background: transparent !important;
  }
  body:not([data-current-page="opening"]):not([data-current-page="businessRisk"]) #appView > .layout {
    min-height: calc(100dvh - var(--nav-header-height) - var(--nav-tab-height) - 1px) !important;
  }
}
@media (max-width: 1100px) {
  #appView > .topbar .stitchSlogan { display: none; }
}
@media (max-width: 980px) {
  body:is([data-current-page="accounts"],[data-current-page="metaApps"]) #appView > .layout > .sidebar .stitchTreeHeading { display: none; }
}
@media (max-width: 768px) {
  #appView > .topbar { padding: 10px 12px !important; gap: 10px; }
  #appView > .topbar .brandBlock { justify-content: flex-start; gap: 10px; }
  #appView > .topbar .brandBlock .stitchWorkspaceName { margin-left: auto; font-size: 10px !important; gap: 8px; }
  #appView > .topbar .topActions { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; gap: 6px; }
  #appView > .topbar .currentUser { max-width: none; font-size: 10px; }
  #appView > .topbar .topActions > button,
  #appView > .topbar .userMenu > summary { min-height: 36px !important; padding: 0 9px !important; }
  #appView > .tabbar { padding: 5px 10px; min-height: 46px; scrollbar-width: none; }
  #appView > .tabbar .navButton { min-height: 36px !important; padding: 0 10px !important; }
  #appView > .layout > .sidebar { padding: 6px 8px !important; border-right: 0; }
  #appView > .layout > .sidebar .stitchTreeHeading { display: none; }
  #appView > .layout > .sidebar .workerNav { padding: 0; gap: 8px; }
  #appView > .layout > .sidebar .workerNavItem { min-height: 36px !important; }
}
