@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-dark: #0a0f1e;
  --bg-card: #111827;
  --bg-card2: #1a2235;
  --border: #1e2d45;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --brand-blue: #1e3a8a;
  --accent: #1e3a8a;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Utility ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 12px; }

/* ── Card ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(16,185,129,.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger);  }
.badge-info    { background: rgba(59,130,246,.15);  color: var(--info);    }
.badge-muted   { background: rgba(71,85,105,.2);    color: var(--text-secondary); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600;
  border: none; cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 0 0 0 var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-card2); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── Form Controls ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-control {
  background: var(--bg-dark); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 10px 14px; width: 100%; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-control::placeholder { color: var(--text-muted); }
.input-icon { position: relative; }
.input-icon .form-control { padding-left: 40px; }
.input-icon .icon {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); vertical-align: middle;
}
tbody tr:hover td { background: var(--bg-card2); }
tbody tr:last-child td { border-bottom: none; }

/* ── Alert ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
}
.alert-danger  { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 520px;
  box-shadow: var(--shadow); animation: slideUp .2s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close  { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; }

@keyframes slideUp { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform:none; } }

/* ── Stat Card ── */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: flex-start; gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon.purple { background: rgba(30, 58, 138,.15); color: var(--primary); }
.stat-icon.green  { background: rgba(16,185,129,.15);  color: var(--success); }
.stat-icon.orange { background: rgba(245,158,11,.15);  color: var(--warning); }
.stat-icon.blue   { background: rgba(59,130,246,.15);  color: var(--info);    }
.stat-icon.red    { background: rgba(239,68,68,.15);   color: var(--danger);  }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-trend { font-size: 11px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Grid ── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ── Sidebar Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--bg-card);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 200;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-icon {
  width: 40px; height: 40px; background: var(--primary);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-logo-text { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.sidebar-logo-sub  { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-muted); padding: 8px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm); margin-bottom: 2px;
  color: var(--text-secondary); transition: all var(--transition); cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-card2); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-glow); color: var(--primary);
  border: 1px solid rgba(30, 58, 138,.2);
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 16px; }
.nav-item .nav-label { font-size: 13px; font-weight: 500; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user-name  { font-size: 13px; font-weight: 600; }
.sidebar-user-role  { font-size: 11px; color: var(--text-muted); }
.sidebar-logout-btn {
  margin: 16px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition);
}
.sidebar-logout-btn:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* ── Main Content ── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: var(--header-h); background: var(--bg-card);
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100;
}
.topbar-search {
  flex: 1; max-width: 400px; display: flex; align-items: center;
  background: var(--bg-dark); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px; gap: 8px;
}
.topbar-search input { background: none; border: none; outline: none; color: var(--text-primary); flex: 1; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  width: 38px; height: 38px; background: var(--bg-dark);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; position: relative;
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.topbar-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; background: var(--danger); border-radius: 50%;
}
.content-area { padding: 28px; flex: 1; }

/* ── Chart container ── */
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; }
.page-btn {
  min-width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 13px; transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 20px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
  box-shadow: var(--shadow); animation: slideIn .3s ease;
  min-width: 280px; max-width: 380px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform:none; } }
