/* ===========================================================================
   屏幕维修工单 · 样式
   一套文件同时伺候甲乙两套界面：靠 body[data-role] 区分配色
   （甲方=蓝、乙方=绿），让人一眼知道自己现在在"哪一边"。
   =========================================================================== */

:root {
  --bg: #f4f6f9;
  --card: #fff;
  --line: #e4e8ee;
  --text: #1f2430;
  --muted: #6b7482;
  --accent: #2563eb;
  --accent-soft: #eaf0fe;
  --ok: #0d8a52;
  --ok-soft: #e6f6ee;
  --warn: #b26a00;
  --warn-soft: #fdf3e2;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

body[data-role="yi"] {
  --accent: #0d8a52;
  --accent-soft: #e6f6ee;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

/* ---------------- 顶栏 ----------------
 * ⚠️ `flex-wrap: wrap` + 按钮 `white-space: nowrap`：顶栏按钮多了之后（乙方现在四个），
 *    窄屏上**不能靠"按钮自己把文字挤成两行"**来腾地方 —— 那会让「批量扫码」竖着排、
 *    标题也被挤断，看着像坏了。这里宁可整体多占一行。 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
}
.topbar .tb-title { font-size: 16px; font-weight: 700; }
.topbar .tb-sub { font-size: 12px; opacity: .85; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .tb-acts { display: flex; align-items: center; gap: 10px; }
.tb-btn {
  appearance: none; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(255, 255, 255, .18); color: #fff;
  padding: 7px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tb-btn:hover { background: rgba(255, 255, 255, .3); }

.wrap { max-width: 1220px; margin: 0 auto; padding: 14px; padding-bottom: 90px; }

/* ---------------- 卡片 / 排版 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card > h2 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card > h2 .cnt { font-size: 12px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.center { text-align: center; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* 「我的」页里说明 App 版本的小块（见 api.js 的 appRowHtml / fillAppRow） */
.apptip {
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
  background: #f6f7f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; margin-top: 6px;
}
.apptip.warn { background: var(--warn-soft); border-color: #f0d9b0; color: #7a4a00; }
.apptip code { display: block; margin-top: 4px; word-break: break-all; color: var(--text); }

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none; cursor: pointer; border: 1px solid var(--line); background: #fff;
  color: var(--text); border-radius: 9px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  font-family: inherit; line-height: 1.2;
}
.btn:hover { border-color: #cbd4e1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.xs { padding: 5px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.grow { flex: 1; }
/* 亮着的快捷筛选（现在是「今日」）：跟着角色配色走（甲方蓝 / 乙方绿） */
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------------- 表单 ---------------- */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
/* ⚠️ `input:not([type])` 这条别删：不写 type 的 <input> 默认就是文本框，
   但它**不匹配** `input[type=text]`（属性选择器看的是字面属性，不是默认值）。
   漏了它，这种输入框会掉回浏览器默认样式 —— 21px 高、153px 宽、没有圆角，
   一排框里"只有几个又小又窄"，看着像布局坏了（2026-10-19 老板截图报的就是这个）。 */
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; outline: none;
}
/* 台账那种一行五个框的密集表格：内边距收一点，同样的列宽能多留出字符位 */
.tw .t input { padding: 6px 8px; font-size: 13.5px; border-radius: 8px; }
/* 物料台账：**必须固定布局**。auto 布局下浏览器会按内容重新分配，写了 width 的列
   也可能被压到 min-content（实测「单位」列写 84px，实际只给 66px），于是那几个框
   看着又小又窄；固定布局后写多少就是多少，「名称 / 备注」两列平分剩下的宽度。 */
.t-sup { table-layout: fixed; }
/* 物料台账的列宽（2026-10-23 从 th 的 inline style 搬到这儿）：
   inline 的宽度**压不过媒体查询**，手机上就没法把"单位/库存"收窄、把宽度让给名称。
   名称列不写宽度 = 吃剩下的（fixed 布局下就是"填满"）。 */
.t-sup .c-unit   { width: 78px; }
.t-sup .c-stock  { width: 104px; }
.t-sup .acts-col { width: 158px; }
/* 手机上表单行放不下就换行，不要把框压成一条线 */
.sheet .row { flex-wrap: wrap; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
textarea { resize: vertical; min-height: 60px; }
/* 弹层里跟按钮并排的小输入框（额外工艺审核的「确认价」）—— 全局 input 是 width:100%，
   不覆盖的话它会把那一格撑爆、按钮被挤到下一行 */
input.mini { width: 88px; display: inline-block; padding: 5px 8px; font-size: 13px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button {
  flex: 1; appearance: none; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600;
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 6px; color: var(--muted);
}
.tabs button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------------- 登录页 / 入口页 ----------------
   甲方、乙方各有独立入口，页面上**没有角色选择器** —— 你是哪一方，由
   "你在哪一页 / 哪个域名"决定（见 assets/login.js）。
   data-auth 三个状态：
     pending  会话还没验完 → 工作台一律不渲染（免得闪一下工单表格再跳走）
     anon     没登录       → 显示登录卡片
     in       已登录       → 显示工作台
   ------------------------------------------------------------------ */
body[data-auth="pending"] #appRoot,
body[data-auth="anon"] #appRoot { display: none !important; }
body[data-auth="in"] #authRoot { display: none !important; }

.rolehead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rolepille {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.rolepille.yi { background: var(--ok-soft); color: var(--ok); }

/* 首页（域名还没绑）：两边各一个入口，选完就进各自的登录页 */
.entrypick { display: grid; gap: 10px; }
.entry {
  display: block; text-decoration: none; color: var(--text);
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px;
  padding: 12px 14px; background: #fff;
}
.entry:hover { border-color: #cbd4e1; }
.entry b { display: block; font-size: 15px; }
.entry i { font-style: normal; font-size: 12.5px; color: var(--muted); }
.entry.jia { border-left-color: var(--accent); }
.entry.yi { border-left-color: var(--ok); }

/* ---------------- 徽标 / 统计 ---------------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  background: #eef1f5; color: #4b5563;
}
.badge.b-created { background: #eef1f5; color: #4b5563; }
.badge.b-sent { background: var(--warn-soft); color: var(--warn); }
.badge.b-received { background: #e8f1fd; color: #1d4ed8; }
.badge.b-claimed { background: #efeafd; color: #6d28d9; }
.badge.b-completed { background: var(--ok-soft); color: var(--ok); }
.badge.b-returned { background: #e6f4fa; color: #0e7490; }
.badge.b-rework { background: var(--danger-soft); color: var(--danger); }
.badge.b-closed { background: #eef1f5; color: #111827; }
/* 已报废：和"退回重做"的橙红区分开 —— 那是"还要修"，这是"这台没了"。
   用灰褐底 + 深红字，扫一眼就知道是**终点**，不是待办。 */
.badge.b-scrapped { background: #e8e5e2; color: #7a3b3b; }

/* ---- 操作日志（甲方「日志」弹层）----
   一行 = 一条记录，时间是主角（出事都是先按时间轴找），
   所以时间放最左边、等宽数字；动作和对象紧跟其后，说明放第二行小字。
   不做表格：弹层只有一列宽，表格在手机上会被压成一条缝。 */
.auditrow {
  display: grid; grid-template-columns: 96px 1fr; gap: 2px 10px;
  padding: 7px 0; border-top: 1px solid var(--line);
}
.auditrow:first-child { border-top: 0; }
.auditrow .t { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.auditrow .m { font-size: 13px; }
.auditrow .m .who { font-weight: 700; }
.auditrow .d { grid-column: 2; font-size: 12px; color: var(--muted); word-break: break-all; }
.auditrow .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---- 手工单（SG-，2026-10-21）----
   弹层里的卡片行。为什么不用表格：手机上一个弹层只有 360 宽，
   表格得横向滑，"哪张还没审"一眼看不出来；卡片把编号+状态+金额竖着摆，
   滑一遍就清楚。三档状态的颜色按"谁要动手"配，跟额外工艺同一套思路。 */
.morder { padding: 9px 0; border-top: 1px solid var(--line); }
.morder:first-child { border-top: 0; }
.morder .l1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.morder .mcode { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.morder .l2 { margin-top: 3px; font-size: 13px; }
.morder .l3 { margin-top: 2px; }
.morder .acts { display: flex; gap: 8px; margin-top: 6px; }

.badge.b-m-pending  { background: var(--warn-soft);   color: var(--warn); }
.badge.b-m-approved { background: var(--ok-soft);     color: var(--ok); }
.badge.b-m-rejected { background: var(--danger-soft); color: var(--danger); }

/* ---- 回收站（2026-10-24）----
   一张删除批次一张卡，卡里是这一批的单号（一行一张，带复选框）。
   ⚠️ 单号用等宽字体 + tabular-nums：老板核对时是拿去和机器上的标签**逐位比**的，
      比例字体下 0/O、1/l 一眼分不清。已恢复的整行压暗并划掉单号 ——
      "还能点"和"已经回来了"必须一眼分得开，否则会反复点同一张。
   ⚠️ 列表限高 260px 自己滚：一次误删 51 张很常见（2026-10-24 就是 51 张），
      不限高的话弹层会被拉到两屏，下面的「恢复所选」得滑半天才够得着。 */
.trashlist { max-height: 260px; overflow: auto; border-top: 1px solid var(--line); padding-top: 4px; }
.trashitem {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 2px; font-size: 13px; border-bottom: 1px solid var(--line);
}
.trashitem:last-child { border-bottom: 0; }
.trashitem input[type="checkbox"] { flex: 0 0 auto; margin: 0; }
.trashitem .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap;
}
.trashitem.done { opacity: .5; }
.trashitem.done .code { text-decoration: line-through; }
/* 「恢复所选」那一行钉在弹层底部：
   ⚠️ .sheet 自己是 `max-height:88vh; overflow:auto`，底部按钮会跟着内容滚走。
      一次误删 51 张时列表很长，滑到一半想恢复手里勾的那几张，却得先滑到底找按钮。
      负的 bottom/margin 是把 sheet 那 16px 内边距"吃掉"，贴齐可视区下沿。 */
.sheet .trash-foot {
  position: sticky; bottom: -16px;
  padding: 10px 0 14px; margin: 14px 0 -16px;
  background: #fff; border-top: 1px solid var(--line);
}

/* ---- 额外工艺（乙方现场加项）----
   列表里不占新列：工艺列下面一行小字 + 只在需要动作时才出现的徽章。
   ⚠️ 颜色编码是**按"谁要动手"**定的，别按状态顺序随便配：
     x-warn（橙）= 等甲方审核 → 甲方要动手
     x-todo（紫）= 已通过待维修 → 乙方要动手
     x-ok  （灰）= 都完事了，最不起眼
     x-no  （红）= 被驳回了
   ------------------------------------------------------------------ */
.xline { font-size: 12px; margin-top: 2px; }
.xline.x-warn { color: var(--warn); font-weight: 700; }
.xline.x-todo { color: #6d28d9; font-weight: 700; }
.xline.x-ok { color: var(--muted); }
.xline.x-no { color: var(--danger); }

.xbadge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.xbadge.x-pending { background: var(--warn-soft); color: var(--warn); }
.xbadge.x-approved { background: #efeafd; color: #6d28d9; }
.xbadge.x-done { background: var(--ok-soft); color: var(--ok); }
.xbadge.x-rejected { background: var(--danger-soft); color: var(--danger); }
/* 「被驳回」（乙方在待签收那一步退回来的）：和额外工艺驳回同色系，
   但它是**这张单当前的状态提示**，所以加一圈描边，显得比普通小标签重要 */
.xbadge.x-refused { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }

/* ---- 发往哪一家乙方 ----
   甲方列表里"这张单在谁手上"要一眼看出来。两家给两个**不同的**颜色
   （乙方1 蓝、乙方2 紫），扫一列就能分清；还没送修的（vendor 为空）给灰的"未定"，
   不是"未知"——它就是"甲方还没点送修"，别让人以为是数据缺了。 */
.vbadge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.vbadge.v1 { background: #e8f1fd; color: #1d4ed8; }
.vbadge.v2 { background: #efeafd; color: #6d28d9; }
.vbadge.none { background: #f3f4f6; color: #9ca3af; font-weight: 400; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat.hi { background: var(--accent-soft); border-color: var(--accent); }
.stat.warn { background: var(--warn-soft); border-color: #f0d9b0; }

/* ---- 统计卡分组（2026-10-17） ----
   甲方那排数字里混着**两种维度**（一单在哪一步 / 在谁手上），
   平铺成一排会让人以为它们是同一条链、能相加。给它两行小标题隔开。 */
.statgroup + .statgroup { margin-top: 11px; }
.statgroup-h {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
  margin: 0 0 6px; font-size: 12.5px; line-height: 1.35;
}
.statgroup-h b { font-weight: 700; }
.statgroup-h .muted { font-size: 11.5px; }

/* ---- 「在乙方手上还没回来」汇总条（2026-10-22 老板要的） ----
   老板要的不是"再摆一排数字"，而是**一个数**：现在还有多少块屏压在乙方。
   所以它单独一条、放在统计区最上面，数字比下面的卡大一号；右边按阶段/按家拆开，
   每一块都能点（点完 = 筛出这一批单，和统计卡同一套行为）。
   ⚠️ 这一条**不是**「一单走到哪一步」那一排的同类：那一排是互斥的全量拆分，
      这一条只挑"还在外面"的那几档。所以它有自己的边框和底色，别和下面混成一片。 */
.atv {
  border: 1px solid var(--accent); background: #f6f9ff;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.atv-top { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }

/* 左边那个大数 */
.atv-hero {
  appearance: none; font: inherit; cursor: pointer; text-align: left; color: var(--text);
  display: flex; flex-direction: column; justify-content: center;
  border: 1px solid var(--accent); background: #fff; border-radius: 10px;
  padding: 5px 18px 7px; min-width: 152px;
}
.atv-hero .n {
  font-size: 34px; font-weight: 800; line-height: 1.06; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.atv-hero .n small { font-size: 13px; font-weight: 700; margin-left: 4px; }
.atv-hero .l { font-size: 12px; color: var(--muted); margin-top: 1px; }
.atv-hero:hover { border-color: #1d4ed8; }
.atv-hero.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.atv-hero.on .l { color: var(--accent); font-weight: 700; }

/* 右边两行：按阶段 / 按家 */
.atv-rows { display: flex; flex-direction: column; gap: 6px; flex: 1 1 260px; min-width: 0; }
.atv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.atv-rl { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }

.atv-chip {
  appearance: none; font: inherit; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: 12px; line-height: 1.7; white-space: nowrap;
}
.atv-chip b { font-weight: 800; font-variant-numeric: tabular-nums; }
.atv-chip:hover { border-color: #cbd4e1; }
.atv-chip.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.atv-chip.on b { color: var(--accent); }
/* 按家的两枚跟着列表「发往」的颜色走（乙方1 蓝 / 乙方2 紫），不用再认一遍字 */
.atv-chip.v1 b { color: #1d4ed8; }
.atv-chip.v2 b { color: #6d28d9; }
/* 停用的那家（2026-10-22）：只在"手上还压着东西"时才出现，虚线+灰表示它不再接新活 */
.atv-chip.off { border-style: dashed; color: var(--muted); }
.atv-chip.off b { color: var(--muted); font-weight: 700; }

.atv-note { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; }
.atv-note b { color: var(--warn); font-weight: 700; }

/* ---- 可点的统计卡（点一下 = 筛出对应的工单） ----
   统计数字和它下面那个列表本来就是一回事 —— 让人能在数字上直接点，
   少走"先看数字、再去找分栏"那一步。
   ⚠️ 用真 <button> 而不是给 div 挂 onclick：键盘、读屏、长按菜单
      都跟着来，而且天生有 :focus 态。样式上得把 button 的默认外观洗掉。
   ⚠️ .on（当前正筛着这一档）必须有**额外**的视觉 —— 光靠数字变化不够，
      用户切到别的分栏再切回来时要能看出来"现在看的就是这一档"。 */
.stat.link {
  appearance: none; font: inherit; text-align: left; cursor: pointer;
  position: relative; padding-right: 22px; color: var(--text);
}
.stat.link::after {
  content: '›'; position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 15px; font-weight: 700; opacity: .55;
}
.stat.link:hover { border-color: #cbd4e1; }
.stat.link:active { transform: scale(.985); }
.stat.link.on {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.stat.link.on .k { color: var(--accent); font-weight: 700; }
.stat.link.on .v { color: var(--accent); }

/* ---------------- 表格 ---------------- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th, table.t td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 700; background: #fafbfd; position: sticky; top: 0; }
table.t td.code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .2px; }
/* 有现场照片的工单：工单号后面跟一个小小的「📷N」。
   ⚠️ 故意用 **CSS 生成内容**（::after + attr()）而不是真写进 DOM。
      原因：本项目的自检里有一批判据是拿 `td.code` 的 **textContent** 去和
      接口返回的工单号做**严格相等**比较的（`=== VA.code`、`=== reworkCode`…）。
      真把徽章写进 DOM，那些判据会全线变成假红 —— 而"生成内容不进 textContent"
      正好把这两件事分开：人看得到，判据一个都不受影响。
      以后往这一格加任何装饰，都照这个办法加。 */
table.t td.code[data-photos]::after {
  content: '📷' attr(data-photos);
  margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0;
}
table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td.note { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
/* 备注格 = 补备注的入口（甲方列表）。
   ⚠️ 只给甲方的这一格加 can-edit：乙方的备注是只读的，别让那边看着像能点。 */
table.t td.note.can-edit { cursor: pointer; }
table.t td.note.can-edit:hover { background: var(--accent-soft); }
/* 没填备注时的那句"＋ 备注"：淡一点，不抢眼，但一眼看得出这里能点 */
.note-add { color: var(--muted); opacity: .55; white-space: nowrap; }
table.t td.note.can-edit:hover .note-add { opacity: 1; color: var(--accent); }
table.t tr.sel td { background: var(--accent-soft); }
table.t tr.dim td { opacity: .5; }
table.t tbody tr:hover td { background: #f8fafc; }

/* 工具条：筛选 + 批量操作 */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .grow { flex: 1 1 130px; }
.bulkbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(15, 20, 30, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow: auto;
}
.sheet {
  background: #fff; border-radius: 14px; padding: 16px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(16, 24, 40, .22);
}
.sheet h3 { margin: 0 0 10px; font-size: 16px; }
.sheet .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* 弹窗右上角的 ×（2026-10-19 老板：别让人每次都滑到底点「关闭」）
 * 用 sticky 而不是 absolute/fixed：
 *   - absolute 会跟着 sheet 里的内容滚走（sheet 自己 overflow:auto）；
 *   - fixed 要靠 JS 量 rect 摆位置，内容一异步撑高坐标就过期（实测跟不住）。
 * sticky 在流里占 34px 高度 —— 那就是给标题让出来的"安全带"，滚动时钉在卡片顶上，
 * 内容从它下面滑过去。 */
.sheet-x {
  position: sticky; top: 0; z-index: 3;
  display: block; width: 34px; height: 34px; margin: -4px 0 10px auto; padding: 0; border: 0;
  border-radius: 50%; background: #eef1f6; color: #55606f;
  font-size: 22px; font-weight: 600; line-height: 34px; text-align: center;
  cursor: pointer; box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
  -webkit-tap-highlight-color: transparent;
}
.sheet-x:active { background: #e1e6ee; }

/* ---------------- 提示 ---------------- */
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast-item {
  background: #1f2430; color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); max-width: 90vw;
}
.toast-item.ok { background: #0d8a52; }
.toast-item.err { background: #c0392b; }

.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f5, #f6f8fb, #eef1f5); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { 0% { background-position: 0 0 } 100% { background-position: -200% 0 } }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13.5px; }

/* ---------------- 扫码 ---------------- */
.scanwrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; }
.scanwrap video { width: 100%; display: block; }
.scanwrap canvas.prev { width: 100%; display: block; }
.scanframe {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 56%; aspect-ratio: 1 / 1; border: 2px solid rgba(255, 255, 255, .9); border-radius: 10px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .38);
}
.scanhud { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; color: #fff; font-size: 12.5px; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.scannerr { color: #ffd7d2; font-size: 12.5px; }
/* HUD 按这一张的判定变色（连续扫：绿=收了 / 黄=收不了 / 红=这个码不对） */
.scanhud.ok { color: #b8f5d3; }
.scanhud.warn { color: #ffe3a3; }
.scanhud.bad { color: #ffc2ba; }

/* ---------------- 批量扫码（连续扫）----------------
   相机上方是「动作切换 + 手输兜底」，下方是已扫清单。
   ⚠️ `.scanbelow` 必须**自己限高并滚动**：一次可能扫几十台，而弹层总高只有 88vh
      （见 .sheet）—— 不限高的话清单会把底部的「完成」按钮顶出屏幕，人就点不到了。
   ⚠️ 手机横放时高度更小，用 vh 而不是固定 px。 */
.scanmodes { display: flex; gap: 6px; margin-bottom: 8px; }
.scanmodes button {
  flex: 1; appearance: none; cursor: pointer; border: 1px solid var(--line);
  background: #fff; color: var(--muted); border-radius: 8px; padding: 8px 6px;
  font-size: 13px; font-weight: 600;
}
.scanmodes button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
/* 批量模式下画面限高：整块弹层只有 88vh，让给下面的清单和「完成」按钮。
   裁掉的只是**显示**，解码用的是 video 自己的像素（中心 ROI），完全不受影响。 */
.scanwrap.batch video { max-height: 32vh; object-fit: cover; }
.scanbelow { max-height: 26vh; overflow: auto; margin-top: 10px; }
.scanbelow:empty { display: none; }
.scanitem { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-top: 1px solid var(--line); font-size: 12.5px; }
.scanitem:first-child { border-top: 0; }
.scanitem .cd { font-family: var(--mono, ui-monospace, monospace); font-weight: 700; }
.scanitem .msg { color: var(--muted); flex: 1; min-width: 0; }
.scanitem.ok .cd { color: #0d8a52; }
.scanitem.warn .cd { color: #a86a00; }
.scanitem.bad .cd { color: #c0392b; }
.scanitem .rm { appearance: none; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 2px 4px; }

/* ===========================================================================
   标签打印：热敏标签纸 40×30mm（横向：40 宽 × 30 高），一张一签。
   尺寸全部写绝对 mm —— 浏览器直接打印就是正确版式。
   ⚠️ 打印机驱动里的纸张也要设成 40×30，两边一致才不会缩版/转方向。

   ⚠️ 这一整段是 2026-10-13 从上一个工单系统（笔记本工单 assets/style.css）
      **原样移植**的，唯一差异：原版二维码下面印「配置」（型号/内存/硬盘），
      这里改印「工艺」。移植时连档位表、字号、gap、留白、text-rendering 一起搬 ——
      那些毫米数都是按「203dpi 热敏上扫得动 + 小字不断笔画」倒推出来的，
      **别凭手感调**（逐档的推导见 qr.js 的 LABEL_QR_MM 注释）。
   =========================================================================== */

/* 打印区：屏幕上完全不渲染（id 选择器特异度高于任何 class，压得住） */
#printArea { display: none; }

.labelsheet {
  width: 40mm; height: 30mm; box-sizing: border-box; overflow: hidden;
  border: 1px dashed #cfd4dc; border-radius: 4px; padding: 0.6mm;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  /* gap 0.3mm（一路从 0.5 → 0.35 → 0.3 让位）：省下的每一丝都拿去放大编号/工艺。
     ⚠️ 0.25mm 以下肉眼就开始分不清「二维码」和「编号」是两块了，别再往下抠。 */
  gap: 0.3mm; break-inside: avoid; background: #fff;
  /* 让 Chrome / Edge 打印时按**几何精度**排字，不做屏幕端的次像素 hinting ——
     小字号在 203dpi 热敏纸上的断笔画会明显减轻。对屏幕显示无影响。 */
  text-rendering: geometricPrecision;
  /* ---- 字体：整张标签统一微软雅黑（2026-10-14 张先生口径）----
     放在 .labelsheet 上，签上所有文字（编号 / 工艺 / 提示）一起生效；
     原来单独用等宽的「工单号」也改成跟着走（见下面 .cd）。
     ⚠️ 为什么把 "Microsoft YaHei" 写在最前：车间的打印机接在 Windows 上，
        而这一串原来以 -apple-system / PingFang SC 打头，在 Windows 上前两个
        都不存在、最后才落到雅黑 —— 行为上等于"碰运气"，写死了才叫统一。
        Mac 上没装雅黑时会依次落到 PingFang SC / 冬青黑，不会变成方块。
     ⚠️ 字体一换，**字宽就变了**，而标签的毫米数是按字宽倒推出来的
        （见下面 .cd 与 .craft 的注释）—— 动这里必须重跑 tools/e2e-ui.mjs。 */
  font-family: "Microsoft YaHei", "微软雅黑", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

/* 二维码尺寸分档（档位由 qr.js 的 labelLineCount 决定）：
   40×30mm 的高度是硬约束，二维码下方每多一行字，二维码就得让一行出来。
   可扫门槛（203dpi 热敏）：≥0.50mm/模块扫得轻松、≥0.33mm/模块勉强可扫。
   本码是 V4（33 模块 + 两侧静默区 = 41 模块），「边长 ÷ 41」就是模块尺寸：
     lbl-l0（无工艺行）     24mm   ÷ 41 = 0.585mm → 4.68 dots  ← 故意不缩，见下
     lbl-l1（工艺 1 行）    21mm   ÷ 41 = 0.512mm → 4.10 dots（主力场景）
     lbl-l2（工艺 2 行）    19.2mm ÷ 41 = 0.468mm → 3.75 dots
     lbl-l3（工艺 2 行+提示）17.2mm ÷ 41 = 0.420mm → 3.36 dots
   ⚠️ l0 档**故意不缩**（仍是 24mm）：那一档没有工艺行，「字太小」的矛盾不存在，
      缩它只会净亏可扫性。要缩的是下面三档。
   ⚠️ 改任一个数字都要跑 tools/e2e-ui.mjs：它会按 203dpi 真栅格化后用 jsQR 解码，
      并真打一份 PDF 数页数。 */
.labelsheet .qrbox { width: 24mm;   height: 24mm;   flex: none; }
.labelsheet.lbl-l1 .qrbox { width: 21mm;   height: 21mm; }
.labelsheet.lbl-l2 .qrbox { width: 19.2mm; height: 19.2mm; }
.labelsheet.lbl-l3 .qrbox { width: 17.2mm; height: 17.2mm; }
.labelsheet .qrbox svg { width: 100%; height: 100%; display: block; }

/* 工单号 PM-20261013001 共 14 字符。
   原来用等宽（约 0.6em/字符）：8pt → 约 23.7mm。2026-10-14 起改成跟着标签统一的
   微软雅黑（等宽字体在标签上和「工艺」那行的松紧差得太明显）。
   雅黑的数字是比例宽度、比等宽**更窄**，所以这一行只会更宽裕，不会顶到 38.8mm。
   粗体必须留着 —— 203dpi 热敏纸上细笔画会断，粗体能保住每个字。 */
.labelsheet .cd {
  flex: none;   /* ⚠️ flex:none 是必须的：否则内容超出时 flex 会先把这一行压扁，
                   溢出被「压」掉而不是暴露出来，而 .labelsheet 又是 overflow:hidden，
                   结果就是静默裁切、没人发现。 */
  font-family: inherit; font-size: 8pt; font-weight: 700;
  letter-spacing: 0; white-space: nowrap; line-height: 1.05;
}

/* 工艺（换A壳 / 换A壳+膜 / 换膜）—— 原项目的「配置」行，本项目的唯一差异。
   7pt 字号下 38.8mm 宽约 15 个全角字位。默认压一行、超出打省略号；
   工艺名是甲方在「工艺管理」里自定义的，理论上可能很长 ⇒ 超过就由 JS 加
   .craft-lg 折两行（同时把二维码降到 lbl-l2 档）。
   ⚠️ 15 这个阈值与 qr.js 的 craftLabelLines() 是一对，改字号必须同时改两边。
   ⚠️ font-weight:700 不是可有可无 —— 6pt 的常规体在 203dpi 上笔画只有 1 个点，
      打出来断断续续像被虫蛀；加粗后 2 个点，清晰度提升比放大 1pt 还明显。 */
.labelsheet .craft {
  flex: none;   /* 同 .cd：不允许被 flex 压扁，超出就要能被自检抓到 */
  box-sizing: border-box; max-width: 100%;
  font-size: 7pt; font-weight: 700; line-height: 1.15; text-align: center; color: #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.labelsheet.craft-lg .craft {
  white-space: normal; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

@media print {
  /* ===========================================================================
     ⚠️⚠️ 这一条是 2026-10-13 那次事故的修复，**别删**。

     原来这里逐个列选择器藏（.no-print, .topbar, #toast, .mask）——
     **漏了 <main>**。后果：用户点「打印二维码」，打印预览里是**整个甲方工作台**
      （统计卡 + 工单表），按 40×30 出纸时 3 张标签变成 **20 页**。
     而当时所有自检都是绿的 —— 因为它们只量 #printArea 里那个 DOM，
     从来不问"打印时**别人**还在不在"。

     现在改成「body 下除 #printArea 之外**全部**藏掉」——
     以后往 body 里加任何东西（升级提示条、公告浮层、新的弹层）都不会再漏进来。
   =========================================================================== */
  body.printing-labels > *:not(#printArea) { display: none !important; }
  body { background: #fff; margin: 0; }

  /* 打印时才放出打印区（里面只装勾选的工单） */
  body.printing-labels #printArea { display: block; }

  /* 一张标签一页纸：每张后面断页，最后一张不打标记否则会多出一页空白 */
  .labelsheet.brk { break-after: page; }
  .labelsheet { border: 0; border-radius: 0; }

  /* ⚠️ 故意不声明 @page size！
     Chromium 系浏览器（Edge/Chrome）见到 size 声明后会自己再映射一次纸型，
     与驱动里的横竖向标志叠加 → 内容被旋转 90°、偏向一角（Windows 实测）。
     去掉 size 后浏览器直接用打印时选中的纸张坐标系，纸型交给驱动。
     代价：打印时必须手动选对 40×30 纸张（页面上已提示）。 */
  @page { margin: 0; }
}

/* ---------------- 现场照片（额外工艺的证据） ----------------
   场景：乙方拍下"背光有问题"的那台机器，传给甲方看。四处会用到这套样式：
     ① 乙方填单时的「已选 N 张」（.pstrip 里的 .pthumb，带删除角标）
     ② 乙方/甲方列表与面板里的缩略图（.pthumb，点了开大图）
     ③ 全屏看大图（.photoview）
   ⚠️ .photoview 挂在 <body> 下、不在 #appRoot 里 —— 打印白名单是
      `body.printing-labels > *:not(#printArea)` 一律藏掉，正好也不会
      把照片印到 40×30 的标签纸上。
   ------------------------------------------------------------------ */
.pstrip { display: flex; flex-wrap: wrap; gap: 6px; }
.pthumb {
  position: relative; width: 62px; height: 62px; flex: none;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #f1f4f8;
  cursor: pointer;
}
.pthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 只填了容器、图还没来的那些格子：给个浅色底，别是一片白 */
.pthumb img:not([src]) { opacity: 0; }
.pthumb .pdel {
  position: absolute; right: 2px; top: 2px; width: 19px; height: 19px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer; line-height: 1;
  background: rgba(15, 20, 30, .62); color: #fff; font-size: 13px; font-weight: 700;
}
.pthumb .pdel:hover { background: var(--danger); }

.photoview {
  position: fixed; inset: 0; z-index: 70; background: rgba(10, 14, 22, .82);
  display: flex; align-items: center; justify-content: center; padding: 14px; overflow: auto;
}
.photoview .pvin { width: 100%; max-width: 900px; }
.photoview .pvbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: #fff; font-size: 13.5px; font-weight: 600; margin-bottom: 8px;
}
.photoview .pvimg { display: flex; align-items: center; justify-content: center; }
.photoview .pvimg img {
  max-width: 100%; max-height: 78vh; border-radius: 10px; display: block; background: #fff;
}

/* ---------------- 下拉刷新（手机） ----------------
   手机上在页面最顶上一拉就刷新。逻辑在 assets/api.js 的 initPullRefresh。
   ⚠️ 这个元素挂在 <body> 下、**不在 #appRoot 里**：打印白名单是
      `body.printing-labels > *:not(#printArea)` 一律藏掉，放外面才不会
      在标签纸上多印一条「下拉刷新」。
   ⚠️ transform 里那个 -50% 是配合 left:50% 做水平居中的，别删。
   ⚠️ top 由 JS 设成 topbar 的高度（topbar 是 sticky 贴顶的，所以这个值一直对）。
   z-index 15 < topbar 的 20 ⇒ 它只会从顶栏底下往外露，不会盖住顶栏。
   pointer-events:none ⇒ 纯提示，绝不吃点击。
   ------------------------------------------------------------------ */
.pullbar {
  position: fixed; left: 50%; top: 0; z-index: 15;
  transform: translate(-50%, 0); opacity: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 15px; border-radius: 999px;
  background: #fff; color: var(--muted);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(16, 24, 40, .18);
  pointer-events: none;
}
/* 拖动时**不能**有过渡（要有"跟手"的硬感），回弹/刷新时才加 */
.pullbar.anim { transition: transform .22s cubic-bezier(.2, .7, .3, 1), opacity .22s ease; }
.pullbar .sp {
  width: 13px; height: 13px; flex: none; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
}
.pullbar.busy .sp { animation: pspin .7s linear infinite; }
.pullbar.ready { color: var(--accent); }
@keyframes pspin { to { transform: rotate(360deg) } }

/* ---------------- 响应式 ---------------- */

/* ===========================================================================
   手机上的「工单行 → 卡片」（乙方工作台）
   ---------------------------------------------------------------------------
   问题（2026-10-14 老板在手机上实拍反馈）：乙方一行工单有 8 列，
   最后那列才放着「签收 / 领用 / 完成 / 发回 / ＋额外」这些**真正要点的按钮** ——
   手机屏幕那么窄，得先横着划一段才够得着，手上还拿着机器，很别扭。

   做法：**纯 CSS**。给乙方的 table 加一个 .t-cards 类，窄屏下把表格整体
   拆成一块块卡片，每格用 data-th 把自己那列的列名显示出来（列名不用写死在
   CSS 里，改表头不用改样式）。**DOM 一行都不动** —— 这一点是刻意的：
   所有 JS（勾选、行内按钮、批量栏、自检里的 `#tbody tr[data-id] .badge`）
   全都照旧，不会因为"手机上换了个渲染方式"就有一半功能失灵。

   ⚠️ 打印标签走的是 #printArea，跟这里无关（打印白名单把整个 #appRoot 都藏了）。
   ⚠️ 只给乙方开（jia.html 的 table 没有 .t-cards）：甲方那一行列更多、
      而且老板主要在电脑上用它。要开的话加个类就行，样式是通用的。
   =========================================================================== */
@media (max-width: 760px) {
  .tw:has(> .t-cards) { overflow: visible; }
  table.t.t-cards { display: block; font-size: 13.5px; }
  table.t.t-cards thead { display: none; }
  table.t.t-cards tbody { display: block; }

  table.t.t-cards tbody tr {
    display: block; position: relative;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 11px 11px; margin-bottom: 9px;
  }
  /* 选中/悬停的整行底色在卡片模式下会跟卡片自己的白底打架，交给边框表达 */
  table.t.t-cards tbody tr.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
  table.t.t-cards tbody tr:hover td { background: transparent; }
  table.t.t-cards tbody tr.sel td { background: transparent; }

  table.t.t-cards tbody td {
    display: flex; align-items: baseline; gap: 8px;
    border: 0; padding: 2px 0; white-space: normal;
  }
  /* 列名标签：内容取 data-th，所以列名只在 yi.js 那一处维护 */
  table.t.t-cards tbody td[data-th]::before {
    content: attr(data-th); flex: none; width: 5.4em;
    color: var(--muted); font-size: 12.5px;
  }
  /* 工单号 = 卡片标题：不显示列名、字号大一点、左边留给勾选框 */
  table.t.t-cards tbody td.code {
    font-size: 15px; padding-left: 24px; padding-bottom: 4px;
  }
  /* 勾选框钉在左上角 */
  table.t.t-cards tbody td.ck {
    position: absolute; left: 10px; top: 12px; padding: 0;
  }
  /* 备注太长要折行，不能撑破卡片 */
  table.t.t-cards tbody td.note { word-break: break-word; }
  table.t.t-cards tbody td.note:empty { display: none; }

  /* 动作按钮：占满一行、够大（手指点得着），一行放不下就换行 */
  table.t.t-cards tbody td.acts {
    margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line);
    flex-wrap: wrap; gap: 7px;
  }
  table.t.t-cards tbody td.acts .btn { flex: 1 1 auto; min-height: 38px; padding: 8px 12px; }
}

@media (max-width: 640px) {
  .wrap { padding: 10px; padding-bottom: 90px; }
  .card { padding: 12px; }
  .statgrid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  table.t th, table.t td { padding: 7px 7px; }
  .toolbar .grow { flex: 1 1 100%; }
  /* 手机上顶栏的按钮会换行 → 顶栏变高，下拉刷新指示条靠 JS 现算 top 跟上去 */
  .tb-btn { padding: 6px 10px; font-size: 12.5px; }
  /* 乙方四个按钮在窄屏上一行放不下：让它们**整体**落到第二行（右对齐），
     标题那行保持不动。basis 100% 是关键 —— 少写它就会变成"标题后面挤两个、
     第二行再挤两个"，比现在更难看。 */
  .topbar .tb-acts { flex: 1 1 100%; justify-content: flex-end; gap: 8px; }
}

/* ===========================================================================
   手机上的「物料台账」：**保持表格形状，横向滑动看完整行**（2026-10-22 改）
   ---------------------------------------------------------------------------
   历史（别再改回去）：
     · 2026-10-21 老板报"看不到最左侧的名称"。根因是 fixed 布局 + 写死列宽
       （规格 104 + 单位 84 + 库存 104 + 按钮 158 = 450，比手机弹层还宽），
       而「名称/备注」没写宽度 ⇒ fixed 下剩余宽度算成负数 ⇒ 这两列被压成 0 宽。
       当时的修法是"窄屏整行变卡片"。
     · 2026-10-22 老板又提：「手机版改成和桌面端那种显示效果，现在这样看的不太方便，
       无法一次性看完，需要下拉很久。他愿意左右滑动看，但不想这样下拉很多。」
       ⇒ 卡片把 5 个格子摊成 5 行 + 一行按钮，一件物料 ~250px 高，10 件就要滑三屏。
       表格一行 ~34px，同样 10 件一屏多一点就够了。**横向滑动是他明确接受的成本。**
   ⇒ 所以这一段的规矩反过来：**不许变卡片，永远是一张表**；
     靠 `min-width` 撑出横向滚动，靠压 padding/字号把行高压到 34px 上下。
   =========================================================================== */
@media (max-width: 760px) {
  /* .tw 本来就是横向滚动容器，这里只保证它别被别的规则改成 visible */
  .tw:has(> .t-sup) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /*
   * ⚠️ 手机上**不用 fixed 布局**：fixed 是按"表头声明的宽度"算的，剩余空间一旦算成负数，
   *    「名称/备注」就变成 0 宽（2026-10-21 那个"看不见名称"的 bug 就是这么来的）。
   *    auto 布局按内容算，绝不会把有内容的列压成 0。
   *    列宽改成**直接约束输入框**（input 自带宽度，auto 布局照着排），一眼能看出多宽：
   *    名称 170 够认名字，单位/库存收窄，一屏（390px 宽）第一眼就能看到「库存」那一格。
   *    剩下的「保存 / 停用 / 删除」在右边，横着滑一下 —— 老板明确说愿意滑。
   *    （2026-10-23：老板把「规格 / 备注」两列圈掉了，这里跟着把宽度让给名称。）
   */
  table.t.t-sup { table-layout: auto; min-width: 0; display: table; }
  /* 2026-10-23 老板圈掉了「规格 / 备注」两列 ⇒ 省下来的宽度全给名称；
     另外三列收窄，目标是**一屏就看得完**（真放不下时才有横滑，提示语由 JS 按实测决定） */
  .tw .t-sup input[data-name] { width: 170px; }
  .tw .t-sup input[data-unit] { width: 40px; }
  .tw .t-sup input[data-stock] { width: 66px; }
  .tw .t-sup .c-unit { width: 44px; }
  .tw .t-sup .c-stock { width: 62px; }
  .tw .t-sup .acts-col { width: auto; }
  /* 表头要留着：横着滑之后，没有列名就不知道哪一列是什么 */
  table.t.t-sup thead { display: table-header-group; }
  table.t.t-sup thead th { padding: 6px 4px; font-size: 11.5px; white-space: nowrap; }
  table.t.t-sup tbody tr { display: table-row; }
  table.t.t-sup tbody tr.rowoff { opacity: .55; }
  table.t.t-sup tbody td { display: table-cell; padding: 3px 3px; border-top: 1px solid var(--line); }
  /* 一行压到 34px 上下 —— 这才是"一次性看完"的关键，不是把列藏起来 */
  .tw .t-sup input { padding: 4px 6px; font-size: 13px; border-radius: 6px; }
  table.t.t-sup tbody td.acts { white-space: nowrap; padding: 3px; }
  table.t.t-sup tbody td.acts .btn { padding: 3px 5px; font-size: 11.5px; min-height: 0; }
  /* 空状态那行（colspan=4）还是要占满整行 */
  table.t.t-sup tbody td[colspan] { display: table-cell; }
}

/* 手机上表格能横滑 —— 得有人告诉老板"横着滑还有列"。桌面端不显示。
   ⚠️ 2026-10-23 试过"只在真滑得动时才显示"（JS 量 scrollWidth 加类）：
      在真机宽度下这两张表**本来就更宽**（工艺管理 396 vs 326、物料台账 412 vs 326），
      量出来的答案永远是"要滑"，多出来的只是 ResizeObserver + 一处会写错的时序。
      结论：**纯 CSS**，手机上就显示 —— 说得出的话就别说成条件句。 */
.sup-hint { display: none; }
@media (max-width: 760px) {
  .sup-hint { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
}

/* ===========================================================================
   手机上的「工艺管理」：名字按内容宽度撑开，其余列收窄，整张表左右滑
   ---------------------------------------------------------------------------
   背景（2026-10-23 老板报的）："手机页面显示看不完整工艺名称，可以改成左右滑动
   查看，但是要显示完整"。
   根因不是表格截断，而是**输入框太窄**：那一格输入框的宽度由表格自动分配，
   手机弹层里扣掉"单价 110 + 状态 90 + 操作 120"之后只剩几十像素，
   输入框里的字超出去就被切掉了（输入框不会折行，只会自己滚动）。

   修法的两个要点：
     ① 名字这一列的宽度**由 JS 按真实字体量出来**写进 `--w`（见 jia.js
        craftNameWidth）—— 长名字一定不被切，短名字也不白占地方；
     ② 单价/状态/操作三列在手机上收窄（桌面端宽度不变），把省下来的宽度让给名字。
   滑动的成本由 `.tw`（本来就是 overflow-x: auto）承担，**不把表格改成卡片** ——
   一格一行、改完就点保存，这才是这一页的用法。
   =========================================================================== */

/* 桌面端：和改之前一模一样（这两个宽度原来写在 td 的 inline style 上） */
.t-craft .c-price   { width: 110px; }
.t-craft .c-enabled { width: 90px; }
.t-craft .c-acts    { width: 120px; }

/* "可以左右滑"的提示：只在手机上出现（桌面端没有横向滚动，写了反而误导） */
.swipe-hint { display: none; }
@media (max-width: 760px) {
  .swipe-hint { display: block; margin: -2px 0 6px; color: var(--muted); font-size: 12px; }
}

@media (max-width: 760px) {
  .tw:has(> .t-craft) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.t.t-craft { table-layout: auto; }
  /* 名字列：宽度来自 JS 量出来的 --w（兜底 150px）。⚠️ 别改回 100%：
     100% 会重新落进"表格分配宽度"的老坑，手机上又被压窄。 */
  .tw .t-craft input[data-name] { width: var(--w, 150px); }
  .tw .t-craft input[data-price] { width: 62px; }
  .tw .t-craft select[data-enabled] { width: 66px; }
  table.t.t-craft th, table.t.t-craft td { padding: 6px 5px; }
  table.t.t-craft tbody td.c-acts { white-space: nowrap; }
  table.t.t-craft tbody td.c-acts .btn { padding: 4px 6px; font-size: 11.5px; }
  /* 表头留着：横滑之后没有列名就不知道哪一列是什么 */
  table.t.t-craft thead { display: table-header-group; }
  table.t.t-craft thead th { padding: 6px 5px; font-size: 11.5px; }
}

/* ---------------- 物料（台账 / 领用申请 / 采购申请） ----------------
   一张申请一张小卡：标题行是"什么东西 × 几个 + 状态章"，往下是申请人/理由/照片。
   为什么不用表格：手机上一行塞不下"理由 + 照片 + 两个按钮"，表格会横向拖，
   而师傅基本都在手机上提申请。 */
.supcard {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; background: #fff;
}
.supcard:last-child { margin-bottom: 0; }
.supgroup { font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 0 7px; }
.supgroup:first-child { margin-top: 0; }
/* 停用的物料：整行压暗，一眼看出"它不再能领了"（数据还在，历史单还要对账） */
table.t tbody tr.rowoff { opacity: .55; }
/* 顶栏「物料」按钮上的待办数字（有几张等我批 / 有几张可以去拿） */
.tb-btn.hasdot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
@media (max-width: 640px) {
  .supcard { padding: 9px 10px; }
}
