/* 小猪球友会 · 管理后台
 * 视觉沿用小程序「浅色冠军俱乐部」那套：浅灰底 + 白卡 + 金点缀 + 球台绿。
 * 统一走 CSS 变量，改一处全局生效；不再散落硬编码色值。
 */

:root {
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --soft: #F7F8FA;
  --ink: #1C1F26;
  --body: #4E5663;
  --faint: #5F6875;   /* 在 #FFF 上 5.6:1、在 #F3F4F6 上 5.1:1，都过 WCAG AA */
  --gold: #F2C14E;
  --gold-deep: #8A5C12;
  --gold-soft: #FDF4DC;
  --coral: #C0392B;
  --coral-soft: #FCEDEA;
  --green: #0E5A43;
  --green-soft: #E8F3EF;
  --blue: #2563EB;
  --blue-soft: #EAF0FF;
  --line: rgba(0, 0, 0, .065);
  --line-strong: rgba(0, 0, 0, .12);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.2px; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
button { font: inherit; }
[hidden] { display: none !important; }

.muted { color: var(--faint); }
.tiny { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------------- 品牌 ---------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 12px;
}

.brand b { display: block; font-size: 15px; letter-spacing: -.2px; }
.brand small { color: var(--faint); font-size: 11px; letter-spacing: .04em; }

.ball {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--gold);
  color: #2A1E05;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
  flex: none;
}

.brand-lg { padding: 0 0 18px; }
.brand-lg .ball { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.brand-lg b { font-size: 17px; }

/* ---------------- 登录 ---------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 12% -8%, #FFFFFF 0%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(700px 380px at 100% 6%, rgba(14, 90, 67, .07) 0%, rgba(14, 90, 67, 0) 70%),
    radial-gradient(600px 320px at 0 100%, rgba(242, 193, 78, .16) 0%, rgba(242, 193, 78, 0) 70%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 26px 22px;
  box-shadow: var(--shadow);
}

.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .muted { font-size: 13px; margin-bottom: 20px; }

label { display: block; margin-bottom: 14px; }
label > span {
  display: block;
  font-size: 12px;
  color: var(--faint);
  margin-bottom: 6px;
  letter-spacing: .02em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .28);
}

textarea { min-height: 168px; resize: vertical; line-height: 1.7; }

.form-error {
  color: var(--coral);
  font-size: 13px;
  min-height: 18px;
  margin-top: 8px;
}

.api-config { margin-top: 14px; border-top: 1px dashed var(--line-strong); padding-top: 12px; }
.api-config summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--faint);
  /* 19px 的行高在手机上太难点，撑到 32px 才够指头 */
  display: flex;
  align-items: center;
  min-height: 32px;
  margin: -6px 0;
}

/* ---------------- 布局 ---------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: none;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav { padding: 6px 10px; overflow-y: auto; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--body);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: var(--soft); color: var(--ink); }
.nav-item .ico { width: 18px; text-align: center; flex: none; opacity: .85; }

.nav-item.on {
  background: var(--gold-soft);
  color: #5C3E08;
  font-weight: 650;
  box-shadow: inset 2px 0 0 var(--gold);
}

.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  background: var(--green-soft);
  color: var(--green);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}

.sidebar-foot { padding: 12px 14px 16px; border-top: 1px solid var(--line); }

.who { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.who b { display: block; font-size: 13px; }
.who small { color: var(--faint); font-size: 11px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 14px;
}

.topbar h1 { font-size: 20px; }
.topbar p { font-size: 12.5px; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.view { padding: 4px 26px 40px; flex: 1; }

/* ---------------- 基础组件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}

.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #2A1E05; font-weight: 650; }
.btn.primary:hover { background: #E9B63F; }
.btn.danger { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.danger:hover { background: #A93226; }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--body); }
.btn.ghost:hover { background: var(--soft); color: var(--ink); }
.btn.tiny { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { font-size: 14.5px; }
.card-head .muted { font-size: 12px; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat .k { color: var(--faint); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.6px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat.accent { background: linear-gradient(180deg, #FFFDF7 0%, #fff 60%); border-color: rgba(242, 193, 78, .5); }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--faint); font-weight: 600; letter-spacing: .04em; background: var(--soft); white-space: nowrap; }
tbody tr:hover { background: #FCFCFD; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--soft);
  color: var(--body);
  white-space: nowrap;
}

.tag.gold { background: var(--gold-soft); color: var(--gold-deep); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.coral { background: var(--coral-soft); color: var(--coral); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.line { background: transparent; border: 1px solid var(--line-strong); color: var(--faint); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar input, .toolbar select { width: auto; min-width: 132px; padding: 8px 10px; font-size: 13px; min-height: 36px; }
.toolbar .grow { flex: 1; }

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}

.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: .55; }

/* 档位条 */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 62px 1fr 40px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-track { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #F2C14E, #E9B63F); }
.bar-row .n { text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; }

/* 七日柱状 */
.spark { display: flex; align-items: flex-end; gap: 10px; height: 148px; padding: 8px 2px 0; }
.spark .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.spark .bar {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, rgba(14, 90, 67, .88), rgba(14, 90, 67, .55));
  min-height: 3px;
  position: relative;
  transition: height .3s ease;
}
.spark .bar.zero { background: var(--soft); }
.spark .bar em {
  position: absolute;
  top: -18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  font-style: normal;
  color: var(--faint);
}
.spark .lbl { font-size: 11px; color: var(--faint); white-space: nowrap; }

/* 球桌卡 */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.table-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.table-card .no { font-size: 24px; font-weight: 750; letter-spacing: -.6px; }
.table-card .qr { margin-top: 8px; font-size: 11px; color: var(--faint); word-break: break-all; }
.table-card .acts { display: flex; gap: 6px; margin-top: 10px; }

/* 花名册预览 */
.preview { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.preview table { font-size: 12.5px; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 21, 28, .42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(460px, 100%);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
  overflow: hidden;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-card header h2 { font-size: 15px; }
.modal-body { padding: 16px; max-height: 62vh; overflow-y: auto; }
.modal-card footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--soft);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1C1F26;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .28);
  z-index: 80;
  max-width: min(520px, 90vw);
}

.toast.err { background: var(--coral); }
.toast.ok { background: var(--green); }

/* 提示条 */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--gold-soft);
  border: 1px solid rgba(242, 193, 78, .45);
  color: #6B4A0C;
  font-size: 12.5px;
  line-height: 1.65;
}

.notice.info { background: var(--blue-soft); border-color: rgba(37, 99, 235, .25); color: #1E3A8A; }
.notice.warn { background: var(--coral-soft); border-color: rgba(192, 57, 43, .25); color: #8C2A1F; }

/* ---------------- 响应式：手机上后台也要能用 ---------------- */

@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { display: flex; gap: 4px; overflow-x: auto; padding: 4px 10px 10px; }
  .nav-item { width: auto; white-space: nowrap; min-height: 40px; }
  /* 手机上指头比鼠标粗：小按钮与输入框统一撑到 40px，避免点不中 */
  .btn.tiny { min-height: 40px; padding: 8px 12px; font-size: 12.5px; }
  .toolbar input, .toolbar select { min-height: 40px; }
  .nav-item .count { display: none; }
  .sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
  .who { margin-bottom: 0; flex: 1; }
  .sidebar-foot .btn { width: auto; }
  .topbar { padding: 16px 16px 10px; flex-direction: column; align-items: flex-start; }
  .view { padding: 4px 16px 32px; }
  .grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .v { font-size: 22px; }
  .login-card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
