:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
  --topbar-h: 56px;
  --sidebar-w: 232px;
  --bottomnav-h: 60px;
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 布局骨架 ---------- */
.app { min-height: 100vh; }

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  display: flex;
  align-items: center;
}
.topbar-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand svg { color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--bg); }
.chip-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; }
.chip-name { font-weight: 600; font-size: 14px; }
.chip-role { font-size: 12px; color: var(--muted); background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 999px; }

.icon-btn {
  width: 38px; height: 38px;
  border: none; background: transparent;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
}
.icon-btn:hover { background: var(--bg); }
.hamburger { display: none; }

/* 侧边栏（桌面） */
.sidebar {
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  display: none;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  position: relative;
}
.nav-link svg { color: var(--muted); flex-shrink: 0; }
.nav-link:hover { background: var(--bg); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.nav-link.active svg { color: var(--primary); }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 999px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

.main { padding-top: var(--topbar-h); }
.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 90px; }

/* 抽屉 */
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px;
  background: var(--card);
  z-index: 95;
  transform: translateX(-100%);
  transition: transform .28s ease;
  padding: 20px 14px;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin-bottom: 16px; color: var(--primary); }
.drawer-nav { display: flex; flex-direction: column; gap: 4px; }

/* 底部导航（移动端） */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 50;
  display: none;
  overflow-x: auto;
  padding-bottom: env(safe-area-inset-bottom);
  scrollbar-width: none;
}
.bottomnav::-webkit-scrollbar { display: none; }
.bottomnav-item {
  flex: 1 0 72px;
  max-width: 96px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  position: relative;
}
.bottomnav-item svg { color: currentColor; }
.bottomnav-item.active { color: var(--primary); font-weight: 600; }
.bottomnav-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--danger); color: #fff; font-size: 10px;
  border-radius: 999px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- 卡片 / 通用 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.card-head h3 { font-size: 16px; display: flex; align-items: center; gap: 6px; }
