*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  overflow: hidden;
}

a { color: inherit; }

.app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  position: relative;
}

/* ─────────── SIDEBAR ─────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--side-bg);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
  border-right: 1px solid var(--side-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  color: var(--side-text);
  transition: width var(--duration-slow) var(--ease);
  z-index: var(--z-sidebar);
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--side-border);
}

.brand-card {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}

.brand-name span { color: var(--brand); }
.brand-tag {
  font-size: 11px;
  color: var(--side-muted);
  margin-top: 8px;
  text-align: center;
  letter-spacing: 0.4px;
}

.sidebar.collapsed .brand-tag,
.sidebar.collapsed .brand-name span + span,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .nav-count,
.sidebar.collapsed .nav-chevron,
.sidebar.collapsed .sf-name,
.sidebar.collapsed .sf-role,
.sidebar.collapsed .nav-group-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.nav-section { padding: 0 12px; margin-bottom: 4px; }

.nav-label,
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--side-label);
  padding: 14px 8px 8px;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--side-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--duration) var(--ease);
}

.nav-group-toggle:hover { color: var(--side-text); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--side-muted);
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.nav-item:hover {
  background: var(--glass-bg-hover);
  color: var(--side-text);
}

.nav-item.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px -6px var(--brand-glow);
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  background: var(--glass-bg);
  color: var(--side-muted);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.nav-item.active .nav-count { background: rgba(255, 255, 255, 0.2); color: #fff; }
.nav-count.red { background: var(--red-soft); color: var(--red); }

.nav-chevron {
  margin-left: auto;
  font-size: 11px;
  color: var(--side-muted);
  transition: transform var(--duration) var(--ease);
  flex-shrink: 0;
}

.nav-chevron.open { transform: rotate(90deg); }

.nav-dropdown {
  overflow: hidden;
  padding-left: 8px;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 32px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--side-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-bottom: 1px;
  text-decoration: none;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.nav-sub-item:hover {
  background: var(--glass-bg-hover);
  color: var(--side-text);
}

.nav-sub-item.active {
  color: var(--brand);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--side-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sf-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.sf-name { font-size: 13px; font-weight: 600; color: var(--side-text); }
.sf-role { font-size: 11px; color: var(--side-muted); }

.sidebar-collapse-btn {
  position: absolute;
  bottom: 80px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  color: var(--text2);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 10;
  backdrop-filter: blur(8px);
}

@media (min-width: 901px) {
  .sidebar-collapse-btn { display: flex; }
}

/* ─────────── MAIN ─────────── */
.main {
  flex: 1;
  overflow-y: auto;
  background: transparent;
  position: relative;
}

.topbar {
  height: var(--topbar-h);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}

.crumbs { font-size: 13px; color: var(--text2); }
.crumbs b { color: var(--text); font-weight: 600; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.content { padding: 24px 28px; }

.sidebar-toggle {
  display: none;
  height: 38px;
  min-width: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  cursor: pointer;
  font-size: 18px;
  color: var(--text2);
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  z-index: calc(var(--z-sidebar) - 1);
}

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    transform: translateX(calc(-100% - 24px));
    transition: transform var(--duration-slow) var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  body { overflow: auto; height: auto; min-height: 100vh; }
  html, body { overflow-x: hidden; }
  .main { min-height: 100vh; }
  .sidebar-collapse-btn { display: none !important; }
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
}

.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
}

.theme-toggle-btn.active {
  background: var(--brand);
  color: #fff;
}

.theme-toggle-btn svg { width: 16px; height: 16px; }

/* Toast */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 13px;
  font-weight: 500;
  animation: toastIn 0.3s var(--ease);
}

.toast-success { border-color: rgba(34, 197, 94, 0.3); color: var(--green); }
.toast-error { border-color: rgba(239, 68, 68, 0.3); color: var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}
