/* ============================================================
   EXAMARENA ADMIN — Design System
   Premium, modern, dark/light mode ready
   ============================================================ */

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

/* ===== DESIGN TOKENS ===== */
:root {
  /* Primary palette */
  --primary:         #6366f1;
  --primary-hover:   #4f46e5;
  --primary-active:  #4338ca;
  --primary-soft:    #eef2ff;
  --primary-border:  #c7d2fe;
  --primary-glow:    rgba(99,102,241,.15);

  /* Secondary / accent */
  --accent:          #06b6d4;
  --accent-soft:     #ecfeff;
  --accent-border:   #a5f3fc;

  /* Success */
  --success:         #22c55e;
  --success-soft:    #f0fdf4;
  --success-border:  #86efac;
  --success-glow:    rgba(34,197,94,.12);

  /* Danger */
  --danger:          #ef4444;
  --danger-soft:     #fef2f2;
  --danger-border:   #fca5a5;
  --danger-glow:     rgba(239,68,68,.12);

  /* Warning */
  --warning:         #f59e0b;
  --warning-soft:    #fffbeb;
  --warning-border:  #fcd34d;
  --warning-glow:    rgba(245,158,11,.12);

  /* Info */
  --info:            #3b82f6;
  --info-soft:       #eff6ff;
  --info-border:     #93c5fd;

  /* Purple */
  --purple:          #a855f7;
  --purple-soft:     #f3e8ff;

  /* Neutrals */
  --bg:              #f8fafc;
  --bg-alt:          #f1f5f9;
  --surface:         #ffffff;
  --surface-2:       #f8fafc;
  --border:          #e2e8f0;
  --border-2:        #cbd5e1;
  --border-3:        #94a3b8;

  /* Text */
  --text:            #0f172a;
  --text-2:          #334155;
  --text-3:          #64748b;
  --text-4:          #94a3b8;
  --text-5:          #cbd5e1;

  /* Sizing */
  --sidebar-w:      280px;
  --sidebar-collapsed: 0px;
  --header-h:       68px;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  18px;
  --r-2xl: 24px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.02);
  --shadow-md:  0 4px 6px rgba(15,23,42,.04), 0 2px 4px rgba(15,23,42,.03);
  --shadow-lg:  0 10px 15px rgba(15,23,42,.05), 0 4px 6px rgba(15,23,42,.04);
  --shadow-xl:  0 20px 25px rgba(15,23,42,.06), 0 10px 10px rgba(15,23,42,.03);

  /* Font */
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* Transitions */
  --t-fast: .15s cubic-bezier(.4,0,.2,1);
  --t-normal: .25s cubic-bezier(.4,0,.2,1);
  --t-slow: .35s cubic-bezier(.4,0,.2,1);

  /* Sidebar */
  --sidebar-bg: var(--surface);
  --sidebar-text: var(--text-3);
  --sidebar-text-hover: var(--text);
  --sidebar-bg-hover: var(--bg-alt);
  --sidebar-active: var(--primary);
  --sidebar-active-bg: var(--primary-soft);
  --sidebar-width: 280px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --bg:              #0b1120;
  --bg-alt:          #111827;
  --surface:         #1a2332;
  --surface-2:       #1e293b;
  --border:          #1e293b;
  --border-2:        #334155;
  --border-3:        #475569;

  --text:            #f1f5f9;
  --text-2:          #cbd5e1;
  --text-3:          #94a3b8;
  --text-4:          #64748b;
  --text-5:          #475569;

  --primary-soft:    rgba(99,102,241,.12);
  --primary-border:  rgba(99,102,241,.25);
  --primary-glow:    rgba(99,102,241,.1);

  --success-soft:    rgba(34,197,94,.1);
  --success-border:  rgba(34,197,94,.2);
  --danger-soft:     rgba(239,68,68,.1);
  --danger-border:   rgba(239,68,68,.2);
  --warning-soft:    rgba(245,158,11,.1);
  --warning-border:  rgba(245,158,11,.2);
  --info-soft:       rgba(59,130,246,.1);
  --info-border:     rgba(59,130,246,.2);
  --purple-soft:     rgba(168,85,247,.1);

  --shadow-sm:  0 1px 2px rgba(0,0,0,.15);
  --shadow-md:  0 4px 6px rgba(0,0,0,.2);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.25);
  --shadow-xl:  0 20px 25px rgba(0,0,0,.3);

  --sidebar-bg: #111827;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-bg-hover: #1e293b;
  --sidebar-active-bg: rgba(99,102,241,.15);

  img, canvas, video { opacity: .85; }
  .card-gradient, [class*="bg-gradient"] { opacity: .9; }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background var(--t-normal), color var(--t-normal);
}

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

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea, button { font-family: var(--font); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }
::selection { background: var(--primary-soft); color: var(--primary); }

