:root {
  --bg: #f1f3f6;
  --card: #fff;
  --ink: #17212f;
  --muted: #5d6a7c;
  --faint: #8a95a5;
  --line: #e3e7ed;
  --brand: #0b5fa8;
  --brand-dark: #0a2f5a;
  --brand-soft: #e6f0fa;
  --ok: #0f7a52;
  --ok-soft: #e1f3ea;
  --warn: #9a5800;
  --warn-soft: #fdf1da;
  --danger: #b93026;
  --danger-soft: #fdeceb;
  --radius: 14px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[data-busy] { opacity: .6; pointer-events: none; }

#app { max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.boot { padding: 40vh 20px 0; text-align: center; color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 8px 0; }
.hint { color: var(--faint); font-size: 13px; text-align: center; margin-top: 14px; }

/* 顶部标题栏 */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(241, 243, 246, .94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top-back { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -10px; border-radius: 50%; color: var(--brand); flex: none; }
.top-text { flex: 1; min-width: 0; }
.top h1 { font-size: 20px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top p { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 6px 16px 32px; }
main.has-tab { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 24px); }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; max-width: 600px; margin: 0 auto;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--faint); }
.tabbar a.active { color: var(--brand); font-weight: 600; }

/* 卡片 */
.card { display: block; background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(16, 32, 56, .05); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.model { font-size: 18px; font-weight: 700; letter-spacing: .01em; word-break: break-all; }
.order-no { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 20px 4px 8px; }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 14px; }
.kv dt { font-size: 12px; color: var(--faint); }
.kv dd { font-weight: 500; word-break: break-word; }

