:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --green: #16a34a;
  --red: #dc2626;
  --border: #e2e8f0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.scan-page { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.scan-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 18px;
}
.scan-brand { font-weight: 700; font-size: 15px; color: var(--primary); }
.scan-title { font-size: 13px; color: var(--muted); }

.card {
  background: var(--card); border-radius: 16px; padding: 20px;
  box-shadow: 0 1px 3px rgba(15,23,42,.08);
  margin-bottom: 16px;
}
.task-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.task-order { font-size: 14px; font-weight: 600; color: var(--text); }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-status { background: #e2e8f0; color: #334155; }
.badge-status.in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-status.completed { background: #dcfce7; color: #15803d; }
.task-op { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.task-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.task-info-grid > div { background: #f8fafc; border-radius: 10px; padding: 8px 12px; }
.task-info-grid label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.task-info-grid span { font-size: 15px; font-weight: 600; }

.form-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  outline: none;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 10px; padding: 12px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-ghost { background: #f1f5f9; color: var(--text); width: 100%; margin-top: 10px; }
.btn-lg { padding: 15px 18px; font-size: 17px; }

.scan-loading { text-align: center; color: var(--muted); padding: 80px 0; }
.scan-error { text-align: center; padding: 60px 20px; }
.scan-error-icon { font-size: 52px; margin-bottom: 12px; }
.scan-error p { color: var(--muted); margin-bottom: 20px; }
.scan-error .btn { max-width: 220px; margin: 0 auto; display: flex; }

.scan-success { text-align: center; padding: 50px 20px; }
.success-icon {
  width: 84px; height: 84px; line-height: 84px; font-size: 42px;
  background: #dcfce7; color: var(--green); border-radius: 50%;
  margin: 0 auto 18px;
}
.scan-success h2 { font-size: 22px; margin-bottom: 8px; }
.scan-success p { color: var(--muted); margin-bottom: 24px; }

.scan-input-row { display: flex; gap: 8px; align-items: stretch; }
.scan-input {
  flex: 1; padding: 16px 18px; font-size: 18px; border: 2px solid var(--primary);
  border-radius: 12px; outline: none; text-align: center; letter-spacing: .5px;
}
.scan-input:focus { box-shadow: 0 0 0 4px rgba(37,99,235,.18); }
.btn-camera {
  flex: 0 0 56px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; border: 2px solid var(--primary); border-radius: 12px;
  background: #eff6ff; color: var(--primary); cursor: pointer; transition: background .15s;
}
.btn-camera:active { background: #dbeafe; }

/* 实时摄像头扫码模态 */
.cam-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2,6,23,.92);
  display: flex; align-items: center; justify-content: center;
}
.cam-box {
  position: relative; width: min(420px, 92vw); text-align: center;
  border-radius: 16px; overflow: hidden; background: #000;
}
#cam-video { width: 100%; height: auto; display: block; }
.cam-frame {
  position: absolute; inset: 12%; border: 3px solid rgba(37,99,235,.85);
  border-radius: 12px; box-shadow: 0 0 0 9999px rgba(2,6,23,.35);
}
.cam-hint { padding: 10px 12px; font-size: 13px; color: #cbd5e1; background: rgba(2,6,23,.7); }
.cam-box .btn { position: absolute; right: 12px; bottom: 44px; background: rgba(255,255,255,.15); color: #fff; }
.scan-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }
.scan-error-box {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: #fef2f2;
  color: var(--red); font-size: 14px; font-weight: 600; text-align: center;
}
.last-result { margin-top: 12px; font-size: 14px; font-weight: 600; text-align: center; min-height: 20px; }
.stats-card { background: #eff6ff; border: 1px solid #bfdbfe; }
.stats-line { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: #1e40af; }
.stats-line b { font-size: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 999; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: rise .2s ease-out;
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
