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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 35;
  width: 260px;
  height: 100vh;
  overflow-y: auto;
  background: var(--nav-bg);
  color: var(--nav-text);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  will-change: transform;
}

.sidebar-hover-zone {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 80;
  width: 12px;
  height: 100vh;
  background: transparent;
  pointer-events: none;
}

body.sidebar-auto-collapsed .app-shell {
  grid-template-columns: 12px minmax(0, 1fr);
}

body.sidebar-auto-collapsed .sidebar-hover-zone {
  pointer-events: auto;
}

body.sidebar-auto-collapsed .sidebar {
  transform: translateX(calc(-100% + 12px));
  box-shadow: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--top-bar-height);
  min-height: var(--top-bar-height);
  padding: 0 22px;
  border-bottom: 1px solid var(--nav-line);
}

.brand-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #dff1ff;
  background: linear-gradient(135deg, #1d3158, #17263f);
  border: 1px solid rgba(116, 164, 255, 0.32);
  font-weight: 800;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--nav-muted);
}

.nav-section,
.knowledge-group {
  padding: 16px 0;
  border-bottom: 1px solid var(--nav-line);
}

.nav-section {
  flex: 1;
  overflow-y: auto;
}

.sidebar-footer {
  position: relative;
  margin-top: auto;
  padding: 14px 0 18px;
  border-top: 1px solid var(--nav-line);
}

.session-account-menu {
  position: relative;
  padding: 0 12px 10px;
}

.session-account {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dbe8ff;
  text-align: left;
  cursor: pointer;
}

.session-account:hover,
.session-account[aria-expanded="true"] {
  border-color: rgba(122, 166, 255, 0.25);
  background: rgba(122, 166, 255, 0.08);
}

.session-account-label,
.session-account-meta {
  color: var(--nav-muted);
  font-size: 12px;
}

.session-account-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #dbe8ff;
  font-size: 14px;
  line-height: 1.35;
}

.account-menu-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  z-index: 40;
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(122, 166, 255, 0.22);
  border-radius: 8px;
  background: #101827;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
}

.account-menu-panel[hidden] {
  display: none;
}

.account-menu-panel button,
.account-menu-panel a {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dbe8ff;
  font: inherit;
  font-size: 13px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-panel button:hover,
.account-menu-panel a:hover {
  background: rgba(122, 166, 255, 0.12);
}

.sidebar-online-count {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--nav-muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.logout-link {
  min-height: 40px;
  font-size: 15px;
  color: #9ba7bc;
}

.logout-link:hover {
  color: #ffd5d5;
}

.nav-group-title {
  padding: 12px 22px 8px;
  color: var(--nav-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.nav-group:first-child .nav-group-title {
  padding-top: 0;
}

.nav-group-items {
  display: grid;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 18px 0 22px;
  color: #8793a9;
  text-decoration: none;
  font-size: 14px;
  border-left: 4px solid transparent;
}

.nav-link:hover {
  color: #dbe8ff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: var(--active);
  background: rgba(76, 154, 255, 0.12);
  border-left-color: var(--active);
}

.nav-parent {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: stretch;
}

.nav-parent .nav-link {
  min-width: 0;
  padding-right: 8px;
}

.nav-child-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  color: #8793a9;
  background: transparent;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.nav-child-toggle:hover,
.nav-child-toggle:focus-visible {
  color: #dbe8ff;
  background: rgba(255, 255, 255, 0.04);
  outline: none;
}

.nav-parent.active .nav-child-toggle {
  color: var(--active);
  background: rgba(76, 154, 255, 0.12);
}

.nav-child-toggle-icon {
  display: inline-block;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.16s ease;
}

.nav-child-toggle[aria-expanded="false"] .nav-child-toggle-icon {
  transform: rotate(0deg);
}

.nav-children {
  display: grid;
  gap: 2px;
  padding: 2px 12px 6px 44px;
}

.nav-children[hidden] {
  display: none;
}

.nav-child-link {
  display: block;
  min-height: 30px;
  padding: 7px 10px;
  color: #7f8ca4;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
  border-left: 2px solid rgba(148, 163, 184, 0.18);
}

.nav-child-link:hover,
.nav-child-link.active {
  color: #dbe8ff;
  background: rgba(255, 255, 255, 0.04);
  border-left-color: var(--active);
}

.nav-link.disabled {
  cursor: default;
  opacity: 0.68;
}

.nav-link.disabled:hover {
  color: #8793a9;
  background: transparent;
}

.nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.nav-dot.ready {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.nav-dot.pending {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.muted-link {
  padding: 13px 22px 13px 62px;
  color: #7f8ca4;
  font-size: 16px;
}

.workspace {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  background: var(--surface);
  padding-right: var(--assistant-panel-width);
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  height: auto;
  min-height: var(--top-bar-height);
  padding: 14px 24px;
  background: rgba(244, 246, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.workspace-title {
  min-width: 220px;
  flex: 1 1 320px;
}

.workspace-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

.workspace-header p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-surface {
  padding: 18px 24px 40px;
}

.page-frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}

.page-frame > style + * {
  margin-top: 0;
}

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

  .sidebar-hover-zone {
    display: none;
  }

  .sidebar {
    display: none;
  }

  .dashboard-surface {
    padding: 12px 16px;
  }
}

.login-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 22, 38, 0.94), rgba(29, 49, 88, 0.9)),
    var(--surface);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 30;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.96);
  color: #fff;
  box-shadow: 0 14px 28px rgba(16, 24, 40, 0.18);
  pointer-events: none;
  animation: login-toast-in 140ms ease-out;
}

.login-toast.hide {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.login-panel {
  width: min(100%, 1040px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.login-panel-split {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-panel-hero {
  position: relative;
  min-height: 560px;
  background: #0b1220;
}

.login-panel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-panel-hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 32px;
  background: linear-gradient(180deg, rgba(6, 10, 20, 0.04) 0%, rgba(6, 10, 20, 0.56) 100%);
  color: #fff;
}

.login-panel-hero-overlay p {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.8;
  white-space: nowrap;
}

.login-panel-hero-overlay h1 {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  font-size: 28px;
  line-height: 1.15;
}

.login-title-main,
.login-title-sub {
  display: block;
  max-width: 100%;
  white-space: nowrap;
}

.login-title-main {
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-title-sub {
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 2.5px;
}

.login-panel-body {
  padding: 32px 34px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-panel-body .login-brand {
  justify-content: center;
}

.login-brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d6ddeb;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
}

.login-form button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 960px) {
  .login-panel {
    width: min(100%, 520px);
  }

  .login-panel-split {
    grid-template-columns: 1fr;
  }

  .login-panel-hero {
    min-height: 260px;
  }

  .login-panel-body {
    padding: 26px;
  }
}

@media (max-width: 640px) {
  .login-shell {
    padding: 14px;
  }

  .login-panel-hero-overlay {
    padding: 22px;
  }

  .login-panel-hero-overlay h1 {
    font-size: 22px;
  }
}

@keyframes login-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