.callout { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #f4f6f9; font-size: 14px; word-break: break-word; }
.callout b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.callout-warn { background: var(--warn-soft); }
.callout-warn b { color: var(--warn); }

.tag { display: inline-block; flex: none; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-brand { background: var(--brand-soft); color: var(--brand); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-muted { background: #eceff3; color: var(--muted); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 12px;
  font-size: 16px; font-weight: 600; background: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: #fff; border-color: #f0c9c5; color: var(--danger); }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; flex: none; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; font-weight: 400; color: var(--faint); margin-left: 8px; }
.field input, .field select, .field textarea {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid #cfd6df; border-radius: 10px; background: #fff;
  font-size: 16px; /* 16px 以上 iPhone 才不会在输入时自动放大页面 */
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 登录 */
.login { padding: 12vh 20px 40px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-mark { width: 64px; height: 64px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(145deg, var(--brand), var(--brand-dark)); color: #fff; font-size: 30px; font-weight: 700; }
.login-brand h1 { font-size: 24px; }
.login-brand p { color: var(--muted); margin-top: 4px; }
.login-form { padding: 22px 18px; }

/* 分段切换 */
.segmented { display: flex; gap: 4px; padding: 4px; margin-bottom: 12px; background: #e4e8ee; border-radius: 12px; }
.segmented button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: none; font-size: 14px; font-weight: 600; color: var(--muted); }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 32, 56, .12); }
.segmented b { margin-left: 6px; font-weight: 600; color: var(--faint); }
.segmented .active b { color: var(--brand); }

/* 任务与订单卡片 */
.task-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.facts span { padding: 2px 8px; border-radius: 6px; background: #f1f3f6; font-size: 13px; }
.task-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.task-foot b { color: var(--ink); font-size: 16px; }
.note-line { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-card:active, .order-card:active { background: #fafbfc; }

/* 照片 */
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.field .photos { margin-top: 0; }
.photo { position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #e9edf2; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; }
.photo-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1.5px dashed #b9c3cf; background: #f8fafc; color: var(--brand); font-size: 12px; font-weight: 600; cursor: pointer; }
.photo-add:focus-within { border-color: var(--brand); }
.photo-loading { display: grid; place-items: center; font-size: 12px; color: var(--muted); }

.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0, 0, 0, .92); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 打卡时的自动计算 */
.calc:empty { display: none; }
.calc { margin-bottom: 14px; }
.calc dl { display: flex; gap: 10px; padding: 12px; border-radius: 10px; background: var(--brand-soft); }
.calc dl div { flex: 1; }
.calc dt { font-size: 12px; color: var(--muted); }
.calc dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-warn { margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

/* 工序进度条 */
.steps { display: flex; margin-top: 14px; }
.card > .steps:first-child { margin-top: 0; }
.step { flex: 1; position: relative; text-align: center; font-size: 12px; color: var(--faint); }
.step::before { content: ""; position: absolute; top: 10px; right: 50%; width: 100%; height: 2px; background: var(--line); }
.step:first-child::before { display: none; }
.step i { position: relative; z-index: 1; display: grid; place-items: center; width: 22px; height: 22px; margin: 0 auto 4px; border-radius: 50%; background: #fff; border: 2px solid #cfd6df; }
.step i svg { width: 14px; height: 14px; stroke-width: 3; }
.step-done { color: var(--ok); }
.step-done i { background: var(--ok); border-color: var(--ok); color: #fff; }
.step-done::before, .step-pending::before { background: var(--ok); }
.step-pending { color: var(--brand); font-weight: 700; }
.step-pending i { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.step-pending i::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* 空状态 */
.empty { padding: 48px 20px; text-align: center; }
.empty h2 { font-size: 17px; }
.empty p { color: var(--muted); margin-top: 6px; }
.empty .btn { margin-top: 18px; }
.page-error { padding-top: 30vh; }
.page-error .btn { margin: 18px 4px 0; }

/* 我的 */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 22px; font-weight: 700; }
.profile h2 { font-size: 18px; }
.profile p { color: var(--muted); font-size: 13px; }
.list { padding: 0; overflow: hidden; }
.list-item { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 54px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--line); background: none; font-size: 16px; text-align: left; }
.list-item:last-child { border-bottom: 0; }
.list-item svg { color: var(--faint); width: 18px; height: 18px; }
.list-item.danger { color: var(--danger); justify-content: center; }

/* 弹窗与提示 */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(12, 22, 38, .5); }
.modal { width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; padding: 22px 18px calc(18px + var(--safe-b)); background: #fff; border-radius: 18px 18px 0 0; }
.modal h2 { font-size: 18px; margin-bottom: 14px; }
.modal h2 small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.modal-text { color: var(--muted); margin: -6px 0 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-wrap { align-items: center; }
  .modal { max-width: 420px; border-radius: 18px; padding-bottom: 22px; }
}

#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 24px); z-index: 70; transform: translate(-50%, 12px); max-width: calc(100% - 40px); padding: 10px 16px; border-radius: 10px; background: rgba(20, 28, 40, .94); color: #fff; font-size: 14px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 总览 */
.hero { background: linear-gradient(145deg, var(--brand), var(--brand-dark)); color: #fff; padding: 20px; }
.hero-label { font-size: 13px; opacity: .85; }
.hero-num { font-size: 52px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.hero-num small { font-size: 22px; margin-left: 2px; }
.hero-foot { margin-top: 10px; font-size: 13px; opacity: .85; }
.bar { height: 8px; border-radius: 999px; background: #e4e8ee; overflow: hidden; }
.bar i { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--ok); }
.hero .bar { background: rgba(255, 255, 255, .22); margin-top: 8px; }
.hero .bar i { background: #fff; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: #fff; border-radius: 12px; padding: 12px 4px; text-align: center; box-shadow: 0 1px 2px rgba(16, 32, 56, .05); }
.stat b { display: block; font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.dept-row, .recent, .batch-row, .user-row { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dept-row:last-child, .recent:last-child, .batch-row:last-child, .user-row:last-child { border-bottom: 0; }
.dept-row:active, .recent:active { background: #fafbfc; }
.dept-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dept-head strong { font-size: 16px; }
.dept-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.dept-sub { margin-top: 6px; font-size: 13px; color: var(--muted); }
.dept-head + .dept-sub { margin-top: -2px; }
.recent p { font-size: 13px; color: var(--muted); }

/* 订单 */
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; min-height: 46px; padding: 0 14px; border: 1px solid #cfd6df; border-radius: 12px; background: #fff; font-size: 16px; -webkit-appearance: none; appearance: none; }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.stage { border-left: 4px solid #d5dbe3; }
.stage-done { border-left-color: var(--ok); }
.stage-pending { border-left-color: var(--brand); }
.stage > .muted { margin-top: 8px; }
.sub-block { margin-top: 16px; padding-top: 14px; border-top: 1px dashed #cfd6df; }
.sub-block h3 { font-size: 14px; }
.sub-block > .muted { margin-top: 6px; font-size: 14px; }

/* 上传与账号 */
.tips { margin: 10px 0 4px; padding-left: 18px; list-style: disc; color: var(--muted); font-size: 14px; }
.tips li { margin-bottom: 4px; }
.batch-row, .user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.batch-row > div, .user-row > div { min-width: 0; }
.batch-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-row p, .user-row p { font-size: 13px; color: var(--muted); }
.user-row strong { margin-right: 6px; }
.user-row.inactive strong { color: var(--faint); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* 任务进度与打卡记录 */
.progress { margin-top: 12px; }
.progress-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; }
.progress-head b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.progress-head span { font-size: 13px; color: var(--muted); }
.progress .bar { height: 10px; }
.task-bar { margin-top: 12px; }
.task-foot.plain { border-top: 0; padding-top: 0; margin-top: 8px; }
.calc dl { flex-wrap: wrap; }
.calc dl div { flex: 1 1 40%; }

.who { margin: 4px 0 14px; padding: 10px 12px; border-radius: 10px; background: #f4f6f9; font-size: 14px; color: var(--muted); }
.who strong { color: var(--ink); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin-bottom: 14px; border: 1px solid #cfd6df; border-radius: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }
.check span { font-weight: 600; }
.check em { display: block; font-style: normal; font-weight: 400; font-size: 13px; color: var(--muted); }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.sub-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 0; }
.checkins { margin-top: 4px; }
.checkin { padding: 12px 0; border-bottom: 1px solid var(--line); }
.checkin:last-child { border-bottom: 0; padding-bottom: 0; }
.checkin-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.checkin-head .account { font-size: 12px; color: var(--faint); }
.checkin-head time { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.checkin-main { margin-top: 2px; font-weight: 500; }
.checkin-sub { font-size: 13px; color: var(--muted); word-break: break-word; }
.checkins-empty { margin-top: 8px; }
