:root {
  --c-bg: #f5f6f8;
  --c-card: #ffffff;
  --c-border: #e4e6eb;
  --c-text: #1f2329;
  --c-sub: #8a9099;
  --c-primary: #185fa5;
  --c-blue: #e6f1fb;
  --c-blue-text: #0c447c;
  --c-green: #e1f5ee;
  --c-green-text: #085041;
  --c-amber: #faefd8;
  --c-amber-text: #854f0b;
  --c-red: #fce8e8;
  --c-red-text: #a32d2d;
  --c-purple: #eeedfe;
  --c-purple-text: #534ab7;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.5;
}
.app { max-width: 760px; margin: 0 auto; padding: 16px; }
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
header.top h1 { font-size: 17px; margin: 0; font-weight: 600; }
.top-meta { font-size: 13px; color: var(--c-sub); }
.section { margin-top: 18px; }
.section h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.badge.gray { background: #eef0f3; color: var(--c-sub); }
.badge.blue { background: var(--c-blue); color: var(--c-blue-text); }
.badge.green { background: var(--c-green); color: var(--c-green-text); }
.badge.amber { background: var(--c-amber); color: var(--c-amber-text); }
.badge.red { background: var(--c-red); color: var(--c-red-text); }
.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--c-sub); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  background: #fafbfc;
  cursor: pointer;
  user-select: none;
}
.chip.normal { background: #fafbfc; border-color: var(--c-border); }
.chip.leave { background: var(--c-blue); border-color: #b5d4f4; color: var(--c-blue-text); }
.chip.late { background: var(--c-amber); border-color: #fac775; color: var(--c-amber-text); }
.chip.absent { background: var(--c-red); border-color: #f7c1c1; color: var(--c-red-text); }
.stu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 12px; }
.stu {
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  font-size: 14px;
  background: #fafbfc;
  cursor: pointer;
  user-select: none;
}
.stu .sname { font-weight: 500; }
.stu .sstate { font-size: 12px; margin-top: 4px; color: var(--c-sub); }
.stu.leave { background: var(--c-blue); border-color: #b5d4f4; }
.stu.leave .sstate { color: var(--c-blue-text); }
.stu.late { background: var(--c-amber); border-color: #fac775; }
.stu.late .sstate { color: var(--c-amber-text); }
.stu.absent { background: var(--c-red); border-color: #f7c1c1; }
.stu.absent .sstate { color: var(--c-red-text); }
.stu.early { background: var(--c-purple); border-color: #cfcbf2; }
.stu.early .sstate { color: var(--c-purple-text); }
.chip.early { background: var(--c-purple); border-color: #cfcbf2; color: var(--c-purple-text); }
.leave-form { margin-top: 8px; padding: 10px; background: #f7f9fc; border-radius: 8px; display: none; }
.leave-form.show { display: block; }
.leave-form input { width: 100%; padding: 8px; border: 1px solid var(--c-border); border-radius: 6px; margin-top: 6px; font-size: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--c-sub); margin-bottom: 6px; }
select, input[type="text"], input[type="password"] {
  width: 100%; padding: 10px; border: 1px solid var(--c-border); border-radius: 8px; font-size: 15px; background: #fff;
}
.btn {
  width: 100%; padding: 13px; border: none; border-radius: 10px;
  background: var(--c-primary); color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  margin-top: 8px;
}
.btn:active { opacity: .9; }
.btn.secondary { background: #eef0f3; color: var(--c-text); }
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 14px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: .95; }
.warn-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.warn-item:last-child { border-bottom: none; }
.warn-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.warn-dot.high { background: #a32d2d; }
.warn-dot.mid { background: #ba7517; }
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: flex-end; z-index: 40; }
.modal-mask.show { display: flex; }
.modal { background: #fff; width: 100%; border-radius: 16px 16px 0 0; padding: 18px 16px 24px; max-height: 80vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hist th, table.hist td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--c-border); }
table.hist th { color: var(--c-sub); font-weight: 500; }
.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; background: #f7f9fc; border-radius: 8px; padding: 8px; text-align: center; }
.stat .n { font-size: 18px; font-weight: 600; }
.stat .l { font-size: 12px; color: var(--c-sub); }
.empty { text-align: center; color: var(--c-sub); padding: 24px; font-size: 14px; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cfg-row label { font-size: 13px; color: var(--c-sub); }
.cfg-input { width: 84px; padding: 8px; border: 1px solid var(--c-border); border-radius: 8px; font-size: 15px; text-align: center; }
.hist-wrap { overflow-x: auto; }
