/* Application chrome only. Business pages retain their own layout and typography.
   !important is limited to properties already locked by legacy density rules. */
#appView {
  --nav-ink: #192538;
  --nav-muted: #5c6d82;
  --nav-line: #e4e9f1;
  --nav-sidebar: #fff;
  --nav-blue: #2355bf;
  --nav-selected: #eaf1ff;
  --nav-selected-line: #cfdef9;
  --nav-header-height: 60px;
  --nav-tab-height: 54px;
  --nav-control-height: 36px;
}

body.density-compact #appView {
  --nav-header-height: 54px;
  --nav-tab-height: 48px;
  --nav-control-height: 32px;
}

body.density-dense #appView {
  --nav-header-height: 50px;
  --nav-tab-height: 44px;
  --nav-control-height: 30px;
}

#appView > .topbar {
  min-height: var(--nav-header-height) !important;
  padding: 8px 24px !important;
  gap: 20px;
  background: #fff;
  border-bottom: 1px solid var(--nav-line);
  box-shadow: none;
  color: var(--nav-ink);
}

#appView > .topbar .brandBlock {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

#appView > .topbar .brandLockup {
  flex: 0 0 auto;
}

#appView > .topbar .navLogo {
  width: 28px;
  height: 28px;
}

#appView > .topbar h1 {
  margin: 0;
  color: var(--nav-ink);
  font-size: 17px !important;
  font-weight: 600 !important;
  line-height: 1.2;
}

#appView > .topbar .brandBlock p {
  margin: 0;
  padding-left: 18px;
  border-left: 1px solid var(--nav-line);
  color: var(--nav-muted);
  line-height: 18px;
  white-space: nowrap;
}

#appView > .topbar .topActions {
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
}

#appView > .topbar .currentUser {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--nav-muted);
}

#appView > .topbar .topActions > button,
#appView > .topbar .userMenu > summary {
  min-height: var(--nav-control-height) !important;
  padding: 0 12px !important;
  border: 1px solid var(--nav-line);
  border-radius: 6px;
  background: #fff;
  color: #475569;
  box-shadow: none;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

#appView > .topbar .userMenu > summary::after {
  content: "";
  width: 5px;
  height: 5px;
  margin-left: 9px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

#appView > .topbar .topActions > button:hover,
#appView > .topbar .userMenu > summary:hover {
  border-color: #cbd5e1;
  background: #f5f7fb;
  color: var(--nav-ink);
}

#appView > .topbar .userMenu[open] > summary {
  border-color: var(--nav-selected-line);
  background: var(--nav-selected);
  color: var(--nav-blue);
}

#appView > .topbar .userMenu[open] .userMenuPanel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 232px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid var(--nav-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(25, 37, 56, 0.12);
}

#appView > .tabbar {
  min-height: var(--nav-tab-height);
  gap: 5px;
  padding: 6px 24px;
  border-bottom: 1px solid var(--nav-line);
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow-x: auto;
}

#appView > .tabbar .navButton {
  flex: 0 0 auto;
  min-height: var(--nav-control-height) !important;
  padding: 0 13px !important;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  box-shadow: none;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.3;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

#appView > .tabbar .navButton:hover {
  background: #f5f7fb;
  color: var(--nav-ink);
}

#appView > .tabbar .navButton.active {
  border-color: var(--nav-selected-line);
  background: var(--nav-selected);
  color: var(--nav-blue);
  font-weight: 600 !important;
}

#appView > .layout > .sidebar {
  padding: 16px 10px !important;
  border-right: 1px solid var(--nav-line);
  background: var(--nav-sidebar);
  box-shadow: none;
}

#appView > .layout > .sidebar .workerNav {
  gap: 12px;
}

#appView > .layout > .sidebar .projectNavGroup {
  gap: 4px;
}

#appView > .layout > .sidebar .projectNavButton {
  min-height: 32px !important;
  padding: 5px 9px !important;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  font-size: 12px !important;
  font-weight: 600 !important;
  line-height: 20px;
  white-space: normal;
}

#appView > .layout > .sidebar .projectNavButton > span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

#appView > .layout > .sidebar .projectChevron {
  color: #7b8ba0;
  font-size: 10px;
}

/* The project selects a scope; expansion still follows the existing renderer. */
#appView > .layout > .sidebar .projectNavGroup:has(> .expanded) .projectChevron {
  transform: rotate(0deg);
}

#appView > .layout > .sidebar .projectNavChildren {
  gap: 5px;
  margin-left: 14px;
  padding: 3px 0 9px 9px;
  border-left: 1px solid #dce3ee;
}

#appView > .layout > .sidebar .workerNavItem {
  position: relative;
  min-height: 36px !important;
  padding: 6px 10px !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  background: transparent !important;
  color: #475569;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease;
}

#appView > .layout > .sidebar .workerNavItem span {
  color: inherit !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 20px;
}

#appView > .layout > .sidebar .workerNavCluster {
  gap: 5px;
}

#appView > .layout > .sidebar .assetActionList {
  gap: 3px;
  margin-left: 12px;
  padding-left: 9px;
  border-left-color: #dce3ee;
}

#appView > .layout > .sidebar .assetActionItem {
  min-height: 32px !important;
  padding: 5px 8px !important;
  border: 1px solid transparent;
  background: transparent;
  color: #526278;
  font-size: 12px !important;
  line-height: 20px;
}

#appView > .layout > .sidebar .projectNavButton:hover,
#appView > .layout > .sidebar .assetActionItem:hover {
  background: #edf1f7;
  color: var(--nav-ink);
}

#appView > .layout > .sidebar .workerNavItem:hover {
  background: #edf1f7 !important;
  color: var(--nav-ink);
}

#appView > .layout > .sidebar .projectNavButton.active {
  background: #edf2fa;
  color: var(--nav-blue);
}

#appView > .layout > .sidebar .workerNavItem.active,
#appView > .layout > .sidebar .assetActionItem.active {
  border-color: var(--nav-selected-line) !important;
  background: var(--nav-selected) !important;
  color: var(--nav-blue);
}

#appView > .layout > .sidebar .workerNavItem.active::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: -1px;
  width: 3px;
  border-radius: 2px;
  background: #2563eb;
}

#appView > .topbar :is(button, summary):focus-visible,
#appView > .tabbar .navButton:focus-visible,
#appView > .layout > .sidebar button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

@media (max-width: 768px) {
  #appView > .topbar {
    gap: 10px;
    padding: 12px 16px !important;
  }

  #appView > .topbar .brandBlock {
    justify-content: space-between;
    gap: 10px;
  }

  #appView > .topbar .brandBlock p {
    padding-left: 0;
    border-left: 0;
    font-size: 10px !important;
  }

  #appView > .topbar .topActions {
    gap: 7px;
  }

  #appView > .topbar .topActions > button,
  #appView > .topbar .userMenu > summary {
    min-height: 36px !important;
    padding: 0 10px !important;
  }

  #appView > .tabbar {
    min-height: 50px;
    gap: 4px;
    padding: 6px 10px;
  }

  #appView > .tabbar .navButton {
    min-height: 36px !important;
  }

  #appView > .layout > .sidebar {
    padding: 8px 10px !important;
    border-right: 0;
    border-bottom: 1px solid var(--nav-line);
  }

  #appView > .layout > .sidebar .workerNav {
    gap: 10px;
  }

  #appView > .layout > .sidebar .projectNavChildren {
    padding-top: 0;
    padding-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #appView > .topbar *,
  #appView > .tabbar .navButton,
  #appView > .layout > .sidebar button {
    transition: none;
  }
}
