/* ============================================================
   工厂宇通生产管理系统 — 样式
   设计目标：车间环境（灰尘/手套/强光）下依然清晰、可单手操作
   ============================================================ */

:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --primary: #1d4ed8;
  --primary-soft: #dbeafe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --tap: 46px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

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

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

/* ---------------------------------------------------------- 布局 */

#app {
  min-height: 100%;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #0f172a;
  color: #fff;
  padding-top: calc(10px + env(safe-area-inset-top));
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.topbar .spacer {
  flex: 1;
}

.topbar .who {
  font-size: 12px;
  color: #cbd5e1;
  text-align: right;
  line-height: 1.2;
}

.topbar .who b {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.content {
  padding: 14px 14px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 2px 14px;
}

.page-title h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

.page-title .sub {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* ---------------------------------------------------------- 底部导航 */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0 7px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.bottom-nav a .ico {
  font-size: 19px;
  line-height: 1;
}

.bottom-nav a.active {
  color: var(--primary);
}

.bottom-nav a.active .ico {
  transform: translateY(-1px);
}

/* ---------------------------------------------------------- 卡片 */

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

.card.tight {
  padding: 0;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-head h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 700;
}

.card-head .more {
  margin-left: auto;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* 概览数字 */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 640px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.stat .value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat .unit {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 3px;
}

.stat .foot {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.stat.accent {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  border-color: transparent;
}

.stat.accent .label,
.stat.accent .foot,
.stat.accent .unit {
  color: rgba(255, 255, 255, 0.82);
}

.stat.warn {
  border-color: #fecd8b;
  background: var(--warn-soft);
}

.stat.warn .value {
  color: var(--warn);
}

/* ---------------------------------------------------------- 列表 */

.list {
  display: flex;
  flex-direction: column;
}

.list > * + * {
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.row:active {
  background: var(--surface-2);
}

.row .main {
  flex: 1;
  min-width: 0;
}

.row .t1 {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .t2 {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 17px;
  text-align: right;
}

.row .num small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

/* ---------------------------------------------------------- 徽章 */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.info {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.gray {
  background: #e2e8f0;
  color: #475569;
}

/* ---------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, background 0.15s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.28);
}

.btn-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 54px;
  font-size: 17px;
  border-radius: 14px;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn-group .btn {
  flex: 1;
}

/* ---------------------------------------------------------- 表单 */

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  outline: none;
  font-size: 15px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.textarea {
  min-height: 80px;
  resize: vertical;
}

.input-lg {
  min-height: 58px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
  text-align: center;
}

.input-row {
  display: flex;
  gap: 10px;
}

.input-row > * {
  flex: 1;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

/* 数量步进器 */
.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.stepper button {
  width: 56px;
  border: 0;
  background: var(--surface-2);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.stepper button:active {
  background: #e2e8f0;
}

.stepper input {
  flex: 1;
  border: 0;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  min-width: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- 进度 */

/* 检验报告照片 */
.photo-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.photo-strip img,
.photo-thumb {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  cursor: pointer;
  background: var(--surface-2);
}

.photo-thumb.add {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.photo-wrap {
  position: relative;
}

.photo-wrap .del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: var(--danger);
  color: #fff;
  font-size: 13px;
  line-height: 22px;
  cursor: pointer;
  padding: 0;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 20px;
  cursor: zoom-out;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* 检验项目行 */
.item-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 40px 28px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.item-row .input {
  min-height: 38px;
  padding: 6px 8px;
  font-size: 13px;
}

.item-row .ok-box {
  width: 22px;
  height: 22px;
  margin: 0 auto;
}

/* 分步演示：跳转后的「下一步 / 继续」浮条 */
.demo-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  /* 抬高到 toast 之上（toast 在 84px，会盖住底下） */
  bottom: calc(84px + 56px + env(safe-area-inset-bottom, 0px));
  z-index: 99;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.38);
  animation: demo-bar-in 0.22s ease-out;
}

.demo-bar .db-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.demo-bar .db-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: 0 0 auto;
}

.demo-bar .db-text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.demo-bar .db-x {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.demo-bar .db-next {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  opacity: 0.94;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-bar .db-go {
  background: #fff;
  color: var(--primary);
  border: 0;
  border-radius: 9px;
  padding: 7px 13px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex: 0 0 auto;
}

.demo-bar .db-go:disabled {
  opacity: 0.7;
}

@keyframes demo-bar-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 演示：顶部"正在做什么"的小药丸 */
.demo-pill {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.93);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 92vw;
}

.demo-pill.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.demo-pill .dp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex: 0 0 auto;
  animation: dp-pulse 1.2s infinite;
}

.demo-pill .dp-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes dp-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* 演示：被点到的元素闪一圈 */
.demo-hit {
  outline: 3px solid #f59e0b !important;
  outline-offset: 2px;
  border-radius: 10px;
  transition: outline-color 0.15s;
}

/* 演示：正在输入的框 */
.demo-typing {
  outline: 2px solid #22c55e !important;
  outline-offset: 1px;
  background: #f0fdf4 !important;
}

/* 新手教程卡片 */
.tuto-card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
  z-index: 101;
  background: #0f172a;
  color: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.45);
  animation: demo-bar-in 0.25s ease-out;
}

.tuto-card .tc-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuto-card .tc-badge {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  flex: 0 0 auto;
}

.tuto-card .tc-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
}

.tuto-card .tc-x {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.tuto-card .tc-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.6;
}

.tuto-card .tc-why {
  margin-top: 6px;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
}

.tuto-card .tc-go {
  margin-top: 10px;
}

/* 教程指路的绿圈 */
.tuto-hit {
  outline: 3px solid #22c55e !important;
  outline-offset: 3px;
  border-radius: 10px;
  animation: tuto-pulse 1.4s infinite;
}

@keyframes tuto-pulse {
  0%, 100% { outline-color: #22c55e; }
  50% { outline-color: #86efac; }
}

/* 工序异常提示 */
.alert-box {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.55;
}

.alert-box.alert-blocked {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-box.alert-resolved {
  background: var(--surface-2);
  color: #475569;
  border: 1px solid var(--line);
}

.alert-box .small {
  font-size: 12px;
  margin-top: 2px;
}

/* 工序异常提示 */

.progress {
  height: 7px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 7px;
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  transition: width 0.3s ease;
}

.progress.done > i {
  background: linear-gradient(90deg, #15803d, #22c55e);
}

/* ---------------------------------------------------------- 工序流程 */

.flow {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 14px;
}

.step:last-child {
  padding-bottom: 0;
}

.step .rail {
  width: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.step .node {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
  z-index: 1;
}

.step .line {
  flex: 1;
  width: 2px;
  background: var(--line);
  margin-top: 2px;
}

.step:last-child .line {
  display: none;
}

.step.done .node {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.step.done .line {
  background: var(--ok);
}

.step.doing .node {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.16);
}

.step.blocked .node {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.step .body {
  flex: 1;
  min-width: 0;
}

.step .name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.step.done .name {
  color: var(--ink-2);
}

.step .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.step .ops {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.step .ops .btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

/* ---------------------------------------------------------- 扫码 */

.scan-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
}

.scan-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  inset: 14%;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.scan-frame::before,
.scan-frame::after,
.scan-frame > i::before,
.scan-frame > i::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  border: 3px solid #22c55e;
}

.scan-frame::before {
  top: -3px;
  left: -3px;
  border-right: 0;
  border-bottom: 0;
  border-top-left-radius: 10px;
}

.scan-frame::after {
  top: -3px;
  right: -3px;
  border-left: 0;
  border-bottom: 0;
  border-top-right-radius: 10px;
}

.scan-frame > i::before {
  bottom: -3px;
  left: -3px;
  border-right: 0;
  border-top: 0;
  border-bottom-left-radius: 10px;
}

.scan-frame > i::after {
  bottom: -3px;
  right: -3px;
  border-left: 0;
  border-top: 0;
  border-bottom-right-radius: 10px;
}

.scan-hint {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 4px #000;
}

/* 扫到的零件卡 */
.part-card {
  border: 2px solid var(--primary);
  background: linear-gradient(180deg, #eff6ff, #fff 60%);
}

.part-card .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.part-card .pname {
  font-size: 20px;
  font-weight: 700;
  margin: 2px 0;
}

.part-card .pspec {
  font-size: 13px;
  color: var(--muted);
}

.stock-big {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
}

.stock-big b {
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stock-big span {
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------- 弹层 */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
  animation: fade 0.14s ease;
}

@media (min-width: 640px) {
  .overlay {
    align-items: center;
    padding: 20px;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow: auto;
  animation: rise 0.18s ease;
}

@media (min-width: 640px) {
  .sheet {
    border-radius: 18px;
    padding-bottom: 18px;
  }
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
}

.sheet h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.sheet .sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.sheet .sheet-actions .btn {
  flex: 1;
}

/* ---------------------------------------------------------- 提示 */

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.3);
  animation: toastIn 0.18s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.ok {
  background: #15803d;
}

.toast.err {
  background: #b91c1c;
}

@keyframes toastIn {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* ---------------------------------------------------------- 空状态 */

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
  font-size: 13px;
}

.empty .big {
  font-size: 30px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ---------------------------------------------------------- 工具类 */

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.between {
  justify-content: space-between;
}

.wrap {
  flex-wrap: wrap;
}

.mt8 {
  margin-top: 8px;
}

.mt12 {
  margin-top: 12px;
}

.mt16 {
  margin-top: 16px;
}

.right {
  margin-left: auto;
}

.nowrap {
  white-space: nowrap;
}

.seg {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow-x: auto;
}

.seg button {
  flex: 1;
  min-height: 38px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  padding: 0 10px;
}

.seg button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* ---------------------------------------------------------- 看板 */

.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.kanban .col {
  flex: 0 0 240px;
  scroll-snap-align: start;
  background: #e8edf5;
  border-radius: 12px;
  padding: 10px;
}

.kanban .col h4 {
  margin: 0 0 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  color: var(--ink-2);
}

.kanban .kcard {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
  cursor: pointer;
  border-left: 3px solid var(--primary);
}

.kanban .kcard .no {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.kanban .kcard .pd {
  font-weight: 600;
  font-size: 13px;
  margin: 2px 0 6px;
}

/* ---------------------------------------------------------- 标签打印 */

.label-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  row-gap: 10px;
  margin-bottom: 12px;
}

.label-preview-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.label-sheet {
  background: #fff;
  padding: 8mm;
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0;
  width: 198mm;
  max-width: none;
}

.label-cell {
  border: 1px dashed #cbd5e1;
  padding: 3mm;
  display: flex;
  gap: 3mm;
  align-items: center;
  overflow: hidden;
  min-height: 26mm;
}

.label-cell img {
  width: 16mm;
  height: 16mm;
  display: block;
  flex-shrink: 0;
}

.label-cell .info {
  min-width: 0;
  flex: 1;
}

.label-cell .lcode {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.3px;
  word-break: break-all;
}

.label-cell .lname {
  font-size: 10px;
  margin-top: 1px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.label-cell .lspec {
  font-size: 8px;
  color: #64748b;
  margin-top: 1px;
}

/* 条形码版式 */
.label-cell.fmt-bar,
.label-cell.fmt-both {
  flex-direction: column;
  gap: 2mm;
}

.label-cell .lbar {
  width: 100% !important;
  height: auto !important;
  display: block;
}

.label-cell.fmt-bar .info,
.label-cell.fmt-both .info {
  width: 100%;
}

/* 条码 + 二维码 */
.label-cell.fmt-both .both-row {
  display: flex;
  gap: 2.5mm;
  align-items: center;
  width: 100%;
}

.label-cell.fmt-both .lqr {
  width: 13mm !important;
  height: 13mm !important;
  flex: 0 0 auto;
}

/* 登录页 */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a, #0f172a 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 21px;
}

.login-card .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ---------------------------------------------------------- 打印 */

@media print {
  @page {
    size: A4;
    margin: 6mm;
  }

  body {
    background: #fff;
  }

  #app {
    padding: 0;
  }

  .topbar,
  .bottom-nav,
  .toast-wrap,
  .no-print,
  .page-title {
    display: none !important;
  }

  .content {
    padding: 0;
    max-width: none;
  }

  .label-sheet {
    box-shadow: none;
    padding: 0;
    border-radius: 0;
    width: 100%;
  }

  .label-preview-wrap {
    overflow: visible;
  }

  .label-cell {
    border: 1px solid #e2e8f0;
    break-inside: avoid;
  }
}

/* ============================================================
   车间工位机（免登录全屏）
   ============================================================ */

body.kiosk-mode .app-nav,
body.kiosk-mode .topbar,
body.kiosk-mode .demo-bar,
body.kiosk-mode .tuto-card {
  display: none !important;
}

body.kiosk-mode {
  background: #0f172a;
}

.kiosk {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0f172a;
  color: #fff;
}

.kiosk .k-head {
  font-size: 20px;
  font-weight: 800;
  padding: 6px 2px 2px;
}

.kiosk .k-sec {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 10px;
}

.kiosk .k-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.kiosk .k-chip {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.kiosk .k-chip.on {
  background: #2563eb;
  border-color: #2563eb;
}

.kiosk .k-go {
  margin-top: 18px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: #2563eb;
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
}

.kiosk .k-go:disabled {
  opacity: 0.35;
}

.kiosk .k-foot {
  margin-top: auto;
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.4);
  padding-top: 10px;
}

.kiosk .k-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
}

.kiosk .k-who {
  font-size: 18px;
  font-weight: 700;
}

.kiosk .k-at {
  font-size: 14px;
  color: #93c5fd;
  font-weight: 600;
}

.kiosk .k-switch {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.kiosk .k-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.kiosk .k-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 17px;
  outline: none;
}

.kiosk .k-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.kiosk .k-btn {
  padding: 14px 22px;
  border: 0;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.kiosk .k-btn-sm {
  padding: 14px 18px;
}

.kiosk .k-btn-line {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  margin-top: 12px;
}

.kiosk .k-card {
  background: #fff;
  color: #0f172a;
  border-radius: 16px;
  padding: 16px;
  margin-top: 4px;
}

.kiosk .k-order {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}

.kiosk .k-product {
  font-size: 22px;
  font-weight: 800;
  margin-top: 2px;
}

.kiosk .k-meta {
  font-size: 13px;
  color: #64748b;
  margin-top: 2px;
}

.kiosk .k-step-label {
  margin-top: 14px;
  font-size: 12.5px;
  color: #64748b;
}

.kiosk .k-step {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
}

.kiosk .k-shift {
  margin-top: 4px;
  font-size: 13px;
  color: #475569;
}

.kiosk .k-done {
  margin-top: 14px;
  font-size: 18px;
  font-weight: 700;
  color: #16a34a;
}

.kiosk .k-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.75);
  gap: 6px;
  min-height: 260px;
}
/* 白色卡片里的输入框（数量）要浅色 */
.kiosk .k-card .k-row {
  margin-top: 14px;
}

.kiosk .k-card .k-input {
  background: #f1f5f9;
  color: #0f172a;
  border: 1.5px solid #cbd5e1;
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  padding: 12px;
}

.kiosk .k-card .k-input::placeholder {
  color: #94a3b8;
  font-weight: 500;
}

.kiosk .k-card .k-btn {
  font-size: 18px;
  min-width: 96px;
}

.kiosk .k-card .k-btn-line {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
  margin-top: 10px;
  font-size: 15px;
  padding: 10px;
}
/* ---------- 工位机：机台快捷切换 ---------- */
.kiosk .k-stabar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  -webkit-overflow-scrolling: touch;
}

.kiosk .k-mini {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.kiosk .k-mini.on {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 700;
}

/* ---------- 机台二维码打印页 ---------- */
.qr-sheet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.qr-cell {
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  background: #fff;
}

.qr-cell img {
  width: 100%;
  max-width: 150px;
  height: auto;
}

.qr-cell-name {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
  color: #0f172a;
}

.qr-cell-code {
  font-size: 11px;
  color: #94a3b8;
  font-family: ui-monospace, monospace;
}

@media print {
  body.kiosk-mode,
  .app-nav,
  .topbar,
  .page-title,
  #btn-print-st,
  .toast,
  .demo-bar {
    display: none !important;
  }

  .qr-sheet {
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }

  .qr-cell {
    border: 1px dashed #999;
    break-inside: avoid;
    padding: 10mm 4mm;
  }

  .qr-cell img {
    max-width: 70mm;
  }
}
/* ---------- 工序删除按钮 ---------- */
.step {
  position: relative;
}

.step-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.step-del:active {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
/* ---------- 工序工具条（上移 / 下移 / 删） ---------- */
.step-tools {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
}

.step-tools button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.step-tools button:active {
  background: #e2e8f0;
}

.step-tools button.danger:active {
  background: #fee2e2;
  color: #b91c1c;
}
/* ---------- 工序模板勾选 ---------- */
.tpl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tpl-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.tpl-chip.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tpl-chip b {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 11px;
  margin-right: 2px;
}

/* ---------- 订单批量选择 ---------- */
.row.bulk {
  position: relative;
  padding-left: 44px;
}

.bulk-box {
  position: absolute;
  left: 12px;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #fff;
}

.row.picked {
  background: #eff6ff;
  border-color: var(--primary);
}

.row.picked .bulk-box {
  background: var(--primary);
  border-color: var(--primary);
}
/* ---------- 客户分组标题 ---------- */
.cust-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1.5px solid var(--line);
  margin-top: 10px;
}

.cust-head:first-child {
  margin-top: 0;
}
/* ---------- 流程图 ---------- */
.fm-strip {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 4px 14px; align-items: stretch;
  -webkit-overflow-scrolling: touch;
}
.fm-chip {
  flex: 0 0 92px; background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; text-align: center;
}
.fm-cn { font-size: 15px; font-weight: 800; color: var(--primary); }
.fm-ct { font-size: 13px; font-weight: 700; margin-top: 2px; }
.fm-cs { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.fm-carrow { align-self: center; color: #cbd5e1; font-size: 16px; flex: 0 0 auto; }

.fm-lanes { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.fm-lane {
  flex: 0 0 190px; background: #fff; border: 1px solid var(--line); border-left: 4px solid;
  border-radius: 12px; padding: 10px;
}
.fm-lane-h { font-weight: 800; font-size: 13px; margin-bottom: 8px; }
.fm-step { background: #f8fafc; border-radius: 8px; padding: 7px 8px; }
.fm-step-t { font-size: 13px; font-weight: 700; }
.fm-step-s { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.fm-arrow { text-align: center; color: #cbd5e1; font-size: 12px; line-height: 1.6; }

.fm-op { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fm-op:last-of-type { border-bottom: none; }
.fm-op-n {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.fm-op-t { font-weight: 700; font-size: 14px; }
.fm-op-s { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
/* 工位机：机台分组 */
.k-station-group { margin-bottom: 10px; }
.k-station-label {
  font-size: 12px; color: #94a3b8; margin: 0 0 6px 2px;
  display: flex; align-items: baseline; gap: 8px;
}
.k-station-count { font-size: 11px; opacity: .7; }
/* 库存分配 */
.alloc-card { padding: 12px 14px; }
.alloc-list { margin-top: 10px; border-top: 1px solid var(--line); }
.alloc-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px dashed var(--line);
}
.alloc-row:last-child { border-bottom: none; }
.alloc-o .t1 { font-size: 13px; font-weight: 600; }
.alloc-o .t2 { font-size: 11px; color: var(--muted); margin-top: 2px; }
.alloc-n { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
/* 库存分配：要补做 */
.alloc-make {
  margin-top: 8px; padding: 6px 10px; border-radius: 8px;
  background: #fef2f2; color: #b91c1c; font-size: 12px;
}
.alloc-make b { font-size: 14px; }
/* 顶部栏 logo */
.topbar .brand .brand-logo {
  width: 26px;
  height: 26px;
  display: block;
  border-radius: 50%;
}
/* 图纸 + 二维码（打印用） */
.draw-sheet { margin-top: 12px; }
.draw-page {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}
.draw-img { display: block; width: 100%; height: auto; }
.draw-pdf { display: block; width: 100%; height: 70vh; border: 0; }
.draw-qr {
  position: absolute; top: 10px; right: 10px;
  background: #fff; padding: 6px; border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15,23,42,.15);
  text-align: center;
}
.draw-qr img { display: block; width: 84px; height: 84px; }
.draw-qr-cap { font-size: 9px; margin-top: 2px; color: #0f172a; word-break: break-all; max-width: 84px; }

@media print {
  .draw-page { border: 0; page-break-after: always; border-radius: 0; margin: 0; }
  .draw-pdf { height: 96vh; }
  .draw-qr { top: 6mm; right: 6mm; box-shadow: none; }
  .draw-qr img { width: 26mm; height: 26mm; }
  .draw-qr-cap { max-width: 26mm; font-size: 7pt; }
}