:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --purple: #7c3aed;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

body.dark {
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #253045;
}

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

html {
  scroll-behavior: smooth;
}

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

a {
  text-decoration: none;
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: var(--shadow-md);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

.sidebar-brand h2 {
  font-size: 15px;
  line-height: 1.15;
}

.sidebar-brand p {
  color: rgba(255,255,255,0.65);
  font-size: 11px;
  margin-top: 3px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.82);
  transition: 0.2s ease;
  font-size: 13px;
}

.nav-link i {
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  transform: translateX(3px);
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  transition: 0.2s ease;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}

.sidebar-btn:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

.sidebar-btn.danger {
  background: rgba(220, 38, 38, 0.18);
}

.sidebar-btn.danger:hover {
  background: rgba(220, 38, 38, 0.28);
}

/* Main */
.admin-main {
  flex: 1;
  padding: 20px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.topbar p {
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Search box */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  min-width: 240px;
  box-shadow: var(--shadow-sm);
}

.search-box i {
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  border: 0;
  outline: none;
  width: 100%;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

/* Profile */
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.profile-chip strong {
  font-size: 13px;
}

.profile-chip p {
  color: var(--muted);
  font-size: 11px;
}

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card h3 {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 3px;
}

.stat-card p {
  color: var(--muted);
  font-size: 12px;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  flex: 0 0 auto;
}

.stat-icon.blue { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.stat-icon.green { background: linear-gradient(135deg, #16a34a, #4ade80); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-icon.purple { background: linear-gradient(135deg, #7c3aed, #c084fc); }

/* Flash */
.flash-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

.flash-success {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

.flash-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.flash-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.flash-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.filter-form {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn,
.action-btn,
.filter-select,
.filter-form input[type="date"],
.filter-form select {
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s ease;
  color: var(--text);
  font-size: 13px;
}

.tab-btn:hover,
.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.action-btn {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

/* Sections */
.content-section {
  display: none;
}

.content-section.active,
.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin: 8px 0 12px;
}

.section-head h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.section-head p {
  color: var(--muted);
  font-size: 12px;
}

/* Cards */
.chart-card,
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-bottom: 16px;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  color: #334155;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

body.dark .data-table thead th {
  background: #0f172a;
  color: #cbd5e1;
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: #334155;
  vertical-align: middle;
  font-size: 13px;
}

body.dark .data-table tbody td {
  color: #e5e7eb;
}

.data-table tbody tr {
  transition: 0.2s ease;
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

body.dark .data-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  color: #fff;
  font-weight: 700;
  flex: 0 0 auto;
  font-size: 12px;
}

.user-cell p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge.pending {
  background: #fffbeb;
  color: #92400e;
}

.badge.review {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.approved {
  background: #ecfdf5;
  color: #166534;
}

.badge.rejected {
  background: #fef2f2;
  color: #991b1b;
}

/* Row actions */
.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  transition: 0.2s ease;
  font-size: 12px;
}

.row-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.row-btn.danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* Empty */
.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state i {
  font-size: 34px;
  color: #94a3b8;
  margin-bottom: 10px;
}

.empty-state h3 {
  color: var(--text);
  margin-bottom: 6px;
  font-size: 16px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.pagination a,
.pagination span {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quick-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: 0.2s ease;
  font-size: 13px;
}

.quick-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.quick-card i {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--primary);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid,
  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box {
    min-width: 220px;
  }
}

@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 14px;
  }

  .admin-main {
    padding: 14px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right,
  .toolbar-left,
  .topbar-actions {
    width: 100%;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .profile-chip {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-form {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .stats-grid,
  .quick-actions {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card h3 {
    font-size: 20px;
  }

  .section-head h2 {
    font-size: 16px;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 10px 12px;
    font-size: 12px;
  }

  .row-btn {
    padding: 5px 9px;
    font-size: 11px;
  }

  .tab-btn,
  .action-btn,
  .filter-select,
  .filter-form input[type="date"],
  .filter-form select {
    width: 100%;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }
}