/* ===== 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; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }

/* Responsive display utilities */
@media (min-width: 1024px) { .lg-hidden { display: none !important; } }
@media (max-width: 1023px) { .hidden-mobile { display: none !important; } }

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t-slow), background var(--t-normal);
  display: flex;
  flex-direction: column;
}

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

#sidebar .sidebar-brand .brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

#sidebar .sidebar-brand .brand-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}

#sidebar .sidebar-brand .brand-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: auto;
  border: 1px solid var(--primary-border);
}

#sidebar nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

#sidebar nav .nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-4);
  padding: 12px 12px 6px;
  margin-top: 8px;
}

#sidebar nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--t-fast);
  margin-bottom: 2px;
  position: relative;
}

#sidebar nav .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

#sidebar nav .nav-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-hover);
}

#sidebar nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--primary);
  font-weight: 600;
}

#sidebar nav .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

#sidebar nav .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 16px;
}

#sidebar nav .nav-link.danger {
  color: var(--danger);
}

#sidebar nav .nav-link.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ===== SIDEBAR OVERLAY ===== */
#sidebarOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

#sidebarOverlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== HEADER ===== */
#header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: background var(--t-normal);
}

#header .header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#header .header-left .menu-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all var(--t-fast);
}

#header .header-left .menu-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

#header .page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--t-fast);
  cursor: pointer;
  border: none;
}

.theme-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
  transform: rotate(15deg);
}

/* Header Admin Avatar */
.admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
  cursor: pointer;
}

.admin-profile:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.admin-profile .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.admin-profile .admin-info {
  display: none;
}

@media (min-width: 640px) {
  .admin-profile .admin-info { display: block; }
}

.admin-profile .admin-info .admin-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.admin-profile .admin-info .admin-role {
  font-size: 11px;
  color: var(--text-4);
}

/* ===== MAIN CONTENT ===== */
#main-content {
  min-height: 100vh;
  transition: margin-left var(--t-slow);
  width: 100%;
}

@media (min-width: 1024px) {
  #main-content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
  }
}

.content-body {
  padding: 24px 28px;
}

@media (min-width: 1200px) {
  .content-body { padding: 28px 36px; }
}

@media (min-width: 1440px) {
  .content-body { padding: 32px 40px; }
}

@media (min-width: 1920px) {
  .content-body { padding: 36px 48px; }
}

@media (max-width: 640px) {
  .content-body { padding: 16px; }
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.4px;
}

