/* Application shell: compact rail (68px) + expanded overlay (240px, never pushes content). */

.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width-compact);
  height: 100vh;
  height: 100dvh;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: var(--sidebar-surface);
  border-right: 1px solid var(--border-soft);
  z-index: var(--z-sidebar);
  overflow: hidden;
  transition: width 160ms ease, box-shadow 160ms ease;
}

.sidebar[data-mode="expanded"] {
  width: var(--sidebar-width-expanded);
  box-shadow: var(--shadow-nav-panel);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}

.sidebar__top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 8px;
  flex: none;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.sidebar[data-mode="expanded"] .sidebar__top {
  align-items: stretch;
  gap: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar[data-mode="compact"] .sidebar__top {
  padding-bottom: 4px;
}

.sidebar[data-mode="compact"] .sidebar__head {
  flex-direction: column;
  align-items: center;
  width: auto;
}

.sidebar[data-mode="compact"] .sidebar__nav {
  padding-top: 0;
}

.sidebar[data-mode="compact"] .sidebar__branding {
  display: none;
}

.sidebar__toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--icon-secondary);
  flex: none;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.12s ease, color 0.12s ease;
}

.sidebar__toggle:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.sidebar__toggle:active {
  background: var(--blue-soft);
  color: var(--blue);
}

.sidebar__toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.sidebar__toggle .icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
}

.sidebar__branding {
  flex: 1;
  min-width: 0;
  user-select: none;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.sidebar__branding:hover {
  text-decoration: none;
}

.sidebar__branding:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 8px;
}

.sidebar__item--skeleton {
  pointer-events: none;
  opacity: 0.55;
}

.sidebar__skel-icon,
.sidebar__skel-label {
  display: block;
  border-radius: 6px;
  background: var(--hover);
}

.sidebar__skel-icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.sidebar__skel-label {
  width: 48px;
  height: 10px;
}

.sidebar[data-mode="expanded"] .sidebar__skel-label {
  width: 96px;
}


.sidebar__wordmark {
  display: block;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-family: var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__wordmark-main {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.sidebar__wordmark-tld {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-secondary);
}

.sidebar__mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--primary);
  color: var(--text-on-blue);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.sidebar__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  flex: none;
}

.sidebar__spacer {
  flex: 1 1 auto;
  min-height: 8px;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0 10px;
  border-top: 1px solid var(--border-soft);
  flex: none;
}

/* Nav items — compact: vertical icon + short label; expanded: horizontal */
.sidebar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 48px;
  min-width: 44px;
  margin: 0 7px;
  padding: 6px 4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  pointer-events: auto;
  width: calc(100% - 14px);
}

.sidebar[data-mode="expanded"] .sidebar__item {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  height: auto;
  margin: 0 10px;
  padding: 7px 10px;
  width: calc(100% - 20px);
  font-size: var(--fs-14);
  font-weight: 400;
  line-height: 20px;
  text-align: left;
}

.sidebar__item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar__item:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.sidebar__item .icon {
  width: 18px;
  height: 18px;
  color: var(--icon-secondary);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.sidebar__item:hover .icon,
.sidebar__item[aria-current="page"] .icon,
.sidebar__item.is-active .icon {
  color: inherit;
}

.sidebar__label {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar[data-mode="compact"] .sidebar__label--full,
.sidebar[data-mode="compact"] .sidebar__text {
  display: none;
}

.sidebar[data-mode="expanded"] .sidebar__label--short {
  display: none;
}

.sidebar__text {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.sidebar[data-mode="expanded"] .sidebar__text {
  display: flex;
}

.sidebar__text-title {
  display: block;
  width: 100%;
  font-size: var(--fs-12);
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__text-sub {
  display: block;
  width: 100%;
  font-size: var(--fs-11);
  font-weight: 400;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__item[aria-current="page"],
.sidebar__item.is-active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 500;
}

.sidebar[data-mode="expanded"] .sidebar__item[aria-current="page"],
.sidebar[data-mode="expanded"] .sidebar__item.is-active {
  font-weight: 500;
}

.sidebar__avatar {
  width: 24px;
  height: 24px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--border-soft);
  color: var(--text-secondary);
  font-size: var(--fs-11);
  font-weight: 600;
}

.sidebar[data-mode="expanded"] .sidebar__item--profile {
  min-height: 44px;
}

.sidebar[data-mode="expanded"] .sidebar__item--org,
.sidebar[data-mode="expanded"] .sidebar__item--profile {
  padding-left: 7px;
  gap: 7px;
}

.sidebar__avatar--profile {
  border-radius: 50%;
  background: var(--blue-soft-2);
  color: var(--blue);
}

@media (max-height: 720px) {
  .sidebar[data-mode="compact"] .sidebar__item {
    min-height: 44px;
    gap: 3px;
    padding: 5px 4px 4px;
  }
  .sidebar[data-mode="compact"] .sidebar__top {
    gap: 6px;
    padding-top: 8px;
  }
}

/* ---------- Backdrop (tablet + mobile overlay) ---------- */
.navigation-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-soft);
  z-index: var(--z-sidebar-backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.navigation-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.app.is-navigation-overlay .sidebar {
  z-index: var(--z-sidebar);
}

.app.is-navigation-overlay .navigation-backdrop {
  z-index: var(--z-sidebar-backdrop);
}

/* Mobile overlays the top bar — elevate panel/backdrop above chrome */
@media (max-width: 767px) {
  .app.is-navigation-overlay .navigation-backdrop {
    z-index: calc(var(--z-sidebar) + 6);
  }
  .app.is-navigation-overlay .sidebar {
    z-index: calc(var(--z-sidebar) + 7);
  }
}

@media (prefers-reduced-motion: reduce) {
  .navigation-backdrop {
    transition: none;
  }
}

/* ---------- Device Workspace — full viewport, no sidebar ---------- */
.app.is-workspace .sidebar,
.app.is-workspace .navigation-backdrop {
  display: none !important;
}
.app.is-workspace .content,
.app.is-workspace .app-main {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}
.app.is-workspace .main {
  padding: 16px 18px 24px;
}

/* ---------- Main content — always offset by compact rail only ---------- */
.content,
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-compact-width);
  width: calc(100% - var(--sidebar-compact-width));
  max-width: calc(100% - var(--sidebar-compact-width));
}

.main {
  flex: 1;
  min-width: 0;
  padding: 18px 22px 32px;
  overflow-x: hidden;
}

@media (max-width: 1280px) {
  .main { padding: 14px 14px 28px; }
}

.main:focus { outline: none; box-shadow: none; }

/* ---------- Page header / breadcrumb (shell-level) ---------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head__titles h1 {
  font-size: var(--fs-20);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.page-head__subtitle {
  margin-top: 3px;
  font-size: var(--fs-13);
  color: var(--text-secondary);
}
.page-head__actions { display: flex; gap: 9px; flex: none; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--blue); text-decoration: none; }
.breadcrumb .icon { width: 13px; height: 13px; }
.breadcrumb__current { color: var(--text); font-weight: 700; }
