:root {
  --green: #16a34a;
  --green-deep: #15803d;
  --green-bg: #f0fdf4;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #eceef1;
  --bg: #f5f6f8;
  --card: #ffffff;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  max-width: 100vw;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 14px 12px 96px; width: 100%; }
a { color: inherit; text-decoration: none; }
img, canvas, table { max-width: 100%; }

/* ---------- 卡片与通用 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  overflow: hidden;
}
.card-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.card-title-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 8px; }
.modal-sub { font-size: 12.5px; color: var(--muted); margin: 4px 0 10px; }
.empty { text-align: center; color: var(--faint); padding: 22px 0; font-size: 13px; }
.err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.link { background: none; border: none; color: var(--green); font-size: 13px; padding: 4px 2px; cursor: pointer; }
.link.danger { color: var(--red); }

/* ---------- 首页 ---------- */
.hero { text-align: center; padding: 26px 16px 20px; }
.hero-title { font-size: 21px; font-weight: 700; letter-spacing: 0.5px; }
.hero-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.badge-row { margin-top: 12px; }
.badge {
  display: inline-block; font-size: 11.5px; padding: 3px 10px; border-radius: 999px;
  background: #f3f4f6; color: var(--muted); font-weight: 500;
}
.badge-green { background: var(--green-bg); color: var(--green-deep); }
.badge-gray { background: #f3f4f6; color: var(--muted); }
.stats-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.stat-cell {
  flex: 1; min-width: 44%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 6px; text-align: center;
}
.stat-num { font-size: 19px; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.menu { margin-top: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 10px; transition: border-color .15s; width: 100%; text-align: left;
}
.menu-item:active { border-color: var(--green); }
.menu-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none; position: relative;
  background: var(--green-bg);
}
.icon-teacher::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid var(--green); border-radius: 50%; box-shadow: inset 0 0 0 2px #fff; }
.icon-teacher::before { content: ""; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: 22px; height: 10px; border: 2px solid var(--green); border-top: none; border-radius: 0 0 12px 12px; }
.icon-student::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid var(--green); border-radius: 4px; }
.icon-student::before { content: ""; position: absolute; inset: 0; margin: auto; width: 6px; height: 6px;
  background: var(--green); border-radius: 1px; }
.icon-admin::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid var(--green); border-radius: 50%; }
.icon-admin::before { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 4px;
  background: var(--green); border-radius: 2px; }
