/* ============================================================
 *  工地工具集 · 工人端 H5
 *  设计语言:深蓝品牌 + 安全橙强调 + 翡翠成功 + 现代卡片
 *  mobile-first · safe-area · 44px 触控目标
 * ============================================================ */

:root {
  /* —— 品牌 —— */
  --brand:        #0E4DA4;
  --brand-press:  #0A3A82;
  --brand-soft:   #E8F0FE;
  --accent:       #F97316;       /* 安全橙 — 仅给关键 CTA */
  --accent-soft:  #FFF2E5;

  /* —— 语义 —— */
  --primary:      var(--brand);
  --primary-press: var(--brand-press);
  --danger:       #DC2626;
  --danger-soft:  #FEE2E2;
  --success:      #10B981;
  --success-soft: #D1FAE5;
  --warning:      #F59E0B;
  --warning-soft: #FEF3C7;

  /* —— 表面 —— */
  --bg:           #F6F8FB;
  --surface:      #FFFFFF;
  --surface-2:    #F1F5F9;
  --surface-3:    #E2E8F0;

  /* —— 文字 —— */
  --text:         #0F172A;
  --text-2:       #334155;
  --text-muted:   #64748B;
  --text-soft:    #94A3B8;
  --text-on-brand: #FFFFFF;

  /* —— 描边 —— */
  --line:         #E2E8F0;
  --line-soft:    #F1F5F9;

  /* —— 阴影 —— */
  --shadow-sm:    0 1px 2px rgba(15,23,42,.05);
  --shadow:       0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
  --shadow-md:    0 4px 6px rgba(15,23,42,.07), 0 12px 24px rgba(15,23,42,.06);
  --shadow-lg:    0 10px 30px rgba(15,23,42,.10);
  --shadow-brand: 0 6px 16px rgba(14,77,164,.30);

  /* —— 圆角 —— */
  --r-xs: 6px;
  --r-sm: 10px;
  --r:    14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-pill: 999px;

  /* —— 间距 —— */
  --gap:   12px;
  --gap-2: 16px;
  --gap-3: 20px;
  --gap-4: 28px;

  /* —— 字体 —— */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
          "Helvetica Neue", "Hiragino Sans GB", sans-serif;

  /* —— 动效 —— */
  --ease:    cubic-bezier(.2, .7, .2, 1);
  --t-fast:  .12s;
  --t:       .18s;
  --t-slow:  .28s;

  /* —— 触控 —— */
  --tap:     44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* 子页面通用：返回首页 */
.back-portal {
  display: inline-block;
  color: var(--brand);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  margin: 8px 14px 0;
  border-radius: var(--r-sm);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.back-portal:hover { background: var(--brand-soft); }
.back-portal:active { transform: scale(.98); }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.55;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom);
  animation: screenIn var(--t-slow) var(--ease);
}
.screen.active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

/* ===== 顶部品牌条 ===== */
.brand-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 22px 0 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 1px;
}
.brand-bar .logo {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--brand) 0%, #1e6fd0 100%);
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-brand);
}

/* ============ Step 1: 姓名录入 ============ */
#step-name .card {
  margin: 8px auto 24px;
  max-width: 520px;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 28px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
#step-name h1 {
  font-size: 24px;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.muted { color: var(--text-muted); margin: 0 0 20px; font-size: 14px; }

.lbl {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin: 18px 0 8px;
  letter-spacing: .2px;
}
.lbl .req-dot { color: var(--accent); margin-left: 2px; }

.ipt {
  width: 100%;
  font-size: 16px;
  font-family: inherit;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
  min-height: var(--tap);
}
.ipt:hover { border-color: var(--surface-3); }
.ipt:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(14,77,164,.12);
  background: var(--surface);
}
select.ipt {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2364748B' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  padding-right: 40px;
}

.req {
  margin: 20px 0 14px;
  padding: 14px 16px 14px 16px;
  background: var(--warning-soft);
  border: 1px solid #FDE68A;
  border-left: 3px solid var(--warning);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: #78350F;
  line-height: 1.6;
}
.req h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: #92400E;
}
.req ol { margin: 6px 0 0; padding-left: 22px; }
.req li { margin: 3px 0; }
.req strong { color: #4B2E07; font-weight: 600; }

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: var(--tap);
  font-size: 15.5px;
  font-weight: 600;
  padding: 13px 20px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  margin-top: 18px;
  font-family: inherit;
  letter-spacing: .3px;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease),
              background var(--t) var(--ease);
}
.btn:active { transform: scale(.985); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #1665C9 100%);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(14,77,164,.40); }
.btn-primary:active { background: var(--brand-press); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--surface-3); background: var(--surface-2); }
.btn.sm { width: auto; padding: 8px 14px; font-size: 13.5px; min-height: 36px; margin-top: 0; }

.err {
  min-height: 22px;
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
  font-weight: 500;
}

.tip {
  min-height: 20px;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 4px;
}
.tip.warn { color: #B45309; }
.tip.ok   { color: var(--success); }
.tip:empty { display: none; }

/* ============ Step 2: 拍照 ============ */
#step-camera {
  padding: 0;
  background: #000;
}
.cam-stage {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}
#video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
#video.mirrored { transform: scaleX(-1); }

#overlay {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#overlay.mirrored { transform: scaleX(-1); }

.guide {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.guide.mirrored { transform: scaleX(-1); }
.head-guide {
  width: 70vw; max-width: 340px;
  aspect-ratio: 3 / 4;
  border: 2.5px dashed rgba(255,255,255,.85);
  border-radius: 50% / 40%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.40);
  position: relative;
}
.shoulder-guide {
  width: 86vw; max-width: 440px;
  height: 2px;
  background: rgba(255,255,255,.7);
  margin-top: 7vh;
  position: relative;
}

