:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --in: #16a34a;
  --in-50: #f0fdf4;
  --out: #ea580c;
  --out-50: #fff7ed;
  --transfer: #2563eb;
  --check: #7c3aed;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warning: #d97706;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 720px;
  --header-h: 52px;
  --bottom-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; position: relative; }

.page {
  min-height: 100vh;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--bottom-h) + var(--safe-bottom));
  background: var(--bg);
}
.page.no-bottom { padding-bottom: 16px; }

/* ---------------- 顶部导航 ---------------- */
.appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.appbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-2); font-size: 22px;
  cursor: pointer;
}
.appbar-action {
  margin-right: 6px;
  padding: 7px 12px;
  font-size: 14px; font-weight: 600;
  color: var(--primary); background: none; border: none;
}
.appbar-actions { display: flex; align-items: center; flex-shrink: 0; }
.appbar-actions .appbar-action { margin-right: 0; }
/* 标题栏右侧的业务线切换下拉（新建任务 / 产品管理，需求 8.2/9） */
.appbar-actions .select {
  max-width: 150px; height: 34px; padding: 0 30px 0 10px;
  font-size: 13px; background-color: var(--bg);
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.appbar-inner { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 12px; display: flex; align-items: center; gap: 8px; }

/* 标题栏仓库选择 pill（出入库/调拨页，点击弹出仓库列表） */
.wh-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 170px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.wh-pill:active { border-color: var(--primary); }
.wh-pill .wh-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wh-pill .caret { font-size: 10px; flex: none; }
.wh-arrow { color: var(--text-3); font-size: 14px; flex: none; }
/* 调拨页标题栏放两个 pill + 箭头，小屏必须允许收缩，否则会横向溢出 */
.appbar-actions .wh-pill { flex-shrink: 1; min-width: 0; }

/* ---------------- 底部导航 ---------------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: calc(var(--bottom-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex;
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-2); text-decoration: none; font-size: 11px;
}
.bottom-nav a.active { color: var(--primary); background: var(--primary-50); }
.bottom-nav .icon { font-size: 22px; line-height: 1; }

/* ---------------- 通用布局 ---------------- */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 12px; }
.section { margin-bottom: 14px; }

/* ---------------- 固定头尾的列表页（分类界面 / 产品界面） ----------------
   顶部搜索栏、底部操作按钮固定不动，仅中间 .list-scroll 局部滚动。 */
.listing-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* 移动端地址栏收起/展开时以动态视口为准 */
  min-height: 0;
}
.listing-page .listing-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 0;
}
.listing-page .search-box { flex: none; }
.listing-page .list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.listing-page .fixed-actions {
  flex: none;
  padding: 10px 0 4px;
  background: var(--bg);
}
/* 吸底 fixed 按钮遮住列表底部：滚动区预留出按钮的高度 */
.list-scroll.with-sticky-btn { padding-bottom: calc(76px + var(--safe-bottom)); }
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin: 0 0 8px 4px; letter-spacing: 0.02em;
}

/* ---------------- 功能主菜单（登录后落地页） ---------------- */
.menu-page .menu-list { margin-top: 8px; }
.menu-page .menu-entry { padding: 18px 14px; }
.menu-page .menu-icon {
  width: 44px; height: 44px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  background: var(--primary-50);
  border-radius: 12px;
  margin-right: 4px;
}
.menu-page .menu-entry .title { font-size: 16px; font-weight: 600; }
.menu-page .menu-hint {
  text-align: center; color: var(--text-2);
  font-size: 12px; margin: 16px 0 0;
}

/* ---------------- 列表/卡片 ---------------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: #f9fafb; }
/* 列表行多是 <a href>：禁止浏览器把它当链接拖起来，否则拖动排序会被原生拖拽抢走 */
.list-row { -webkit-user-drag: none; }

/* 长按删除：屏蔽系统菜单与文字选择，长按命中时给视觉反馈 */
.list-row.long-pressable {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}
.list-row.pressing {
  background: var(--danger-50);
  transition: background .12s ease;
}
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-size: 16px; font-weight: 500; word-break: break-all; }
.list-row .sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.list-row .arrow { color: var(--text-3); font-size: 18px; }
.list-row .extra { text-align: right; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-2); font-size: 14px; }
.empty .icon { font-size: 36px; margin-bottom: 8px; display: block; }