.page-header p {
  font-size: 14px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ===== ALERTS ===== */
.alert {
  padding: 16px 20px;
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  animation: slideDown .3s ease;
}

.alert i { font-size: 20px; flex-shrink: 0; }

.alert-success {
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert-danger {
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.alert-warning {
  background: var(--warning-soft);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.alert-info {
  background: var(--info-soft);
  border: 1px solid var(--info-border);
  color: var(--info);
}

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 28px;
}

@media (min-width: 1200px) { .stat-grid { gap: 24px; } }
@media (min-width: 1920px) { .stat-grid { gap: 28px; } }

.stat-grid-4 {
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 540px) { .stat-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .stat-grid-4 { grid-template-columns: repeat(4, 1fr); } }

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

@media (min-width: 540px) { .stat-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .stat-grid-6 { grid-template-columns: repeat(6, 1fr); } }

.stat-card {
  border-radius: var(--r-xl);
  padding: 20px 24px;
  transition: all var(--t-normal);
}

@media (min-width: 1200px) { .stat-card { padding: 24px 28px; } }
@media (min-width: 1920px) { .stat-card { padding: 28px 32px; } }

.stat-card.gradient-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
}

.stat-card.gradient-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}

.stat-card.gradient-purple {
  background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: #fff;
}

.stat-card.gradient-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.stat-card.gradient-info {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #fff;
}

.stat-card.gradient-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.stat-card.gradient-emerald {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.stat-card .stat-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card .stat-info .stat-label {
  font-size: 13px;
  opacity: .85;
  margin-bottom: 4px;
  font-weight: 500;
}

@media (min-width: 1920px) {
  .stat-card .stat-info .stat-label { font-size: 14px; }
}

.stat-card .stat-info .stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
}

@media (min-width: 1200px) { .stat-card .stat-info .stat-value { font-size: 30px; } }
@media (min-width: 1920px) { .stat-card .stat-info .stat-value { font-size: 34px; } }

.stat-card .stat-info .stat-change {
  font-size: 12px;
  opacity: .75;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (min-width: 1920px) { .stat-card .stat-info .stat-change { font-size: 13px; } }

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,.15);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}

@media (min-width: 1200px) { .stat-card .stat-icon { width: 56px; height: 56px; font-size: 26px; } }
@media (min-width: 1920px) { .stat-card .stat-icon { width: 60px; height: 60px; font-size: 28px; } }

/* Mini stat cards */
.mini-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: all var(--t-fast);
  display: block;
}

.mini-stat-card:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.mini-stat-card .mini-stat-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mini-stat-card .mini-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.mini-stat-card .mini-stat-icon.indigo { background: var(--primary-soft); color: var(--primary); }
.mini-stat-card .mini-stat-icon.green { background: var(--success-soft); color: var(--success); }
.mini-stat-card .mini-stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.mini-stat-card .mini-stat-icon.yellow { background: var(--warning-soft); color: var(--warning); }
.mini-stat-card .mini-stat-icon.emerald { background: var(--success-soft); color: var(--success); }
.mini-stat-card .mini-stat-icon.gray { background: var(--surface-2); color: var(--text-3); }

.mini-stat-card .mini-stat-info .mini-stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}

.mini-stat-card .mini-stat-info .mini-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: all var(--t-normal);
}

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

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 24px;
}

@media (max-width: 640px) {
  .card-body { padding: 16px; }
  .card-header { padding: 16px; }
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== TABLES ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.table-wrap th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-wrap td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-2);
  vertical-align: middle;
}

.table-wrap tr:last-child td { border-bottom: none; }

.table-wrap tbody tr {
  transition: background var(--t-fast);
}

.table-wrap tbody tr:hover {
  background: var(--primary-soft);
}

.table-wrap tbody tr.highlight {
  background: var(--primary-soft);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: var(--surface-2); color: var(--text-3); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--t-fast);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  line-height: 1;
}

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--r-lg); }

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  box-shadow: 0 4px 14px var(--success-glow);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  box-shadow: 0 4px 14px var(--danger-glow);
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-warning:hover {
  box-shadow: 0 4px 14px var(--warning-glow);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-2);
  color: var(--text-2);
  background: var(--surface-2);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-soft);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--r-md);
}

.btn-icon.btn-sm { padding: 6px; }
.btn-icon.btn-xs { padding: 4px; }

.btn-danger-ghost {
  color: var(--danger);
  background: transparent;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.btn-primary-ghost {
  color: var(--primary);
  background: transparent;
}

.btn-primary-ghost:hover {
  background: var(--primary-soft);
}

/* ===== FORMS ===== */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  transition: all var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-4);
}

.form-input-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-input-center {
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-input-icon-wrap {
  position: relative;
}

.form-input-icon-wrap .form-input {
  padding-left: 40px;
}

.form-input-icon-wrap .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 14px;
  pointer-events: none;
}

.form-input-icon-wrap .input-right {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .2s ease;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn .25s ease;
}

