/* App shell: sidebar + topbar + content. Sign-in screens use .auth. */

.app { min-height: 100vh; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.sidebar-brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-grad-from), var(--brand-grad-to));
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -.02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.brand-text span { font-size: 11px; color: var(--text-3); font-weight: 500; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-title {
  margin: 0 10px 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-3);
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius);
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-count {
  margin-left: auto;
  min-width: 20px; padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--danger-soft); color: var(--danger);
  font-size: 11px; font-weight: 600; text-align: center; line-height: 18px;
}

.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
}

/* ---------- main column ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 600; min-width: 0; }
.topbar-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-3); font-size: 13px; }
.topbar-crumbs a { color: var(--text-3); }
.topbar-crumbs a:hover { color: var(--text); }
.topbar-crumbs svg { width: 14px; height: 14px; flex: none; }
.topbar-crumbs .current { color: var(--text); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar .menu-toggle { display: none; }

.impersonation-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 24px;
  background: var(--warning-soft); color: var(--warning);
  font-size: 13px; font-weight: 500;
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
}

.content { padding: 24px; width: 100%; max-width: 1440px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { min-width: 0; }
.page-head p { color: var(--text-2); margin-top: 4px; max-width: 72ch; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(var(--sidebar-w), 84vw);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: none; }
  .nav-scrim { position: fixed; inset: 0; background: rgba(5, 10, 20, .45); z-index: 35; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .impersonation-bar { padding: 8px 16px; }
}

/* ---------- sign-in screens ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
}
.auth-form-col {
  display: flex; flex-direction: column;
  padding: 28px 40px;
  background: var(--surface);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-body {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 400px; margin: 0 auto; padding: 32px 0;
}
.auth-body h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.auth-body .lead { color: var(--text-2); margin: 6px 0 26px; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--text-3); }

.auth-art {
  position: relative; overflow: hidden;
  margin: 16px 16px 16px 0;
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, .16), transparent 42%),
    radial-gradient(circle at 85% 90%, rgba(94, 163, 224, .35), transparent 45%),
    linear-gradient(150deg, var(--brand-grad-from), var(--brand-grad-to));
  color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 48px;
}
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
.auth-art > * { position: relative; }
.auth-art .art-brand { position: absolute; top: 40px; left: 48px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.auth-art .art-brand .brand-mark { background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); }
.auth-art h2 { font-size: 34px; font-weight: 700; letter-spacing: -.02em; max-width: 16ch; }
.auth-art p { margin-top: 10px; font-size: 16px; opacity: .85; max-width: 40ch; }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-form-col { padding: 20px 16px; }
}
