:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sidebar: #0f1c2e;
  --sidebar-hover: #1a2d45;
  --primary: #1a56db;
  --primary-soft: #e8effc;
  --accent: #0d9f6e;
  --warning: #d97706;
  --danger: #dc2626;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 28, 46, 0.06);
  --font: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0f1c2e 0%, #152238 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a56db, #0d9f6e);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
}
.brand strong { display: block; font-size: 15px; }
.brand small { color: rgba(255,255,255,0.5); font-size: 12px; }

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active {
  background: rgba(26, 86, 219, 0.35);
  color: #fff;
  box-shadow: inset 3px 0 0 #4f8cff;
}
.nav-icon { width: 20px; opacity: 0.85; }
.nav-logout { margin-top: auto; color: #fca5a5 !important; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.admin-chip { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: #1a56db; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.admin-chip strong { display: block; font-size: 13px; }
.admin-chip small { color: rgba(255,255,255,0.5); font-size: 11px; text-transform: capitalize; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.content { padding: 24px 28px 40px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card.blue .value { color: var(--primary); }
.stat-card.green .value { color: var(--accent); }
.stat-card.orange .value { color: var(--warning); }
.stat-card.purple .value { color: #7c3aed; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1546b8; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbfc;
}
.table tr:hover td { background: #f9fafb; }

.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-control {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.alert {
  margin: 16px 28px 0;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }

/* Sortable rows */
.sortable-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.drag-handle {
  cursor: grab;
  color: #9ca3af;
  font-size: 16px;
  padding: 4px 8px;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.4; background: var(--primary-soft) !important; }
.sortable-chosen td { background: #f0f5ff !important; }

.thumb {
  width: 56px; height: 42px;
  object-fit: cover;
  border-radius: 8px;
  background: #eee;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(26,86,219,0.15), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(13,159,110,0.12), transparent 50%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 20px 50px rgba(15,28,46,0.1);
  border: 1px solid var(--border);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 28px; font-size: 14px; }
.login-card .form-group { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-hint {
  margin-top: 16px;
  padding: 10px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.switch {
  position: relative;
  width: 42px; height: 24px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}
.slider:before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.empty {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .sidebar { width: 72px; }
  .brand > div:last-child, .nav a span:not(.nav-icon), .admin-chip > div:last-child { display: none; }
  .nav a { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
}