.modal-content.wide {
  max-width: 720px;
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
}

.modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}

.page-btn:hover {
  border-color: var(--primary-border);
  color: var(--primary);
  background: var(--primary-soft);
}

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

/* ===== SEARCH INPUT ===== */
.search-box {
  position: relative;
  max-width: 400px;
}

.search-box .form-input {
  padding-left: 40px;
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  font-size: 14px;
}

.search-box .search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  cursor: pointer;
  transition: color var(--t-fast);
}

.search-box .search-clear:hover {
  color: var(--text-2);
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
  cursor: pointer;
}

.filter-btn:hover {
  border-color: var(--primary-border);
  color: var(--primary);
}

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

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

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

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

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-xl);
  background: var(--surface-2);
}

.empty-state .empty-icon {
  font-size: 48px;
  color: var(--text-5);
  margin-bottom: 16px;
}

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

.empty-state p {
  font-size: 14px;
  color: var(--text-3);
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr; gap: 16px; }

@media (min-width: 540px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

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

@media (min-width: 1200px) {
  .grid-2 { gap: 20px; }
  .grid-3 { gap: 20px; }
  .grid-4 { gap: 20px; }
}

@media (min-width: 1920px) {
  .grid-2 { gap: 24px; }
  .grid-3 { gap: 24px; }
  .grid-4 { gap: 24px; }
}

/* ===== SECTION DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ===== STEP NUMBER ===== */
.step-num {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

.animate-in {
  animation: fadeUp .3s ease both;
}

.animate-in-scale {
  animation: scaleIn .3s ease both;
}

/* ===== RESPONSIVE ===== */

/* === Mobile sidebar === */
@media (max-width: 1023px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* === Small screens === */
@media (max-width: 640px) {
  :root {
    --header-h: 60px;
  }

  #header {
    padding: 0 16px;
  }

  #header .page-title {
    font-size: 15px;
  }

  .content-body {
    padding: 16px;
  }

  .stat-card .stat-info .stat-value {
    font-size: 22px;
  }

  .stat-card .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .table-wrap table {
    min-width: 480px;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .btn {
    padding: 9px 16px;
    font-size: 13px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .stat-grid { gap: 12px; }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }

  .mini-stat-card { padding: 12px 14px; }

  .card-body { padding: 16px; }
  .card-header { padding: 16px; }
}

@media (max-width: 480px) {
  .stat-grid-4 { grid-template-columns: 1fr; }
  .stat-grid-6 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* === Very small === */
@media (max-width: 400px) {
  .table-wrap table {
    min-width: 360px;
  }

  .stat-card {
    padding: 16px;
  }
}

/* === Large screens: 1200px–1439px === */
@media (min-width: 1200px) {
  .content-body { padding: 28px 36px; }
  .stat-grid { gap: 24px; }
  .stat-card { padding: 24px 28px; }
  .stat-card .stat-info .stat-value { font-size: 30px; }
  .stat-card .stat-icon { width: 56px; height: 56px; font-size: 26px; }
  .card-body { padding: 28px; }
  .card-header { padding: 22px 28px; }
  .table-wrap th, .table-wrap td { padding: 14px 18px; }
}

/* === Large screens: 1440px–1919px === */
@media (min-width: 1440px) {
  .content-body { padding: 32px 40px; }
  .stat-grid { gap: 24px; }
  .card-body { padding: 32px; }
  .card-header { padding: 24px 32px; }
  .table-wrap th, .table-wrap td { padding: 16px 20px; }
  .mini-stat-card { padding: 18px 22px; }
  .mini-stat-card .mini-stat-value { font-size: 20px; }
}

/* === Ultra-wide: 1920px–2559px === */
@media (min-width: 1920px) {
  .content-body { padding: 36px 48px; }
  .stat-grid { gap: 28px; margin-bottom: 36px; }
  .stat-card { padding: 28px 32px; }
  .stat-card .stat-info .stat-value { font-size: 34px; }
  .stat-card .stat-info .stat-label { font-size: 14px; }
  .stat-card .stat-icon { width: 60px; height: 60px; font-size: 28px; }
  .card-body { padding: 36px; }
  .card-header { padding: 26px 36px; }
  .card-header h2 { font-size: 20px; }
  .table-wrap th, .table-wrap td { padding: 18px 24px; font-size: 14px; }
  .table-wrap th { font-size: 12px; }
  .page-header h1 { font-size: 28px; }
  .mini-stat-card { padding: 20px 24px; }
  .mini-stat-card .mini-stat-label { font-size: 13px; }
  .mini-stat-card .mini-stat-value { font-size: 22px; }
  .mini-stat-card .mini-stat-icon { width: 48px; height: 48px; font-size: 20px; }
  .grid-2, .grid-3, .grid-4 { gap: 24px; }
}

/* === 4K: 2560px+ === */
@media (min-width: 2560px) {
  .content-body { padding: 40px 56px; }
  .stat-grid { gap: 32px; margin-bottom: 40px; }
  .stat-card { padding: 32px 36px; }
  .stat-card .stat-info .stat-value { font-size: 38px; }
  .stat-card .stat-icon { width: 68px; height: 68px; font-size: 32px; }
  .card-body { padding: 40px; }
  .card-header { padding: 28px 40px; }
  .card-header h2 { font-size: 22px; }
  .table-wrap th, .table-wrap td { padding: 20px 28px; font-size: 15px; }
  .table-wrap th { font-size: 13px; }
  .page-header h1 { font-size: 32px; }
  .mini-stat-card { padding: 22px 28px; }
  .mini-stat-card .mini-stat-value { font-size: 24px; }
  .grid-2, .grid-3, .grid-4 { gap: 28px; }
}

/* ===== PRINT ===== */
@media print {
  #sidebar, #sidebarOverlay, #header, .theme-toggle, .btn,
  .no-print { display: none !important; }

  #main-content { margin-left: 0 !important; }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    border: 1px solid #ddd;
    box-shadow: none;
  }
}

/* ===== ACCESSIBILITY: FOCUS-VISIBLE ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:focus-visible,
.page-btn:focus-visible,
.filter-btn:focus-visible,
.modal-close:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== SPINNER / LOADING ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

.spinner-white { border-color: rgba(255,255,255,.25); border-top-color: #fff; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes dotPulse {
  0%, 80%, 100% { opacity: .2; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}

.skeleton-text:last-child { width: 70%; }

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: 12px;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--r-xl);
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== TOAST ENHANCEMENTS ===== */
.toast {
  animation: toastIn .35s cubic-bezier(.21,1.02,.73,1) both;
}

.toast.removing {
  animation: toastOut .25s ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(100%) scale(.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(100%) scale(.9); }
}

/* ===== MODAL BACKDROP ENHANCEMENT ===== */
.modal-overlay.open {
  animation: fadeIn .2s ease;
}

.modal-content {
  animation: modalIn .25s cubic-bezier(.21,1.02,.73,1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-5);
}

/* ===== TEXT SELECTION ===== */
::selection {
  background: var(--primary);
  color: #fff;
}

/* ===== UTILITY CLASSES ===== */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-mono {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: .9em;
}

.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }
.gap-xl { gap: 20px; }

.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 20px; }
.mb-xl { margin-bottom: 28px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* ===== HOVER RIPPLE (buttons) ===== */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.btn:active::after {
  opacity: 1;
}

.btn-ghost::after,
.btn-outline::after,
.btn-danger-ghost::after,
.btn-primary-ghost::after {
  background: rgba(0,0,0,.05);
}

.dark .btn-ghost::after,
.dark .btn-outline::after,
.dark .btn-danger-ghost::after,
.dark .btn-primary-ghost::after {
  background: rgba(255,255,255,.08);
}

/* ===== DARK MODE SCROLLBAR ===== */
.dark ::-webkit-scrollbar-thumb {
  background: var(--border);
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: var(--text-5);
}

/* ===== SMOOTH SIDEBAR MOBILE ===== */
@media (max-width: 1023px) {
  #sidebar {
    transition: transform var(--t-slow) cubic-bezier(.21,1.02,.73,1);
  }
}


