/* Frame of the surface: grid of sidebar and main area, brand, navigation, sidebar foot,
   top bar with title, view and sign-in card. On the left the dark anchor, on the right the light work area. */

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

/* ═══ Sidebar ══════════════════════════════════════════════════════ */

#sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-deep) 100%);
  color: var(--side-ink);
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden auto;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
#sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }

.brand {
  display: flex; align-items: center; gap: 11px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--side-line);
  flex: none;
}

.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6 55%, #A855F7);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700; font-size: 17px;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-mark svg { display: block; }
.brand-mark.big { width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }

.brand-text {
  font-family: var(--font-sign);
  font-weight: 600; font-size: 14.5px; line-height: 1.15;
  letter-spacing: -0.01em; color: var(--side-ink);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

#nav { flex: 1; padding: 10px 10px 14px; }

#nav a {
  display: flex; align-items: center; gap: 10px;
  height: 33px; margin: 1px 0;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  color: var(--side-ink-2);
  text-decoration: none;
  position: relative;
  white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1);
}
#nav a:hover { background: var(--side-hover); color: var(--side-ink); text-decoration: none; }
#nav a.active {
  background: var(--side-active);
  color: var(--side-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--side-line);
}
#nav a.active::before {
  content: "";
  position: absolute; left: -10px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #818CF8, #A855F7);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.7);
}
#nav a .nav-ico { width: 16px; height: 16px; flex: none; opacity: 0.9; display: grid; place-items: center; }
#nav a .nav-ico svg { width: 16px; height: 16px; display: block; }
#nav a .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#nav a .dot { margin-left: auto; }

/* Navigation without entries: a quiet sentence instead of an empty bar */
.nav-empty { margin: 6px 10px; font-size: 12px; color: var(--side-ink-3); }

.sidebar-foot {
  flex: none;
  border-top: 1px solid var(--side-line);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-foot .btn-quiet { color: var(--side-ink-3); box-shadow: none; }
.sidebar-foot .btn-quiet:hover { background: var(--side-hover); color: var(--side-ink); }

/* Sign-in state in the sidebar foot */
#session { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#session .btn { justify-content: flex-start; }
.session-chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px 0 10px;
  border: 1px solid var(--side-line);
  border-radius: var(--r-pill);
  background: var(--side-hover);
  color: var(--side-ink);
  font-size: 12.5px; font-weight: 500;
}

/* ═══ Main area ════════════════════════════════════════════════════ */

#main { display: flex; flex-direction: column; min-width: 0; }

#topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 26px;
  background: color-mix(in srgb, var(--base) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-subtle);
}

#page-title {
  font-family: var(--font-heading);
  font-weight: 600; font-size: 16.5px; line-height: 24px;
  letter-spacing: -0.01em;
  margin: 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1480px;
  padding: 26px 30px 60px;
}

/* ═══ Sign-in: a card over the whole surface ═══════════════════════ */

.login-wrap {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 60% 45% at 15% 0%, rgba(99, 102, 241, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(168, 85, 247, 0.09), transparent 50%),
    var(--sunken);
}

.login-card {
  width: min(420px, 92vw);
  background: var(--raised);
  border: 1px solid var(--line-subtle);
  border-radius: var(--r-xl);
  box-shadow: var(--e4);
  padding: 36px 36px 32px;
  animation: rise-in var(--dur-3) var(--ease);
}

@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.login-head {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 16px; margin-bottom: 26px;
}
.login-head h1 {
  font-family: var(--font-heading);
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0;
}
.login-head p { margin: 5px 0 0; color: var(--ink-3); font-size: 13.5px; }

.login-card label {
  display: block;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin-bottom: 14px;
}
.login-card input { display: block; width: 100%; margin-top: 6px; height: 40px; }

.login-error {
  color: var(--bad); background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 12.5px;
  margin: 0 0 14px;
}
.login-error small { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 11px; opacity: 0.8; }

.login-actions { display: flex; flex-direction: column; gap: 8px; }
.login-actions .btn { width: 100%; height: 40px; }

/* ═══ Narrow windows and reduced motion ════════════════════════════ */

@media (max-width: 980px) {
  #shell { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    flex-direction: row; align-items: center; height: auto;
    border-top: 1px solid var(--side-line);
    z-index: 45; overflow-x: auto;
  }
  .brand { display: none; }
  .sidebar-foot { border-top: none; border-left: 1px solid var(--side-line); padding: 6px 8px; }
  .session-chip { display: none; }
  #nav { display: flex; flex-direction: row; padding: 6px 8px; gap: 2px; }
  #nav a { flex-direction: column; gap: 3px; height: 50px; justify-content: center; font-size: 11px; padding: 0 9px; }
  #nav a .nav-label { display: block; flex: none; max-width: 14ch; }
  #nav a .dot { position: absolute; top: 6px; right: 6px; margin: 0; }
  #nav a.active::before { display: none; }
  #main { padding-bottom: 62px; }
  .view { padding: 16px 16px 36px; }
  #topbar { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .live-dot, .scan-badge .dot, .skel { animation: none !important; }
  .skel { background: var(--skeleton); }
}
