/* ===== 1. Layout ===== */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; margin-left: var(--sb-w); padding: 24px 32px 48px; min-width: 0; transition: margin-left 0.3s ease; }

/* ===== 2. Sidebar (.sb) ===== */
.sb {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sb-w);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.sb-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.sb-brand-text { display: flex; flex-direction: column; }
.sb-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.sb-brand-tag { font-size: 11px; color: var(--muted); }

.sb-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 12px;
}

.sb-section { margin-top: 12px; }
.sb-section:first-child { margin-top: 0; }

.sb-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.6px;
  padding: 8px 12px 4px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
}

.sb-item:hover { background: var(--bg); }
.sb-item.active { background: var(--accent-l); color: var(--accent); font-weight: 600; }

.sb-item-icon { font-size: 18px; flex-shrink: 0; }
.sb-item-label { flex: 1; }

.sb-chevron {
  font-size: 10px;
  transition: transform 0.2s ease;
}

/* Collapsible groups */
.sb-group.open .sb-chevron { transform: rotate(90deg); }

.sb-group .sb-sub {
  display: none;
  padding-left: 36px;
}

.sb-group.open .sb-sub {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-sub-item {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
}

.sb-sub-item:hover { background: var(--bg); }
.sb-sub-item.active { color: var(--accent); font-weight: 600; }

/* Sidebar footer */
.sb-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sb-footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.sb-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

/* ===== 3. Topbar ===== */
.topbar {
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.topbar-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-badge { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 100px; background: var(--accent-l); color: var(--accent); }

/* ===== 4. Panel (slide-out) ===== */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.panel-overlay.open { opacity: 1; visibility: visible; }

.panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: var(--panel-w);
  height: 100vh;
  background: var(--white);
  box-shadow: var(--sh3);
  z-index: 201;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.panel.open { right: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 16px; font-weight: 700; }

.panel-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

.panel-close:hover { color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Panel sections */
.panel-section { margin-bottom: 20px; }

.panel-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ===== 5. Mobile menu button ===== */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 150;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--sh);
}

/* ===== 6. Responsive ===== */
@media (max-width: 900px) {
  .sb {
    transform: translateX(-100%);
    position: fixed;
    z-index: 150;
  }

  .sb.open { transform: translateX(0); }

  .main {
    margin-left: 0;
    padding: 16px;
  }

  .mobile-menu-btn { display: block; }

  .topbar { padding: 12px 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .cols-2,
  .cols-3,
  .cols-23,
  .cols-32 {
    grid-template-columns: 1fr;
  }

  .panel { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
