/* ================= 基础 ================= */
:root {
  --brand: #2f9e6a;
  --brand-deep: #1f7a4d;
  --brand-2: #57bd8b;
  --brand-soft: #e9f7ef;
  --ink: #17352a;
  --ink-2: #3c5a4c;
  --muted: #7b9a8a;
  --line: #dcefe3;
  --line-2: #eef8f2;
  --card: #ffffff;
  --bg: #f3faf5;
  --ok: #219a63;
  --ok-soft: #e6f7ee;
  --warn: #b9752a;
  --warn-soft: #fff5e6;
  --danger: #d15b5b;
  --danger-soft: #fdeeee;
  --gold: #c99a3f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(23, 53, 42, .04), 0 8px 24px -12px rgba(23, 53, 42, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 420px at 50% -180px, #dff3e7 0%, rgba(223, 243, 231, 0) 70%),
    linear-gradient(180deg, #f3faf5 0%, #fbfdfb 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--brand-deep); text-decoration: none; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* ================= 头部 ================= */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, #e4f6eb 0%, #f8fdfa 46%, #e9f7f0 100%);
  color: var(--ink);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 22px;
  border-radius: 0 0 26px 26px;
  border-bottom: 1px solid #dff0e6;
  box-shadow: 0 12px 30px -22px rgba(31, 122, 77, .55);
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.hero::before {
  width: 220px; height: 220px; right: -70px; top: -90px;
  background: radial-gradient(circle, rgba(87, 189, 139, .22) 0%, rgba(87, 189, 139, 0) 70%);
}
.hero::after {
  width: 180px; height: 180px; left: -60px; bottom: -110px;
  background: radial-gradient(circle, rgba(47, 158, 106, .14) 0%, rgba(47, 158, 106, 0) 70%);
}

.hero-top { display: flex; align-items: flex-start; gap: 10px; position: relative; }
.hero-id { flex: 1; min-width: 0; }
.hero-id h1 {
  font-size: 16px; font-weight: 700; letter-spacing: .2px;
  color: #14523a; line-height: 1.35;
}
.hero-id p {
  font-size: 12px; color: #6d9280; margin-top: 3px;
  letter-spacing: .3px;
}
.hero-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.hero-badge {
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, .8); color: var(--brand-deep);
  border: 1px solid #cfeadd; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.school-logo {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 50%; object-fit: cover;
  background: #fff; border: 1.5px solid #fff;
  box-shadow: 0 2px 10px rgba(31, 122, 77, .18);
}
.school-logo.sm { width: 32px; height: 32px; flex: 0 0 32px; }

.hero-clock { margin-top: 16px; position: relative; }
.clock {
  font-size: 44px; font-weight: 300; letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05; color: var(--brand-deep);
  font-feature-settings: "tnum";
}
.dateline {
  display: flex; align-items: center; gap: 8px;
  margin-top: 7px; font-size: 12.5px; color: #6d9280;
  font-variant-numeric: tabular-nums;
}
.dateline .dot { width: 3px; height: 3px; border-radius: 50%; background: #a9c9b8; }

.hero-hint {
  margin-top: 14px; font-size: 12.5px; line-height: 1.5;
  color: #41604f;
  background: rgba(255, 255, 255, .72);
  border: 1px solid #d9eee2;
  padding: 8px 12px; border-radius: 11px;
  position: relative;
}

/* ================= 卡片 / 步骤 ================= */
main { padding: 16px 14px 0; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 15px;
  margin-bottom: 13px;
  border: 1px solid rgba(220, 239, 227, .9);
  animation: rise .34s cubic-bezier(.22,.8,.3,1) both;
}
.card-soft {
  background: #f0f9f4; border: 1px solid #e0f1e7; border-radius: 14px;
  display: flex; gap: 8px; align-items: flex-start;
  padding: 11px 13px; font-size: 12px; color: var(--ink-2); line-height: 1.55;
  margin-bottom: 13px;
}
.card-soft svg { flex: 0 0 16px; margin-top: 1px; color: var(--brand); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.step.is-locked {
  opacity: .38;
  pointer-events: none;
  filter: saturate(.4);
  transition: opacity .3s, filter .3s;
}
.step.is-hidden { display: none; }

.step-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; }
.step-no {
  width: 22px; height: 22px; flex: 0 0 22px;
  border-radius: 8px; background: var(--brand-soft); color: var(--brand-deep);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.step-head h2 { font-size: 15px; font-weight: 650; letter-spacing: .2px; color: #14523a; }
.link-btn {
  margin-left: auto; font-size: 12px; color: var(--brand-deep);
  padding: 4px 2px; font-weight: 500;
}
.link-btn:active { opacity: .6; }

/* ================= 类型选择 ================= */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.type-card {
  position: relative;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 13px 12px 12px;
  background: #fff;
  transition: border-color .18s, background .18s, transform .12s, box-shadow .18s;
  overflow: hidden;
}
.type-card .tc-icon {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; margin-bottom: 9px;
}
.type-card b { display: block; font-size: 15px; font-weight: 650; }
.type-card small {
  display: block; font-size: 11.5px; color: var(--muted);
  margin-top: 2px; line-height: 1.45;
}
.type-card:active { transform: scale(.985); }
.type-card.is-on {
  border-color: var(--brand);
  background: linear-gradient(180deg, #f3fbf6, #fff);
  box-shadow: 0 0 0 3px rgba(47, 158, 106, .1);
}
.type-card.is-on .tc-icon { background: var(--brand); color: #fff; }
.type-card .tc-count {
  position: absolute; top: 11px; right: 11px;
  font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* ================= 班次 ================= */
.shift-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.shift {
  position: relative;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
  background: #fff;
  transition: border-color .18s, background .18s, transform .12s;
}
.shift .sh-name { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.shift .sh-time {
  font-size: 15px; font-weight: 650; margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: .2px;
}
.shift .sh-state { margin-top: 6px; font-size: 11px; display: flex; align-items: center; gap: 5px; color: var(--muted); }
.shift .sh-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.shift.is-open .sh-state { color: var(--ok); }
.shift.is-open:active { transform: scale(.985); }
.shift.is-on {
  border-color: var(--brand);
  background: linear-gradient(180deg, #f3fbf6, #fff);
  box-shadow: 0 0 0 3px rgba(47, 158, 106, .1);
}
.shift.is-off { background: #fafdfb; }
.shift.is-off .sh-time { color: #9db5a8; }
.shift.is-off .sh-state { color: #a9c0b3; }
.shift .sh-taken {
  position: absolute; top: 9px; right: 10px;
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  background: var(--ok-soft); color: #16774e; font-variant-numeric: tabular-nums;
}
.shift.is-full .sh-taken { background: var(--brand-soft); color: var(--brand-deep); }

/* ================= 表单 ================= */
.field { display: block; margin-bottom: 12px; }
.field-label {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 6px; font-weight: 500;
}
.field input {
  width: 100%; height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 16px;
  color: var(--ink);
  background: #fbfefc;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
  -webkit-appearance: none;
  appearance: none;
}
.field input::placeholder { color: #a8c1b4; }
.field input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(47, 158, 106, .12);
}

.name-suggest { display: flex; gap: 7px; flex-wrap: wrap; margin: -4px 0 12px; }
.chip {
  font-size: 12px; padding: 5px 11px; border-radius: 999px;
  background: var(--line-2); color: var(--ink-2); border: 1px solid transparent;
}
.chip:active { background: var(--brand-soft); color: var(--brand-deep); }
.chip small { color: var(--muted); margin-left: 4px; font-size: 10.5px; }

.cam-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.seg {
  display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px;
}
.seg-btn {
  font-size: 12.5px; padding: 6px 13px; border-radius: 8px;
  color: var(--muted); font-weight: 500; transition: all .18s;
}
.seg-btn.is-on { background: #fff; color: var(--brand-deep); box-shadow: 0 1px 3px rgba(23,53,42,.1); font-weight: 650; }
.micro { font-size: 11px; color: #a3bcaf; margin-left: auto; }

/* ================= 拍照 ================= */
.shot {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  background: #fbfefc;
  border: 1.5px dashed #c4e2d3;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  transition: border-color .2s, background .2s;
}
.shot.is-filled { border: 1.5px solid var(--line); background: #0d1a14; }
.shot-empty {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: #93b3a3; text-align: center; padding: 10px;
}
.shot-empty b { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-top: 2px; }
.shot-empty span { font-size: 11.5px; color: #a3bcaf; }
.shot-filled { position: absolute; inset: 0; }
.shot-filled img { width: 100%; height: 100%; object-fit: cover; }
.shot-meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 24px 12px 9px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.62) 100%);
  color: #fff; font-size: 11px; font-variant-numeric: tabular-nums;
}
.shot-retake {
  position: absolute; top: 10px; right: 10px;
  font-size: 12px; padding: 6px 12px; border-radius: 999px;
  background: rgba(15,26,20,.55); color: #fff;
  backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.22);
}
.shot-busy {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 9px;
  justify-content: center; background: rgba(255,255,255,.92);
  font-size: 13px; color: var(--ink-2);
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(47,158,106,.2); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 底部提交 ================= */
.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 15px calc(11px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  max-width: 560px; margin: 0 auto;
  box-shadow: 0 -8px 24px -18px rgba(23,53,42,.4);
}
.sb-info { flex: 1; min-width: 0; }
.sb-main {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-sub { font-size: 11px; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }

.btn-primary {
  height: 44px; padding: 0 22px; border-radius: 12px;
  background: linear-gradient(180deg, #3cb377, #2f9e6a);
  color: #fff; font-size: 15px; font-weight: 650; letter-spacing: .3px;
  box-shadow: 0 6px 16px -6px rgba(47,158,106,.55), inset 0 1px 0 rgba(255,255,255,.18);
  transition: transform .12s, filter .18s, background .2s;
  white-space: nowrap;
  flex: 0 0 auto;
}
.btn-primary:active { transform: scale(.975); }
.btn-primary:disabled {
  background: #cfe3d7; box-shadow: none; color: #fff; transform: none;
}
.btn-ghost {
  height: 44px; padding: 0 18px; border-radius: 12px;
  background: #eef8f2; color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.btn-ghost:active { background: #e3f2ea; }

.foot-link { text-align: center; padding: 6px 0 10px; }
.foot-link a { font-size: 12px; color: #a3bcaf; }
.foot-link a:active { color: var(--brand-deep); }

/* ================= 成功页 ================= */
.receipt-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 30, 22, .42);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fade .22s ease both;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.receipt {
  width: 100%; max-width: 350px;
  background: #fff; border-radius: 22px; overflow: hidden;
  box-shadow: 0 30px 70px -24px rgba(8, 26, 18, .55);
  animation: pop .32s cubic-bezier(.2,.9,.3,1.05) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.receipt-top {
  background: linear-gradient(150deg, #2f9e6a, #3cb377 50%, #63c995);
  color: #fff; text-align: center;
  padding: 24px 20px 20px;
  position: relative; overflow: hidden;
}
.receipt-top::after {
  content: ""; position: absolute; width: 200px; height: 200px;
  right: -80px; top: -100px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.22), rgba(255,255,255,0) 70%);
}
.check-ring {
  width: 64px; height: 64px; margin: 0 auto 10px;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  animation: ring .5s cubic-bezier(.2,.9,.3,1.2) both .1s;
}
@keyframes ring { from { transform: scale(.6); opacity: 0 } to { transform: none; opacity: 1 } }
.receipt-top h2 { font-size: 19px; font-weight: 650; letter-spacing: 1px; }
.receipt-sub { font-size: 12px; color: rgba(255,255,255,.85); margin-top: 3px; }
.receipt-body { padding: 6px 20px 4px; }
.rc-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; padding: 11px 0; border-bottom: 1px dashed var(--line-2);
  font-size: 13px;
}
.rc-row:last-child { border-bottom: none; }
.rc-row span { color: var(--muted); flex: 0 0 auto; }
.rc-row b { font-weight: 600; text-align: right; color: var(--ink); }
.rc-time { font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: .3px; }
.rc-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted) !important; font-weight: 500 !important; }
.receipt-actions { display: flex; gap: 10px; padding: 12px 20px 20px; }
.receipt-actions .btn-primary { flex: 1; }
.receipt-actions .btn-ghost { flex: 0 0 auto; }

.status-pill {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  font-weight: 600; vertical-align: 1px;
}
.status-ok { background: var(--ok-soft); color: #16774e; }
.status-late { background: var(--danger-soft); color: var(--danger); }
.status-early { background: var(--brand-soft); color: var(--brand-deep); }

/* ================= 提示 ================= */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 10px);
  max-width: min(88vw, 420px);
  background: rgba(23, 53, 42, .94);
  color: #fff; font-size: 13px; line-height: 1.5;
  padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; z-index: 90;
  transition: opacity .2s, transform .2s;
  text-align: center;
  box-shadow: 0 12px 30px -12px rgba(0,0,0,.5);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-err { background: rgba(163, 40, 40, .95); }

/* 骨架 */
.skeleton {
  border-radius: 12px; min-height: 60px;
  background: linear-gradient(100deg, #f0faf4 20%, #e6f6ed 40%, #f0faf4 60%);
  background-size: 220% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton.h86 { height: 86px; }
@keyframes shimmer { from { background-position: 120% 0 } to { background-position: -20% 0 } }

/* ================= 打卡口令闸门 ================= */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, #dcf3e4 0%, rgba(220, 243, 228, 0) 70%),
    linear-gradient(170deg, #eef9f2 0%, #f9fdfa 55%, #e7f5ed 100%);
}
.gate-corner {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 16px;
}
.gate-corner img {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; background: #fff;
  border: 1.5px solid #fff;
  box-shadow: 0 3px 12px rgba(31, 122, 77, .2);
}
.gate-card {
  width: 100%; max-width: 340px;
  background: #fff; border-radius: 22px;
  padding: 30px 24px 22px; text-align: center;
  box-shadow: 0 30px 70px -30px rgba(15, 60, 40, .45);
  border: 1px solid #eaf6ee;
  animation: pop .3s cubic-bezier(.2,.9,.3,1.05) both;
}
.gate-logo {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(150deg, #2f9e6a, #3cb377 55%, #63c995);
  color: #fff; font-size: 23px; font-weight: 700;
  box-shadow: 0 10px 24px -12px rgba(47, 158, 106, .8);
}
.gate-card h2 { font-size: 19px; font-weight: 650; letter-spacing: .5px; color: #14523a; }
.gate-org { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.gate-tip { font-size: 12.5px; color: var(--ink-2); margin: 16px 0 9px; }
.gate-card input {
  width: 100%; height: 48px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 20px; letter-spacing: 4px; font-variant-numeric: tabular-nums;
  background: #fbfefc; outline: none; color: var(--ink);
  -webkit-appearance: none; appearance: none;
  transition: border-color .18s, box-shadow .18s;
}
.gate-card input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3.5px rgba(47,158,106,.12); }
.gate-err {
  font-size: 12.5px; color: var(--danger); background: var(--danger-soft);
  padding: 8px 10px; border-radius: 9px; margin: 10px 0 0;
}
.gate-card .btn-primary { margin-top: 12px; height: 46px; }
.gate-foot { font-size: 11px; color: #a8c1b4; margin-top: 14px; }

@media (min-width: 620px) {
  .hero { border-radius: 0 0 30px 30px; padding-left: 26px; padding-right: 26px; }
  main { padding: 18px 0 0; }
  .clock { font-size: 50px; }
  .shift-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-id h1 { font-size: 18px; }
}
