:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1b2333;
  --ink-2: #55607a;
  --muted: #8a93a8;
  --line: #e3e8f2;
  --brand: #b03a3a;
  --brand-2: #d8604f;
  --ok: #2f9e6b;
  --warn: #d08a1c;
  --err: #c04545;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--err); min-height: 18px; font-size: 13px; margin: 8px 0 0; }
.icp { margin: 10px 0 0; text-align: center; }
.icp a { color: var(--muted); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #2b3448, #1b2333 60%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 18px 50px rgba(10, 15, 30, .35);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand h1 { font-size: 20px; margin: 0; }
.brand p { margin: 2px 0 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px; flex: none;
}
.brand-logo.small { width: 32px; height: 32px; font-size: 16px; border-radius: 9px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
}
.field input:focus, .input:focus { border-color: var(--brand-2); background: #fff; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { border-color: #cfd6e6; background: #f7f9fd; }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { background: #fdecea; border-color: #f5c2c0; color: #c0392b; }
.btn.block { display: block; width: 100%; padding: 11px; font-size: 15px; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.on { background: var(--brand); border-color: transparent; color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left strong { font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex: none; }

.page { padding: 16px; max-width: 1280px; margin: 0 auto; padding-bottom: 90px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 12px 0 10px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--brand); font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h3 { font-size: 14px; margin: 0 0 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.grow { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat {
  background: linear-gradient(180deg, #fff, #f8fafd);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; white-space: nowrap; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #f5f7fb; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; z-index: 2; }
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
th.sticky-col { z-index: 3; background: #f5f7fb; }
tr:hover .sticky-col { background: #f9fbff; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; background: #eef1f7; color: var(--ink-2); }
.tag.ok { background: #e6f6ee; color: var(--ok); }
.tag.warn { background: #fdf1dd; color: var(--warn); }
.tag.err { background: #fbe9e9; color: var(--err); }

/* ---------- 图表 ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 74px; gap: 8px; align-items: center; font-size: 12px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar-track { background: #eef1f7; border-radius: 999px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #7c93c9, #4f6aa8); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* 玩家活跃度分析（趋势页） */
.act-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.act-head h2, .card-head h2 { margin: 0; }
.card-head { margin-bottom: 10px; }
.act-summary { margin: 8px 0 10px; font-size: 13px; color: var(--ink-2); }
.act-summary strong { color: var(--ink); font-weight: 600; }
.act-scroll { overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.act-scroll canvas { display: block; }
.act-note { margin: 10px 0 0; }

/* 热力图单元格 */
.heat td { text-align: center; font-variant-numeric: tabular-nums; }
.heat td .rate-val { display: block; font-weight: 600; color: #1b2333; }

/* 分组对比进度条 */
.rate { display: flex; align-items: center; gap: 8px; }
.rate-track { flex: 1; height: 6px; background: #eef1f7; border-radius: 999px; overflow: hidden; min-width: 60px; }
.rate-fill { height: 100%; background: var(--ok); }
.rate-fill.low { background: var(--warn); }

/* ---------- 统计图表（文字概览，导出图片时与单机版一致） ---------- */
.overview-text { font-size: 14px; line-height: 1.7; color: var(--ink); }
.overview-text p { margin: 2px 0; }
.ov-title { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.ov-section { margin-bottom: 10px; }
.ov-group-title { font-weight: 700; }
.ov-label { color: var(--muted); }
.ov-label.ml { margin-left: 14px; }
.ov-absent { white-space: pre-wrap; font-size: 13px; }
.text-danger { color: #c0392b; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 20, 35, .45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 860px;
  max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(10,15,30,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(27,35,51,.92); color: #fff; padding: 9px 16px;
  border-radius: 999px; font-size: 13px; z-index: 80; max-width: 86vw;
}
.toast.err { background: rgba(192,69,69,.95); }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 13px; }

/* ---------- 捐款：免捐成员勾选列表 ---------- */
.link { color: var(--brand); text-decoration: none; }
.link:hover { text-decoration: underline; }
.member-picker {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 44vh;
  overflow: auto;
  background: #fbfcfe;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: #f4f7fd; }
.member-row input[type="checkbox"] { width: auto; flex: none; }
.member-rank { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.member-name { font-weight: 600; }

/* ---------- 奖励任务 ---------- */
.rw-page { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; }
.rw-title { margin: 0 0 8px; font-size: 20px; }
.rw-desc { margin: 0 0 10px; color: var(--ink-2); white-space: pre-wrap; line-height: 1.6; }
.rw-stat { margin: 8px 0 0; }
.rw-cover { display: block; max-width: 100%; margin-top: 10px; border-radius: 10px; border: 1px solid var(--line); }
.rw-cover-admin { display: block; max-width: 320px; width: 100%; margin-top: 12px; border-radius: 10px; border: 1px solid var(--line); }
.rw-link-row { display: flex; gap: 8px; align-items: stretch; margin: 10px 0; }
.rw-link-row .input { flex: 1; min-width: 0; }
.rw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.rw-item { position: relative; }
.rw-item img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; background: #eef1f7; cursor: zoom-in; }
.rw-item-time { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
.rw-del { position: absolute; top: 4px; right: 4px; padding: 2px 6px; font-size: 11px; }
.rw-upload { border: 1px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; background: #fbfcfe; }
.rw-ended { font-size: 20px; font-weight: 700; text-align: center; padding: 18px 0 4px; }
.rw-my-title { margin: 0 0 4px; font-size: 16px; }
.rw-foot { text-align: center; margin: 14px 0 0; }
.rw-foot a { color: var(--muted); text-decoration: none; }
.suggest { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fbfcfe; }
.suggest button {
  display: block; width: 100%; padding: 10px 12px; border: 0;
  border-bottom: 1px solid var(--line); background: transparent;
  font-size: 14px; text-align: left; color: var(--ink); cursor: pointer;
}
.suggest button:last-child { border-bottom: none; }
.suggest button:hover { background: #eef3fb; }
.suggest .suggest-fallback { color: var(--brand); font-size: 13px; }
.rw-lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 24, .88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px;
}
.rw-lightbox img { max-width: 96vw; max-height: 82vh; border-radius: 8px; }

/* ---------- 手机 ---------- */
@media (max-width: 767px) {
  .page { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .topbar-right { gap: 4px; }
  .topbar-right .btn.small { padding: 5px 8px; }
  .topbar-right #who { display: none; }
  .card { padding: 12px; border-radius: 10px; }
  .stat .value { font-size: 19px; }
  .tab { font-size: 12px; }
  .hide-mobile { display: none !important; }
  .bar-row { grid-template-columns: 78px 1fr 64px; }
  th, td { padding: 7px 8px; }
  /* 考勤对比：两个快照选择在手机上各占一整行，避免挤在一起 */
  .cmp-pickers { flex-direction: column; align-items: stretch; }
  .cmp-pickers > * { width: 100%; flex: none; }
}

@media (min-width: 768px) {
  .page { padding: 20px; }
}
