.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(99, 102, 241, 0.08), transparent 140px),
    var(--color-sidebar);
  color: rgba(255, 255, 255, 0.78);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__brand-title {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.app-sidebar__brand-subtitle {
  color: rgba(255, 255, 255, 0.52);
  font-size: 12px;
  margin-top: 2px;
}

.app-sidebar__section {
  padding: 18px 14px 0;
}

.app-sidebar__section-title {
  padding: 0 10px 8px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-sidebar__nav {
  display: grid;
  gap: 4px;
}

.app-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  transition: background 0.18s ease, color 0.18s ease;
}

.app-sidebar__link svg {
  width: 16px;
  height: 16px;
}

.app-sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-sidebar__link.is-active {
  background: rgba(99, 102, 241, 0.28);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.24);
}

.app-sidebar__footer {
  margin-top: 18px;
  padding: 16px 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar__user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.app-sidebar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.9);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.app-shell-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 16px 24px;
  background: rgba(247, 248, 250, 0.88);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px);
}

.app-navbar__left,
.app-navbar__right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-navbar__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}

.app-navbar__subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 24px;
}

.app-page {
  max-width: 1360px;
  margin: 0 auto;
}

.app-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-switcher {
  min-width: 220px;
}

.app-user-menu {
  position: relative;
}

.app-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.app-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  display: none;
}

.app-user-dropdown.is-open {
  display: block;
}

.app-user-dropdown a,
.app-user-dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--color-text-secondary);
}

.app-user-dropdown a:hover,
.app-user-dropdown button:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.app-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fff;
}

.legacy-page-main {
  padding: 24px;
}

.legacy-page-main > div:first-child {
  max-width: 1360px;
  margin: 0 auto;
}

.shell-overlay {
  display: none;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
  }

  .app-shell.is-sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .shell-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    z-index: 40;
  }

  .app-shell.is-sidebar-open .shell-overlay {
    display: block;
  }

  .app-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .app-navbar {
    padding: 14px 16px;
  }

  .app-main,
  .legacy-page-main {
    padding: 16px;
  }

  .app-switcher {
    min-width: 160px;
  }
}

@media (max-width: 768px) {
  .app-navbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-navbar__left,
  .app-navbar__right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .app-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  .app-switcher {
    width: 100%;
    min-width: 0;
  }
}