.card-head h3 svg { color: var(--primary); }
.card-tools { padding: 14px 18px; }
.card-table { padding: 0; overflow: hidden; }
.card-table .table-wrap { margin: 0; }
.card-table table { margin: 0; }
.card-table thead th { background: #f9fafb; }

.section-block { margin-bottom: 22px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h3 { font-size: 17px; display: flex; align-items: center; gap: 6px; }
.section-head .section-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.section-title { margin: 18px 0 10px; font-size: 14px; color: var(--muted); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .muted { margin-top: 2px; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.link { color: var(--primary); font-weight: 500; font-size: 14px; }

.text-primary { color: var(--primary); }
.text-up { color: var(--success); font-weight: 600; }
.text-down { color: var(--danger); font-weight: 600; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.stat-card.primary { background: linear-gradient(135deg, #4f46e5, #7c3aed); border: none; color: #fff; }
.stat-card.primary .stat-label { color: rgba(255,255,255,0.85); }
.stat-card.warn-card .stat-icon { background: var(--warn-light); color: var(--warn); }
.stat-icon { width: 46px; height: 46px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }

/* 快捷入口 */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.quick-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  color: var(--text); box-shadow: var(--shadow);
}
.quick-card svg { color: var(--primary); margin-bottom: 6px; }
.quick-card span { font-weight: 600; }
.quick-card small { color: var(--muted); }
.quick-card:hover { border-color: var(--primary); }

.quick-list { display: flex; flex-direction: column; }
.quick-row { display: flex; align-items: center; gap: 10px; padding: 12px 8px; border-radius: 8px; color: var(--text); font-weight: 500; }
.quick-row svg { color: var(--primary); }
.quick-row:hover { background: var(--bg); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .card { margin-bottom: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-outline-danger { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-outline-danger:hover { border-color: var(--danger); background: var(--danger-light); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-disabled, .btn-muted { background: var(--border); color: var(--muted); pointer-events: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 14px; font-weight: 500; }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field input[type="date"], .field input[type="email"],
.field select, .field textarea,
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
textarea { resize: vertical; min-height: 60px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-wrap { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.form-row-wrap .btn { flex-shrink: 0; }
.field-grow { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.form-row.between { justify-content: space-between; align-items: center; flex-direction: row; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.field .input-wrap > input { padding-left: 38px; }
.field .input-wrap > input[type="password"], .field .input-wrap > input[type="text"] { padding-right: 42px; }
.input-action {
  position: absolute; right: 4px;
  width: 34px; height: 34px;
  border: none; background: transparent;
  color: var(--muted);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.input-action:hover { background: var(--bg); color: var(--text); }

.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checkbox.disabled { opacity: .55; cursor: not-allowed; }
.checkbox.disabled input { cursor: not-allowed; }
.checkbox em { font-style: normal; font-size: 12px; color: var(--muted); }

.role-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px; padding: 16px 12px;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.role-option svg { color: var(--muted); }
.role-option input { position: absolute; opacity: 0; }
.role-option:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.role-option:has(input:checked) svg { color: var(--primary); }

.file-input { padding: 8px; border: 1px dashed var(--border); border-radius: 8px; font-size: 13px; }
.file-input::file-selector-button { margin-right: 10px; }

/* ---------- 图标选择器 ---------- */
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-option input { position: absolute; opacity: 0; }
.icon-option span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); cursor: pointer;
}
.icon-option input:checked + span { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-panel {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; }
.modal-body { margin-bottom: 16px; line-height: 1.6; color: var(--muted); }
.modal-body strong { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.result-student { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.result-line { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; color: var(--text); border-bottom: 1px dashed var(--border); }
.result-line:last-child { border-bottom: none; }
.result-label { flex: 0 0 64px; color: var(--muted); }
.result-balance { font-weight: 700; color: var(--primary); }
.result-extra { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: var(--warn-light); color: #78350f; font-size: 13px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -18px; }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table-wrap th, .table-wrap td { padding: 12px 18px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table-wrap th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table-wrap tbody tr:last-child td { border-bottom: none; }
.table-wrap tbody tr:hover { background: #f9fafb; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-unread { background: var(--primary-light); }
.row-highlight { background: var(--primary-light); }
.row-highlight td:first-child { border-left: 3px solid var(--primary); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }
.pg-btn { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font-size: 14px; }
.pg-btn.disabled { opacity: .45; pointer-events: none; }
.pg-info { color: var(--muted); font-size: 14px; }

/* ---------- 标签 / 徽章 ---------- */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.tag-success { background: var(--success-light); color: var(--success); }
.tag-danger { background: var(--danger-light); color: var(--danger); }
.tag-warn { background: var(--warn-light); color: var(--warn); }
.tag-primary { background: var(--primary-light); color: var(--primary); }
.tag-purple { background: var(--purple-light); color: var(--purple); }
.tag-muted { background: var(--bg); color: var(--muted); }

/* 抽奖管理：类型徽章、概率条 */
.award-type-tag { white-space: nowrap; }
.prob-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.prob-row { display: flex; align-items: center; gap: 6px; }
.prob-row input { width: 60px; padding: 6px 8px; flex-shrink: 0; }
.prob-bar { height: 5px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.prob-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #818cf8); width: 0; transition: width .2s; }
.prob-pct { font-size: 11px; color: var(--muted); width: 34px; text-align: right; flex-shrink: 0; }
.no-value-note { font-size: 11px; color: var(--muted); line-height: 1.5; }
.award-name-cell { display: flex; gap: 6px; align-items: center; min-width: 130px; }
.award-name-cell .tag { flex-shrink: 0; }
.setup-steps { display: grid; gap: 8px; margin-bottom: 14px; padding: 12px 14px; background: var(--primary-light); border-radius: 10px; }
.setup-steps .step { display: flex; gap: 8px; font-size: 13px; color: var(--text); align-items: flex-start; }
.setup-steps .step b { color: var(--primary); flex-shrink: 0; }

/* 排行榜 */
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg); color: var(--muted);
  font-weight: 700; font-size: 13px;
}
.rank-1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #cbd5e1); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #b45309, #d97706); color: #fff; }
.mini-badges { display: flex; align-items: center; gap: 2px; }
.mini-badge { color: var(--primary); }
.mini-badge.muted { color: var(--muted); font-size: 12px; }

/* 徽章展示 */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.badge-item { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 10px 6px; border: 1px solid var(--border); border-radius: 10px; }
.badge-icon { color: var(--primary); }
.badge-name { font-size: 12px; font-weight: 600; }
.badge-date { font-size: 11px; }
.badge-inline { display: flex; align-items: center; gap: 10px; }
.badge-inline svg { color: var(--primary); flex-shrink: 0; }

/* ---------- 商品 ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.product-card.readonly { opacity: .92; }
.product-thumb {
  height: 130px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  color: var(--primary);
  position: relative;
  overflow: hidden;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.abs-tag { position: absolute; top: 8px; right: 8px; }
.product-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.product-desc { color: var(--muted); font-size: 13px; min-height: 20px; }
.product-meta { display: flex; align-items: center; justify-content: space-between; }
.product-cost { color: var(--primary); font-weight: 700; }
.product-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* 兑换列表 */
.exchange-list { display: flex; flex-direction: column; gap: 12px; }
.exchange-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 0; }
.exchange-name { font-weight: 600; }
.exchange-meta { font-size: 13px; margin-top: 2px; }
.exchange-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 学生卡片 */
.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.student-card { display: flex; align-items: center; gap: 12px; margin-bottom: 0; }
.student-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0; }
.student-name { font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.student-points { color: var(--primary); font-weight: 700; }
.student-card .btn { margin-left: auto; }

/* 时间线 */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.timeline-dot.up { background: var(--success); }
.timeline-dot.down { background: var(--danger); }
.timeline-body { flex: 1; }
.timeline-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tl-reason { font-weight: 500; }
.tl-meta { font-size: 12px; }

/* 列表 */
.plain-list { list-style: none; }
.plain-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.plain-item:last-child { border-bottom: none; }
.plain-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* 个人资料 */
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.profile-row:last-child { border-bottom: none; }

/* 标签页 */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; overflow-x: auto; }
.tab {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.tab.active { background: var(--primary); color: #fff; }
.sub-tabs { margin-bottom: 12px; }

/* 提示 */
.alert {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-success { background: var(--success-light); color: #14532d; }
.alert-error { background: var(--danger-light); color: #7f1d1d; }
.alert-warn { background: var(--warn-light); color: #78350f; }
.alert-info { background: var(--primary-light); color: #1e3a5f; }
.alert-close { background: none; border: none; font-size: 18px; color: inherit; opacity: .7; }

/* ---------- 系统维护公告 ---------- */
.maintenance-banner {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; margin-bottom: 16px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--warn-light, #fef3c7) 0%, #fff7ed 100%);
  border: 1px solid #fcd34d;
  color: #78350f;
  font-size: 14px;
}
.maintenance-banner .maintenance-title {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 15px; color: #92400e;
}
.maintenance-banner .maintenance-msg { line-height: 1.5; }
.maintenance-banner .maintenance-contact { font-size: 13px; color: #92400e; opacity: .85; }
.maintenance-banner.is-off { opacity: .55; }

/* ---------- 认证页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #eef2ff 0%, #f5f3ff 100%); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 20px; color: var(--primary); text-align: center; }
.auth-brand h1 { font-size: 24px; color: var(--text); }
.auth-brand p { color: var(--muted); font-size: 14px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px 26px; margin-bottom: 0; }
.auth-title { font-size: 20px; margin-bottom: 4px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--muted); }
.auth-switch a { font-weight: 600; }
.auth-wrap .alert { width: 100%; max-width: 420px; }

/* ---------- 积分抽奖转盘 ---------- */
.lottery-card { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lottery-wrap { position: relative; width: 320px; max-width: 100%; aspect-ratio: 1; }
.wheel-ring {
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  background: repeating-conic-gradient(#f9c9d3 0deg 20deg, #fde6c8 20deg 40deg, #fff3c2 40deg 60deg, #c9efd4 60deg 80deg, #c4e4f7 80deg 100deg, #ddd0f6 100deg 120deg);
  box-shadow: 0 0 18px rgba(246, 190, 160, 0.45), 0 6px 16px rgba(0, 0, 0, 0.12);
  z-index: 0;
  pointer-events: none;
}
.wheel-ring::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.16);
}
.wheel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid #f7e3c3;
  box-shadow: 0 0 0 4px rgba(246, 205, 185, 0.5), 0 10px 26px rgba(140, 120, 170, 0.35), inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 6px 20px rgba(0, 0, 0, 0.1);
  z-index: 1;
}
.wheel-disk {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: transform 4s cubic-bezier(0.12, 0.9, 0.16, 1);
  will-change: transform;
}
.wheel-disk::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.07) 48%, rgba(0, 0, 0, 0.06) 84%);
  pointer-events: none;
  z-index: 1;
}
.wheel-label {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #6d4f6e;
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), 0 0 3px rgba(255, 255, 255, 0.75), 0 0 9px rgba(255, 255, 255, 0.5);
  line-height: 1.25;
  max-width: 16px;
  max-height: 96px;
  overflow: hidden;
  writing-mode: vertical-lr;
  transform: translate(-50%, -50%) rotate(var(--rot)) translateY(calc(-1 * var(--ty, 90px)));
  transform-origin: center;
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
}
.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fffdf7, #fde8d8 60%, #f4cfa9);
  border: 4px solid #ecd3b0;
  box-shadow: 0 0 0 6px rgba(245, 215, 190, 0.55), 0 5px 12px rgba(0, 0, 0, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.wheel-start {
  border: none;
  background: linear-gradient(180deg, #ffd9c0, #f8b195 45%, #f2937e);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  border-radius: 999px;
  padding: 9px 10px;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(180, 100, 80, 0.45);
  box-shadow: 0 4px 10px rgba(240, 150, 130, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: wheelStartPulse 1.6s ease-in-out infinite;
}
.wheel-start:disabled { background: #d8c9d8; cursor: not-allowed; box-shadow: none; animation: none; color: #fff; }
@keyframes wheelStartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 38px solid #f2937e;
  z-index: 4;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.3));
}
.wheel-pointer::after {
  content: "";
  position: absolute;
  top: -34px;
  left: -10px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 22px solid #fff;
}
.wheel-pointer::before {
  content: "";
  position: absolute;
  top: -45px;
  left: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #ffd700);
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.95);
}
.lottery-hint { color: var(--muted); font-size: 13px; }
.lottery-recent { width: 100%; max-width: 320px; }
.lottery-recent h4 { font-size: 14px; margin-bottom: 8px; }
.lottery-recent ul { list-style: none; }
.lottery-recent li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.lottery-recent li:last-child { border-bottom: none; }
.lottery-recent li .muted { margin-left: auto; }
.modal-center { text-align: center; }
.lottery-result-icon { color: #f59e0b; margin: 0 auto 10px; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--warn-light); }
.lottery-result-icon svg { display: block; }
.lottery-result-msg { font-size: 15px; margin: 6px 0 4px; }
.modal-center .modal-actions { justify-content: center; }

/* ---------- 响应式 ---------- */
@media (max-width: 1023px) {
  .sidebar { display: none; }
  .hamburger { display: inline-flex; }
  .container { padding-bottom: calc(var(--bottomnav-h) + 24px); }
  .bottomnav { display: flex; }
}

@media (min-width: 1024px) {
  .sidebar { display: block; }
  .main { margin-left: var(--sidebar-w); }
}

@media (max-width: 767px) {
  body { font-size: 14px; }
  .container { padding: 14px 12px calc(var(--bottomnav-h) + 24px); }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .page-head { align-items: flex-start; }
  .chip-name, .chip-role { display: none; }
  .chip { padding: 4px; }

  /* 表格在移动端变成卡片 */
  .table-wrap { margin: 0; }
  .table-wrap table { min-width: 0; }
  .card-table .table-wrap table,
  .card-table table { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .table-wrap tr:last-child { border-bottom: none; }
  .table-wrap td { border-bottom: none; padding: 6px 0; }
  .table-wrap td:first-child { font-weight: 600; }
  .table-wrap td::before {
    content: attr(data-label);
    display: inline-block;
    width: 82px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
  }
  .table-wrap td[data-label] { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
  .table-wrap td[data-label]:first-child { display: flex; }
  .row-actions { justify-content: flex-start; }
  .row-highlight td:first-child { border-left: none; border-radius: 8px; }

  .form-row { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .modal-panel { padding: 16px; }

  /* 移动端登录页：卡片靠上、品牌区缩小，配合软键盘防遮挡滚动 */
  .auth-wrap { justify-content: flex-start; padding-top: 6vh; min-height: 100vh; min-height: 100svh; }
  .auth-brand { margin-bottom: 14px; }
  .auth-brand h1 { font-size: 20px; }
  .auth-brand p { font-size: 13px; margin: 0; }
  .auth-card { padding: 22px 20px; }
}

/* ---------- 快捷积分 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-tabs { display: inline-flex; gap: 6px; margin-bottom: 14px; }
.quick-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.quick-tab:hover { border-color: var(--primary); color: var(--primary); }
.quick-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.manage-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; user-select: none;
  padding: 4px 8px;
}
.manage-toggle input { width: 15px; height: 15px; cursor: pointer; }
.manage-mode .manage-toggle { color: var(--primary); }
/* 管理模式专属控件：默认隐藏，勾选管理模式后显示 */
.quick-manage-only { display: none !important; }
.manage-mode .quick-manage-only { display: inline-flex !important; }
.manage-mode .quick-btn { cursor: default; }
.manage-mode .quick-btn:hover { border-color: var(--border); box-shadow: none; transform: none; }
/* 管理模式下快捷按钮展示可编辑提示 */
.manage-mode .quick-btn { outline: 1px dashed var(--primary); outline-offset: 2px; }
.manage-mode .quick-btn:hover { outline-color: var(--primary); }
.quick-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.quick-btn:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.quick-btn:active { transform: translateY(0); }
.quick-amount { font-size: 18px; font-weight: 800; }
.quick-name { font-size: 13px; color: var(--text); }
.quick-btn-add .quick-amount { color: var(--success); }
.quick-btn-deduct .quick-amount { color: var(--danger); }
.quick-btn-add { border-top: 3px solid var(--success); }
.quick-btn-deduct { border-top: 3px solid var(--danger); }
.quick-btn-disabled { pointer-events: none; opacity: .6; cursor: not-allowed; }
.quick-btn-loading::after {
  content: '';
  position: absolute; right: 12px; top: 12px;
  width: 14px; height: 14px;
  border: 2px solid rgba(0,0,0,.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: quick-spin .7s linear infinite;
}
@keyframes quick-spin { to { transform: rotate(360deg); } }
.quick-del {
  position: absolute; right: 6px; top: 6px;
  color: var(--muted); cursor: pointer;
  opacity: 0; transition: opacity .15s;
  display: flex; align-items: center;
  padding: 2px;
}
.quick-btn:hover .quick-del { opacity: 1; }
.quick-del:hover { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff;
  padding: 10px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 120; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 自动规则周期配置 ---------- */
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--card); transition: border-color .15s, background .15s; }
.chip-chip input { display: none; }
.chip-chip span { font-size: 13px; color: var(--muted); }
.chip-chip:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.chip-chip:has(input:checked) span { color: var(--primary); font-weight: 600; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check-line input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- 抽奖管理页：紧凑布局（R32） ---------- */
.stats-grid.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats-grid.compact .stat-card { padding: 10px 12px; gap: 10px; }
.stats-grid.compact .stat-icon { width: 34px; height: 34px; border-radius: 8px; }
.stats-grid.compact .stat-value { font-size: 19px; }
.stats-grid.compact .stat-label { font-size: 12px; }

/* 活动设置折叠卡 */
.lottery-collapse { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.lottery-collapse > .card { border: 0; box-shadow: none; margin: 0; border-top: 1px solid var(--border); border-radius: 0; }
.lottery-collapse summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 18px; user-select: none; }
.lottery-collapse summary::-webkit-details-marker { display: none; }
.lottery-collapse summary .chevron { transition: transform .15s; color: var(--muted); flex-shrink: 0; }
.lottery-collapse[open] summary .chevron { transform: rotate(90deg); }
.lottery-collapse summary:hover { background: #f9fafb; }
.lottery-collapse summary h3 { font-size: 15px; display: flex; align-items: center; gap: 6px; margin: 0; }
.lottery-collapse summary h3 svg { color: var(--primary); }
.lottery-collapse .collapse-meta { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lottery-collapse .collapse-meta .muted { font-size: 12.5px; }

/* 紧凑表单 */
.form-compact { display: flex; flex-direction: column; gap: 12px; }
.form-compact label { font-size: 13px; font-weight: 500; }
.form-compact .form-row { grid-template-columns: 1fr auto; gap: 10px; }
.form-compact .field-grow { gap: 4px; }
.form-compact .field-narrow { max-width: 220px; }

/* 学生选择 chips */
.student-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.student-chip { position: relative; }
.student-chip input { position: absolute; opacity: 0; pointer-events: none; }
.student-chip span { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; background: var(--card); cursor: pointer; transition: all .15s; white-space: nowrap; }
.student-chip input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.student-chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.student-chip.disabled span { opacity: .55; cursor: not-allowed; }
.student-chip em { font-style: normal; font-size: 11px; opacity: .8; }

/* 紧凑表格 */
.table-dense th, .table-dense td { padding: 8px 10px; font-size: 13px; }
.table-dense input[type="text"], .table-dense input[type="number"], .table-dense select { padding: 5px 8px; font-size: 13px; }
.table-dense .prob-wrap { min-width: 118px; }
.table-dense .prob-row input { width: 50px; padding: 5px 6px; }

/* 奖项操作行 */
.award-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }

/* 步骤条横排 */
.setup-steps { grid-template-columns: repeat(3, 1fr); gap: 6px 14px; padding: 10px 14px; margin-bottom: 12px; }
.setup-steps .step { font-size: 12.5px; }
@media (max-width: 560px) {
  .setup-steps { grid-template-columns: 1fr; }
  .form-compact .field-narrow { max-width: none; }
}

/* ---------- 系统设置折叠面板 ---------- */
.settings-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.settings-nav a { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; transition: all .15s ease; }
.settings-nav a:hover { border-color: var(--primary); color: var(--primary); }
.settings-panel { border: 1px solid var(--border); border-radius: 14px; background: var(--card); margin-bottom: 12px; overflow: hidden; }
.settings-panel > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer; user-select: none; }
.settings-panel > summary::-webkit-details-marker { display: none; }
.settings-panel > summary:hover { background: var(--bg); }
.settings-panel > summary .sp-icon { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary-light); color: var(--primary); flex-shrink: 0; }
.settings-panel > summary .sp-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-panel > summary .sp-label strong { font-size: 15px; }
.settings-panel > summary .sp-status { flex-shrink: 0; }
.settings-panel > summary .sp-arrow { flex-shrink: 0; color: var(--muted); transition: transform .2s ease; }
.settings-panel[open] > summary .sp-arrow { transform: rotate(180deg); }
.settings-panel .sp-body { border-top: 1px solid var(--border); padding: 18px; }
.settings-panel .sp-body > .card { border: none; box-shadow: none; padding: 0; }
.sp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
@media (max-width: 560px) {
  .settings-panel > summary { padding: 12px 14px; gap: 10px; }
  .settings-panel > summary .sp-status { display: none; }
  .settings-panel .sp-body { padding: 14px; }
  .load-more-btn { width: 100%; min-width: 0; }
}

/* ---------- 必填项星标 ---------- */
.req { color: #ef4444; font-weight: 700; margin-left: 2px; }
label .req { text-decoration: none; }

/* ---------- 加载更多 ---------- */
.load-more-wrap { text-align: center; padding: 14px 0 6px; }
.load-more-btn { min-width: 180px; }
.load-more-spinner { color: var(--text-muted, #888); font-size: 13px; }

/* ---------- 积分趋势柱状图 ---------- */
.trend-chart { display: flex; gap: 6px; height: 230px; overflow-x: auto; padding: 10px 2px 0; }
.trend-col { flex: 1 0 30px; min-width: 30px; height: 200px; position: relative; }
.trend-col:hover { background: rgba(0,0,0,.02); }
.trend-mid { position: absolute; top: 50%; left: 0; right: 0; border-top: 1px dashed #e2e5ea; }
.bar-earn, .bar-spend { position: absolute; left: 50%; width: 13px; border-radius: 3px; transform: translateX(-50%); transition: opacity .2s; }
.bar-earn { bottom: 50%; background: linear-gradient(180deg, #22c55e, #16a34a); }
.bar-spend { top: 50%; background: linear-gradient(0deg, #f87171, #dc2626); }
.trend-col:hover .bar-earn, .trend-col:hover .bar-spend { opacity: .85; }
.trend-day { position: absolute; bottom: -26px; left: 50%; transform: translateX(-50%); font-size: 11px; color: #9aa1ad; white-space: nowrap; }
.trend-legend { display: flex; gap: 18px; font-size: 13px; color: #6b7280; margin-top: 8px; }
.trend-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.trend-legend .lg-earn { background: #16a34a; }
.trend-legend .lg-spend { background: #dc2626; }