/* ---------------- 长按防护（全局） ----------------
 * 部分移动端浏览器长按按钮类元素会触发系统原生行为：
 * Android 弹出 contextmenu 操作菜单、文字被选中（放大镜）、iOS 呼出复制/预览菜单。
 * 这里对交互元素统一关闭文字选中与系统呼出菜单；
 * 输入框与正文内容不受影响，仍可长按选择/复制。
 */
button, .btn, .fab, .list-row, .bottom-nav a, .wh-pill, .drag-handle, .sheet .row {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* 所有链接（含未套 .list-row 的）同样关闭 iOS 长按呼出菜单与原生拖拽 */
a { -webkit-touch-callout: none; -webkit-user-drag: none; }
/* 按钮类消除双击缩放/300ms 点击延迟干扰 */
button, .btn, .fab, .bottom-nav a { touch-action: manipulation; }
/* 输入控件内文本必须保持可选可编辑（部分内核会继承父级的 user-select） */
button input, button textarea, .list-row input, .list-row textarea {
  -webkit-user-select: auto; user-select: auto;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 16px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:disabled { background: #93c5fd; }
.btn.secondary { background: var(--primary-50); color: var(--primary); }
.btn.outline { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger-50); color: var(--danger); }
.btn.success { background: var(--in); color: #fff; }
.btn-warning { background: var(--out); color: #fff; }
.btn.fixed-bottom {
  position: fixed; bottom: calc(var(--bottom-h) + var(--safe-bottom));
  left: 0; right: 0; z-index: 101;
  border-radius: 0; padding: 16px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
/* 无底部导航的页面（盘点/出入库/调拨/确认单）：按钮直接吸到视口底 */
.btn.sticky-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 101;
  border-radius: 0; padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  background: var(--primary);
}

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

.fab {
  position: fixed; right: 16px; bottom: calc(72px + var(--safe-bottom));
  z-index: 99;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--primary); color: #fff;
  border: none; font-size: 26px; box-shadow: 0 4px 12px rgba(37,99,235,0.35);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 14px; font-weight: 500;
  color: var(--text-2); margin-bottom: 6px;
}
.input, .select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 16px; background: var(--card); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.input::placeholder, textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { background: var(--bg); color: var(--text-2); cursor: not-allowed; }
select.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 38px; }
textarea { min-height: 80px; resize: vertical; }

.field-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.page-tip { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 12px; }
.sub { font-size: 13px; color: var(--text-2); }

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

.input-qty {
  text-align: center; font-weight: 600; font-size: 18px;
}

/* ---------------- 数量输入：[ 3 ]件 [ 5 ]个 ---------------- */
.qty-field { margin-top: 2px; }
.qty-input { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.qty-input .bracket {
  color: var(--text-3); font-size: 24px; font-weight: 300; line-height: 1;
  user-select: none; -webkit-user-select: none;
}
.qty-input .qty-num {
  width: 74px; text-align: center; font-weight: 700; font-size: 18px;
  padding: 10px 6px; margin: 0 2px;
}
.qty-input .qty-unit { font-size: 15px; color: var(--text-2); margin: 0 10px 0 2px; }
.qty-input .qty-num:disabled { background: var(--bg); color: var(--text-3); }
.qty-hint { font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* ---------------- 价格项（名称 + 内容，只能添加不能删除） ---------------- */
.price-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.price-row .price-name { flex: 1; min-width: 0; }
.price-row .price-value { flex: 1.4; min-width: 0; }
.price-empty { font-size: 13px; color: var(--text-3); padding: 4px 0 10px; }

/* ---------------- 搜索 ---------------- */
.search-box {
  position: relative; margin-bottom: 12px;
}
/* 出入库/调拨页搜索面板：去掉卡片标题、紧凑，固定悬浮在视口（listing 布局中 flex:none） */
.search-panel { flex: none; }
.search-panel .search-box { margin-bottom: 8px; }
.search-panel .search-box input { padding-top: 10px; padding-bottom: 10px; }
.search-suggest {
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: var(--radius);
}
.search-box .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 18px;
}
.search-box input {
  width: 100%; padding: 12px 14px 12px 40px;
  border: 1px solid var(--line); border-radius: 22px;
  font-size: 16px; background: var(--card);
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box .clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--line); border: none; border-radius: 50%;
  width: 22px; height: 22px; color: var(--text-2); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------------- 库存数字展示 ---------------- */
.qty-display { font-size: 22px; font-weight: 700; color: var(--text); white-space: nowrap; }
.qty-display.zero { color: var(--text-2); }
.qty-label { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.qty-main { display: flex; align-items: baseline; gap: 6px; }
.unit-label { font-size: 13px; color: var(--text-2); }

/* 产品详情页价格值：与库存数量同级的视觉权重（大字加粗、右对齐不换行） */
.price-value { font-size: 18px; font-weight: 700; color: var(--text); white-space: nowrap; }

/* ---------------- 产品行（分类页） ---------------- */
.product-row { position: relative; }
.product-row .no { color: var(--text-3); font-size: 13px; min-width: 26px; }
.product-row .info { flex: 1; min-width: 0; }
.product-row .name { font-size: 17px; font-weight: 500; word-break: break-all; }
.product-row .meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.product-row .per-case { font-size: 13px; color: var(--text-2); background: var(--bg); padding: 2px 8px; border-radius: 10px; }
.product-row .qty { text-align: right; min-width: 90px; }

/* 搜索结果卡片：标题行（名称 + 合计）+ 仓库行列表（>2 行可展开/收起） */
.search-card { align-items: flex-start; }
.search-card .thumb { margin-top: 2px; }
.search-card .arrow { margin-top: 6px; }
.search-card .main { display: flex; flex-direction: column; gap: 6px; }
.search-card .title-row { display: flex; align-items: baseline; gap: 10px; }
.search-card .title-row .title { flex: 1; min-width: 0; }
.search-card .title-row .total {
  flex: none; font-size: 13px; font-weight: 600;
  color: var(--text-2); background: var(--bg);
  padding: 2px 8px; border-radius: 10px;
}
.search-card .stock-rows { display: flex; flex-direction: column; gap: 4px; }
.search-card .stock-line { display: flex; align-items: baseline; gap: 10px; font-size: 14px; line-height: 1.5; }
.search-card .stock-line .stock-name { flex: 1; min-width: 0; color: var(--text-2); word-break: break-all; }
.search-card .stock-line .stock-qty { flex: none; font-weight: 600; color: var(--text); }
.search-card .expand-btn {
  align-self: flex-start;
  background: none; border: none; padding: 2px 0; margin: 0;
  color: var(--primary); font-size: 13px; font-weight: 600;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.search-card .expand-btn:active { opacity: 0.7; }
.drag-handle {
  width: 32px; height: 44px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 18px; cursor: grab; touch-action: none; flex-shrink: 0;
}
.drag-handle:active { cursor: grabbing; }
.product-row .drag-handle { margin-right: 2px; }
.stocktake-card .drag-handle { margin-left: 2px; }

/* 三条直线组成的排序手柄：只用于长按上下拖动排序，轻点不触发任何跳转 */
.drag-handle.bars {
  flex-direction: column; gap: 4px;
  width: 36px; height: 46px;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.drag-handle.bars i {
  display: block;
  width: 18px; height: 2px; border-radius: 2px;
  background: currentColor;
  opacity: 0.75;
}
.drag-handle.bars:active i { background: var(--primary); opacity: 1; }
.list-row.sort-chosen .drag-handle.bars i { background: var(--primary); opacity: 1; }

/* ---------------- 图片 ---------------- */
.thumb {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg); flex-shrink: 0;
}
.thumb-lg { width: 100%; max-width: 240px; height: auto; border-radius: var(--radius); background: var(--bg); }

/* ---------------- 盘点卡片 ---------------- */
.stocktake-card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
  position: relative;
}
.stocktake-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stocktake-card .sys-qty { color: var(--text-2); font-size: 14px; }
.stocktake-card .input-grid { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.stocktake-card .input-grid .field { margin: 0; flex: 1; }
.stocktake-card .input-grid .field label { font-size: 12px; margin-bottom: 3px; color: var(--text-2); }
.stocktake-card .input-grid input { text-align: center; padding: 10px; font-size: 17px; }
.stocktake-card .zero-btn { padding: 8px 12px; font-size: 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--text-2); }
.stocktake-card .zero-btn.active { background: var(--danger-50); color: var(--danger); border-color: var(--danger); }
.stocktake-card .diff { font-size: 14px; font-weight: 600; }
.stocktake-card .diff.pos { color: var(--in); }
.stocktake-card .diff.neg { color: var(--out); }

/* ---------------- 数量输入表单（入库/出库/调拨） ---------------- */
.sheet-line {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.sheet-line .header { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sheet-line .title { flex: 1; font-weight: 500; }
.sheet-line .remove { color: var(--danger); font-size: 13px; border: none; background: none; }
.sheet-line .qty-row { display: flex; align-items: flex-end; gap: 10px; }
.sheet-line .qty-row .field { flex: 1; margin: 0; }

/* ---------------- 二次确认 ---------------- */
/* ---------------- 确认单页（flex 列：标题栏 + 中间滚动 + 吸底按钮） ---------------- */
.confirm-body {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  min-height: 0;
  background: var(--bg);
  padding-top: calc(var(--header-h) + var(--safe-top));
}
.confirm-body .confirm-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  width: 100%; max-width: var(--max-width); margin: 0 auto;
}
.confirm-body .container { padding-bottom: calc(84px + var(--safe-bottom)); }
.confirm-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.confirm-table td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.confirm-table td:first-child { color: var(--text-2); width: 5em; }

/* 确认单顶部仓库高亮条：仓库名称醒目 */
.confirm-warehouse {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-50);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.confirm-warehouse .wh-tag {
  flex: none;
  font-size: 12px; font-weight: 600;
  color: var(--primary); background: var(--card);
  padding: 3px 9px; border-radius: 999px;
}
.confirm-warehouse .wh-names { font-size: 17px; font-weight: 700; color: var(--text); word-break: break-all; }

/* 确认单产品行：产品名居左、数量居右（加粗放大） */
.confirm-row { background: var(--card); padding: 14px; border-radius: var(--radius); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.confirm-row .name { font-weight: 600; flex: 1; min-width: 0; word-break: break-all; }
.confirm-row .change { color: var(--text-2); flex: none; }
.confirm-row .change.qty { font-size: 17px; font-weight: 700; color: var(--text); }
.confirm-row .change.qty.in { color: var(--in); }
.confirm-row .change.qty.out { color: var(--out); }

/* 盘点修改确认单：与出入库/调拨共用 .confirm-warehouse 高亮条，下方一行变更数说明 */
.confirm-summary-sub { color: var(--text-3); font-size: 13px; }
/* 盘点行：第一行产品名（突出），下一行 左灰「原」→ 右高亮「现」 */
.confirm-row.compare-row { flex-direction: column; align-items: stretch; gap: 0; }
.confirm-row.compare-row .name {
  flex: none; width: 100%;
  font-size: 16px; font-weight: 700;
  white-space: normal; word-break: break-all;
  margin-bottom: 10px;
}
.confirm-row.compare-row .change.compare { flex: none; }
.confirm-row .change.compare { flex: 1; min-width: 0; }
.confirm-row .change { display: flex; align-items: center; gap: 8px; }
.confirm-row .change-cell { flex: 1; display: flex; align-items: baseline; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.confirm-row .change-cell.before .change-val { color: var(--text-2); }
.confirm-row .change-cell.after .change-val { color: var(--primary); font-weight: 700; }
.confirm-row .change-label { font-size: 12px; color: var(--text-3); flex: none; }
.confirm-row .change-val { font-size: 15px; font-weight: 600; }
.confirm-row .change-arrow { color: var(--text-3); font-size: 16px; flex: none; }

/* ---------------- Toast / Dialog ---------------- */
#toast-root {
  position: fixed; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: rgba(0, 0, 0, 0.78); color: #fff;
  padding: 10px 18px; border-radius: 20px; font-size: 14px;
  opacity: 0; transform: translateY(-8px); animation: fadeInDown 0.25s forwards;
  max-width: 80vw; text-align: center;
}
@keyframes fadeInDown { to { opacity: 1; transform: translateY(0); } }

.overlay {
  position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: var(--max-width); max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-title { font-size: 18px; font-weight: 600; margin-bottom: 14px; text-align: center; }
.sheet .row {
  display: flex; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.sheet .row:last-child { border-bottom: none; }
.sheet .row .name { flex: 1; }
.sheet .row .check { color: var(--primary); font-weight: 700; font-size: 18px; }
/* 底部弹层表单（添加缺料 / 补充信息等） */
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

.dialog {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dialog-box {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 360px;
}
.dialog-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.dialog-body { color: var(--text-2); margin-bottom: 20px; }
.dialog-actions { display: flex; gap: 10px; }

/* ---------------- 菜单 ---------------- */
.popover-menu {
  position: absolute; right: 6px; top: 42px; z-index: 200;
  background: var(--card); border-radius: var(--radius-sm); box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  min-width: 150px; overflow: hidden;
}
.popover-menu button {
  display: block; width: 100%; text-align: left; padding: 12px 14px;
  background: none; border: none; border-bottom: 1px solid var(--line);
  font-size: 15px; color: var(--text); cursor: pointer;
}
.popover-menu button:last-child { border-bottom: none; }
.popover-menu button.danger { color: var(--danger); }

/* ---------------- 登录 ---------------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; background: #fff; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { font-size: 64px; }
.login-logo h1 { font-size: 22px; margin: 10px 0 4px; }
.login-logo p { color: var(--text-2); font-size: 14px; margin: 0; }
.login-hint { margin-top: 24px; font-size: 12px; color: var(--text-2); text-align: center; }

/* ---------------- 响应式 PC ---------------- */
@media (min-width: 769px) {
  body { background: #e5e7eb; }
  .appbar { justify-content: center; }
  .bottom-nav { justify-content: center; }
  .page { padding-bottom: calc(var(--bottom-h) + var(--safe-bottom) + 12px); }
  .container { padding: 16px; }
  .card, .list { border: 1px solid var(--line); }
}

/* ---------------- 拖动排序 ---------------- */
.sort-ghost { opacity: 0.5; background: var(--primary-50); }
/* 长按激活后被"抬起"的那一行 */
.sort-chosen {
  position: relative; z-index: 5;
  background: var(--card);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  transform: scale(1.015);
  opacity: 0.96;
}
body.sort-dragging {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
/* 长按拖拽进行中的浮层提示 */
.drag-tip {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + var(--safe-bottom));
  z-index: 800;
  background: rgba(17, 24, 39, 0.84); color: #fff;
  padding: 9px 18px; border-radius: 20px; font-size: 13px;
  pointer-events: none; max-width: 88vw; text-align: center;
  animation: fadeInDown 0.2s forwards;
}
.sort-hint {
  font-size: 12px; color: var(--text-3); text-align: center;
  margin: 10px 4px 0;
}

/* ================= 工厂订单管理系统 ================= */

/* 看板（需求书 10-14） */
.board-section { margin-bottom: 18px; }
.board-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin: 0 4px 8px; display: flex; align-items: center; gap: 6px;
}
.board-title.danger-text { color: var(--danger); }
.board-list { display: flex; flex-direction: column; gap: 10px; min-height: 30px; }
.board-empty {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  text-align: center; color: var(--text-3); font-size: 13px;
}

/* 订单任务卡片（需求书 13） */
.order-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-user-drag: none;
}
.order-card img { -webkit-touch-callout: none; -webkit-user-drag: none; }
.order-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.order-main { flex: 1; min-width: 0; }
/* 三行布局（需求 6）：行1 客户+风险（弱化）；行2 产品+数量（核心）；行3 节点+交期。
   右列（数量/交期）用 margin-left:auto 统一贴卡片右缘对齐到同一条竖线 */
.order-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.order-row-top { font-size: 12px; color: var(--text-2); }
.order-row-top .tag { font-size: 11px; padding: 1px 7px; }
.order-customer {
  font-size: 12px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 60%;
}
.order-customer.self { color: var(--primary); font-weight: 600; }
.order-row-main { margin-top: 3px; }
.order-product {
  font-size: 16px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.order-qty { font-size: 18px; font-weight: 700; color: var(--text); margin-left: auto; white-space: nowrap; }
.order-row-sub { margin-top: 3px; font-size: 13px; }
.order-node { color: var(--primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-date { margin-left: auto; color: var(--text-2); white-space: nowrap; }
.order-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-2); margin-top: 4px;
}
.order-node { color: var(--primary); font-weight: 500; }

/* 标签（缺料 / 交期提醒 / 优先级，需求书 14/39） */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5; flex-shrink: 0;
}
.tag.danger { background: var(--danger-50); color: var(--danger); }
.tag.warn { background: #fef3c7; color: #b45309; }
.tag.shortage { background: var(--danger); color: #fff; }
.tag.muted { background: var(--bg); color: var(--text-2); }

/* 分段选择（优先级 / 客户类型） */
.segment { display: flex; gap: 6px; }
.segment-btn {
  flex: 1; padding: 10px 0; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  font-size: 15px; cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.segment-btn.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 图片横排（订单/产品图片管理） */
.img-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.img-item { position: relative; flex-shrink: 0; }
.img-item img {
  width: 72px; height: 72px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg); display: block;
  -webkit-touch-callout: none; -webkit-user-drag: none;
}
.img-del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(17,24,39,.78); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; line-height: 1;
}
.img-main {
  position: absolute; left: 0; bottom: 0; right: 0;
  background: rgba(37,99,235,.85); color: #fff;
  font-size: 11px; text-align: center; padding: 1px 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* 行编辑（节点 / 原料 / 附件列表） */
.row-item { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.row-item .input { flex: 1; min-width: 0; padding: 9px 10px; font-size: 15px; }
.row-item .input.unit { flex: 0 0 76px; text-align: center; }
.row-idx { color: var(--text-3); font-size: 14px; flex-shrink: 0; min-width: 20px; text-align: center; }
.row-idx.current { color: var(--primary); font-weight: 700; }
.row-del, .mini-btn {
  flex-shrink: 0; border: none; cursor: pointer;
  background: var(--bg); color: var(--text-2);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.mini-btn.danger { background: var(--danger-50); color: var(--danger); }
.mini-btn.success { background: #dcfce7; color: #15803d; }
.mini-btn:disabled { opacity: .35; cursor: not-allowed; }
.att-link { flex: 1; min-width: 0; color: var(--primary); text-decoration: none; word-break: break-all; }

/* 详情页信息行 */
.info-row { display: flex; padding: 7px 0; font-size: 15px; border-bottom: 1px solid var(--line); }
.info-row:last-of-type { border-bottom: none; }
.info-label { width: 84px; flex-shrink: 0; color: var(--text-2); }
.info-value { flex: 1; min-width: 0; word-break: break-all; }
.order-detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-detail-head > span:last-child { display: flex; gap: 6px; }

/* 当前节点 / 完整流程（需求书 53/54） */
.current-node {
  background: var(--primary-50); color: var(--primary);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 16px;
  display: flex; align-items: center; gap: 6px;
}
.flow-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.flow-item:last-of-type { border-bottom: none; }
.flow-item.done .flow-name { color: var(--text-3); text-decoration: line-through; }
.flow-item.current .flow-name { color: var(--primary); font-weight: 700; }
.flow-idx {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.flow-item.current .flow-idx { background: var(--primary); color: #fff; }
.flow-item.done .flow-idx { background: #dcfce7; color: #15803d; }
.flow-name { flex: 1; min-width: 0; }
.flow-done-at { font-size: 12px; color: var(--text-3); flex-shrink: 0; }

/* 缺料（需求书 55；需求 1 缺口红色加大；需求 5 缺数与备齐确认同行） */
.shortage-item {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--danger-50); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px;
}
.shortage-info { min-width: 0; }
.shortage-info .title { font-weight: 600; font-size: 15px; }
.shortage-info .sub { margin-top: 2px; }
.shortage-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 2px; padding-left: 4px;
}
.shortage-miss {
  font-size: 17px; font-weight: 700; color: var(--danger, #ef4444);
  white-space: nowrap;
}
.shortage-resolve { flex-shrink: 0; white-space: normal; text-align: center; line-height: 1.3; max-width: 60%; }

/* 操作记录（需求书 52） */
.log-item { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log-item:last-child { border-bottom: none; }
.log-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.log-detail { color: var(--text-2); margin-top: 2px; word-break: break-all; }

/* 状态卡（回收站 / 已完成） */
.status-card.danger .card-title { color: var(--danger); }

/* 回收站条目 */
.trash-item { margin-bottom: 14px; }
.trash-actions { display: flex; gap: 10px; margin-top: 8px; }
.trash-actions .btn { flex: 1; padding: 10px 0; font-size: 15px; }

/* 大图预览 */
.img-preview {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.86);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.img-preview img { max-width: 96vw; max-height: 92vh; object-fit: contain; }
.img-preview-close {
  position: absolute; top: 12px; right: 14px;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; font-size: 22px; line-height: 1;
}

/* ---------------- 补充信息（需求 3） ---------------- */
.supp-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 4px 0 2px; }
.supp-list { display: flex; flex-direction: column; }
.supp-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.supp-item:last-child { border-bottom: none; }
.supp-row { display: flex; align-items: center; gap: 8px; }
.supp-note {
  flex: 1; min-width: 0; font-size: 14px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.supp-count { flex-shrink: 0; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.supp-arrow { flex-shrink: 0; font-size: 12px; color: var(--text-2); transform: rotate(0deg); transition: transform .15s; }
.supp-arrow.up { transform: rotate(180deg); }
.supp-more { flex-shrink: 0; }
.supp-detail { margin-top: 8px; }
.supp-note-full { font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-all; margin-bottom: 6px; }
.supp-item.open { background: var(--bg); border-radius: var(--radius-sm); margin: 0 -8px; padding: 10px 8px; }

/* ---------------- 产品管理模式（需求 6） ---------------- */
.manage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.manage-head .manage-name { font-weight: 600; }
.manage-head.sub .manage-name { font-weight: 500; color: var(--text-2); }

/* 图片全屏预览：多图切换 + 位置指示（需求 3 十二） */
/* 预览层子元素定位（父级为 fixed，不覆盖其定位方式） */
.img-preview-count {
  position: absolute; top: 16px; right: 20px;
  color: #fff; font-size: 14px; text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.img-preview-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,.35); color: #fff; border: none;
  width: 44px; height: 64px; font-size: 28px; border-radius: 8px;
}
.img-preview-nav.prev { left: 12px; }
.img-preview-nav.next { right: 12px; }

/* ---------------- 产品管理筛选区（需求 7） ---------------- */
.fp-filters { display: flex; gap: 8px; margin-bottom: 10px; }
.fp-filters .select { flex: 1; min-width: 0; height: 38px; font-size: 14px; }

/* ---------------- 分组设置页（需求 8） ---------------- */
.group-line-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 4px 8px; border-bottom: 1px solid var(--line);
}
.group-line-arrow { width: 20px; text-align: center; color: var(--text-2); font-size: 13px; }
.group-line-name { flex: 1; font-size: 15px; font-weight: 600; }
.group-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px 10px 28px; border-bottom: 1px solid var(--line);
}
.group-cat-name { flex: 1; font-size: 14px; }
.group-add-btn { width: 100%; margin: 10px 0 4px; }

/* ---------------- 整改项 33：长按管理区域屏蔽浏览器原生长按菜单 ---------------- */
.app-longpress, .long-pressable {
  -webkit-touch-callout: none;        /* iOS/Safari：长按不弹系统菜单 */
  -webkit-user-select: none;
  user-select: none;
}
.app-longpress img, .long-pressable img { -webkit-user-drag: none; }
/* 输入/备注/明确允许复制的内容恢复原生能力 */
input, textarea, [contenteditable='true'], .allow-select {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
