/* ============ 设计 token（照 docs/screenshots 设计截图）============
 * 浅灰底 + 白圆角卡 + 深靛蓝纯色页头 + 浅底小标签 + 三种按钮。
 * 手机端 390 宽，大号点击区（≥44px），吸底操作条。
 */
:root {
  --paper: #f2f2f3;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-soft: #8a90a2;
  --ink-strong: #2e3a68;
  --line: #e2e5ee;
  --line-soft: #f0f1f6;
  --cinnabar: #c0392b;
  --green: #1e7e34;
  --red: #c0392b;
  --amber: #b97a1f;
  --indigo: #2e3a68;
  --indigo-deep: #2e3a68;
  --sel: #eef1f8;
  --radius: 11px;
  --gap-block: 10px;
  --gap-ctl: 8px;
  --tap: 44px;
  --shadow: 0 1px 2px rgba(30, 40, 80, 0.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html,
body,
#root {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ============ 布局 ============ */
.app-shell {
  max-width: 448px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: transparent;
}

.page {
  padding: 0 12px calc(96px + var(--safe-b));
}

/* ============ 页头 ============ */
.dye-header {
  position: relative;
  background: var(--indigo);
  color: #fff;
  padding: 13px 16px 16px;
  overflow: hidden;
}
.dye-header .hd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}
.dye-header .hd-back {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dye-header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dye-header .hd-sub {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-variant-numeric: tabular-nums;
}
.hd-stamp {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 4px 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  font-size: 12.5px;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* ============ 卡片 ============ */
.dye-card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
}
.dye-card + .dye-card {
  margin-top: var(--gap-block);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
  line-height: 22px;
  margin: 0 0 var(--gap-ctl);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .spacer {
  flex: 1;
}
.muted {
  color: var(--ink-soft);
  font-size: 12px;
}
.rule-line {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  color: var(--ink-soft);
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.5;
}
.rule-line .dot {
  flex: 0 0 auto;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-soft);
  margin-top: 7px;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ============ 单据信息 dl ============ */
dl.kv {
  margin: 0;
  display: grid;
  grid-template-columns: 78px 1fr;
  row-gap: 6px;
  column-gap: 8px;
  align-items: baseline;
}
dl.kv dt {
  color: var(--ink-soft);
  font-size: 12.5px;
}
dl.kv dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============ 入口卡 ============ */
.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 13px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
}
.entry + .entry {
  margin-top: 8px;
}
.entry:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.entry .ic {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  color: var(--indigo);
}
.entry .ic svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.6;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.entry .tx {
  flex: 1;
  min-width: 0;
}
.entry .tx b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.entry .tx span {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  line-height: 1.4;
}
.entry .chev {
  flex: 0 0 16px;
  color: #c3bdb0;
  font-size: 16px;
}

/* ============ 徽标（浅底小圆角，照截图） ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 9px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: none;
  white-space: nowrap;
}
.badge.amber {
  color: #b97a1f;
  background: #fdf0dc;
}
.badge.green {
  color: #1e7e34;
  background: #e6f4ea;
}
.badge.red {
  color: #c0392b;
  background: #fdeaea;
}
.badge.indigo {
  color: #4a5a9a;
  background: #e8eef8;
}
.badge.plain {
  color: var(--ink-soft);
  background: #eef0f6;
}

/* ============ 表单 ============ */
.field {
  display: block;
  margin-top: var(--gap-ctl);
}
.field > label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid #dcd7cc;
  border-radius: 10px;
  background: #fff;
  font-size: 16px; /* iOS 防缩放 */
  outline: none;
}
.input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(46, 58, 104, 0.1);
}
.input:disabled {
  background: #f6f4ef;
  color: #a9a49a;
}
textarea.input {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-ctl);
}

