.app-layout {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--ui-sidebar-expanded) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  background: var(--color-sidebar);
  padding: var(--space-6) var(--space-4);
}

.sidebar-brand {
  min-height: var(--ui-touch-target);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: #ffffff;
  text-decoration: none;
}

.sidebar-brand:hover {
  color: #ffffff;
}

.sidebar-brand small {
  display: block;
  color: var(--color-sidebar-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.sidebar-brand .sidebar-organization {
  margin-top: 2px;
  color: #ffffff;
}

.sidebar-brand-copy {
  min-width: 0;
}

.sidebar-brand-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  color: var(--color-accent);
  font-weight: 800;
}

.sidebar-nav {
  display: grid;
  gap: var(--space-2);
}

.nav-item {
  position: relative;
  min-height: var(--ui-touch-target);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--ui-radius-button);
  color: var(--ui-nav-text);
  padding: 0 var(--space-3);
  text-decoration: none;
  transition:
    background-color var(--ui-motion-hover) ease,
    color var(--ui-motion-hover) ease;
}

.nav-item:hover,
.nav-item.active {
  background: var(--ui-nav-hover);
  color: #ffffff;
}

.nav-item.active {
  background: var(--ui-nav-active);
  box-shadow: inset 3px 0 0 var(--ui-brand);
}

.nav-item.active .nav-icon {
  color: var(--color-accent);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: grid;
  place-items: center;
  color: var(--color-sidebar-muted);
}

.ui-icon {
  width: 20px;
  height: 20px;
}

.sidebar-caption {
  margin: auto 0 0;
  color: var(--ui-nav-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.workspace {
  width: 100%;
  min-width: 0;
}

.workspace-topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-width: 0;
  height: var(--ui-topbar-desktop);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: rgb(255 255 255 / 96%);
  padding: 0 var(--space-8);
  backdrop-filter: blur(12px);
}

.topbar-context {
  min-width: 0;
}

.topbar-kicker {
  margin-bottom: var(--space-1);
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.topbar-title {
  display: block;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.user-menu {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-text);
  font-weight: 800;
}

.user-meta strong,
.user-meta span {
  display: block;
  overflow: hidden;
  max-width: 220px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.app-shell {
  width: 100%;
  min-width: 0;
  min-height: calc(100vh - var(--ui-topbar-desktop));
}

.content-panel {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) 56px;
  overflow-wrap: anywhere;
}

.narrow-panel {
  max-width: 920px;
}

.page-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.page-heading > * {
  min-width: 0;
}

.page-heading p {
  margin-bottom: 0;
  color: var(--color-text-secondary);
}

.skip-link {
  position: fixed;
  left: var(--space-4);
  top: var(--space-3);
  z-index: 50;
  border-radius: var(--ui-radius-button);
  background: var(--ui-surface);
  color: var(--ui-text);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--ui-motion-hover) ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.mobile-bottom-navigation {
  display: none;
}

@media (min-width: 768px) and (max-width: 1279.98px) {
  .app-layout {
    grid-template-columns: var(--ui-sidebar-collapsed) minmax(0, 1fr);
  }

  .sidebar {
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-4) 10px;
  }

  .sidebar-brand {
    justify-content: center;
  }

  .sidebar-brand-copy,
  .sidebar-caption,
  .sidebar .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .sidebar-nav {
    width: 100%;
  }

  .sidebar .nav-item {
    min-height: 52px;
    justify-content: center;
    padding: 0;
  }

  .sidebar .nav-item.active {
    box-shadow: inset 3px 0 0 var(--ui-brand);
  }

  .workspace-topbar {
    padding: 0 var(--space-6);
  }

  .content-panel {
    padding-inline: var(--space-5);
  }
}

@media (max-width: 767.98px) {
  .app-layout {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .workspace-topbar {
    height: var(--ui-topbar-mobile);
    gap: var(--space-3);
    padding: 0 var(--space-4);
  }

  .topbar-kicker,
  .user-meta {
    display: none;
  }

  .topbar-title {
    font-size: 14px;
  }

  .topbar-actions {
    gap: var(--space-2);
  }

  .user-avatar {
    width: 32px;
    height: 32px;
  }

  .app-shell {
    min-height: calc(100vh - var(--ui-topbar-mobile));
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  .content-panel,
  .message-stack {
    max-width: 100%;
    padding-inline: var(--space-4);
  }

  .content-panel {
    padding-top: var(--space-6);
  }

  .message-stack {
    margin-top: var(--space-4);
  }

  .page-heading {
    gap: var(--space-4);
    margin-bottom: var(--space-5);
  }

  .page-heading > .button-row {
    width: 100%;
  }

  .mobile-bottom-navigation {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    min-height: calc(64px + env(safe-area-inset-bottom));
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    border-top: 1px solid rgb(255 255 255 / 10%);
    background: var(--ui-nav);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -8px 24px rgb(13 23 32 / 14%);
  }

  .mobile-bottom-navigation .nav-item {
    min-width: 0;
    min-height: 64px;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    border-radius: 0;
    padding: 5px 3px;
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
  }

  .mobile-bottom-navigation .nav-item.active {
    background: var(--ui-nav-active);
    box-shadow: inset 0 3px 0 var(--ui-brand);
  }

  .mobile-bottom-navigation .nav-icon {
    width: 24px;
    height: 24px;
  }

  .mobile-bottom-navigation .nav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
}
