:root {
  --bg: #eceef3;
  --panel: #fbfbfd;
  --card: #ffffff;
  --line: #e2e5ec;
  --line-strong: #d5dae4;
  --text: #20293a;
  --text-2: #5d6474;
  --muted: #98a0b0;
  --brand: #2749c9;
  --brand-soft: #e8edfd;
  --green: #177a48;
  --green-soft: #e7f7ef;
  --red: #c22b2b;
  --red-soft: #fdeaea;
  --grey-soft: #eff0f4;
  --black-soft: #3a4353;
  --shadow: 0 8px 24px rgba(30, 40, 60, .09);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

#app { min-height: 100vh; }

/* ---------- 通用 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: 54px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; font-size: 15px; }
.topbar .brand small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.topbar .right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--text-2); }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.badge.secretary { background: #f3eafd; color: #6b3fc9; }
.badge.commissary { background: #e6f6f5; color: #10716c; }

.shell { display: flex; align-items: flex-start; }

.side {
  width: 200px; flex: none; position: sticky; top: 54px;
  height: calc(100vh - 54px); padding: 14px 11px;
  background: #f4f5f9; border-right: 1px solid var(--line);
}
.side .cap { font-size: 11px; color: #a6adbb; padding: 0 12px 10px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 9px; font-size: 13px;
  color: var(--text-2); margin-bottom: 4px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: #eceff7; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }

.main { flex: 1; min-width: 0; padding: 16px 20px 40px; }

.mobile-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav .mi { flex: 1; text-align: center; padding: 8px 0 9px; font-size: 10.5px; color: var(--text-2); }
.mobile-nav .mi .ico { display: block; font-size: 16px; line-height: 18px; color: #b6bccb; }
.mobile-nav .mi.active { color: var(--brand); font-weight: 700; }
.mobile-nav .mi.active .ico { color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 700; font-size: 13.5px; }
.card-head .sub { font-weight: 400; color: var(--muted); font-size: 11.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 12.5px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text-2);
}
.btn:hover { border-color: #b9c2d4; color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn.primary:hover { background: #1f3cae; }
.btn.danger { color: var(--red); border-color: #f0c9c9; }
.btn.ghost { border-color: transparent; background: #f4f6fa; }
.btn:disabled { background: #f2f3f6; color: #b4bac7; border-color: #e6e9f0; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 11.5px; }
.btn.lg { padding: 11px 26px; font-size: 13.5px; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.grey { background: var(--grey-soft); color: #828a99; }
.tag.black { background: var(--black-soft); color: #fff; }
.tag.blue { background: var(--brand-soft); color: var(--brand); }

.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-2); }
.input {
  width: 100%; padding: 10px 12px; border-radius: 9px; font-size: 13px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
}
.input:focus { outline: none; border-color: #9db0ea; box-shadow: 0 0 0 3px #eaf0ff; }
.empty { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 13px; }

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

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f6f7fb; }
.login-box { width: min(760px, 100%); }
.login-title { text-align: center; font-size: 24px; font-weight: 700; margin: 12px 0 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.roles { display: flex; gap: 12px; }
.role-card {
  flex: 1; padding: 20px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; text-align: center; transition: .15s;
}
.role-card:hover { border-color: #b7c4ee; transform: translateY(-2px); }
.role-card.active { border: 2px solid var(--brand); box-shadow: 0 6px 18px rgba(39, 73, 201, .12); }
.role-card .avi { width: 44px; height: 44px; border-radius: 50%; background: #eef1f8; margin: 0 auto 10px; }
.role-card.active .avi { background: var(--brand-soft); }
.role-card .nm { font-weight: 700; font-size: 15px; }
.role-card .desc { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.pwd-row { display: flex; gap: 10px; align-items: center; margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 12px 16px; }
.pwd-row span { font-size: 12.5px; color: var(--text-2); }
.pwd-row .input { flex: 1; letter-spacing: 4px; }
.login-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 10px; text-align: center; }
.login-foot { text-align: center; color: #a6adbb; font-size: 11.5px; margin-top: 16px; line-height: 1.9; }

/* ---------- 首页 ---------- */

.home-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; }
.rank-1 { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 10px; background: #f3f6ff; border: 1px solid #e2e9fb; }
.rank-1 .ava { width: 50px; height: 50px; border-radius: 50%; background: #dbe5fd; color: var(--brand); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rank-1 .nm { font-size: 19px; font-weight: 700; }
.rank-1 .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.rank-1 .score { text-align: right; font-size: 26px; font-weight: 700; color: var(--brand); }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 8px 2px; }
.rank-row .no { width: 24px; height: 24px; border-radius: 50%; background: #eff1f6; color: var(--text-2); font-size: 11px; display: flex; align-items: center; justify-content: center; }
.rank-row .nm { width: 72px; font-weight: 600; font-size: 13px; }
.rank-row .bar { flex: 1; height: 6px; background: #eef0f6; border-radius: 4px; overflow: hidden; }
.rank-row .bar i { display: block; height: 6px; background: #8fa6f2; border-radius: 4px; }
.rank-row .sc { width: 36px; text-align: right; font-weight: 700; color: var(--brand); }

.flow { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.flow-row { display: flex; align-items: center; gap: 10px; }
.flow-row .t { width: 46px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-row .ti { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-row .nm { color: var(--text-2); }
.flow-total { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--text-2); }
.locked { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 200px; background: #f7f8fb; border: 1px dashed #d8dce6; border-radius: 10px; color: var(--muted); }
.locked h4 { color: var(--muted); font-size: 15px; margin-bottom: 6px; }

.quick { display: flex; gap: 10px; }
.quick a { flex: 1; text-align: center; padding: 16px 0; border-radius: 10px; background: #f7f8fb; border: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.quick a:hover { border-color: #b9c2d4; }

/* ---------- 成员 ---------- */

.search-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.member-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.member-card { cursor: pointer; transition: .15s; }
.member-card:hover { border-color: #b9c6ee; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(40, 60, 120, .08); }
.member-card .top { display: flex; justify-content: space-between; align-items: baseline; }
.member-card .name { font-weight: 700; font-size: 15px; }
.member-card .score { font-weight: 700; color: var(--brand); }
.member-card .line { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.detail-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }
.info-list { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
.info-item { padding: 9px 0; border-bottom: 1px dashed #e9ecf2; }
.info-item .k { font-size: 11px; color: var(--muted); }
.info-item .v { font-size: 13px; margin-top: 3px; }
.link { color: #4a72e0; cursor: pointer; font-size: 11px; margin-left: 6px; }

/* ---------- 表格 ---------- */

.table-tools { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-2); margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: #fff; max-height: calc(100vh - 190px); }
.grid-table { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 1180px; }
.grid-table th, .grid-table td { padding: 9px 12px; border-bottom: 1px solid #f0f2f6; white-space: nowrap; text-align: left; }
.grid-table thead th { position: sticky; top: 0; background: #f4f6fa; z-index: 5; font-weight: 700; color: var(--text-2); border-bottom: 1px solid var(--line); }
.grid-table th.sortable { cursor: pointer; user-select: none; }
.grid-table th.sortable:hover { color: var(--brand); }
.grid-table td:first-child, .grid-table th:first-child { position: sticky; left: 0; background: #f8faff; font-weight: 700; z-index: 6; border-right: 1px solid var(--line); }
.grid-table thead th:first-child { z-index: 7; background: #eef3fd; }
.grid-table tbody tr:nth-child(even) td { background: #fafbfd; }
.grid-table tbody tr:nth-child(even) td:first-child { background: #f5f8ff; }
.grid-table td.score-cell { font-weight: 700; color: var(--brand); }

/* ---------- 加分 ---------- */

.step { margin-bottom: 12px; }
.step .no { display: inline-block; color: var(--brand); font-weight: 700; margin-right: 6px; }
.cat-row { display: flex; gap: 10px; }
.cat-btn { padding: 10px 26px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; font-size: 13px; color: var(--text-2); }
.cat-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.chips { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 10px; max-height: 300px; overflow: auto; padding-right: 4px; }
.chip { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--text-2); text-align: left; background: #fff; }
.chip.on { border-color: #c7d3f7; background: #eef3ff; color: var(--brand); font-weight: 700; }
.score-row { display: flex; gap: 7px; flex-wrap: wrap; }
.score-btn { width: 44px; height: 38px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; font-size: 13px; }
.score-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.add-foot { display: flex; justify-content: space-between; align-items: center; }

/* ---------- 登记 ---------- */

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { padding: 9px 20px; border-radius: 9px; border: 1px solid var(--line-strong); background: #fff; font-size: 13px; color: var(--text-2); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.task-list, .attend-list { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.row-card .ti { font-size: 14px; font-weight: 700; }
.row-card .sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.row-card .right { display: flex; align-items: center; gap: 12px; }
.progress { width: 120px; height: 7px; background: #f0f1f6; border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 7px; background: var(--red); }
.progress.ok i { background: var(--green); }
.bar-red { border-left: 4px solid var(--red); }
.bar-green { border-left: 4px solid var(--green); }

.roster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.roster-item { padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); font-size: 12px; color: var(--muted); background: #fff; text-align: left; }
.roster-item.on { border-color: #bfe3cd; background: var(--green-soft); color: var(--green); font-weight: 700; }

.attend-row { display: flex; align-items: center; gap: 5px; padding: 7px 6px; border-radius: 8px; }
.attend-row:nth-child(even) { background: #f8f9fc; }
.attend-row .nm { width: 84px; font-weight: 600; font-size: 12.5px; flex: none; }
.state-btn { flex: 1; padding: 6px 0; border-radius: 6px; border: 1px solid transparent; font-size: 11.5px; background: var(--grey-soft); color: #828a99; }
.state-btn.on-green { background: var(--green-soft); color: var(--green); font-weight: 700; }
.state-btn.on-black { background: var(--black-soft); color: #fff; font-weight: 700; }
.state-btn.on-red { background: var(--red-soft); color: var(--red); font-weight: 700; }
.state-btn.on-grey { background: #e4e6ec; color: #575f6e; font-weight: 700; }

/* ---------- 分数 ---------- */

.score-grid { display: grid; grid-template-columns: 360px 1fr; gap: 12px; }
.score-list { max-height: calc(100vh - 210px); overflow: auto; }
.score-row-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid #f0f2f6; font-size: 12px; cursor: pointer; }
.score-row-item:hover { background: #f7f9ff; }
.score-row-item .rno { width: 26px; font-weight: 700; color: var(--brand); }
.score-row-item .rnm { width: 76px; font-weight: 700; }
.score-row-item .radd { flex: 1; color: var(--muted); }
.score-row-item .rsc { font-weight: 700; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.rec-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rec-table th { text-align: left; padding: 9px 8px; background: #f4f6fa; color: var(--text-2); font-weight: 700; }
.rec-table td { padding: 9px 8px; border-bottom: 1px solid #eef0f5; }
.rec-table td.num { text-align: right; font-weight: 700; }
.rec-table td.num.pos { color: var(--green); }
.rec-table td.num.neg { color: var(--red); }
.rec-total { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--text-2); }

/* ---------- 弹层 ---------- */

.overlay { position: fixed; inset: 0; background: rgba(20, 26, 40, .38); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 18px; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); max-height: 88vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 13px 18px; border-top: 1px solid var(--line); }
.modal .close { border: none; background: none; font-size: 18px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: rgba(25, 32, 46, .92); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 80; max-width: 80vw; }
.toast.error { background: #b52c2c; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

.day-filter { display: flex; gap: 6px; }
.date-input { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line-strong); font-size: 11.5px; }

/* ---------- 手机 ---------- */

@media (max-width: 860px) {
  .side { display: none; }
  .mobile-nav { display: flex; }
  .main { padding: 12px 12px 78px; }
  .topbar { padding: 0 12px; height: 50px; }
  .topbar .brand small { display: none; }
  .topbar .right { gap: 8px; }
  .home-grid, .detail-grid, .score-grid { grid-template-columns: 1fr; }
  .member-grid { grid-template-columns: 1fr 1fr; }
  .chips { grid-template-columns: 1fr 1fr; }
  .roster { grid-template-columns: 1fr 1fr; }
  .row-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .row-card .right { width: 100%; justify-content: space-between; }
  .progress { flex: 1; }
  .attend-row .nm { width: 66px; font-size: 12px; }
  .state-btn { font-size: 11px; padding: 7px 0; }
  .table-wrap { max-height: calc(100vh - 240px); }
  .grid-table { min-width: 980px; }
  .login-wrap { padding: 16px; align-items: flex-start; padding-top: 40px; }
  .roles { flex-direction: column; }
  .pwd-row { flex-wrap: wrap; }
  .pwd-row .input { min-width: 120px; }
  .add-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters { overflow-x: auto; }
  .info-list { grid-template-columns: 1fr; }
  .score-list { max-height: none; }
}