/* chips 单选/多选 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid #d5d9e4;
  background: #fff;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.chip[aria-pressed='true'] {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
  font-weight: 600;
}
.chip.bad[aria-pressed='true'] {
  background: var(--red);
  border-color: var(--red);
}
.chip:disabled {
  opacity: 0.5;
}

/* ============ 按钮 ============ */
.btn {
  width: 100%;
  min-height: var(--tap);
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 10px 14px;
}
.btn.primary {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
}
.btn.primary:disabled {
  background: #b9bcc9;
  cursor: not-allowed;
}
.btn.pass {
  background: var(--green);
  color: #fff;
}
.btn.pass:disabled {
  background: #b9c6c2;
  cursor: not-allowed;
}
.btn.danger {
  background: #fff;
  border-color: var(--red);
  color: var(--red);
}
.btn.danger.armed {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn.ghost {
  background: #fff;
  border-color: #dcd7cc;
  color: var(--ink);
}
.btn.sm {
  min-height: 36px;
  font-size: 13px;
  width: auto;
  padding: 6px 12px;
}
.btn-row {
  display: flex;
  gap: var(--gap-ctl);
}

/* 吸底操作条 */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: rgba(244, 242, 236, 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.dock-inner {
  max-width: 448px;
  margin: 0 auto;
}
.dock-note {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

/* ============ 步骤条 ============ */
.steps {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.steps::-webkit-scrollbar {
  display: none;
}
.step {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.step.done {
  border-color: #c2ddd6;
  background: #e7f1ee;
  color: #22463f;
}
.step.now {
  border-color: var(--indigo);
  background: var(--sel);
  color: #26325e;
  font-weight: 600;
}

/* ============ 条码 chips（四态） ============ */
.code-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.code-chip {
  position: relative;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid #dcd7cc;
  background: #fff;
  font-size: 13.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor: pointer;
  padding: 8px 20px 8px 10px;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.code-chip .tick {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #fff;
}
.code-chip[data-state='selected'] {
  background: #2e3a68;
  border-color: #2e3a68;
  color: #fff;
  font-weight: 600;
}
.code-chip[data-state='inspected'] {
  background: #dcefe6;
  border-color: #a9d3c1;
  color: #1f463d;
}
.code-chip[data-state='both'] {
  background: #3d8a5f;
  border-color: #3d8a5f;
  color: #fff;
  font-weight: 600;
}
.code-chip[data-state='returned'] {
  background: #f6f4ef;
  border-color: var(--line);
  color: #b3ada2;
  text-decoration: line-through;
  cursor: not-allowed;
}

/* ============ 检验卡 ============ */
.qc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.qc-card + .qc-card {
  margin-top: var(--gap-block);
}
.qc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.qc-head .idx {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--sel);
  color: var(--indigo);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qc-head .code {
  font-size: 14.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
}
.qc-head .spacer {
  flex: 1;
}

/* ============ 留证照片 ============ */
.shot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--gap-ctl);
}
.shot .thumb {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px dashed #cfc9bc;
  background: #faf9f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b8b2a6;
  font-size: 10.5px;
  overflow: hidden;
}
.shot .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shot .meta {
  flex: 1;
  min-width: 0;
}
.shot .meta b {
  display: block;
  font-size: 13px;
  font-weight: 600;
}
.shot .meta span {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.shot .acts {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ============ 表格（核对清单） ============ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl th {
  text-align: left;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 11.5px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.tbl td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
.tbl td.over {
  color: var(--red);
  font-weight: 700;
}
.tbl tr.over-row {
  background: #fdf6f6;
}
.tbl .num {
  text-align: right;
}

/* ============ 提示条 ============ */
.notice {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: var(--gap-ctl);
}
.notice.info {
  background: var(--sel);
  color: #26325e;
}
.notice.ok {
  background: #e7f1ee;
  color: #1f463d;
}
.notice.warn {
  background: #fbf1de;
  color: #7a4a10;
}
.notice.bad {
  background: #fbe9e9;
  color: #7f2626;
}

/* ============ 汇总数字块 ============ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: var(--gap-ctl);
}
.stat {
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.stat .k {
  font-size: 11.5px;
  color: var(--ink-soft);
}
.stat .v {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin-top: 2px;
}
.stat .v.small {
  font-size: 13px;
}

/* ============ 进度条 ============ */
.bar {
  height: 6px;
  border-radius: 999px;
  background: #ece9e1;
  overflow: hidden;
  margin-top: 8px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--indigo);
  transition: width 0.25s;
}

/* ============ 底部 Tab ============ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar-inner {
  max-width: 448px;
  margin: 0 auto;
  display: flex;
  width: 100%;
}
.tabbar a {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-decoration: none;
}
.tabbar a.on {
  color: var(--indigo);
  font-weight: 600;
}
.tabbar a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ 空态 ============ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
  font-size: 13px;
}
.empty b {
  display: block;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 6px;
}

/* 滚动吸附定位高亮 */
.flash {
  animation: flash 0.9s ease-in-out 2;
  outline: 2px solid rgba(194, 69, 45, 0.5);
  outline-offset: 2px;
  border-radius: var(--radius);
}
@keyframes flash {
  50% {
    outline-color: rgba(194, 69, 45, 0.15);
  }
}

/* ============ V2 进度卡组件 ============ */

/* 进度条 */
.pbar {
  height: 7px;
  border-radius: 4px;
  background: #e6e8f0;
  overflow: hidden;
}
.pbar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--indigo), var(--indigo-deep));
}
.pbar i.grn { background: linear-gradient(90deg, #1d7a3f, #4aa06a); }
.pbar i.red { background: linear-gradient(90deg, #c0392b, #e06a5a); }

/* 大数字统计行（hero 内） */
.hero-nums {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.hero-nums > div {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 8px 12px;
}
.hero-nums b {
  display: block;
  font-size: 19px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.hero-nums span {
  font-size: 10px;
  opacity: 0.8;
}

/* 步进器（点数用） */
.stepper {
  display: flex;
  align-items: center;
  border: 1.5px solid #d5d9e4;
  border-radius: 10px;
  overflow: hidden;
}
.stepper button {
  width: 34px;
  height: 34px;
  border: 0;
  background: #f2f3f8;
  font-size: 17px;
  font-weight: 800;
  color: var(--indigo);
}
.stepper .val {
  width: 46px;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* 差额小徽标 */
.dif {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  min-width: 36px;
  text-align: center;
}
.dif.n { background: #fbe4e4; color: #a33; }
.dif.p { background: #fdf0dc; color: #a8650b; }
.dif.z { background: #e8f0ea; color: #1d7a3f; }

/* 尺码格（4 列） */
.szgrid {
  display: flex;
  gap: 6px;
}
.szgrid > div {
  flex: 1;
  background: #f6f7fb;
  border-radius: 10px;
  text-align: center;
  padding: 7px 2px;
}
.szgrid .s { font-size: 10.5px; font-weight: 800; color: var(--indigo); }
.szgrid .n {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}
.szgrid .e { font-size: 9px; font-weight: 700; color: var(--red); }
.szgrid .e.ok { color: var(--green); }

/* 正常/异常 胶囊段（质检逐项勾） */
.seg {
  display: flex;
  border: 1.5px solid #d5d9e4;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.seg button {
  border: 0;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  color: var(--ink-soft);
}
.seg button.on-g { background: var(--green); color: #fff; }
.seg button.on-r { background: var(--red); color: #fff; }

/* 照片缩略（拍好可见，点开看大图） */
.shot {
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.shot .img {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
}
.shot .img.ok {
  background: linear-gradient(170deg, #9db4c9, #5d768f);
  color: #fff;
}
.shot .img.no {
  background: #e8eaf2;
  color: #7c86a8;
}
.shot .ts {
  position: absolute;
  bottom: 5px;
  left: 7px;
  font-size: 9px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
}
.shot .zoom {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 环节小条（卡片底部） */
.flowline {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.flowline b { color: var(--green); }
.flowline .hl { color: var(--red); font-weight: 800; }

/* 有底部 Tab 的页面：操作条(Dock)要让开 Tab，不能互相盖 */
.app-shell.has-tabs .dock { bottom: calc(54px + var(--safe-b)); }
.app-shell.has-tabs .page { padding-bottom: calc(158px + var(--safe-b)); }
