:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-soft: #5b6675;
  --line: #e6eaf0;
  --primary: #2f6bff;
  --primary-dark: #1f4fd1;
  --primary-soft: #eaf0ff;
  --accent: #0fb39a;
  --danger: #e5484d;
  --shadow: 0 1px 3px rgba(20, 30, 50, .06), 0 6px 24px rgba(20, 30, 50, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* 预留网页滚动条位置，避免刷新时滚动条出现导致整页内容左右跳动 */
html { scrollbar-gutter: stable; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: #0f1b33;
  color: #cdd6e6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 22px 20px; font-size: 18px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  letter-spacing: .5px;
}
.sidebar .brand small { display:block; font-size: 11px; font-weight: 400; color:#7c8aa5; margin-top: 4px; letter-spacing: 0; }
.nav { padding: 12px 10px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin: 4px 0; border-radius: 9px;
  color: #cdd6e6; text-decoration: none; cursor: pointer; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255,255,255,.06); color:#fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ico { width: 18px; text-align: center; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--ink-soft); font-size: 13px; }
.topbar .topbar-logout {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink-soft); font-size: 13px; text-decoration: none;
  background: #fff; transition: border-color .15s, color .15s;
}
.topbar .topbar-logout:hover { border-color: var(--primary); color: var(--primary); }
.content { padding: 26px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* 产品图册：iframe 填满内容区 */
.content.catalog-frame { padding: 0; max-width: none; height: calc(100vh - 61px); position: relative; background: #f4f6f6; }
.content.catalog-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #f5f6f8; position: relative; z-index: 1; color-scheme: light; }

/* 电子签章：原生视图，填满内容区（顶栏由工作台统一提供） */
.content.seal-view { padding: 0; max-width: none; height: calc(100vh - 61px); width: 100%; position: relative; }

/* cards */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: 18px; margin: 0 0 16px; font-weight: 650; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 16px; }

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { color: var(--ink-soft); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .value.small { font-size: 20px; }
.stat.clickable { cursor: pointer; transition: background .15s, border-color .15s; }
.stat.clickable:hover { background: #f4f7fb; border-color: #c5cdd8; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 15px; border-radius: 9px; font-size: 13.5px; font-weight: 400;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  transition: all .15s; text-decoration: none; line-height: 1;
}
.btn:hover { border-color: #c7cfdb; background: #f7f9fc; }
.btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 400; border-radius: 4px; height: 34px; padding: 0 16px; box-sizing: border-box; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: #dc2626; border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
/* 工具栏：非主按钮统一样式（T3 扁平极简） */
.list-toolbar .btn:not(.primary) {
  border: 1px solid #e2e2e2; border-radius: 4px; color: #444;
  background: transparent; font-weight: 400;
  height: 34px; padding: 0 12px; box-sizing: border-box;
}
.list-toolbar .btn:not(.primary):hover { background: #f5f5f5; border-color: #ccc; }
/* 批量删除：红色文字 */
.list-toolbar .btn.danger { color: #dc2626 !important; border-color: #fecaca !important; font-weight: 400; }
.list-toolbar .btn.danger:hover { background: #fef2f2 !important; }
/* 批量导入：覆盖内联青绿色为黑色 */
.list-toolbar .batch-bar > .btn[style*="0fb39a"],
.list-toolbar .batch-bar > .btn[style*="teal"],
.list-toolbar a.btn[style*="0fb39a"] { color: #1f2733 !important; border-color: #e2e2e2 !important; }
.list-toolbar .batch-bar > .btn[style*="0fb39a"]:hover,
.list-toolbar .batch-bar > .btn[style*="teal"]:hover,
.list-toolbar a.btn[style*="0fb39a"]:hover { color: #1f2733 !important; background: #f5f5f5 !important; }
/* 批量改状态：蓝框蓝字（最初版本） */
.list-toolbar .batch-bar > div.btn {
  height: 34px; box-sizing: border-box; padding: 0; display: inline-flex; align-items: center;
  border: 1px solid #2563eb; border-radius: 4px; background: #fff;
}
.list-toolbar .batch-bar > div.btn > select {
  padding: 0 24px 0 10px !important; font-size: 13.5px !important;
  height: 34px !important; background: transparent !important; border: none !important;
  cursor: pointer; color: #2563eb !important;
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* table */
/* 使用 border-collapse: separate 而非 collapse，避免 Chrome/Edge 在缩放/高分屏下
   出现 position:sticky 表头被下方数据行穿透的渲染 bug（边框线仍然保留） */
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
table.data th,
table.data td {
  border: 1px solid #d9d9d9;
  border-width: 0 1px 1px 0;
}
table.data td:first-child,
table.data th:first-child {
  border-left-width: 1px;
}
table.data th {
  text-align: left; padding: 12px 12px;
  background: #f1f5f9;
  border-top-width: 1px;
  border-bottom: 2px solid #cbd5e1;
  font-weight: 600; color: #1e293b;
  font-size: 14px; white-space: nowrap; transition: background .15s, color .15s;
  position: sticky; top: 0; z-index: 3;
  backface-visibility: hidden;
}
table.data td {
  text-align: left; padding: 9px 12px; font-size: 14px;
  background: #fff;
  /* 给 td 建立独立层叠上下文并置于 z-index:1，确保 sticky 表头在滚动时始终覆盖数据行 */
  position: relative; z-index: 1;
}
table.data th.sort-col { cursor: pointer; user-select: none; }
table.data th.sort-col:hover { background: #e0f2fe; color: #1d4ed8; }
table.data th.sort-col.sort-active { color: #1d4ed8; }
table.data th.sort-col .sort-arrow { margin-left: 2px; font-size: 10px; opacity: .5; transition: opacity .15s, color .15s; }
table.data th.sort-col.sort-active .sort-arrow { opacity: 1; color: #1d4ed8; }
table.data tr { cursor: pointer; }
table.data tr:hover td { background: #f8fafc; }
table.data tr.hover-row td { background: #f8fafc; }
table.data tr.selected-row td { background: #eef6ff; }
table.data tr.selected-row:hover td { background: #e0efff; }
/* 合同列表表格统一微软雅黑（覆盖全局宋体），与新建合同页/工具栏一致，仅改字体不动布局 */
.list-scroll table.data, .list-scroll table.data th, .list-scroll table.data td, .list-scroll table.data * {
  font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif;
}
/* 合同编号列强制不换行（微软雅黑比宋体宽，140px 放不下会分行） */
.list-scroll table.data td:nth-child(3) { white-space: nowrap; }
/* 合同列表页：整页不滚动，仅表格卡片内部滚动。
   内容区占满 topbar 下方剩余视口高度，筛选卡片固定高度，表格卡片自适应剩余高度。 */
.content.list-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 61px); /* topbar 60px + 1px border */
  overflow: hidden;
}
/* 合同列表页：把表格卡片向右扩，吃掉 .content padding 26 + .card padding 20 + max-width 1400 占掉的横向空间（只对列表页生效，其它页面不动） */
.content.list-page { padding: 8px; max-width: none; }
.content.list-page .card { padding: 12px; }
.content.list-page .list-filter-card { flex: 0 0 auto; }
.content.list-page .list-table-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.content.list-page .list-table-card .list-meta { flex: 0 0 auto; }
/* #listBox 是 .list-scroll 的父容器，必须也是 flex 容器，.list-scroll 的 flex:1 才会生效 */
.content.list-page .list-table-card #listBox {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.content.list-page .list-table-card #listBox .list-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  position: relative; /* 建立独立层叠上下文，配合 sticky 表头正确裁剪 */
}
.content.list-page .list-table-card #pager { flex: 0 0 auto; }
.list-scroll table.data { table-layout: fixed; }
/* 手机端卡片视图：桌面端默认隐藏，≤820px 时由下方媒体查询显示。电脑端布局完全不受影响 */
.list-cards { display: none; }
.batch-bar { display:flex; gap:10px; align-items:center; }
.table-tools { display:flex; gap:10px; align-items:center; margin-bottom: 14px; flex-wrap: wrap; }
/* 列表页：搜索/操作区独立成卡片后，去掉工具条自带下边距，由卡片间距控制 */
.list-filter-card .table-tools { margin-bottom: 0; }
/* 列表页：筛选卡片内「左筛选 / 右操作」分区 */
.list-toolbar {
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
}
/* 工具栏内状态下拉：覆盖全局 select 的大字号/大圆角 */
.list-toolbar > select#statusFilter {
  padding: 2px 28px 2px 12px !important; font-size: 15px !important;
  line-height: 1 !important;
  border-radius: 4px !important; height: 34px !important; box-sizing: border-box !important;
  border: 1px solid #ddd !important; background: #fff;
}
/* 列表页：表格卡片顶部信息条（共 N 个合同 / 已选 M 条） */
.list-meta { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; font-size:13px; color:var(--ink-soft); flex-wrap:wrap; }
.meta-left { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.meta-stats { display:flex; align-items:center; gap:10px; }
.meta-actions { display:flex; align-items:center; gap:8px; }
.list-meta b { color:var(--ink); font-weight:600; }
.list-meta .meta-dot { color:#cbd5e1; }
.list-meta .meta-sel { color:var(--danger); }
/* 列表页：导出按钮（T3 扁平极简，与工具栏统一） */
.btn.btn-export { display:inline-flex; align-items:center; gap:7px; padding:0 14px; border-radius:4px; height:34px; box-sizing:border-box; font-size:15px; font-weight:400; letter-spacing:0; }
/* 覆盖 btn-sm 的小尺寸，与新建合同按钮等高 */
.btn.btn-export.btn-sm { padding:0 14px !important; font-size:15px !important; height:34px !important; }
.btn-export-primary { background:#2563eb; border-color:#2563eb; color:#fff; }
.btn-export-primary:hover { background:#1d4ed8; border-color:#1d4ed8; }
.btn-export-secondary { background:#fff; border-color:#2563eb; color:#2563eb; }
.btn-export-secondary:hover { background:#2563eb; border-color:#2563eb; color:#fff; }
.btn-export-secondary svg { fill:#2563eb; }
.btn-export svg { width:16px; height:16px; }
/* 列表页：操作列链接（统一蓝 + 删除加粗） */
.op-link { color:var(--primary); cursor:pointer; text-decoration:none; margin-right:14px; font-size:13.5px; }
.op-link:last-child { margin-right:0; }
.op-link:hover { color:var(--primary-dark); }
.op-link.op-primary { color:var(--primary); }
.op-link.op-primary:hover { color:var(--primary-dark); }
.op-link.op-danger { color:var(--danger); font-weight:500; }
.op-link.op-danger:hover { color:#c0392b; }
.search-input {
  border: 1px solid #ddd; border-radius: 4px; padding: 8px 12px; font-size: 15px;
  min-width: 200px; outline: none; background: #fff; height: 34px; box-sizing: border-box;
}
.search-input:focus { border-color: #2563eb; }

/* form */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: #444; margin-bottom: 6px; font-weight: 500; }
.field .req { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; border: 1px solid #d9d9d9; border-radius: 4px;
  padding: 8px 12px; font-size: 14px !important;
  font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif;
  outline: none; background:#fff; color: #1f2733;
}
::placeholder { font-size: inherit; opacity: 0.6; }
/* 数字输入框：隐藏上下箭头 */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* items table (注: 货物清单表格的字体/字号统一在下方 221 行起的专用块中定义) */
.items-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.items { width: 100%; border-collapse: collapse; min-width: 920px; }
table.items .col-idx { width: 42px; text-align: center; color: var(--ink-soft); }
table.items .col-amount { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals-bar {
  display: flex; justify-content: flex-end; gap: 30px; align-items: center;
  margin-top: 14px; flex-wrap: wrap;
}
.totals-bar .t { font-size: 14px; }
.totals-bar .t b { font-size: 18px; color: var(--primary-dark); }

/* 实物图单元格 */
table.items .col-pic { width: 116px; }
.pic-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pic-drop {
  width: 104px; height: 64px; border: 1px dashed #c2cad8; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  cursor: pointer; background: #fafbfd; transition: all .15s; outline: none;
}
.pic-drop:hover { border-color: var(--primary); background: #f3f7ff; }
.pic-drop.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.pic-drop.drag { border-color: var(--accent); background: #eafffb; }
.pic-drop.uploading { opacity: .6; }
.pic-drop .ph { font-size: 11px; color: var(--ink-soft); text-align: center; line-height: 1.3; }
.pic-drop img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.pic-act { display: flex; gap: 8px; font-size: 12px; }
.link.sm { font-size: 12px; }
.link.danger { color: var(--danger); }

/* 电子章上传 */
.seal-box { min-width: 160px; flex: 1; }
.seal-drop {
  width: 150px; height: 150px; border: 2px dashed #c2cad8; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  cursor: pointer; background: #fafbfd; transition: all .15s; outline: none;
}
.seal-drop:hover { border-color: var(--primary); background: #f3f7ff; }
.seal-drop.has { border-style: solid; border-color: var(--accent); }
.seal-drop.uploading { opacity: .6; }
.seal-drop .ph { font-size: 12px; color: var(--ink-soft); text-align: center; line-height: 1.5; }
.seal-drop img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 签章区印章（预览/打印） */
.sign .seal-col { position: relative; }
.seal-img {
  position: absolute; width: 150px; height: 150px;
  object-fit: contain; opacity: .88;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.seal-img.buyer-seal {
  top: -20px; left: 4px;
}
.seal-img.seller-seal {
  top: -20px; left: 4px;
}

/* badge */
.badge { display:inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.empty { text-align:center; color: var(--ink-soft); padding: 50px 0; }
.link { color: var(--primary); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* toast */
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 999;
  background: #1f2733; color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2); font-size: 13.5px; opacity: 0; transform: translateY(-8px);
  transition: all .25s; pointer-events: none; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #c0392b; }
.toast.ok { background: #2f9e6b; }

/* ====== contract preview (A4) ====== */
.preview-shell { background: #e9edf3; padding: 24px; }
.preview-shell.mobile-view { padding: 8px; background: #f0f2f5; }
.doc {
  background: #fff; width: 794px; max-width: 100%; margin: 0 auto;
  padding: 36px 36px 46px; color: #1a1a1a; font-size: 15px; line-height: 1.8;
  font-family: "Microsoft YaHei","PingFang SC","Hiragino Sans GB",sans-serif;
  box-shadow: 0 4px 30px rgba(0,0,0,.12);
}
/* 手机端合同内容：宽度自适应，可横向滑动查看完整A4 */
@media (max-width: 820px) {
  .doc {
    width: 100%;
    padding: 20px 16px 28px;
    font-size: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
  }
  /* 合同内容区包裹层：允许横向滚动 */
  .preview-shell {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 4px;
  }
  /* 表格最小宽度保证不压缩变形 */
  .doc table.goods { min-width: 600px; }
}
@media (max-width: 480px) {
  .doc { padding: 16px 12px 24px; font-size: 13px; }
  .doc h1.title { font-size: 20px; letter-spacing: 4px; margin-bottom: 18px; }
  .doc table.goods { min-width: 540px; font-size: 12px; }
  .doc table.goods th, .doc table.goods td { padding: 4px 2px; }
}
.doc h1.title { text-align: center; font-size: 26px; letter-spacing: 4px; margin: 0 0 18px; font-weight: 700; }
.doc .parties { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.doc .parties .p { font-size: 16px; font-weight: 700; }
.doc .section-title { font-size: 16px; }
.doc .intro { margin: 16px 0 18px; text-indent: 0; font-size: 16px; }
.doc table.goods { border-collapse: collapse; margin: 8px 0 6px; font-size: 14px; max-width: 100%; table-layout: auto; }
.doc table.goods th, .doc table.goods td { border: 1px solid #333; padding: 4px 3px; text-align: center; vertical-align: middle; }
.doc table.goods th { font-weight: 600; white-space: nowrap; }
.doc table.goods td .pic { width: 100px; height: auto; cursor: pointer; display: block; }
/* 实物图单元格去掉内边距，消除图片周围空白 */
.doc table.goods td:has(> .pic) { padding: 2px 1px; }

/* 新建/编辑页表格：单元格居中，输入框居中 */
table.items { border-collapse: collapse; width: 100%; font-size: 15px; font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif; }
table.items th, table.items td { border: 1px solid #ccc; padding: 5px 4px; text-align: center; vertical-align: middle; }
table.items th { background: #f1f5f9; white-space: nowrap; font-size: 15px; color: #1e293b; font-weight: 600; }
table.items th.col-idx { color: var(--ink); }
table.items td input, table.items td select, table.items td textarea { text-align: center; font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif; font-size: 15px !important; box-sizing: border-box; border: none !important; outline: none !important; background: transparent; min-height: 36px; padding: 4px 6px; width: 100%; }
/* 聚焦：无任何边框/高亮（纯净无边框） */
table.items td input:focus, table.items td select:focus { outline: none !important; border-color: transparent !important; box-shadow: none !important; background: transparent !important; }
table.items td.col-amount { font-size: 15px; font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif; }
table.items td input[data-f="spec"] { border: none !important; outline: none !important; background: transparent; box-shadow: none !important; text-align: center !important; padding: 0 !important; width: 100% !important; }
/* 产品名称：padding留白让文字视觉居中 */
table.items td.cell-name { vertical-align: middle; text-align: center !important; padding: 4px 6px; }
table.items td.cell-name textarea[data-f="name"] { width: 100%; padding: 12px 6px 4px 6px; line-height: 1.25; text-align: center !important; border: none; outline: none; background: transparent; resize: none; overflow-y: hidden; font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif; font-size: 15px !important; word-break: break-word; box-sizing: border-box; min-height: 36px !important; height: 36px !important; }
/* 备注：td 2px + flex 容器让 textarea 真正垂直居中，四周统一 2px */
table.items td:has(textarea[data-f="note"]) { padding: 2px !important; }
.note-cell-wrap { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 36px; }
table.items td textarea[data-f="note"] { width: 100%; padding: 8px 0 !important; line-height: 1.15 !important; text-align: center !important; border: none; outline: none; background: transparent; resize: none; overflow-y: hidden; font-family: -apple-system,"Microsoft YaHei","PingFang SC",sans-serif; font-size: 15px !important; word-break: break-word; box-sizing: border-box; min-height: 36px !important; }
table.items td input[data-f="spec"]:focus { border: none !important; outline: none !important; box-shadow: none !important; }
table.items td input.locked-input { border: none; background: transparent; outline: none; cursor: default; -webkit-appearance: none; appearance: none; }
table.items td.col-idx { cursor: pointer; position: relative; user-select: none; transition: background 0.15s; border-radius: 3px; }
table.items td.col-idx:hover { background: #e8f4fd; color: #1677ff !important; font-weight: 600; }
table.items td.col-idx:hover .idx-num { display: none !important; }
table.items td.col-idx:hover .idx-copy { display: inline !important; }
.doc .total-line { display:flex; justify-content: space-between; margin-top: 8px; padding: 6px 2px; }
.doc .total-line .big { font-weight: 700; }
.doc .section { margin-top: 20px; }
.doc .section .st { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.doc .terms li { margin: 4px 0; }
.doc .sign { display: flex; justify-content: space-between; margin-top: 34px; }
.doc .sign .col { width: 44%; }
.doc .sign .col:last-child { margin-left: auto; }
.doc .sign .line { margin: 22px 0 6px; }
.doc .sign .label { color: #333; }
.preview-toolbar { display:flex; gap:8px; justify-content:center; margin-bottom: 16px; flex-wrap: wrap; }
.preview-toolbar .btn { font-size: 13px; padding: 8px 12px; }
.print-tip { font-size: 12px; color: #d97706; text-align: center; margin: -6px 0 10px; }

/* 手机端货物清单卡片列表（桌面端隐藏，仅手机端显示） */
.rc-item-list { display: none; }

/* ====== 新建/编辑页 货物清单 手机端折叠展开（方案C，仅 max-width:820px 生效，桌面端不动） ====== */
@media (max-width: 820px) {
  .items-wrap { overflow-x: hidden; border: none; background: transparent; padding: 0; }
  /* 隐藏原始表格，用 JS 生成的卡片列表替代 */
  table.items { display: none !important; }
  .rc-item-list { display: flex; flex-direction: column; gap: 10px; }
  /* 卡片列表容器 */
  .rc-item-list { display: flex; flex-direction: column; gap: 10px; }
  /* 每行 = 一张可折叠卡片 */
  .rc-item {
    border: 1px solid #e0e4ea; border-radius: 10px;
    background: #fff; overflow: hidden;
  }
  /* 展开时允许溢出（规格型号下拉框需要超出 .rc-item 边界显示） */
  .rc-item.rc-open { overflow: visible; }
  /* ── 摘要栏（始终可见）── */
  .rc-sum {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; cursor: pointer;
    user-select: none; -webkit-tap-highlight-color: transparent;
  }
  .rc-sum .s-idx {
    width: 26px; height: 26px; border-radius: 50%;
    background: #eaf0ff; color: #1f4fd1; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .rc-sum .s-name {
    flex: 1; font-size: 15px; font-weight: 600; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
  }
  .rc-sum .s-amt {
    font-weight: 700; color: #1f4fd1; font-size: 15px; flex-shrink: 0;
    margin-right: 2px;
  }
  .rc-sum .s-arrow {
    color: #94a3b8; font-size: 18px; flex-shrink: 0;
    transition: transform .2s;
  }

  /* ── 展开区（默认隐藏）── */
  .rc-detail { display: none; }
  .rc-item.rc-open .rc-detail { display: block; }
  .rc-item.rc-open { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
  .rc-item.rc-open .rc-sum .s-arrow { transform: rotate(90deg); }
  .rc-item.rc-open .rc-sum { border-bottom: 1px solid #eef1f5; }

  .rc-fld-lab { font-size: 12.5px; color: #475569; font-weight: 600; }
  /* 整行字段：产品名称 / 备注 / 实物图 */
  .rc-full { border-bottom: 1px solid #f5f6f7; padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; }
  /* 三列行：规格型号 / 单位 / 数量 */
  .rc-row3 { display: grid; grid-template-columns: 1.65fr 0.9fr 1fr; border-bottom: 1px solid #f5f6f7; }
  .rc-row3 .rc-fld { padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid #f5f6f7; position: relative; }
  .rc-row3 .rc-fld:last-child { border-right: none; }
  /* 两列行：含税单价 / 含税总价 */
  .rc-row2 { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #f5f6f7; }
  .rc-row2 .rc-fld { padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid #f5f6f7; position: relative; }
  .rc-row2 .rc-fld:last-child { border-right: none; }
  /* 操作行 */
  .rc-acts { display: flex; justify-content: flex-end; gap: 16px; padding: 10px 14px; border-top: 1px solid #eef1f5; }

  /* 输入框统一样式 */
  .rc-fld input, .rc-fld textarea, .rc-full input, .rc-full textarea {
    border: 1px solid #d8dee8; border-radius: 8px;
    background: #fff; padding: 8px 10px; min-height: 38px;
    width: 100%; font-size: 15px; font-family: inherit; box-sizing: border-box;
  }
  .rc-full textarea { resize: none; overflow-y:hidden; line-height:1.3; }
  /* 实物图占位 */
  .rc-pic-drop { width:100%; height:60px; border:1px dashed #c2cad8; border-radius:8px; display:flex; align-items:center; justify-content:center; background:#fafbfd; }
  .rc-pic-drop .ph { font-size:12px; color:#5b6675; text-align:center; line-height:1.3; }
}

/* print */
@media print {
  body { background: #fff; margin: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sidebar, .topbar, .preview-toolbar, .no-print, .print-tip, .pic-lightbox { display: none !important; }
  .preview-shell { padding: 0; background: #fff; overflow-x: hidden !important; }
  .doc {
    box-shadow: none;
    width: 100%;
    box-sizing: border-box;
    padding: 14mm;
    font-size: 11pt;
    line-height: 1.75;
    font-family: "Arial", "SimHei", "DengXian", "Microsoft YaHei", sans-serif;
  }
  .doc h1.title { font-size: 20pt; letter-spacing: 4px; }
  .doc table.goods { font-size: 11pt; }
  .doc table.goods th { font-size: 11pt; font-weight: 600; }
  .doc .section-title { font-size: 12pt; }
  @page { size: A4; margin: 0; }
  /* 列表页快捷打印：仅显示背后渲染的 #printContainer，不进预览页、不弹新标签 */
  body.printing-list > *:not(#printContainer) { display: none !important; }
  body.printing-list #printContainer { position: static !important; left: auto !important; top: auto !important; width: auto !important; display: block !important; opacity: 1 !important; background: #fff; }
  body.printing-list #printContainer .no-print,
  body.printing-list #printContainer .preview-toolbar,
  body.printing-list #printContainer .print-tip,
  body.printing-list #printContainer .pic-lightbox { display: none !important; }
}

/* 列表页快捷打印：平时隐藏；打印准备态时变为"完全透明覆盖层"。
   图片必须在视口内被 Chrome 真实光栅化，离屏容器图片不会被光栅化→打印空白（此前失败根因）。
   opacity:0 让用户在列表页完全看不到过程页面，z-index:99999 保证仍在渲染顶层被真实绘制；
   打印对话框弹出后 @media print 恢复 opacity:1 显示合同。 */
#printContainer { display: none; }
body.printing-list #printContainer {
  display: block;
  position: fixed; inset: 0;
  left: 0; top: 0; right: 0; bottom: 0;
  width: auto; background: #fff;
  overflow: auto;
  opacity: 0;          /* 完全不可见，避免闪现合同页；但元素仍在视口内，浏览器继续光栅化 */
  z-index: 99999;      /* 保持最高层，确保被浏览器真实光栅化 */
  pointer-events: none; /* 不拦截鼠标、不抢焦点 */
}
/* 准备态也隐藏工具栏/无打印元素，避免闪现预览界面 */
body.printing-list #printContainer .preview-toolbar,
body.printing-list #printContainer .no-print,
body.printing-list #printContainer .print-tip,
body.printing-list #printContainer .pic-lightbox { display: none; }

/* 规格型号自定义下拉（替代 datalist，下拉文字可居中/改字体） */
/* 注意：position / left / top / width 均由 JS openSpec() 动态设置（absolute 挂 .rc-fld 内，CSS 已设 position:relative） */
.spec-combo {
  background: #fff; border: 1px solid #e6eaf0; border-radius: 9px;
  box-shadow: 0 6px 24px rgba(20,30,50,.12);
  max-height: 240px; overflow-y: auto;
  font-family: "Microsoft YaHei","PingFang SC","Hiragino Sans GB",-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans CJK SC",sans-serif;
  font-size: 16px;
}
.spec-combo-item { padding: 9px 14px; text-align: center; cursor: pointer; color: #1f2733; white-space: nowrap; }
.spec-combo-item:hover, .spec-combo-item.active { background: #eef5ff; color: #1677ff; font-weight: 600; }

/* 管理材质选项弹窗 */
.spec-manage-mask { position: fixed; inset: 0; background: rgba(15,27,51,.45); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.spec-manage-box { background: #fff; border-radius: 14px; width: 420px; max-width: 92vw; max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; font-family: "Microsoft YaHei","PingFang SC","Hiragino Sans GB",-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans CJK SC",sans-serif; }
.spec-manage-box .sm-head { padding: 16px 18px; font-size: 17px; font-weight: 650; border-bottom: 1px solid var(--line); }
.spec-manage-box .sm-head .sm-sub { font-size: 12px; color: #888; font-weight: 400; }
.spec-manage-box .sm-list { padding: 14px 18px; overflow-y: auto; }
.spec-manage-box .sm-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.spec-manage-box .sm-input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 15px; font-family: inherit; outline: none; }
.spec-manage-box .sm-input:focus { border-color: var(--primary); }
.spec-manage-box .sm-actions { display: flex; gap: 10px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }

/* ===================== 手机端适配 ===================== */
/* 汉堡按钮与遮罩默认隐藏（桌面端不显示） */
.hamburger { display: none; }
.nav-overlay { display: none; }

@media (max-width: 820px) {
  /* 侧边栏改为可滑出的抽屉 */
  .app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: 80vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-overlay.show {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0,0,0,.45);
  }
  /* 顶栏显示汉堡按钮，缩小高度 */
  .hamburger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; font-size: 22px; line-height: 1;
    border: none; background: transparent; color: var(--ink); cursor: pointer;
    margin-right: 6px; flex-shrink: 0;
  }
  .topbar { height: 54px; padding: 0 12px; position: relative; justify-content: center; }
  .topbar .hamburger { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); margin-right: 0; }
  .topbar > div:nth-of-type(1) { text-align: center; width: 100%; padding: 0 46px; box-sizing: border-box; }
  .topbar > div:nth-of-type(2) { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { font-size: 12px; }

  /* 内容区 */
  .content { padding: 14px; }
  .content.catalog-frame { height: calc(100vh - 54px); }

  /* 表单单列、行竖排；合同编号 / 需方 仍占满整行（保持原样） */
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field:nth-child(1),
  .form-grid .field:nth-child(2) { grid-column: 1 / -1; }
  /* 签订日期 + 状态：移动端一行两列 */
  .form-grid .field:nth-child(3) { grid-column: 1; }
  .form-grid .field:nth-child(4) { grid-column: 2; }
  /* 需方行：移动端 label 行右侧放按钮，输入框单独一整行（下移留间隙，不压线） */
  .form-grid .field:nth-child(1) input { width: 100%; box-sizing: border-box; }
  .form-grid .field.field-buyer { position: relative; }
  .form-grid .field.field-buyer > label { min-height: 30px; padding-right: 120px; box-sizing: border-box; display: flex; align-items: center; }
  .form-grid .field.field-buyer > .buyer-row { display: flex !important; flex-direction: column !important; }
  .form-grid .field.field-buyer > .buyer-row > input#buyer { width: 100% !important; box-sizing: border-box; order: 2; margin-top: 6px; }
  .form-grid .field.field-buyer > .buyer-row > button { position: absolute; top: 0; right: 0; height: 30px; font-size: 13px; padding: 0 12px; }
  .form-grid .field.field-buyer > .buyer-row > button:first-of-type { right: 62px; }
  .row { flex-direction: column; align-items: stretch; }
  .grid-stats { grid-template-columns: 1fr 1fr; gap: 12px; }

  /* 卡片内宽表格可横向滚动，避免撑破屏幕 */
  .card { padding: 16px; overflow-x: auto; }
  table.data { width: 100%; }

  /* 手机端合同列表：操作列竖排（间距适中，防误点） */
  .list-page table.data td:last-child {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: flex-start;
    min-width: 52px;
    padding: 4px 0;
  }
  .list-page table.data td:last-child .link {
    font-size: 13px;
    margin-left: 0 !important;
    white-space: nowrap;
    padding: 3px 0;
    line-height: 1.5;
  }

  /* 手机端合同列表：隐藏宽表格，改为卡片「整页滚动」（电脑端不变，仅 ≤820px 生效） */
  .list-scroll-table { display: none; }
  /* 解除桌面端「整页不滚、仅内容区内部滚」的约束，手机端整页可上下滑动看完全部合同 */
  .content.list-page {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    display: block !important;
  }
  .content.list-page .list-filter-card { flex: none !important; }
  .content.list-page .list-table-card {
    flex: none !important;
    min-height: 0 !important;
    display: block !important;
    height: auto !important;
  }
  .content.list-page .list-table-card #listBox {
    flex: none !important;
    min-height: 0 !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  /* 列表卡片在手机端减少左右内边距，让合同卡片更宽、更舒展 */
  .content.list-page .list-table-card { padding: 16px 8px !important; }
  /* 搜索框卡片与列表卡片左右留白保持一致（手机端） */
  .content.list-page .list-filter-card { padding: 16px 8px !important; }
  /* 手机端批量操作区：批量改状态 / 批量删除 / 批量导入 三按钮并成一行（电脑端不变） */
  .list-toolbar .batch-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 8px;
    width: 100%;
  }
  .list-toolbar .batch-bar > .btn,
  .list-toolbar .batch-bar > div.btn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 34px !important;
    padding: 0 4px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
  }
  .list-toolbar .batch-bar div.btn select {
    width: 100%;
    height: 100% !important;
    text-align: center;
    text-align-last: center;
    padding: 0 14px 0 3px !important;
    font-size: 13.5px !important;
    line-height: 1 !important;
    border: none !important;
    background: transparent !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M1 1.4 L5 4.8 L9 1.4' fill='none' stroke='%232563eb' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 2px center !important;
    background-size: 10px 6px !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
  }
  .list-toolbar .search-input {
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }
  .list-toolbar #statusFilter,
  .list-toolbar > a.btn.primary {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .list-toolbar > a.btn.primary {
    justify-content: center !important;
    text-align: center !important;
  }
  /* 手机端：列表底部「取消选择 / 打印导出PDF / 开票汇总」三按钮——强制横排一行占满整行，
     压缩内边距与图标间距腾出空间，配合 nowrap 保证任何浏览器下文字都单行、不被裁 */
  .list-meta { width: 100% !important; }
  .meta-actions { width: 100% !important; flex-wrap: nowrap !important; }
  .meta-actions a.btn-export.btn-sm {
    flex: 1 1 auto !important;
    white-space: nowrap !important;
    padding: 0 6px !important;
    gap: 4px !important;
    justify-content: center !important;
  }
  .list-cards {
    display: block !important;
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: auto;
    padding: 10px 0 20px;
  }
  .content.list-page .list-table-card #pager { flex: none !important; margin-top: 6px; }
  .list-empty { text-align: center; color: #94a3b8; padding: 40px 0; font-size: 14px; }
  .contract-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 12px 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(15,23,42,.06);
  }
  .contract-card.selected-row { border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
  .cc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .cc-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; cursor: pointer; }
  .cc-check input { width: 18px; height: 18px; }
  .cc-buyer { font-size: 17px; font-weight: 700; color: #0f172a; line-height: 1.4; margin-bottom: 8px; word-break: break-word; }
  .cc-line { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; border-top: 1px dashed #eef2f7; }
  .cc-k { color: #94a3b8; flex-shrink: 0; }
  .cc-v { color: #334155; font-weight: 500; text-align: right; margin-left: 12px; font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; }
  .cc-prods {
    margin-top: 8px;
    font-size: 14px;
  }
  .cc-prods .cc-k { display: block; margin-bottom: 4px; color: #94a3b8; }
  .cc-prod { color: #334155; font-weight: 500; padding: 2px 0; line-height: 1.5; word-break: break-word; font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; }
  .cc-prod-empty { color: #94a3b8; }
  .cc-ops { display: flex; gap: 16px; margin-top: 10px; border-top: 1px solid #eef2f7; padding-top: 10px; }
  .cc-ops .op-link { font-size: 14px; }

  /* 移动端：规格型号下拉框适配——缩小字体 + 加大每行点按区域，方便手指操作 */
  .spec-combo { font-size: 15px; }
  .spec-combo-item { padding: 13px 14px; min-height: 46px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; }

  /* 手机端合同预览：工具栏竖排（每行一个按钮，方便点击）—— 仅屏幕生效，打印时隐藏 */
  @media screen {
    .btn { padding: 11px 16px; font-size: 15px; }
    .btn.sm { padding: 9px 13px; }
    .preview-toolbar {
      display: flex !important;
      flex-direction: column !important;
      flex-wrap: nowrap !important;
      align-items: stretch !important;
      justify-content: stretch !important;
      gap: 8px !important;
    }
    .preview-toolbar .btn {
      width: 100% !important;
      justify-content: center !important;
      padding: 12px 16px !important;
      font-size: 14.5px !important;
      box-sizing: border-box !important;
    }
    /* 复制为图片按钮醒目 */
    #btn-copy-img {
      background: #0fb39a !important;
      color: #fff !important;
      border-color: #0fb39a !important;
      font-weight: 600 !important;
    }
  }
  .doc { padding: 18px; }
}

@media (max-width: 480px) {
  .grid-stats { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 16px; }
}

/* ===== 实物图点击放大灯箱（仅在屏幕显示，不参与打印）===== */
@media screen {
  .pic-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    display: none; align-items: center; justify-content: center;
    padding: 20px; box-sizing: border-box;
    background: rgba(0,0,0,0.85);
  }
  .pic-lightbox.open { display: flex; }
  .pic-lightbox img.pic-lb-img {
    max-width: 94%; max-height: 90%;
    object-fit: contain; background: #fff;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
  }
  .pic-lightbox .pic-lb-tip {
    position: absolute; top: 14px; left: 0; right: 0;
    text-align: center; color: #fff; font-size: 13px; opacity: 0.85;
    pointer-events: none;
  }
  .pic-lightbox .pic-lb-close {
    position: absolute; top: 12px; right: 14px;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.2); color: #fff; border: none;
    font-size: 20px; line-height: 1; cursor: pointer;
  }
}

