:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --ink: #16202b;
  --ink-soft: #3c4854;
  --muted: #6d7885;
  --line: #e2e7ee;
  --line-strong: #cfd7e1;
  --primary: #0f766e;
  --primary-dark: #0b5a54;
  --primary-soft: #e7f4f2;
  --pending: #1d4ed8;
  --pending-soft: #e8eefc;
  --ok: #15803d;
  --ok-soft: #e6f4ea;
  --warn: #b45309;
  --warn-soft: #fdf0e3;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 6px 18px -10px rgba(22, 32, 43, .25);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 32px;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px) * 0);
}
.topbar-inner {
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(145deg, #128c82, #0b5a54);
  display: grid; place-items: center; color: #fff; flex: none;
  box-shadow: 0 4px 10px -4px rgba(15, 118, 110, .8);
}
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.brand-text p { margin: 0; font-size: 11px; color: var(--muted); letter-spacing: .3px; }

.who {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  background: #f6f8fa; border: 1px solid var(--line);
  padding: 6px 8px 6px 12px; border-radius: 999px; font-size: 13px;
  max-width: 46%; flex: none;
}
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who button {
  color: var(--primary); font-size: 12px; padding: 3px 7px;
  border-radius: 999px; background: var(--primary-soft); flex: none;
}

/* ---------- 布局 ---------- */
.wrap { max-width: 620px; margin: 0 auto; padding: 16px; }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: #e6eaf0; padding: 4px; border-radius: 13px; margin-bottom: 16px;
}
.tabs button {
  height: 44px; border-radius: 10px; font-size: 15px; font-weight: 600;
  color: var(--muted); transition: background .18s, color .18s;
}
.tabs button.active {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 3px rgba(22, 32, 43, .12);
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- 提示 ---------- */
.hint {
  display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: var(--primary-soft); color: #0d5f59; font-size: 13px;
  line-height: 1.6; margin-bottom: 14px;
}
.hint svg { flex: none; margin-top: 2px; opacity: .85; }
.hint b { color: #0a4f4a; }

/* ---------- 拍照区 ---------- */
.shoot { display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px; margin-bottom: 12px; }
.shoot button {
  height: 92px; border-radius: var(--radius); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 7px;
  font-size: 16px; font-weight: 650; letter-spacing: .3px;
  transition: transform .12s ease, box-shadow .2s;
}
.shoot button:active { transform: scale(.975); }
.shoot .cam {
  background: linear-gradient(160deg, #14897f, #0b5a54);
  color: #fff; box-shadow: 0 8px 20px -10px rgba(11, 90, 84, .95);
}
.shoot .cam small { font-weight: 400; font-size: 11px; opacity: .8; letter-spacing: .4px; }
.shoot .gal {
  background: var(--surface); color: var(--ink-soft);
  border: 1.5px dashed var(--line-strong);
}
.shoot .gal small { font-weight: 400; font-size: 11px; color: var(--muted); }
.shoot svg { display: block; }

.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px;
}
.photo-grid:empty { display: none; }
.pthumb {
  position: relative; aspect-ratio: 3 / 4; border-radius: 11px; overflow: hidden;
  background: #eef1f5; border: 1px solid var(--line);
}
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pthumb .kill {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px;
  border-radius: 50%; background: rgba(18, 24, 33, .72); color: #fff;
  display: grid; place-items: center; backdrop-filter: blur(4px);
}
.pthumb .tag {
  position: absolute; left: 5px; bottom: 5px; font-size: 10px; padding: 2px 6px;
  border-radius: 6px; background: rgba(18, 24, 33, .66); color: #fff; letter-spacing: .2px;
}
.pthumb .tag.ok { background: rgba(21, 128, 61, .9); }
.pthumb .tag.bad { background: rgba(185, 28, 28, .92); }
.pthumb.busy::after {
  content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .6);
}
.pthumb.busy::before {
  content: ""; position: absolute; z-index: 2; top: 50%; left: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 2px solid var(--primary); border-top-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.form { padding: 16px; display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--ink-soft); margin-bottom: 6px; }
.field label i { color: var(--danger); font-style: normal; margin-left: 2px; }
.field label em { font-weight: 400; color: var(--muted); font-style: normal; margin-left: 6px; font-size: 12px; }
.field input, .field textarea {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: #fbfcfd; padding: 13px 14px; font-size: 17px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 76px; font-size: 16px; line-height: 1.5; }
.field input:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
  background: #fff;
}
.field input::placeholder, .field textarea::placeholder { color: #a8b2be; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-primary {
  width: 100%; height: 56px; border-radius: 14px; font-size: 17px; font-weight: 700;
  color: #fff; background: linear-gradient(160deg, #14897f, #0b5a54);
  box-shadow: 0 10px 22px -12px rgba(11, 90, 84, .9);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s, opacity .2s;
}
.btn-primary:active { transform: translateY(1px) scale(.995); }
.btn-primary[disabled] { opacity: .55; box-shadow: none; }
.btn-ghost {
  height: 48px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: #fff; color: var(--ink-soft); font-weight: 600; width: 100%;
}
.form-foot { font-size: 12px; color: var(--muted); text-align: center; margin: -4px 0 0; }

/* 上传进度 */
.progress { display: none; }
.progress.on { display: block; }
.bar { height: 8px; background: #e6ebf1; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #18a094, #0f766e); transition: width .2s; }
.progress p { margin: 7px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 我的单据 ---------- */
.list { display: grid; gap: 12px; }
.item { padding: 14px; }
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.chip {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; letter-spacing: .3px;
  flex: none;
}
.chip.pending { color: var(--pending); background: var(--pending-soft); }
.chip.approved { color: var(--ok); background: var(--ok-soft); }
.chip.returned { color: var(--warn); background: var(--warn-soft); }
.item-head .code { font-size: 12px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.item-title { font-size: 16px; font-weight: 650; margin: 0 0 3px; }
.item-sub { font-size: 13px; color: var(--muted); }
.item-thumbs { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.item-thumbs img {
  width: 62px; height: 78px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: #eef1f5;
}
.item-thumbs .more {
  width: 62px; height: 78px; border-radius: 8px; background: #f1f4f8;
  display: grid; place-items: center; font-size: 13px; color: var(--muted);
  border: 1px solid var(--line);
}
.reason {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--warn-soft); border: 1px solid #f3dcc2;
  color: #8a4b16; font-size: 13.5px; line-height: 1.55;
}
.reason b { display: block; font-size: 12px; color: #a9622a; margin-bottom: 2px; letter-spacing: .3px; }
.item-act { display: flex; gap: 8px; margin-top: 12px; }
.item-act button {
  flex: 1; height: 44px; border-radius: 10px; font-size: 14.5px; font-weight: 650;
}
.item-act .redo { background: var(--warn); color: #fff; }
.item-act .view { background: #f1f4f8; color: var(--ink-soft); border: 1px solid var(--line); }

.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty svg { opacity: .35; margin-bottom: 10px; }
.empty p { margin: 0; font-size: 14px; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 22, 30, .5); z-index: 60;
  display: none; align-items: flex-end; justify-content: center; padding: 0;
  backdrop-filter: blur(2px);
}
.mask.on { display: flex; }
.mask.center { align-items: center; padding: 20px; }
.sheet {
  background: var(--surface); width: 100%; max-width: 620px;
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: slideUp .22s ease-out;
  max-height: 88vh; overflow: auto;
}
.mask.center .sheet { border-radius: 16px; animation: pop .18s ease-out; }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } }
@keyframes pop { from { transform: scale(.96); opacity: .6; } }
.sheet h3 { margin: 0 0 6px; font-size: 17px; }
.sheet p { margin: 0 0 14px; font-size: 14px; color: var(--muted); line-height: 1.65; }
.sheet ul { margin: 0 0 16px; padding-left: 20px; font-size: 14px; color: var(--ink-soft); }
.sheet ul li { margin-bottom: 6px; }
.sheet .actions { display: grid; gap: 8px; }
.sheet .actions.two { grid-template-columns: 1fr 1fr; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: rgba(20, 27, 36, .94); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-size: 14px; z-index: 90; opacity: 0;
  transition: opacity .22s, transform .22s; max-width: 84vw; text-align: center;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: rgba(150, 26, 26, .96); }

/* ---------- 大屏适配（工人端在电脑上打开也不难看） ---------- */
@media (min-width: 760px) {
  .wrap { padding: 24px 16px; }
  .shoot button { height: 108px; }
}

/* ---------- 选填信息 ---------- */
.more {
  border: 1px solid var(--line); border-radius: 12px; background: #fbfcfd;
  padding: 0 14px;
}
.more summary {
  cursor: pointer; list-style: none; padding: 13px 0; font-size: 14px;
  font-weight: 650; color: var(--teal, #0f766e); display: flex; align-items: center; gap: 7px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::after {
  content: "＋"; margin-left: auto; font-weight: 400; color: var(--muted);
}
.more[open] summary::after { content: "－"; }
.more-body { padding: 2px 0 14px; display: grid; gap: 12px; }
.more-body .form-foot { margin: 0; }
.field select {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: #fbfcfd; padding: 13px 14px; font-size: 16px; outline: none;
  appearance: none; color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236d7885' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .13); background-color: #fff; }

.chip { white-space: nowrap; }

/* ---------- 工人端：点选输入 ---------- */
.big-input {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 12px;
  background: #fbfcfd; padding: 15px 14px; font-size: 19px; outline: none;
}
.big-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
  background: #fff;
}
.date-row { display: block; }
.date-row input[type="date"] { width: 100%; }

.quick-row { display: flex; gap: 8px; margin-top: 8px; }
.quick-row .quick {
  flex: 1; height: 42px; border-radius: 10px; font-size: 14px; font-weight: 650;
  background: #f1f4f8; color: var(--ink-soft); border: 1px solid var(--line);
}
.quick-row .quick:active { background: var(--primary-soft); color: var(--primary-dark); }

.calc-display {
  width: 100%; display: flex; align-items: baseline; gap: 8px;
  background: #fbfcfd; border: 1.5px solid var(--line-strong);
  border-radius: 12px; padding: 14px 16px; text-align: left;
}
.calc-display.filled { border-color: var(--primary); background: #f4fbfa; }
.calc-display .calc-value {
  font-size: 30px; font-weight: 700; letter-spacing: .5px;
  font-variant-numeric: tabular-nums; color: var(--ink);
  line-height: 1.2; overflow: hidden; text-overflow: ellipsis;
}
.calc-display.small .calc-value { font-size: 22px; }
.calc-display .calc-unit { font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .pill {
  /* 长名字宁可换行也不截断：限制最大宽度为整行，允许自动折行 */
  min-height: 46px; padding: 9px 16px; border-radius: 12px; font-size: 16px;
  font-weight: 600; background: #f1f4f8; color: var(--ink-soft);
  border: 1.5px solid transparent;
  max-width: 100%; flex: 0 1 auto; white-space: normal;
  word-break: break-word; overflow-wrap: anywhere;
  line-height: 1.3; text-align: center; overflow: visible;
}

.chips .pill.add {
  background: #fff; border: 1.5px dashed var(--line-strong); color: var(--muted);
  font-weight: 500;
}
.chips .pill.on {
  background: var(--primary-soft); color: var(--primary-dark);
  border-color: var(--primary);
}
.chips-empty { font-size: 13px; color: var(--muted); margin: 0; }

/* 品名：直接写名字为主，下面一排快捷按钮 */
.item-input-row { display: flex; gap: 8px; align-items: stretch; }
.field .item-input-row .item-input {
  flex: 1; min-width: 0;
  font-size: 23px; padding: 18px 15px; border-radius: 12px; background: #fff;
  font-weight: 600;
}
.mic-btn {
  flex: 0 0 58px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: #f1f4f8; color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
}
.mic-btn.on {
  background: var(--danger); border-color: var(--danger); color: #fff;
  animation: micPulse 1.4s ease-in-out infinite;
}
.mic-btn.busy { opacity: .55; }
@keyframes micPulse {
  50% { box-shadow: 0 0 0 6px rgba(200, 40, 40, .14); }
}
.mic-status {
  display: flex; align-items: center; gap: 7px; margin: 8px 0 0;
  font-size: 12.5px; font-weight: 650; color: var(--danger);
}
.mic-status[hidden] { display: none; }
.mic-status i {
  width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: micBlink 1s step-end infinite;
}
@keyframes micBlink { 50% { opacity: .2; } }
.mic-debug {
  margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted);
  background: #f6f8fa; border-radius: 8px; padding: 7px 9px;
  word-break: break-all;
}
.mic-debug[hidden] { display: none; }
.kbd-tip {
  display: inline-block; margin: 7px 0 0; padding: 0; border: 0; background: none;
  font-size: 12.5px; font-weight: 650; color: var(--primary-dark);
  text-decoration: underline; text-underline-offset: 3px;
}
.item-hint { margin: 7px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.item-chips {
  margin-top: 9px; max-height: 240px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; padding: 1px;
}

.field.need label { color: var(--danger); }
.field.need .calc-display,
.field.need .item-input,
.field.need .big-input { border-color: var(--danger); background: #fff7f7; }

/* 数字键盘 */
.keypad {
  background: var(--surface); width: 100%; max-width: 620px;
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  animation: slideUp .2s ease-out;
}
.keypad-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 2px 6px 12px;
}
.keypad-head span { font-size: 13px; color: var(--muted); font-weight: 650; }
.keypad-head b {
  font-size: 34px; font-variant-numeric: tabular-nums; letter-spacing: .5px;
  max-width: 70%; overflow: hidden; text-overflow: ellipsis;
}
.keys {
  display: grid; grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 62px; gap: 8px;
}
.keys button {
  border-radius: 12px; font-size: 24px; font-weight: 650;
  background: #f2f5f9; color: var(--ink);
  display: grid; place-items: center;
}
.keys button:active { background: #e3e9f1; }
.keys button.fn { font-size: 16px; color: var(--ink-soft); background: #e9eef5; }
.keys button.ok {
  grid-row: span 2; background: linear-gradient(160deg, #14897f, #0b5a54);
  color: #fff; font-size: 18px;
}
.keys button.zero { grid-column: span 2; }