.guide-label {
  position: absolute;
  color: #fff;
  background: rgba(0,0,0,.55);
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  z-index: 3;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.head-label { top: 16%; left: 50%; transform: translateX(-50%); }
.shoulder-label { bottom: 28%; right: 8%; background: rgba(14,77,164,.85); }

/* —— HUD 顶部/底部 —— */
.cam-hud {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding: env(safe-area-inset-top) 14px calc(env(safe-area-inset-bottom) + 14px);
}
.cam-hud > * { pointer-events: auto; }

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.badge {
  background: rgba(0,0,0,.55);
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
}
.hud-bottom {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
}
.hud-tip {
  color: #fff;
  background: rgba(0,0,0,.55);
  padding: 7px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.1);
}
.cam-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 440px;
}

/* —— 快门 —— */
.btn.shutter {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: #fff;
  margin: 0;
  position: relative;
  border: 4px solid rgba(255,255,255,.35);
  box-shadow: 0 0 0 4px rgba(0,0,0,.30), 0 8px 24px rgba(0,0,0,.4);
  flex-shrink: 0;
  transition: transform .15s var(--ease);
}
.btn.shutter:active { transform: scale(.92); }
.btn.shutter::after {
  content: "";
  position: absolute;
  inset: 6px;
  background: #fff;
  border-radius: 50%;
}
.btn.shutter.flash {
  animation: shutterFlash .3s var(--ease);
}
@keyframes shutterFlash {
  0%   { background: #fff; }
  50%  { background: rgba(255,255,255,.6); transform: scale(1.05); }
  100% { background: #fff; transform: scale(1); }
}

#btn-flip {
  background: rgba(0,0,0,.5);
  color: #fff;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255,255,255,.15);
}
#btn-back, #btn-retake {
  background: rgba(0,0,0,.55);
  color: #fff;
  width: auto;
  padding: 0 18px;
  margin: 0;
  height: 42px;
  border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
}

/* ============ Step 3: 预览 ============ */
.preview-stage {
  margin: 0 auto;
  max-width: 520px;
  padding: 18px;
}
.preview-stage img {
  width: 100%;
  border-radius: var(--r-md);
  background: #000;
  display: block;
  box-shadow: var(--shadow-lg);
  border: 4px solid #fff;
}
.preview-meta {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.preview-meta b { color: var(--text); font-weight: 600; }

.actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.actions .btn { margin-top: 0; flex: 1; }

/* ============ Step 4: 成功 ============ */
.center { text-align: center; }
.success-card {
  margin: 32px auto;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 36px 28px 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line-soft);
}
.ok-circle {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: #fff;
  font-size: 48px;
  line-height: 88px;
  margin: 0 auto 18px;
  box-shadow: 0 8px 20px rgba(16,185,129,.35);
  animation: popIn .35s var(--ease);
}
@keyframes popIn {
  0%   { transform: scale(.5); opacity: 0 }
  60%  { transform: scale(1.08); opacity: 1 }
  100% { transform: scale(1); opacity: 1 }
}
.success-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
.success-card p { margin: 0 0 22px; }

/* ============ Step 0: 未开放 ============ */
.closed-circle {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--warning);
  color: #fff;
  font-size: 44px;
  line-height: 88px;
  margin: 24px auto 18px;
  box-shadow: 0 6px 16px rgba(245,158,11,.30);
}
.slots-list {
  margin: 18px auto;
  max-width: 320px;
  text-align: left;
  font-size: 13px;
  color: var(--text-muted);
}
.slots-list .slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--line);
}
.slots-list .slot:last-child { border-bottom: 0; }
.slots-list .slot .time { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.slots-list .next {
  color: #fff;
  background: var(--warning);
  font-weight: 600;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* ============ 次要 CTA(相册选择) ============ */
.btn-secondary {
  background: var(--surface);
  color: var(--brand);
  border: 1.5px solid var(--brand);
  margin-top: 12px;
}
.btn-secondary:hover { background: var(--brand-soft); }
.btn-secondary:active { background: var(--brand-soft); transform: scale(.985); }
.hint-secondary {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0 0;
}

.cam-secondary-btn {
  display: block;
  width: calc(100% - 28px);
  max-width: 440px;
  margin: 14px auto 0;
  padding: 11px 14px;
  background: rgba(0,0,0,.45);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  font-family: inherit;
}
.cam-secondary-btn:active { background: rgba(0,0,0,.65); transform: scale(.98); }

/* ============ 最近用过 chip ============ */
.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.recent-list:empty { display: none; }
.recent-list::before {
  content: "最近用过";
  display: block;
  width: 100%;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 2px;
  font-weight: 500;
  letter-spacing: .3px;
}
.recent-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  background: var(--brand-soft);
  border: 1px solid #C7D7F7;
  color: var(--brand-press);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.recent-chip b { font-weight: 600; }
.recent-chip i { font-style: normal; opacity: .65; font-size: 12px; }
.recent-chip:active { transform: scale(.96); background: #D6E3FB; }

/* ============ 上传中遮罩 + spinner ============ */
.upload-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn .15s var(--ease);
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.spinner {
  width: 48px; height: 48px;
  border: 3.5px solid rgba(255,255,255,.20);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.um-msg {
  color: #fff;
  margin-top: 16px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .5px;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 36px);
  transform: translateX(-50%) translateY(8px);
  background: rgba(15,23,42,.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
  pointer-events: none;
  z-index: 9999;
  max-width: 84vw;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
