:root {
  --sidebar-w: 250px;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f1f5f9;
  --sidebar-bg: #1e293b;
  --sidebar-fg: #cbd5e1;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: #0f172a; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.5rem; flex: 1; }

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-fg);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  transition: transform .25s ease; z-index: 1040;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1.25rem 1.25rem; font-weight: 700; font-size: 1.1rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand i { color: #818cf8; font-size: 1.4rem; }
.sidebar-nav { padding: .75rem; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-link, .sidebar-logout .nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border-radius: .5rem;
  color: var(--sidebar-fg); text-decoration: none; margin-bottom: .15rem; font-size: .925rem;
  background: none; border: none; width: 100%; text-align: left; cursor: pointer;
}
.sidebar-nav .nav-link:hover, .sidebar-logout .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-link i { width: 20px; text-align: center; }
.sidebar-logout { padding: .75rem; border-top: 1px solid rgba(255,255,255,.08); }
.logout-btn { color: #fca5a5 !important; }
.logout-btn:hover { background: rgba(239,68,68,.15) !important; color: #fecaca !important; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1035; }

/* ---------- Topbar ---------- */
.app-topbar {
  display: flex; align-items: center; gap: 1rem; padding: .85rem 1.5rem; background: #fff;
  border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; z-index: 1020;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

/* ---------- Stat cards ---------- */
.stat-card { display: flex; align-items: center; gap: 1rem; background: #fff; border-radius: .75rem; padding: 1.1rem 1.25rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); height: 100%; }
.stat-icon { width: 52px; height: 52px; border-radius: .65rem; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: #fff; flex-shrink: 0; }
.stat-primary .stat-icon { background: #4f46e5; }
.stat-success .stat-icon { background: #16a34a; }
.stat-danger .stat-icon { background: #dc2626; }
.stat-info .stat-icon { background: #0891b2; }
.stat-label { font-size: .8rem; color: #64748b; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }

.card { border: none; border-radius: .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; background: #e0e7ff; color: #4f46e5; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }

/* ---------- Login page ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); padding: 1rem; }
.login-card { background: #fff; border-radius: 1rem; padding: 2.25rem; width: 100%; max-width: 400px; }
.login-head { text-align: center; margin-bottom: 1.5rem; }
.login-logo { width: 64px; height: 64px; border-radius: 1rem; background: #eef2ff; color: #4f46e5; display: flex; align-items: center; justify-content: center; font-size: 2rem; margin: 0 auto 1rem; }
.login-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .app-sidebar { position: fixed; transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
}
