/* 甬标 MES+ · 手机端样式（2026-10）
   ── 目标：车间/仓库现场用手机看工单、报工、查库存、审批，一路拇指可点：
      · 单列卡片、44px 以上可点区域、底部 4 个 Tab；
      · 顶部安全区（刘海屏）+ 底部 safe-area（iPhone 手势条）；
      · 配色沿用电脑端的红色主色 #c0141b 与灰色体系。 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2937; background: #eef1f5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }

/* ---------------- 启动页 ---------------- */
.boot {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: #fff;
}
.boot-logo { font-size: 30px; font-weight: 800; letter-spacing: 2px; color: #c0141b; }
.boot-logo span { font-size: 16px; font-weight: 700; margin-left: 4px; color: #6b7280; }
.boot-tip { font-size: 13px; color: #9ca3af; }

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100%; padding: 56px 24px 32px; background: #fff;
  display: flex; flex-direction: column;
}
.login-logo { font-size: 32px; font-weight: 800; letter-spacing: 2px; color: #c0141b; }
.login-logo span { font-size: 17px; font-weight: 700; margin-left: 5px; color: #6b7280; }
.login-sub { margin: 6px 0 28px; font-size: 13px; color: #6b7280; }
.login-foot { margin-top: 22px; font-size: 12px; color: #9ca3af; text-align: center; }
.login-err { min-height: 20px; margin-top: 10px; font-size: 13px; color: #c0141b; }

.fld { display: block; margin-bottom: 14px; }
.fld > span { display: block; margin-bottom: 5px; font-size: 12.5px; color: #6b7280; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 11px 12px; font-size: 16px; color: #111827;   /* 16px 防 iOS 自动放大 */
  border: 1px solid #d5dbe3; border-radius: 10px; background: #fff; outline: none;
}
.fld input:focus, .fld select:focus { border-color: #c0141b; box-shadow: 0 0 0 3px rgba(192, 20, 27, .10); }

.btn {
  font: inherit; font-size: 16px; padding: 11px 16px; border-radius: 10px;
  border: 1px solid #d5dbe3; background: #fff; color: #1f2937; cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: #c0141b; border-color: #c0141b; color: #fff; font-weight: 600; }
.btn-block { display: block; width: 100%; }
.btn-sm { font-size: 13.5px; padding: 7px 12px; }
.btn-ghost { border: none; background: transparent; color: #c0141b; }

/* ---------------- 主界面骨架 ---------------- */
.app { display: flex; flex-direction: column; min-height: 100%; }
.hdr {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: #c0141b; color: #fff;
}
.hdr-back, .hdr-act {
  flex: none; width: 34px; height: 34px; font-size: 20px; line-height: 1; color: #fff;
  background: rgba(255, 255, 255, .16); border: none; border-radius: 9px;
}
.hdr-back[hidden] { display: none; }
.hdr-title { flex: 1; font-size: 17px; font-weight: 600; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view { flex: 1; padding: 12px 12px calc(66px + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  padding-bottom: env(safe-area-inset-bottom); background: #fff;
  border-top: 1px solid #e5e8ee;
}
.tab {
  flex: 1; padding: 7px 0 6px; font: inherit; font-size: 11px; color: #8a94a6;
  background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tab i { font-size: 19px; font-style: normal; line-height: 22px; }
.tab.on { color: #c0141b; font-weight: 600; }

/* ---------------- 通用块 ---------------- */
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
.card + .card { margin-top: 10px; }
.card-hd { display: flex; align-items: center; gap: 8px; padding: 12px 13px 0; font-size: 13px; color: #6b7280; }
.card-bd { padding: 10px 13px 13px; }
.sec-title { margin: 16px 4px 8px; font-size: 13px; font-weight: 600; color: #6b7280; }
.empty { padding: 40px 16px; text-align: center; color: #9ca3af; font-size: 14px; }
.small { font-size: 12.5px; }
.faint { color: #9ca3af; }
.warn { color: #b45309; }
.err { color: #c0141b; }
.ok { color: #0f6234; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 首页 KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { padding: 12px 13px; background: #fff; border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
.kpi b { display: block; font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi span { display: block; margin-top: 2px; font-size: 12.5px; color: #6b7280; }
.kpi.alert b { color: #c0141b; }
.kpi.good b { color: #0f6234; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button {
  padding: 12px 4px; font: inherit; font-size: 12px; color: #374151; background: #fff;
  border: 1px solid #eef1f5; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; gap: 5px;
}
.quick button i { font-size: 21px; font-style: normal; line-height: 24px; }

/* ---------------- 待办 ---------------- */
/* ★<button> 的 width:auto 在浏览器里是「收缩到内容宽」，光写 display:flex 不会撑满
   （实测待办行变成一个个小方块）→ 这里显式 width:100% 并清掉按钮默认边框/背景。 */
.todo {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px;
  padding: 12px 13px; font: inherit; text-align: left; color: inherit;
  background: #fff; border: 0; border-radius: 0; appearance: none; cursor: pointer;
}
.card > .todo:first-child { border-radius: 12px 12px 0 0; }
.card > .todo:last-child { border-radius: 0 0 12px 12px; }
.todo + .todo { border-top: 1px solid #f1f3f7; }
.todo .ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  font-size: 17px; background: #fdf2f1; border-radius: 10px; }
.todo .t { font-size: 14.5px; font-weight: 600; }
.todo .d { font-size: 12px; color: #9ca3af; }
.todo .n { font-size: 19px; font-weight: 700; color: #c0141b; font-variant-numeric: tabular-nums; }
.todo.zero { opacity: .55; }
.todo.zero .n { color: #9ca3af; }

/* ---------------- 应用分组 ---------------- */
.apps-grp { margin-top: 12px; }
.apps-grp > .gt { margin: 0 4px 8px; font-size: 13px; font-weight: 600; color: #6b7280; }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.apps-grid button {
  padding: 14px 6px; font: inherit; font-size: 12.5px; color: #374151; background: #fff;
  border: none; border-radius: 12px; box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 76px;
}
.apps-grid button i { font-size: 23px; font-style: normal; line-height: 26px; }

/* ---------------- 列表 ---------------- */
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.search input {
  flex: 1; padding: 10px 12px; font-size: 15px; border: 1px solid #d5dbe3; border-radius: 10px;
  background: #fff; outline: none;
}
.search button { flex: none; padding: 0 15px; font-size: 14px; border-radius: 10px;
  border: 1px solid #d5dbe3; background: #fff; }

.li { display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; }
.li + .li { border-top: 1px solid #f1f3f7; }
.li .lt { font-size: 14.5px; font-weight: 600; }
.li .ls { margin-top: 2px; font-size: 12.5px; color: #6b7280; }
.li .lr { flex: none; text-align: right; }
.li .amt { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.li .st { margin-top: 3px; font-size: 11px; padding: 1px 7px; border-radius: 9px;
  background: #f1f3f7; color: #6b7280; display: inline-block; }
.li .st.green { background: #e8f5ee; color: #0f6234; }
.li .st.red { background: #fdf2f1; color: #c0141b; }
.li .st.blue { background: #eaf2fd; color: #1d4ed8; }
.li .st.orange { background: #fff5e6; color: #b45309; }
.more { margin: 12px 0 4px; text-align: center; }
.more button { padding: 10px 20px; font-size: 14px; border-radius: 10px;
  border: 1px solid #d5dbe3; background: #fff; }

/* ---------------- 单据明细（详情弹层里的商品清单） ---------------- */
.lns { border: 1px solid #eef1f5; border-radius: 10px; overflow: hidden; }
.ln { padding: 10px 11px; }
.ln + .ln { border-top: 1px solid #f1f3f7; }
.ln .lt { font-size: 14px; font-weight: 600; }
.ln .ls { margin-top: 2px; font-size: 12px; color: #6b7280; line-height: 1.45; }
.ln .amt { font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lns + .row-between { margin-top: 10px; }

/* ---------------- 单据抬头卡片（详情弹层顶部） ---------------- */
.dh { padding: 2px 0 6px; }
.dno { font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.dpt { margin-top: 4px; font-size: 15px; font-weight: 600; color: #111827; }
.dmeta { margin-top: 3px; font-size: 12.5px; color: #6b7280; }
.dsum { display: flex; gap: 18px; margin-top: 8px; font-size: 12.5px; color: #6b7280; }
.dsum b { font-size: 16px; color: #c0141b; font-variant-numeric: tabular-nums; }

/* 商品行可点（点进去看图纸） */
.ln[data-i] { cursor: pointer; }
.ln[data-i]:active { background: #f8fafc; }

/* ---------------- 单据动作按钮条 ---------------- */
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed #e5e8ee; }
.acts .btn { flex: 1 1 auto; min-width: 88px; text-align: center; }

/* ---------------- 图纸（工单详情里看） ---------------- */
.dwg { border: 1px solid #eef1f5; border-radius: 10px; overflow: hidden; background: #fafbfc; }
.dwg img { display: block; width: 100%; height: auto; }

/* ---------------- 我的 ---------------- */
.me-hd { display: flex; align-items: center; gap: 12px; padding: 16px 14px; }
.me-av { width: 52px; height: 52px; border-radius: 26px; background: #c0141b; color: #fff;
  display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.me-name { font-size: 17px; font-weight: 700; }
.me-sub { font-size: 12.5px; color: #6b7280; margin-top: 2px; }
.me-list .li { padding: 14px 13px; }
.me-list .li .lt { font-weight: 500; }

/* ---------------- 底部弹层（详情/表单） ---------------- */
.sheet-host { position: fixed; inset: 0; z-index: 50; }
.sheet-mask { position: absolute; inset: 0; background: rgba(17, 24, 39, .42); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow: auto;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  background: #fff; border-radius: 16px 16px 0 0; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
/* ★标签列放宽到 108px 并允许换行：以前 92px 装不下「客户编码」这类 4 字标签，
   文字会顶到右边的值上（实测出现 "customer_codeBP-0080" 这种粘连）。 */
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 9px 10px; font-size: 14px; align-items: start; }
.kv .k { color: #6b7280; overflow-wrap: anywhere; }
.kv .v { color: #111827; word-break: break-all; font-variant-numeric: tabular-nums; }

/* 提示条 */
.toast {
  position: fixed; left: 50%; bottom: calc(78px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 70; max-width: 86vw; padding: 10px 16px; font-size: 14px; color: #fff;
  background: rgba(17, 24, 39, .9); border-radius: 10px; text-align: center;
}
.toast.err { background: rgba(192, 20, 27, .94); }
