/* Phase 1 — workflow-oriented shell. Loaded after main.css and ui22.css. */

.app-auth .app-topbar {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  min-height: 64px;
  padding: 0.62rem 1rem;
}

.app-auth .app-topbar .brand {
  min-width: 0;
}

.app-auth .app-topbar .brand-logo img {
  height: 34px;
}

.app-auth .app-topbar .brand > span {
  display: none;
}

.app-auth .topbar-context {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.app-auth .topbar-context-area {
  color: rgba(220, 235, 250, 0.76);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-auth .topbar-context-title {
  max-width: 100%;
  overflow: hidden;
  color: #fff;
  font-size: 0.98rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-auth .topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.app-auth .topbar-user-menu {
  position: relative;
  margin: 0;
}

.app-auth .topbar-user-menu > summary {
  list-style: none;
}

.app-auth .topbar-user-menu > summary::-webkit-details-marker {
  display: none;
}

.app-auth .topbar-user-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  max-width: min(270px, 28vw);
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(4, 31, 59, 0.35);
  color: #fff;
  cursor: pointer;
  user-select: none;
}

.app-auth .topbar-user-summary:hover,
.app-auth .topbar-user-menu[open] .topbar-user-summary {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(4, 31, 59, 0.58);
}

.app-auth .topbar-user-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-auth .topbar-user-chevron {
  font-size: 0.7rem;
  transition: transform 0.16s ease;
}

.app-auth .topbar-user-menu[open] .topbar-user-chevron {
  transform: rotate(180deg);
}

.app-auth .topbar-user-popover {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 1500;
  width: min(300px, calc(100vw - 1.5rem));
  padding: 0.55rem;
  border: 1px solid var(--line, #d8e3f1);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 20px 44px rgba(4, 31, 59, 0.28);
  color: var(--text, #172536);
}

.app-auth .topbar-user-identity {
  padding: 0.55rem 0.65rem 0.7rem;
  border-bottom: 1px solid var(--line, #d8e3f1);
}

.app-auth .topbar-user-identity strong,
.app-auth .topbar-user-identity small {
  display: block;
  overflow-wrap: anywhere;
}

.app-auth .topbar-user-identity small {
  margin-top: 0.15rem;
  color: var(--text-muted, #70849e);
}

.app-auth .topbar-user-action,
.app-auth .topbar-user-popover .logout-button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 42px;
  margin: 0.2rem 0 0;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text, #172536);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.app-auth .topbar-user-action:hover,
.app-auth .topbar-user-popover .logout-button:hover {
  background: var(--surface-muted, #f4f7fc);
}

.app-auth .topbar-user-popover .logout-form {
  margin: 0;
}

.app-auth .sidebar-v2 {
  min-width: 0;
}

.app-auth .sidebar-nav-v2 {
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
  padding: 0.7rem 0.58rem 1rem;
}

.app-auth .sidebar-section {
  margin: 0;
  overflow: clip;
  border: 1px solid rgba(124, 151, 181, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.app-auth .sidebar-section-summary {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.58rem 0.62rem;
  color: inherit;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.app-auth .sidebar-section-summary::-webkit-details-marker {
  display: none;
}

.app-auth .sidebar-section-summary:hover {
  background: rgba(255, 255, 255, 0.055);
}

.app-auth .sidebar-section-summary:focus-visible {
  outline: 2px solid rgba(255, 176, 122, 0.95);
  outline-offset: -2px;
}

.app-auth .sidebar-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(184, 214, 240, 0.88);
}

.app-auth .sidebar-section-label {
  min-width: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-auth .sidebar-section-chevron {
  color: rgba(199, 220, 239, 0.68);
  font-size: 0.66rem;
  transition: transform 0.16s ease;
}

.app-auth .sidebar-section[open] .sidebar-section-chevron {
  transform: rotate(180deg);
}

.app-auth .sidebar-section-links {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  padding: 0 0.38rem 0.48rem;
}

.app-auth .sidebar-subgroup-label {
  margin: 0.5rem 0.45rem 0.2rem;
  color: rgba(184, 214, 240, 0.58);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.app-auth .sidebar-section-links .sidebar-link {
  min-height: 40px;
  margin: 0;
  border-radius: 8px;
}

.app-auth .sidebar-section-links .sidebar-link.active {
  box-shadow: inset 3px 0 0 var(--brand-accent, #ff7b36);
}

.app-auth .sidebar-link-external {
  display: inline-flex;
  margin-left: auto;
  color: currentColor;
  font-size: 0.62rem;
  opacity: 0.62;
}

.app-auth .sidebar-footer-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-auth .sidebar-footer-v2 small {
  padding: 0.15rem 0.38rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(220, 235, 250, 0.72);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}

.app-sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .app-auth .app-topbar {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 0.42rem;
    min-height: 58px;
    padding: 0.45rem 0.55rem;
  }

  .app-auth .app-topbar .brand-logo img {
    height: 29px;
  }

  .app-auth .app-topbar .nav-toggle {
    min-width: 42px;
    min-height: 42px;
    padding: 0.45rem;
  }

  .app-auth .app-topbar .nav-toggle span,
  .app-auth .topbar-context-area,
  .app-auth .topbar-user-name,
  .app-auth .topbar-user-chevron {
    display: none;
  }

  .app-auth .topbar-context-title {
    font-size: 0.88rem;
  }

  .app-auth .topbar-user-summary {
    min-width: 42px;
    min-height: 42px;
    padding: 0.45rem;
    justify-content: center;
  }

  .app-auth #app-sidebar.sidebar-v2 {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1400;
    display: flex !important;
    width: min(86vw, 330px) !important;
    max-width: 330px;
    height: 100dvh;
    transform: translateX(0);
    transition: transform 0.2s ease;
    box-shadow: 18px 0 42px rgba(3, 22, 43, 0.36);
  }

  .app-auth .app-shell.sidebar-collapsed #app-sidebar.sidebar-v2 {
    display: flex !important;
    transform: translateX(-105%);
    pointer-events: none;
  }

  .app-auth .app-shell:not(.sidebar-collapsed) .app-sidebar-backdrop:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 1350;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(3, 22, 43, 0.52);
    cursor: default;
  }

  .app-auth .app-shell-splitter {
    display: none !important;
  }

  body.app-nav-open {
    overflow: hidden;
  }
}

@media (max-width: 560px) {
  .app-auth .app-topbar {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .app-auth .app-topbar .language-switcher select {
    min-width: 42px;
    min-height: 42px;
    padding-inline: 0.35rem;
  }

  .app-auth .topbar-user-popover {
    position: fixed;
    top: 62px;
    right: 0.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-auth #app-sidebar.sidebar-v2,
  .app-auth .sidebar-section-chevron,
  .app-auth .topbar-user-chevron {
    transition: none;
  }
}
