:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* Auth Pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #e0e7ff 0%, #f4f6fb 50%, #e2e8f0 100%);
}
.auth-page.admin-theme {
  background: radial-gradient(circle at 20% 20%, #1e1b4b 0%, #0f172a 60%, #020617 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .14);
}
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 14px;
}
.auth-badge.admin { background: #fef2f2; color: #b91c1c; }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
}
.brand-logo.admin { background: linear-gradient(135deg, #f43f5e, #f97316); }
.brand-title { font-weight: 700; color: #fff; font-size: 15px; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  color: #cbd5e1; cursor: pointer; margin-bottom: 4px;
  transition: background .15s, color .15s;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #94a3b8;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary);
}
.pill.money { background: var(--success-soft); color: #047857; }

.content { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* Cards & Grids */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat-foot { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* Forms & Buttons */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; color: #475569; font-weight: 600; font-size: 12px; }
tr:hover td { background: #fafbff; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-indigo { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: #047857; }
.badge-amber { background: var(--warning-soft); color: #b45309; }
.badge-red { background: var(--danger-soft); color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Course Verify Panel */
.verify-box {
  margin-top: 16px; padding: 16px; border-radius: 12px;
  border: 1px solid var(--border); background: #f8fafc;
}
.verify-box.ok { border-color: #a7f3d0; background: #ecfdf5; }
.verify-box.err { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.course-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 9px; background: #fff; border: 1px solid var(--border);
  margin-top: 8px; cursor: pointer;
}
.course-item:hover { border-color: var(--primary); }

/* Lightweight Bar Chart */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 150px; padding-top: 16px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; max-width: 40px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #6366f1, #818cf8); min-height: 4px; transition: height .3s; }
.bar-num { font-size: 11px; font-weight: 700; color: #475569; }
.bar-lbl { font-size: 11px; color: var(--text-muted); }

/* Modal & Toast */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: none; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.2);
}
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  padding: 11px 18px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; transform: translateY(-10px);
  transition: all .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: #059669; }
.toast.err { background: #dc2626; }

.hidden { display: none !important; }
@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { display: flex; overflow-x: auto; padding: 8px; }
  .nav-item { white-space: nowrap; width: auto; }
  .sidebar-foot { display: none; }
}
