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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 0.8rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 40;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.55rem 1rem;
  color: #fff;
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #4f8cff, #7c5cff);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.04em;
  box-shadow: 0 6px 16px rgba(79, 140, 255, 0.35);
}
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.brand-text span { font-size: 0.7rem; color: var(--sidebar-text-muted); letter-spacing: 0.04em; text-transform: uppercase; }

.nav-section { margin-top: 0.9rem; }
.nav-label {
  padding: 0 0.65rem 0.35rem;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.64rem;
  padding: 0.56rem 0.66rem;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 0.87rem;
  font-weight: 560;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 2px 0 0 var(--sidebar-accent); }
.nav-link .icon { color: var(--sidebar-text-muted); }
.nav-link.active .icon, .nav-link:hover .icon { color: var(--sidebar-accent); }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-note { padding: 0.55rem 0.66rem; font-size: 0.74rem; line-height: 1.45; color: var(--sidebar-text-muted); }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(6, 12, 24, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.4rem;
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
.topbar-title { display: grid; min-width: 0; }
.topbar-title strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.topbar-title span { font-size: 0.76rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }
.topbar-divider { width: 1px; height: 26px; background: var(--border); margin: 0 0.25rem; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.25rem 0.5rem 0.25rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface);
  min-width: 0;
}
.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 750;
  font-size: 0.78rem;
  text-transform: uppercase;
}
.user-chip-text { display: grid; line-height: 1.15; min-width: 0; }
.user-chip-text strong { font-size: 0.78rem; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-text span { font-size: 0.66rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.6rem 1.4rem 3rem;
}
.page { display: grid; gap: 1.15rem; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.55rem; }
.page-header p { color: var(--text-muted); margin-top: 0.2rem; max-width: 70ch; }
.page-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.kpi-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
@media (max-width: 1100px) {
  .grid-main, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.menu-toggle { display: none; }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, var(--sidebar-w));
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-2);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .backdrop { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 0.9rem; }
  .content { padding: 1.1rem 0.9rem 2.5rem; }
  .user-chip-text { display: none; }
  .topbar-title span { display: none; }
}
@media (min-width: 861px) and (max-width: 1279px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 0.9rem 0.55rem; }
  .brand-text, .nav-label, .nav-link span, .sidebar-note { display: none; }
  .sidebar-brand { justify-content: center; padding-bottom: 0.7rem; }
  .nav-link { justify-content: center; padding: 0.62rem; }
  .nav-link .icon { width: 20px; height: 20px; }
  .sidebar-footer { display: none; }
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
  background: var(--bg-app);
}
.auth-aside {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(2rem, 5vw, 4.5rem);
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 140, 255, 0.35), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(124, 92, 255, 0.3), transparent 45%),
    linear-gradient(150deg, #0d1730, #111f3d 60%, #0b1324);
  color: #eaf0ff;
  overflow: hidden;
}
.auth-aside .brand-mark { width: 44px; height: 44px; font-size: 1rem; }
.auth-copy { max-width: 36rem; }
.auth-copy h1 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.08; letter-spacing: -0.04em; }
.auth-copy p { margin-top: 1rem; color: #a8b8d8; font-size: 1.02rem; max-width: 32rem; }
.auth-points { display: grid; gap: 0.8rem; margin-top: 2rem; padding: 0; list-style: none; }
.auth-points li { display: flex; align-items: center; gap: 0.7rem; color: #c9d6ef; font-size: 0.92rem; }
.auth-points .icon { color: #7fb0ff; }
.auth-foot { color: #7f8faa; font-size: 0.78rem; }
.auth-panel {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.auth-card { width: min(420px, 100%); display: grid; gap: 1rem; }
.auth-card .card { padding: 1.6rem; }
.auth-card h1 { font-size: 1.55rem; }
.auth-card .sub { color: var(--text-muted); margin-top: 0.25rem; }
.auth-card form { display: grid; gap: 0.8rem; margin-top: 1.25rem; }
.auth-card .row { justify-content: space-between; }
.auth-footer { text-align: center; color: var(--text-muted); font-size: 0.86rem; }
.privacy-copy { display: grid; gap: 0.9rem; line-height: 1.6; }
.privacy-copy p { margin: 0; }
.bot-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 36rem;
  padding: 1rem;
  border: 1px solid rgba(160, 190, 255, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}
.bot-qr {
  flex: 0 0 auto;
  width: 112px;
  height: 112px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.bot-copy { display: grid; gap: 0.35rem; color: #c9d6ef; font-size: 0.88rem; }
.bot-copy strong { color: #eaf0ff; font-size: 0.98rem; }
.bot-copy a { display: inline-flex; align-items: center; gap: 0.3rem; color: #9cc2ff; text-decoration: none; }
.bot-copy a:hover { text-decoration: underline; }
.auth-card .auth-lang { justify-content: flex-end; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-panel { min-height: 100vh; }
  .auth-card .auth-lang { justify-content: center; }
}
