:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  --topbar-h: 52px;
  --tabbar-h: 58px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.topbar .brand { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .userbox { display: flex; align-items: center; gap: 10px; font-size: 13px; opacity: .95; }
.topbar .userbox a { color: #fff; opacity: .9; border: 1px solid rgba(255,255,255,.5); padding: 3px 10px; border-radius: 20px; font-size: 12px; }

/* ---------- 内容区 ---------- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 12px) 12px calc(var(--tabbar-h) + 20px);
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}
.tabbar a .ico { font-size: 19px; line-height: 1; }
.tabbar a.active { color: var(--primary); font-weight: 600; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field.req label::after { content: " *"; color: var(--danger); }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 16px;              /* 防止 iOS 自动放大 */
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input[type="checkbox"], input[type="radio"] { width: auto; height: 16px; padding: 0; margin: 0; accent-color: var(--primary); }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: #4b5563; margin: 4px 0 14px; cursor: pointer; user-select: none; }
textarea { resize: vertical; min-height: 62px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
/* 修复：grid 子项默认 min-width:auto，日期/时间等原生控件会被内容撑破，导致两个日期框重叠 */
.grid2 > *, .grid3 > * { min-width: 0; }
input[type=date], input[type=time], input[type=datetime-local] { min-width: 0; }
/* 日期框提示浮层：默认隐藏（桌面端浏览器自带占位文字） */
.date-wrap { position: relative; }
.date-hint { display: none; }

/* 窄屏：两个日期框并排太挤，改成上下两行 */
@media (max-width: 560px) {
  .grid2.dates { grid-template-columns: 1fr; }
  .grid2.dates input[type=date] { font-size: 15px; }

  /* 手机端原生日期框空值时框里什么都没有，用浮层文字当提示；
     一旦选了日期就隐藏，避免和日期文字重叠 */
  .date-wrap .date-hint {
    display: block; position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%); z-index: 2;
    font-size: 15px; color: #9ca3af; pointer-events: none; white-space: nowrap;
  }
  .date-wrap.filled .date-hint { display: none; }
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.gray { background: #eef0f4; color: var(--text); }
.btn.danger { background: #fef2f2; color: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
/* 窄屏：三个按钮允许换行并缩小，避免「按开单人查询」被挤爆 */
@media (max-width: 430px) {
  .btn-row { flex-wrap: wrap; }
  .btn-row .btn { font-size: 13px; padding: 10px 8px; }
}

/* ---------- 列表 ---------- */
.list-item {
  background: #fff;
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
  display: block;
  color: inherit;
}
.list-item:active { background: #fafbfc; }
.li-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.li-name { font-weight: 600; font-size: 15px; }
.li-op { font-size: 12px; color: var(--success); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 余款状态筛选 + 收尾款 ---------- */
.seg { display: flex; gap: 8px; }
.seg-i {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: 9px;
  background: #fff; border: 1px solid var(--border);
  font-size: 13px; color: #374151; text-decoration: none; white-space: nowrap;
}
.seg-i.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.tag-paid { background: #dcfce7; color: var(--success); font-weight: 600; }
.tag-lock { background: #fee2e2; color: #b91c1c; font-weight: 600; }
.tag-admin { background: #dbeafe; color: #1d4ed8; font-weight: 600; }

/* ---------- 页脚：ICP 备案号 ---------- */
.site-footer {
  text-align: center;
  padding: 24px 12px 6px;
  font-size: 12px;
  line-height: 1.6;
  color: #94a3b8;
}
.site-footer a { color: #94a3b8; text-decoration: none; }
.site-footer a:hover { color: #64748b; text-decoration: underline; }
/* 登录页：蓝底 + 卡片居中，页脚固定在最底部 */
.site-footer.on-login {
  position: fixed;
  left: 0; right: 0; bottom: 10px;
  padding: 0;
}
.site-footer.on-login a { color: rgba(255, 255, 255, .78); }
.site-footer.on-login a:hover { color: #fff; text-decoration: underline; }
@media print { .site-footer { display: none !important; } }

/* ---------- 异地登录提醒 ---------- */
.place-notice {
  display: flex; align-items: flex-start; gap: 8px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 10px; padding: 10px 12px; margin: 0 0 12px;
  font-size: 13px; line-height: 1.65;
}
.place-notice .pn-ico { flex: 0 0 auto; }
.place-notice .pn-txt { flex: 1; word-break: break-all; }
.place-notice .pn-sub { font-size: 12px; opacity: .85; }
.place-notice .pn-close {
  flex: 0 0 auto; border: 1px solid #fcd34d; background: #fff; color: #92400e;
  border-radius: 14px; padding: 3px 10px; font-size: 12px;
  font-family: inherit; cursor: pointer; white-space: nowrap;
}
.btn.tiny {
  padding: 2px 10px; font-size: 12px; line-height: 1.7; border-radius: 12px;
  display: inline-block; background: var(--success); color: #fff;
  cursor: pointer; margin-left: 6px; border: none;
}
.btn.tiny:hover { opacity: .88; }

/* ---------- 查询提示条（按开单人查看时） ---------- */
.hint-bar {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 9px; padding: 8px 12px; font-size: 13px;
  margin: 0 0 12px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.hint-bar a { color: #1d4ed8; font-size: 12px; text-decoration: underline; white-space: nowrap; }
.li-no { font-size: 12px; color: var(--muted); }
.li-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.li-amt { color: var(--danger); font-weight: 700; font-size: 16px; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 20px; background: var(--primary-soft); color: var(--primary); }

/* ---------- 同名客户提示 ---------- */
.dupbar {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 12px;
}
.dupbar b { color: #b45309; }
.list-item.dup { border: 1px solid #fde68a; background: #fffdf5; }
.tag.warn { background: #fef3c7; color: #b45309; white-space: nowrap; }

/* 开单页：同名客户选择 */
.cands:empty, .hint-warn:empty { display: none; }
.hint-warn { color: #b45309; font-size: 12px; margin-top: 6px; line-height: 1.5; }
.hint-warn b { color: #b45309; }
.cand {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  margin-top: 8px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.cand:active { background: var(--primary-soft); }
.cand b { display: block; font-size: 14px; margin-bottom: 2px; }
.cand .c-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.cand.on { border-color: var(--primary); background: var(--primary-soft); }

/* ---------- 单据图（就地显示，不弹窗） ---------- */
.share-box {
  margin-top: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
/* 保存图片提示（原来的灰色改成主题蓝，更醒目） */
.save-hint {
  text-align: center;
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}
/* 发送原图提醒 */
.tip-orange {
  margin: 12px 0 0;
  padding: 9px 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #c2410c;
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}
.tip-orange b { color: #c2410c; }

/* ---------- 汇总条 ---------- */
.summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-radius: 10px;
  font-size: 14px;
  margin-top: 10px;
}
.summary b { color: var(--danger); font-size: 18px; }

/* ---------- 明细行 ---------- */
.item-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
  background: #fcfdff;
}
.item-row .row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.item-row .row-idx { font-size: 12px; color: var(--muted); font-weight: 600; }
.item-row .del { background: none; border: none; color: var(--danger); font-size: 13px; cursor: pointer; padding: 2px 4px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 14px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(31,41,55,.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 22px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 999;
  max-width: 86%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #2563eb 0%, #1e3a8a 100%);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 16px;
  padding: 28px 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  position: relative;              /* 安全检测层按登录框定位 */
}
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-error { background: #fef2f2; color: var(--danger); font-size: 13px; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17,24,39,.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  width: 100%;
  max-width: 720px;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }
.modal h3 { margin: 0 0 14px; font-size: 16px; }

.muted { color: var(--muted); font-size: 12.5px; }
.mb0 { margin-bottom: 0; }
.mt10 { margin-top: 10px; }
.hide { display: none !important; }
.text-right { text-align: right; }

/* ==================== 单据纸张（详情页 / 客户签名页共用） ==================== */
.bill-sheet {
  background: #fff;
  border-radius: 10px;
  padding: 16px 14px;
  box-shadow: 0 1px 4px rgba(16,24,40,.08);
  color: #111;
}
.bill-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 12px; }
.bill-head .company { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.bill-head .title { font-size: 19px; font-weight: 700; letter-spacing: 3px; margin: 4px 0 6px; }
.bill-head .meta { font-size: 12px; color: #444; display: flex; justify-content: space-between; }
.bill-cust { font-size: 13px; line-height: 1.9; margin-bottom: 8px; }
.bill-cust .row { display: flex; }
.bill-cust .k { color: #555; flex: 0 0 62px; }
.bill-cust .v { flex: 1; border-bottom: 1px dotted #bbb; min-height: 20px; }
table.bill-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 4px; table-layout: fixed; }
table.bill-table th, table.bill-table td { border: 1px solid #333; padding: 5px 2px; text-align: center; word-break: break-all; height: 26px; }
table.bill-table th { background: #f2f2f2; font-weight: 600; font-size: 11px; }
table.bill-table td.l { text-align: left; padding-right: 0; }
table.bill-table td.r { text-align: right; padding-left: 0; }
.bill-total { font-size: 13px; margin-top: 8px; font-weight: 600; }
.bill-remark { font-size: 12.5px; color: #333; margin-top: 8px; }
.bill-signer { font-size: 13px; color: #222; margin-top: 30px; text-align: left; }
.bill-foot-note { text-align: center; font-size: 11px; color: #888; margin-top: 10px; }

/* ==================================================================
   响应式：电脑 / 平板自动切换布局
   手机（默认，<900px）：保持原有手机样式不变
   电脑（≥900px）：底部导航隐藏；主导航改为【左侧竖排侧边栏】
   ================================================================== */

/* 顶栏内层：手机端与原来完全一致（品牌左、用户右） */
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 100%;
}

/* 左侧竖排导航：手机端不显示 */
.sidebar { display: none; }
.sb-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 侧边栏顶部品牌 logo：居中显示 */
.sb-brand img { display: block; height: 40px; width: auto; max-width: 100%; }

/* ==================================================================
   打开页面的同时自动安全自检（登录页）
   ================================================================== */
.sec-mask {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(17, 24, 39, .84);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  transition: opacity .4s ease;
}
.sec-mask.hide { opacity: 0; }
.sec-card {
  width: 100%; max-width: 430px;
  background: #fff; border-radius: 14px;
  padding: 20px 18px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.sec-head { display: flex; align-items: center; gap: 10px; }
.sec-shield { font-size: 26px; line-height: 1; }
.sec-head-txt b { display: block; font-size: 16px; color: #111827; }
.sec-head-txt small { display: block; font-size: 12px; color: #6b7280; margin-top: 3px; }
.sec-bar { height: 4px; border-radius: 2px; background: #e5e7eb; overflow: hidden; margin: 14px 0 12px; }
.sec-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2563eb, #22c55e); transition: width .16s linear; }
.sec-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: hidden; }
.sec-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; color: #374151; }
.sec-ico {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; background: #9ca3af;
}
.sec-item.ok .sec-ico { background: #22c55e; }
.sec-item.warn .sec-ico { background: #f59e0b; }
.sec-name { flex: 1; }
.sec-st { font-size: 12px; color: #9ca3af; }
.sec-item.ok .sec-st { color: #16a34a; }
.sec-item.warn .sec-st { color: #d97706; }
.sec-result { margin-top: 12px; font-size: 12.5px; line-height: 1.65; border-radius: 8px; padding: 8px 10px; }
.sec-result:empty { display: none; }
.sec-result.ok { background: #ecfdf5; color: #15803d; }
.sec-result.warn { background: #fffbeb; color: #b45309; }

/* ==================================================================
   登录页安全自检（逐项滚动式 + 异常锁登录）
   ================================================================== */
.login-box { position: relative; }
.sec-scan {
  position: absolute; inset: 0; z-index: 5;
  background: #fff; border-radius: 14px;
  display: none;                 /* 默认隐藏：JS 正常才会显示，避免脚本异常时盖住登录框 */
  flex-direction: column; align-items: center; justify-content: center;
  padding: 26px 22px; gap: 12px;
  transition: opacity .35s ease;
}
.sec-scan.on { display: flex; }
.sec-scan.hide { opacity: 0; pointer-events: none; }
.sec-scan .sec-shield { font-size: 30px; line-height: 1; }
.sec-scan .sec-title { font-size: 15px; color: #111827; font-weight: 600; }
.sec-scan .sec-bar { width: 100%; height: 4px; border-radius: 2px; background: #e5e7eb; overflow: hidden; }
.sec-scan .sec-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2563eb, #22c55e); transition: width .18s linear; }
.sec-slot {
  min-height: 26px; width: 100%; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #374151;
  opacity: 0; transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease;
}
.sec-slot.show { opacity: 1; transform: translateY(0); }
.sec-slot .sec-ico {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; background: #9ca3af;
}
.sec-slot.ok .sec-ico { background: #22c55e; }
.sec-slot.warn .sec-ico { background: #f59e0b; }
.sec-slot .sec-name { flex: 1; text-align: left; }
.sec-slot .sec-st { font-size: 12px; color: #9ca3af; }
.sec-slot.ok .sec-st { color: #16a34a; }
.sec-slot.warn .sec-st { color: #d97706; }

/* 登录框下方的检测结果提示 */
.sec-tip-block { display: none; margin-top: 12px; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; line-height: 1.75; }
.sec-tip-block.show { display: block; }
.sec-tip-block.warn { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; }
.sec-tip-block.danger { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.sec-tip-note { opacity: .85; font-size: 12px; }

/* 异常锁登录：按钮与输入框置灰 */
.btn-disabled, .btn[disabled] {
  background: #cbd5e1 !important; color: #64748b !important;
  cursor: not-allowed !important; box-shadow: none !important; transform: none !important;
}
.login-card input[disabled] { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.sb-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; flex: 1; overflow-y: auto; }
.sb-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #374151;
  font-size: 15px;
}
.sb-nav a:hover { background: #f3f4f6; }
.sb-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

@media (min-width: 900px) {
  :root { --topbar-h: 60px; }

  /* --- 左侧竖排侧边栏 --- */
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border);
    z-index: 110;
  }

  /* --- 顶栏：从侧边栏右侧开始 --- */
  .topbar { left: 220px; padding: 0; }
  .topbar-inner { max-width: none; margin: 0; padding: 0 24px; }
  .topbar .brand { font-size: 17px; }

  /* --- 底部导航在电脑上隐藏 --- */
  .tabbar { display: none; }

  /* --- 内容区：让出侧边栏宽度 --- */
  .container {
    margin: 0 0 0 220px;
    max-width: 1180px;
    padding: calc(var(--topbar-h) + 20px) 24px 44px;
  }

  /* --- 卡片更舒展 --- */
  .card { padding: 18px 20px; border-radius: 14px; }
  .list-item { padding: 16px 18px; }
  .list-item:hover { background: #fafbfc; box-shadow: 0 2px 10px rgba(16, 24, 40, .1); }

  /* --- 列表：电脑上排成多列 --- */
  .list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
    align-items: start;
  }
  .list-grid .list-item { margin-bottom: 0; }

  /* --- 开单页：左边录入、右边备注与保存（吸附跟随） --- */
  .cols-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
  }
  .cols-2 .side-col { position: sticky; top: calc(var(--topbar-h) + 16px); }

  /* --- 单据纸张：电脑上保持"纸质"比例并居中 --- */
  .bill-sheet { max-width: 480px; margin: 0 auto; }
  .share-box { max-width: 520px; margin: 0 auto; }
  .share-box #previewImg { max-width: 100%; }

  /* --- 弹窗：电脑上居中显示（不再从底部弹出） --- */
  .modal-mask { align-items: center; }
  .modal { border-radius: 16px; max-width: 520px; }
  .toast { bottom: 32px; }

  /* --- 空状态大字居中更好看 --- */
  .empty { padding: 80px 20px; }
}

/* ==================================================================
   定制单（独立一套）
   ================================================================== */

/* --- 录入页：明细行字段网格（手机 2 列 / 电脑 4 列，自动变化） --- */
.ct-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ct-grid .span-all { grid-column: 1 / -1; }
.ct-grid label { font-size: 12px; }
.ct-grid input { padding: 8px 9px; font-size: 15px; }

/* --- 图片上传区 --- */
.upl { margin-top: 10px; }
.upl-drop {
  display: flex;
  flex-direction: column;
  gap: 3px;
  border: 1.5px dashed #c7d2fe;
  background: #f8faff;
  border-radius: 10px;
  padding: 11px 12px;
  text-align: center;
  cursor: pointer;
}
.upl-drop.drag, .upl.on .upl-drop { border-color: var(--primary); background: var(--primary-soft); }
.upl-t { font-size: 13px; font-weight: 600; color: var(--primary); }
.upl-s { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.upl-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.upl-thumbs:empty { display: none; }
.thumb {
  position: relative;
  width: 76px; height: 76px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute;
  top: 0; right: 0;
  width: 20px; height: 20px;
  border: none;
  background: rgba(17,24,39,.65);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  padding: 0;
  border-radius: 0 0 0 8px;
  cursor: pointer;
}

/* --- 底部三栏合计 --- */
.ct-sum { justify-content: space-around; flex-wrap: wrap; gap: 6px 12px; }
.ct-sum b { font-size: 15px; }

/* --- A4 横向单据纸张 --- */
.ct-sheet {
  background: #fff;
  color: #111;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(16,24,40,.08);
  display: flex;
  flex-direction: column;
}
.ct-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 5px; margin-bottom: 6px; }
.ct-title { font-size: 16px; font-weight: 700; letter-spacing: 2px; }
.ct-company { font-size: 13px; font-weight: 600; margin-right: 10px; letter-spacing: 1px; }
.ct-meta { display: flex; justify-content: space-between; font-size: 10.5px; color: #333; margin-top: 4px; }
.ct-cust { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; margin-bottom: 6px; }
.ct-cust .c3 { flex: 1 1 200px; }
table.ct-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9.5px; }
table.ct-table th, table.ct-table td {
  border: 1px solid #333;
  padding: 3px 1px;
  text-align: center;
  vertical-align: middle;
  word-break: break-all;
}
table.ct-table th { background: #f2f2f2; font-weight: 600; font-size: 9px; line-height: 1.25; }
table.ct-table td { height: 30px; }
table.ct-table td.r { text-align: right; }
.ct-total { display: flex; gap: 18px; flex-wrap: wrap; font-size: 11px; font-weight: 600; margin-top: 6px; }
.ct-note { font-size: 10.5px; margin-top: 4px; }
.ct-signer { font-size: 11px; margin-top: 8px; }

/* 备注区（按樘逐行） */
.ct-notes { margin-top: 8px; border-top: 1px dashed #bbb; padding-top: 6px; }
.ct-block-title { font-size: 11px; font-weight: 600; margin-bottom: 4px; letter-spacing: 1px; }
.ct-note-row { display: flex; gap: 10px; padding: 2px 0; font-size: 10.5px; line-height: 1.6; }
.ct-note-row .n { flex: 0 0 52px; font-weight: 600; color: #444; }
.ct-note-row .tx { flex: 1; word-break: break-all; }

/* 单据底部：左边备注/参考图，右边固定说明 */
.ct-bottom { display: flex; gap: 18px; align-items: flex-start; }
.ct-bottom-left { flex: 1 1 auto; min-width: 0; }
.ct-bottom-right { flex: 0 0 32%; max-width: 32%; margin-left: auto; }
.ct-terms { border-top: 1px dashed #bbb; padding-top: 6px; }
.ct-terms-list { margin: 0; padding-left: 16px; font-size: 9.5px; line-height: 1.55; color: #222; }
.ct-terms-list li { margin-bottom: 2px; }

/* 手机端：说明放在卡片里（不带单据那根虚线） */
.card .ct-terms { border-top: none; padding-top: 0; }
.card .ct-terms .ct-block-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.card .ct-terms-list { font-size: 11.5px; line-height: 1.7; padding-left: 18px; }
.card .ct-terms-list li { margin-bottom: 4px; }

/* 参考图区：最下方，从左侧开始向右排列，支持多张 */
.ct-imgs { margin-top: 8px; border-top: 1px dashed #bbb; padding-top: 6px; }
.ct-img-row { display: flex; flex-wrap: wrap; gap: 10px; }
.ct-img-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ct-img-cell img {
  width: 118px; height: 118px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #ddd;
  display: block;
}
.ct-img-cell span { font-size: 10px; color: #666; }
/* 图片少时（一樘门几张图）自动放大：按数量均分，最多铺到 340px 一张 */
.ct-img-row.few { gap: 14px; }
.ct-img-row.few .ct-img-cell { flex: 1 1 0; min-width: 96px; max-width: 230px; }
.ct-img-row.few .ct-img-cell img { width: 100%; height: auto; aspect-ratio: 1 / 1; }
.ct-img-row.few .ct-img-cell span { font-size: 11px; }

@media (min-width: 900px) {
  /* 电脑端：录入行排成 4 列 */
  .ct-grid { grid-template-columns: repeat(4, 1fr); gap: 10px; }

  /* 电脑端：A4 横向纸张按比例铺开 */
  .ct-sheet { max-width: 1120px; margin: 0 auto; padding: 16px 20px; }
  .ct-title { font-size: 19px; letter-spacing: 4px; }
  .ct-company { font-size: 15px; }
  table.ct-table { font-size: 11px; }
  table.ct-table th { font-size: 10.5px; }
  table.ct-table td { height: 38px; }
  .ct-total { font-size: 13px; }
  .ct-note-row { font-size: 12px; }
  .ct-note-row .n { flex: 0 0 62px; }
  .ct-block-title { font-size: 13px; }
  .ct-img-cell img { width: 152px; height: 152px; }
  .ct-img-cell span { font-size: 11px; }
  .ct-img-row.few .ct-img-cell { max-width: 340px; }
  .ct-img-row.few .ct-img-cell span { font-size: 12px; }
  .ct-bottom { gap: 28px; }
  .ct-bottom-right { flex: 0 0 32%; max-width: 32%; }
  .ct-terms-list { font-size: 10.5px; line-height: 1.58; }
}

/* --- 打印：只打单据，A4 横向 --- */
@media print {
  @page { size: A4 landscape; margin: 8mm; }

  html, body { background: #fff; }
  .sidebar, .topbar, .tabbar, .toast, .btn, .btn-row, .share-box,
  .card, .summary, .list-grid, .empty { display: none !important; }

  .container { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  #billWrap { display: block !important; }

  .ct-sheet {
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
    width: 100%;
  }
  table.ct-table { font-size: 9pt; }
  table.ct-table th { font-size: 8.5pt; }
  table.ct-table td { height: 32px; }
  .ct-img-cell img { width: 134px; height: 134px; }
  .ct-img-cell span { font-size: 10px; }
  .ct-img-row.few .ct-img-cell { max-width: 300px; }
  .ct-notes, .ct-imgs, .ct-terms { border-top: 1px dashed #999; }
  .ct-bottom { gap: 14px; }
  .ct-bottom-right { flex: 0 0 32%; max-width: 32%; }
  .ct-terms-list { font-size: 7.8pt; line-height: 1.45; }
  .ct-title { font-size: 16pt; }
  .ct-total { font-size: 10.5pt; }
}

/* ==================================================================
   定制单录入：电脑端 = 直接在 A4 单据上填（所见即所得）
              手机端 = 卡片式录入
   ================================================================== */
.form-desktop { display: none; }

@media (min-width: 900px) {
  .form-mobile { display: none; }
  .form-desktop { display: block; }
}

/* --- 单据里的透明输入格 --- */
.cell-in {
  width: 100%;
  min-width: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 5px 3px;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
  text-align: center;
  outline: none;
}
.cell-in::placeholder { color: #b9c0cc; font-size: 10px; }
.cell-in:focus { background: #eef4ff; box-shadow: inset 0 0 0 1px var(--primary); }
.cell-in.r { text-align: right; }
.ct-cust .cell-in { text-align: left; }
.ct-meta .cell-in { width: 132px; display: inline-block; }

/* --- 编辑版表格 --- */
table.ct-edit-table td { padding: 1px; height: auto; }
table.ct-edit-table td.idx { font-size: 11px; font-weight: 600; color: #333; }
table.ct-edit-table td.bal { font-size: 11px; padding-right: 5px; color: #111; }
table.ct-edit-table td input.cell-in,
table.ct-edit-table td textarea.cell-in { font-size: 10.5px; padding: 3px 2px; }
table.ct-edit-table td textarea.cell-in {
  resize: none;
  overflow: hidden;
  display: block;
  height: 22px;
  min-height: 0;
  line-height: 1.35;
}
/* 去掉数字输入框两侧自带的上下小箭头（全站） */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- 底部操作条 --- */
.ct-edit-bar { display: flex; gap: 12px; justify-content: flex-end; margin-top: 14px; }

/* --- 参考图（录入用，按樘一行） --- */
.ct-img-line { display: flex; align-items: center; gap: 12px; padding: 5px 0; border-radius: 8px; }
.ct-img-line .n { flex: 0 0 62px; font-size: 12px; font-weight: 600; color: #444; }
.ct-img-line.drag { background: var(--primary-soft); }
.ct-img-line .thumb { width: 118px; height: 118px; }
.add-img {
  width: 118px; height: 118px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed #c7d2fe;
  border-radius: 8px;
  background: #f8faff;
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.add-img:hover { background: var(--primary-soft); border-color: var(--primary); }

/* --- 缩略图容器（手机 / 电脑通用） --- */
.img-thumbs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.img-thumbs:empty { display: none; }
.thumb { position: relative; overflow: hidden; background: #fff; flex: 0 0 auto; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x {
  position: absolute;
  top: 0; right: 0;
  width: 20px; height: 20px;
  border: none;
  background: rgba(17,24,39,.68);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  padding: 0;
  border-radius: 0 0 0 8px;
  cursor: pointer;
}

/* ==================================================================
   开单：电脑端 = 直接在送货单上填
   ================================================================== */
@media (min-width: 900px) {
  .bill-edit { max-width: 880px; padding: 22px 26px; }
}
.bill-edit .bill-cust .v { display: block; }
.bill-edit .bill-cust input.cell-in { text-align: left; }
.bill-edit .bill-meta input.cell-in,
.bill-edit .meta input.cell-in { width: 148px; display: inline-block; }
.bill-edit .title { margin: 6px 0 8px; }

table.bill-edit-table td { padding: 1px 2px; height: auto; }
table.bill-edit-table td.idx { font-size: 11px; color: #333; }
table.bill-edit-table td.r { text-align: right; padding-right: 5px; }
table.bill-edit-table input.cell-in,
table.bill-edit-table textarea.cell-in { font-size: 11.5px; padding: 3px 2px; }
table.bill-edit-table textarea.cell-in {
  resize: none;
  overflow: hidden;
  display: block;
  height: 22px;
  min-height: 0;
  line-height: 1.35;
}
.bill-edit .bill-remark { display: flex; align-items: flex-start; gap: 4px; }
.bill-edit .bill-remark textarea.cell-in {
  flex: 1;
  resize: none;
  overflow: hidden;
  height: 22px;
  min-height: 0;
  padding: 2px 4px;
  font-size: 12.5px;
  text-align: left;
  border-bottom: 1px dotted #bbb;
  border-radius: 0;
}
