/* =============================================================
   积分登记与汇总中心 · Apple 风格样式
   设计基准见 DESIGN.md：#f5f5f7 底 / 白卡 18px / Apple 蓝 #0071e3
   ============================================================= */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --seg-bg: #e8e8ed;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 顶部导航：毛玻璃 ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.nav-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--accent);
  display: inline-block;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 6px;
  border-radius: 50%;
  background: #fff;
}
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }

/* 分段控件 */
.segmented {
  flex: 1;
  display: flex;
  justify-content: center;
}
.segmented-inner, .segmented {
  min-width: 0;
}
.segmented .tab { white-space: nowrap; }
.segmented {
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented .tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-2);
  padding: 6px 18px;
  border-radius: 980px;
  cursor: pointer;
  transition: color 0.2s ease;
}
.segmented {
  background: transparent;
}
@media (min-width: 561px) {
  .segmented {
    background: none;
  }
}
.segmented .tab:hover { color: var(--text); }
.segmented .tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
/* 浅灰槽包裹分段控件 */
.segmented {
  padding: 3px;
  border-radius: 980px;
}
@media (min-width: 0) {
  .segmented { background: var(--seg-bg); }
}

/* ---------- 容器与卡片 ---------- */
.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

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

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { color: var(--text-2); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------- 表单 ---------- */
.field { margin-top: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.field-tip { font-weight: 400; color: var(--text-3); font-size: 12px; }

.input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}
.input-sm { width: auto; padding: 8px 12px; font-size: 13px; }

.row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.row .input { flex: 1; min-width: 180px; }

/* ---------- 按钮：胶囊 ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 980px;
  padding: 10px 22px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-ghost:hover:not(:disabled) { background: rgba(0, 113, 227, 0.08); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: rgba(255, 59, 48, 0.08); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 20px; }

.btn.loading { opacity: 0.6; pointer-events: none; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-extra { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.2s ease; }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: none; }
.ta-r { text-align: right; }
.table .num, .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.num.pos { color: var(--green); }
.num.neg { color: var(--red); }

.placeholder {
  text-align: center;
  color: var(--text-3);
  padding: 36px 12px !important;
  font-size: 13px;
}

/* ---------- 迷你流水列表（登记页） ---------- */
.mini-list { display: flex; flex-direction: column; }
.mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.mini-item:last-child { border-bottom: none; }
.mini-main { min-width: 0; }
.mini-user { font-weight: 600; font-size: 13px; }
.mini-reason {
  color: var(--text-2);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.mini-time { color: var(--text-3); font-size: 12px; white-space: nowrap; }

/* ---------- 筛选条与分页 ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar .input { flex: 0 1 auto; min-width: 120px; }
.filter-bar #fKeyword { min-width: 160px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
}

/* ---------- 搜索框 ---------- */
.search-input { width: 220px; }

/* ---------- 标签徽章 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 500;
}
.badge.green { background: rgba(52, 199, 89, 0.12); color: #248a3d; }
.badge.gray { background: rgba(134, 134, 139, 0.14); color: var(--text-2); }

/* ---------- 提示条 / 校验结果 ---------- */
.auth-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff8e6;
  border: 1px solid rgba(255, 149, 0, 0.35);
  color: #8a5600;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.check-result { margin-top: 14px; font-size: 13px; }
.check-result .ok-line { color: #248a3d; }
.check-result .bad-line { color: var(--red); }
.check-result ul { margin: 8px 0 0 18px; color: var(--text-2); }

.tips { margin: 12px 0 0 18px; color: var(--text-2); font-size: 13px; line-height: 2; }
.card-sub strong { color: var(--text); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 28px;
  width: 100%;
  max-width: 460px;
}
.modal-title { font-size: 18px; font-weight: 600; }
.modal-warn { color: var(--orange); font-size: 13px; margin-top: 10px; line-height: 1.6; }
.key-box {
  display: block;
  margin-top: 14px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(29, 29, 31, 0.88);
  color: #fff;
  font-size: 13px;
  padding: 12px 22px;
  border-radius: 980px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 快捷积分项按钮（登记页/积分墙共用） ---------- */
.item-bar { display: flex; flex-wrap: wrap; gap: 8px; min-height: 34px; margin-top: 4px; }
.item-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 980px;
  padding: 8px 16px;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}
.item-btn:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.item-btn:active { transform: scale(0.95); }
.item-btn:disabled { opacity: 0.5; cursor: wait; }
.item-btn .item-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.item-empty { color: var(--text-3); font-size: 12px; align-self: center; }

/* ---------- 学员搜索候选（登记页） ---------- */
.candidate-list {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.candidate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease;
}
.candidate-row:last-child { border-bottom: none; }
.candidate-row:hover { background: var(--bg); }
.candidate-main { font-weight: 500; }
.candidate-sub { color: var(--text-3); font-size: 12px; margin-left: 8px; }
.candidate-points { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2); }

.selected-stu {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(0, 113, 227, 0.08);
  border: 1px solid rgba(0, 113, 227, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.selected-stu .sel-name { font-weight: 600; }
.selected-stu .sel-meta { color: var(--text-2); font-size: 12px; margin-left: 8px; }
.selected-stu .sel-points { font-variant-numeric: tabular-nums; font-weight: 700; }
.selected-stu .sel-clear {
  border: none; background: none; color: var(--text-3); cursor: pointer;
  font-size: 16px; padding: 0 4px; line-height: 1;
}
.selected-stu .sel-clear:hover { color: var(--text); }

/* ---------- 表单小控件（积分项/等级编辑） ---------- */
.seg-row { display: inline-flex; background: var(--seg-bg); border-radius: 980px; padding: 3px; gap: 2px; }
.seg-opt {
  border: none; background: transparent; font-family: inherit; font-size: 13px;
  color: var(--text-2); padding: 6px 18px; border-radius: 980px; cursor: pointer;
  transition: all 0.2s ease;
}
.seg-opt.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.15s ease, border-color 0.15s ease;
}
.color-dot.active { border-color: var(--text); transform: scale(1.12); }

.icon-row { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-opt {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all 0.15s ease;
}
.icon-opt.active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12); }

.group-check-row { display: flex; gap: 12px; flex-wrap: wrap; }
.scope-check, .group-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap;
}

.level-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.level-row .input { flex: 1; min-width: 0; }
.level-row .level-min { max-width: 140px; }
.level-del {
  border: none; background: none; color: var(--red); cursor: pointer;
  font-size: 13px; padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.level-del:hover { background: rgba(255, 59, 48, 0.08); }

.inline-code {
  background: var(--bg); border-radius: 6px; padding: 2px 7px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .nav-inner { flex-wrap: wrap; gap: 10px; }
  .segmented { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .card { padding: 18px; }
  .table-wrap { margin: 0 -18px; padding: 0 18px; }
  .search-input { width: 100%; }
  .filter-bar .input, .filter-bar .btn { flex: 1 1 40%; }
}

/* ========== 管理台入口口令门 ========== */
.auth-gate {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-gate-card {
  width: 100%; max-width: 360px;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  padding: 32px 28px; text-align: center;
}
.auth-gate-title { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.auth-gate-sub { font-size: 14px; color: var(--text-2); margin-bottom: 20px; }
.auth-gate-card .input { width: 100%; text-align: center; margin-bottom: 10px; }
.auth-gate-error { font-size: 13px; color: var(--red); margin-bottom: 10px; }
.auth-gate-card .btn { width: 100%; }
