:root {
  --bg: #f4f5f7;
  --card: #fff;
  --ink: #14161a;
  --muted: #6b7280;
  --line: #e4e6ea;
  --red: #d62b2b;
  --blue: #1d5bd0;
  --ok: #12805c;
  --warn: #b26a00;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */
header {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 16px 8px;
}
.hrow { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: .5px; }
.brand span { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 1px; }
.tname { font-size: 13px; color: var(--muted); }
.chips { margin-left: auto; display: flex; gap: 6px; }
.chip {
  font-size: 12px; color: var(--muted); background: var(--bg);
  border-radius: 999px; padding: 2px 9px;
}
.chip b { color: var(--ink); }

/* ---------- 授权提示条 ---------- */
.licbar {
  margin-top: 8px; padding: 5px 10px; border-radius: 8px;
  display: flex; gap: 7px; align-items: center; flex-wrap: wrap;
  font-size: 12.5px; line-height: 1.4;
  color: #7a4b00; background: #fff6e5; border: 1px solid #f0d9a8;
}
.licbar.ok { color: #135c44; background: #eef8f3; border-color: #cbe8db; }
.licbar.bad { color: #96201f; background: #fdeeee; border-color: #f3caca; }
.licbar b { font-weight: 700; }
.licbar .sep { opacity: .45; }

/* ---------- 当前用户 ---------- */
.who { display: flex; gap: 6px; align-items: center; }
.who .chip b { font-weight: 700; }

/* ---------- 用户列表 ---------- */
.urow {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.urow:last-child { border-bottom: 0; }
.urow .uname { font-weight: 600; min-width: 72px; }
.urow.off { opacity: .5; }

nav.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  padding: 8px 16px; background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 53px; z-index: 19;
}
nav.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
nav.tabs button.on { background: var(--ink); color: #fff; }

main { padding: 14px; max-width: 1100px; margin: 0 auto; }
section[hidden] { display: none !important; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
h3 { font-size: 14px; margin: 0 0 8px; }
h3 .muted { font-weight: 400; }

.btn {
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  padding: 7px 14px; border-radius: 9px; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn.plain { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: #fff; color: var(--red); border-color: #f0c4c4; }
.btn.sm { padding: 3px 9px; font-size: 13px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input[type=text], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px;
  background: #fff; outline: none; min-width: 0;
}
input:focus, textarea:focus, select:focus { border-color: #9aa3af; }
textarea { width: 100%; min-height: 130px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ---------- 首页 ---------- */
.hero .hero-name { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
.hero .muted { margin-top: 2px; }

.steps { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; }
.step { flex: 1 1 0; min-width: 88px; }
.step .bar { height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 7px; }
.step.done .bar { background: var(--ink); }
.step.now .bar { background: var(--warn); }
.step .lb { font-size: 13px; font-weight: 600; }
.step.done .lb { color: var(--ink); }
.step.now .lb { color: var(--warn); }
.step.todo .lb { color: var(--muted); font-weight: 500; }
.step .ht { font-size: 12px; color: var(--muted); margin-top: 1px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 23px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.alert b { color: var(--red); }
.stat.alert span { color: #9c2a2a; }

.home-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; }

.todo { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.todo:last-child { border-bottom: 0; }
.todo .t { flex: 1; min-width: 0; }
.todo .n { font-weight: 700; }

.matchbox { border-radius: 12px; background: #15171c; color: #fff; padding: 12px; }
.matchbox .cat { font-size: 12px; color: #9aa1ad; }
.matchbox .vs { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 10px; font-size: 15px; font-weight: 700; }
.matchbox .vs .mid { color: #9aa1ad; font-size: 12px; font-weight: 400; }
.matchbox.blank { background: var(--bg); color: var(--muted); font-size: 13px; text-align: center; padding: 22px 12px; border: 1px dashed var(--line); }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .home-grid { grid-template-columns: 1fr; }
}

/* ---------- 报名 ---------- */
.ent {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.ent:last-child { border-bottom: 0; }
.ent .nm { font-weight: 600; }
.ent .meta { font-size: 12px; color: var(--muted); }
.ent select { max-width: 190px; }
.ent .ops { display: flex; gap: 6px; align-items: center; }

.errbox { background: #fff6f6; border: 1px solid #f3cfcf; color: #8f2020; border-radius: 10px; padding: 10px; font-size: 13px; }
.errbox div + div { margin-top: 4px; }

/* ---------- 分组 ---------- */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; align-items: start; }
.cat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 11px; }
.cat .hd { display: flex; align-items: center; gap: 8px; }
.cat .hd b { font-size: 14px; }
.cat .n { margin-left: auto; font-size: 12px; color: var(--muted); }
.cat.small { border-style: dashed; }
.cat ul { margin: 8px 0 10px; padding-left: 16px; color: #333; font-size: 13px; }
.cat ul li { margin-bottom: 2px; }

/* ---------- 称重 ---------- */
.wgroup { margin-bottom: 12px; }
.wgroup h4 { font-size: 13px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.wgroup h4 span { color: var(--muted); font-weight: 400; font-size: 12px; }
.wrow {
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  padding: 8px 6px; border-bottom: 1px dashed var(--line); border-radius: 8px;
}
.wrow.over { background: #fff6f5; }
.wrow.absent { opacity: .55; }
.wrow .wname { flex: 1 1 150px; min-width: 0; }
.wrow .wname b { font-weight: 600; }
.wrow .wbook { font-size: 12px; color: var(--muted); }
.wrow input { width: 92px; }
.wrow .wdelta { font-size: 12px; width: 52px; text-align: right; color: var(--muted); }
.wrow .wdelta.bad { color: var(--red); font-weight: 600; }
.wrow .wops { display: flex; gap: 6px; margin-left: auto; }

/* ---------- 赛程 ---------- */
table.list { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; }
table.list th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12.5px; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.top3 td { background: #fbf6e9; }
.rk { display: inline-block; margin: 2px 12px 2px 0; font-size: 13px; }
.rk b { color: var(--warn); margin-right: 3px; }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.tag.ready { background: #eef4ff; color: #1d4ed8; }
.tag.running { background: #fff1f1; color: var(--red); }
.tag.done { background: #eef9f4; color: var(--ok); }
.tag.bye { background: #f5f0e6; color: var(--warn); }

/* ---------- 现场 ---------- */
.score {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  background: #15171c; color: #fff; border-radius: 14px; padding: 16px; margin-bottom: 10px;
}
.score .side { text-align: center; }
.score .side .nm { font-size: 17px; font-weight: 700; }
.score .side .club { font-size: 12px; color: #9aa1ad; min-height: 16px; }
.score .side .pt { font-size: 46px; font-weight: 800; line-height: 1.05; }
.score .red .pt { color: #ff5a5a; }
.score .blue .pt { color: #5b8dff; }
.score .mid { text-align: center; color: #9aa1ad; font-size: 12px; line-height: 1.7; }
.score .mid b { display: block; color: #fff; font-size: 15px; }

.vgrid { display: grid; gap: 6px; }
.vrow { display: grid; grid-template-columns: 56px repeat(var(--j), minmax(0, 230px)); gap: 6px; align-items: center; justify-content: start; }
.vcell { display: flex; gap: 4px; }
.vcell button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 0; cursor: pointer; font-size: 13px; color: var(--muted);
}
.vcell button.r.on { background: var(--red); border-color: var(--red); color: #fff; }
.vcell button.b.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.vcell button.d.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.vhead { font-size: 12px; color: var(--muted); text-align: center; }
.vlabel { font-size: 13px; color: var(--muted); }

.timer { font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 700; letter-spacing: 1px; }
.timer.over { color: var(--red); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog .dlg { padding: 16px; }
dialog h3 { margin-bottom: 10px; }
.wtgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wtgrid button { padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-align: left; }
.wtgrid button b { display: block; font-size: 14px; }
.wtgrid button span { font-size: 12px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.empty b { display: block; color: var(--ink); margin-bottom: 6px; }

@media (max-width: 560px) {
  .score .side .pt { font-size: 38px; }
  main { padding: 10px; }
  .vrow { grid-template-columns: 44px repeat(var(--j), 1fr); }
}