.menu-text { flex: 1; min-width: 0; }
.menu-title { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sub { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-arrow { color: var(--faint); font-size: 20px; flex: none; }
.foot-note { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 18px; }
.warn-card { background: var(--amber-bg); border-color: #fde68a; font-size: 13px; color: #92400e; }

/* ---------- 页头 ---------- */
.page-head {
  display: flex; align-items: center; gap: 8px; margin: 4px 2px 14px; min-width: 0;
}
.page-title { font-size: 17px; font-weight: 700; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { color: var(--muted); font-size: 14px; padding: 4px 6px 4px 0; flex: none; }

/* ---------- 表单 ---------- */
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 2px 0 8px; }
.input {
  width: 100%; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 16px; font-family: inherit; background: #fafafa; color: var(--ink);
  outline: none; transition: border-color .15s; margin-bottom: 10px;
  -webkit-appearance: none; appearance: none;
}
.input:focus { border-color: var(--green); background: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer; background: var(--green); color: #fff;
  transition: opacity .15s, transform .05s; min-height: 44px;
}
.btn:active { transform: scale(.98); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-small { padding: 9px 13px; font-size: 13px; border-radius: 8px; min-height: 36px; }
.btn-ghost { background: #f3f4f6; color: var(--ink); }
.btn-green { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-present { background: var(--green); color: #fff; }
.btn-leave { background: var(--amber); color: #fff; }
.btn-late { background: var(--blue); color: #fff; }
.btn-absent { background: var(--red); color: #fff; }

/* ---------- 课程选择 ---------- */
.course-list { max-height: 55vh; overflow-y: auto; margin-top: 4px; -webkit-overflow-scrolling: touch; }
.course-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid var(--line); padding: 12px 4px; cursor: pointer; font-family: inherit;
}
.course-item:last-child { border-bottom: none; }
.course-item.picked { background: var(--green-bg); border-radius: 8px; padding-left: 8px; }
.course-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-label { font-size: 12px; font-weight: 600; color: var(--faint); padding: 10px 4px 4px; letter-spacing: 0.5px; }
.student-group { background: var(--green-bg); border-radius: 10px; margin: 6px 0 10px; padding: 2px 6px; }
.student-head { font-size: 14px; font-weight: 700; color: var(--green-deep); padding: 9px 6px 6px; }
.student-cls { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.student-group .course-item { padding-left: 10px; }
.student-group .course-item:last-child { border-bottom: none; padding-bottom: 6px; }

/* ---------- 考勤员主页 ---------- */
.slot-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.btn-slot {
  flex: 1; min-width: 44%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--green-bg); border: 1px solid #bbf7d0; color: var(--green-deep);
  border-radius: 12px; padding: 12px 14px; font-size: 14.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; min-height: 44px;
}
.btn-slot:active { background: #dcfce7; }
.slot-go { font-size: 11.5px; font-weight: 400; color: var(--green); }
.session-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--line); padding: 12px 2px;
  cursor: pointer; font-family: inherit; text-align: left; min-width: 0;
}
.session-item:last-child { border-bottom: none; }
.session-date { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-meta { margin-top: 3px; }
.session-counts { font-size: 11.5px; color: var(--muted); text-align: right; max-width: 46%; flex: none; }

/* ---------- 打卡页 ---------- */
.marking-date { font-weight: 700; font-size: 15px; }
.head-actions { display: flex; gap: 6px; flex: none; }
.counts-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.count-chip {
  flex: 1; min-width: 30%; text-align: center; border-radius: 10px; padding: 7px 2px;
  background: #f9fafb; border: 1px solid var(--line);
}
.count-num { font-size: 16px; font-weight: 700; }
.count-label { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.count-chip.c-present { background: var(--green-bg); border-color: #bbf7d0; }
.count-chip.c-present .count-num { color: var(--green-deep); }
.count-chip.c-leave { background: var(--amber-bg); border-color: #fde68a; }
.count-chip.c-leave .count-num { color: var(--amber); }
.count-chip.c-late { background: var(--blue-bg); border-color: #bfdbfe; }
.count-chip.c-late .count-num { color: var(--blue); }
.count-chip.c-absent { background: var(--red-bg); border-color: #fecaca; }
.count-chip.c-absent .count-num { color: var(--red); }
.marking-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.marking-actions .btn { flex: 1; min-width: 44%; }
.list-card { padding: 4px 10px; }
.stu-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0;
}
.stu-row:last-child { border-bottom: none; }
.stu-row.picked { background: var(--green-bg); border-radius: 8px; }
.stu-row.done { opacity: .85; }
.stu-check {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #d1d5db; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff;
}
.stu-row.picked .stu-check { background: var(--green); border-color: var(--green); }
.stu-row.picked .stu-check::after { content: "✓"; }
.stu-check.on { background: var(--green); border-color: var(--green); }
.stu-check.on::after { content: "✓"; }
.stu-main { flex: 1; min-width: 0; }
.stu-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stu-meta { font-size: 11.5px; color: var(--faint); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-badge {
  font-size: 10px; font-weight: 500; color: var(--blue); background: var(--blue-bg);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 1px;
}
.chip { font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.chip-btn { background: none; border: none; padding: 4px; cursor: pointer; font-family: inherit; }
.chip-present { background: var(--green-bg); color: var(--green-deep); }
.chip-leave { background: var(--amber-bg); color: var(--amber); }
.chip-late { background: var(--blue-bg); color: var(--blue); }
.chip-absent { background: var(--red-bg); color: var(--red); }
.chip-none { background: #f3f4f6; color: var(--faint); }
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: 680px; margin: 0 auto;
  box-shadow: 0 -2px 12px rgba(0,0,0,.05);
}
.bar-count { font-size: 13px; font-weight: 600; color: var(--muted); flex: none; }
.bar-btns { display: flex; gap: 6px; flex: 1; justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
.check-head .check-tip {
  font-size: 13px; color: var(--green-deep); background: var(--green-bg);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 10px;
}
.err-card { background: var(--red-bg); border-color: #fecaca; }
.err-title { font-weight: 700; color: var(--red); font-size: 16px; }
.err-msg { font-size: 14px; margin: 6px 0 10px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin-top: 6px; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.td-name { max-width: 140px; white-space: normal; font-weight: 500; }
.td-pass { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; }
.td-ops { display: flex; gap: 8px; }
.admin-btns { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }

/* ---------- Tab ---------- */
.tab-row { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  border: none; background: #eef0f3; color: var(--muted); border-radius: 999px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 500; font-family: inherit; cursor: pointer; white-space: nowrap; flex: none;
}
.tab.on { background: var(--green); color: #fff; }

/* ---------- 预览卡 ---------- */
.preview { background: var(--green-bg); border-color: #bbf7d0; }
.preview-title { font-weight: 700; color: var(--green-deep); margin-bottom: 4px; }
.preview-line { font-size: 13.5px; margin-bottom: 4px; }
.preview-warn { font-size: 12px; color: #92400e; background: var(--amber-bg); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.danger-card { border-color: #fecaca; }
.danger-card .card-title { color: var(--red); }

/* ---------- Toast / Modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  background: rgba(17, 24, 39, .92); color: #fff; font-size: 13.5px;
  padding: 9px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; max-width: 86%; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#modal { position: fixed; inset: 0; z-index: 50; display: none; }
#modal.show { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(17, 24, 39, .45); }
.modal-box {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 40px)); max-height: 82vh; overflow-y: auto;
  background: #fff; border-radius: 16px; padding: 20px; text-align: center;
  -webkit-overflow-scrolling: touch;
}
.modal-title { font-size: 16px; font-weight: 700; }
.qr-box { display: flex; justify-content: center; margin: 12px 0; min-height: 40px; }
.qr-box img, .qr-box canvas { display: block; max-width: 100%; height: auto; }
.token-url {
  font-size: 11px; color: var(--muted); word-break: break-all; background: #f9fafb;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; text-align: left;
}
.modal-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- 口令记住 / 全校口令 ---------- */
.remember-tip { background: var(--green-bg); border-color: #bbf7d0; font-size: 13px; color: var(--green-deep); }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 2px 0 10px; cursor: pointer; min-height: 32px; }
.remember-row input { width: 18px; height: 18px; accent-color: var(--green); flex: none; }
.scope-tip { font-size: 12px; color: var(--green-deep); background: var(--green-bg); border-radius: 8px; padding: 6px 10px; margin: 8px 0 2px; }
.cur-pass { font-size: 13.5px; margin-bottom: 10px; color: var(--muted); }
.cur-pass b { color: var(--ink); }

/* ---------- 考勤报表 ---------- */
.rep-range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rep-range .input { flex: 1; margin-bottom: 0; min-width: 0; }
.rep-sep { color: var(--muted); font-size: 13px; flex: none; }
.rep-total-row td { font-weight: 700; background: #f9fafb; }

/* ---------- 桌面 ---------- */
@media (min-width: 481px) {
  .wrap { padding-top: 20px; }
  .action-bar { border-radius: 14px 14px 0 0; }
}

/* ---------- 手机精调（≤480px） ---------- */
@media (max-width: 480px) {
  .wrap { padding: 12px 10px 96px; }
  .hero { padding: 20px 12px 14px; }
  .hero-title { font-size: 19px; }
  .card { padding: 12px 13px; }
  .stat-cell { min-width: 44%; padding: 10px 4px; }
  .stat-num { font-size: 17px; }
  .count-num { font-size: 15px; }
  .btn-slot { min-width: 100%; }
  .tbl { font-size: 11.5px; }
  .tbl th, .tbl td { padding: 6px; }
  .td-name { max-width: 108px; }
  .tab { padding: 8px 13px; font-size: 13px; }
  .menu-icon { width: 38px; height: 38px; }
  .modal-box { padding: 16px; width: min(340px, calc(100vw - 28px)); }
  .qr-box { margin: 10px 0; }
  .action-bar { padding: 9px 10px calc(9px + env(safe-area-inset-bottom)); }
  .bar-btns .btn { padding: 10px 12px; font-size: 14px; }
  .page-head { margin-bottom: 12px; }
}
