:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e3e8ef;
  --line-soft: #eef1f6;
  --text: #1f2937;
  --text-2: #5b6675;
  --muted: #8a94a6;
  --primary: #2563eb;
  --primary-soft: #eaf1ff;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --warn: #d97706;
  --warn-soft: #fff5e6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 216px; flex: 0 0 216px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-logo {
  width: 58px; height: 38px; border-radius: 8px; background: #fff; flex: 0 0 auto;
  display: grid; place-items: center; padding: 4px 5px; box-shadow: 0 1px 6px rgba(0,0,0,.25);
}
.brand-logo img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { color: #64748b; font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 8px;
  background: transparent; color: #cbd5e1; font-size: 14px; cursor: pointer; text-align: left; width: 100%;
}
.nav-item i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; }
.sidebar-foot { margin-top: auto; padding: 10px 8px; }
.db-badge { font-size: 11px; color: #64748b; border-top: 1px solid #1e293b; padding-top: 10px; }

/* 主体 */
.main { flex: 1; min-width: 0; padding: 0 24px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px 0 16px; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; }
.topbar-right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.tip { font-size: 12px; color: var(--muted); }
.cur-badge {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--primary-soft); border-radius: 20px; padding: 3px 10px;
}
.lang-sel { width: auto; height: 32px; font-size: 13px; min-width: 132px; max-width: 176px; }
@media (max-width: 980px) {
  .topbar h1 { font-size: 17px; }
  .lang-sel { min-width: 108px; font-size: 12px; }
  .cur-badge { padding: 2px 8px; font-size: 11px; }
}

/* 🔴 .hidden 必须有通用规则。
   以前只写了 .view.hidden / .mask.hidden / .banner.hidden，
   所以 <input class="hidden"> 这种裸用根本不生效 —— 报价弹窗底下那两个
   「选择文件」就一直露在外面，还正好压在提示条上。!important 是为了压住
   .grid-2{display:grid} 这类单类选择器（同权重时后定义的赢）。 */
.hidden { display: none !important; }
.view.hidden { display: none !important; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head.sub { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head .muted { margin-left: auto; }
.card-head .muted > * + * { margin-left: 4px; }
.card-head .muted b { color: var(--brand); }
.muted { color: var(--muted); font-size: 12px; }
.pad { padding: 10px 2px 0; margin: 0; }

.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grow { flex: 1; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 必须写 minmax(0,1fr)：裸 1fr 的最小值仍是 auto，会被表格式 nowrap
     内容的 min-content 顶大（实测财务页被撑到 1407px，整页横向滚动） */
  .cols-3, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { margin-top: 12px; }
.field > span { font-size: 12px; color: var(--text-2); }
input, select {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--text); font-size: 13px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--text); font-size: 13px; outline: none; width: 100%;
  font-family: ui-monospace, Consolas, monospace; line-height: 1.6; resize: vertical;
}
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.btn {
  height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: #c7d2e4; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #1d4fd7; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f3c7c7; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.row-actions { margin-left: auto; display: flex; gap: 8px; }
/* 列表操作列：查看 / 编辑订单 / 收款 / 开票 四个小按钮
   两个坑：① td 不能用 display:flex（会脱离表格布局，列被压成一条）
         ② 不能设 white-space:normal —— 那样列的最小宽度只剩单个按钮宽，四个按钮会竖着排 */
table.grid td.acts { padding: 6px 8px; }
table.grid td.acts .btn { margin-right: 5px; }
table.grid td.acts .btn:last-child { margin-right: 0; }
/* 列表超长文本列截断（鼠标悬停有完整 title），避免整表横向滚动 */
#view-list table.grid td:nth-child(1) { max-width: 138px; overflow: hidden; text-overflow: ellipsis; }
#view-list table.grid td:nth-child(3) { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
#view-list table.grid td:nth-child(4) { max-width: 132px; overflow: hidden; text-overflow: ellipsis; }

/* 表格 */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line-soft); padding: 8px 10px; text-align: left; white-space: nowrap; }
table.grid th { background: #f8fafc; color: var(--text-2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
table.grid td.r, table.grid th.r { text-align: right; }
table.grid tbody tr:hover { background: #fafcff; }
/* 整行可点开详情的表格（报价单列表） */
table.grid tbody tr.row-link { cursor: pointer; }
table.grid tbody tr.row-link:hover { background: var(--primary-soft); }
table.grid input, table.grid select { height: 28px; padding: 0 6px; font-size: 12px; }
table.items td { padding: 4px 5px; }
table.items input { border-color: transparent; background: transparent; padding: 0 4px; }
table.items input:hover { border-color: var(--line); background: #fff; }
/* 金额类输入框：带千分号后要更宽，右对齐更好像账本 */
table.items input[data-k="price"], table.items input[data-k="cost_price"] {
  min-width: 96px; text-align: right; font-variant-numeric: tabular-nums; font-size: 11.5px;
}
table.items input[data-k="qty"] { min-width: 56px; text-align: right; }
/* 窄屏（1366/1440 笔记本）：适度收窄文本列，让带千分号的金额列放得下，不出横向滚动 */
@media (max-width: 1560px) {
  table.items th:nth-child(2) { min-width: 110px !important; }  /* 物资名称 */
  table.items th:nth-child(3) { min-width: 76px !important; }   /* 英文名 */
  table.items th:nth-child(4) { min-width: 78px !important; }   /* 型号规格 */
  table.items th:nth-child(5) { min-width: 72px !important; }   /* 物料编码 */
  table.items th:nth-child(13) { min-width: 84px !important; }  /* 供应商 */
}
td.calc { color: var(--text-2); font-variant-numeric: tabular-nums; }
/* 计算列（金额/含税/成本金额）：跟单价输入框同字号，千万级印尼盾也放得下 */
table.items td.calc { font-size: 11.5px; padding-left: 6px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* 汇总 */
.summary {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; margin-top: 16px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
}
@media (max-width: 1400px) { .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) { .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sum-item { display: flex; flex-direction: column; gap: 3px; }
.sum-item span { font-size: 11px; color: var(--muted); }
.sum-item b { font-size: 15px; font-variant-numeric: tabular-nums; }
.sum-item.hl b { color: var(--primary); }

/* 筛选 */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 130px; }
.filters input[type=date] { min-width: 140px; }
.sep { color: var(--muted); font-size: 12px; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* KPI */
.kpi-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow);
}
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-size: 20px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi.warn b { color: var(--warn); }
.kpi.ok b { color: var(--ok); }
.kpi.primary b { color: var(--primary); }

/* 状态标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.soft { background: var(--primary-soft); color: var(--primary); }
.tag.gray { background: #f1f5f9; color: var(--text-2); }

/* 跟踪列表 */
.list { display: flex; flex-direction: column; max-height: 460px; overflow: auto; }
.list-row { display: flex; gap: 8px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); }
.list-row .t { flex: 1; min-width: 0; }
.list-row .t b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .t span { font-size: 12px; color: var(--muted); }
.list-row .amt { font-variant-numeric: tabular-nums; font-size: 13px; }

/* 图表 */
.chart { height: 260px; padding: 6px 0; }
.chart svg { width: 100%; height: 100%; }
.rank { display: flex; flex-direction: column; gap: 9px; padding: 4px 0; }
.rank-row { display: grid; grid-template-columns: 130px 1fr 92px; gap: 10px; align-items: center; font-size: 12px; }
.rank-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .bar { height: 16px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.rank-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 4px; }
.rank-row .vl { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* 提示 */
/* 校验没过的输入框：红框 + 轻抖一下，把「为什么不让我保存」直接指到那个格子上 */
.invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .14) !important;
  animation: shake .28s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* 🔴 提示条必须盖在所有弹窗之上（弹窗 .mask 是 100、二级弹窗 .mask.top 是 300、
   全屏卡片 900）。以前写 99，弹窗一开提示就被遮罩压住 ——
   「客户名称必填」这类拦截原因用户根本看不见，只会觉得保存按钮点了没反应。 */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

.mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 100; }
.mask.hidden { display: none; }
/* 叠在别的弹窗之上的二级弹窗（如「导入预览」压在报价单弹窗上） */
.mask.top { z-index: 300; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.dlg-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.dlg-tabs .btn.sm.active { background: var(--primary); border-color: var(--primary); color: #fff; }
#dlgOutput .modal { width: min(640px, 94vw); max-height: 88vh; overflow: auto; }
#dlgOutput .muted { font-size: 12px; margin: 10px 0 0; }
#dlgPayee .modal { width: min(720px, 94vw); max-height: 88vh; overflow: auto; }

.modal.lg {
  width: 1000px; max-width: 94vw; max-height: 88vh; overflow: auto; padding: 20px 22px;
}
.detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.detail-head h3 { margin: 0 0 4px; font-size: 17px; }
.detail-head p { margin: 0; }
.detail-acts { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }
.detail-acts .btn { display: inline-flex; align-items: center; gap: 6px; }
#dFull .ic-collapse { display: none; }
#dFull.is-full .ic-expand { display: none; }
#dFull.is-full .ic-collapse { display: inline; }

/* 详情弹窗全屏：铺满视口，头部与底部按钮固定，中间内容独立滚动 */
.modal.lg.is-full {
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  border-radius: 0; padding: 18px 24px 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal.lg.is-full #dBody { flex: 1 1 auto; overflow: auto; min-height: 0; }
.modal.lg.is-full .detail-head { flex: 0 0 auto; }
.modal.lg.is-full .form-actions { flex: 0 0 auto; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.detail-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 16px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 16px;
}
.detail-grid .it { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-grid .it span { font-size: 11px; color: var(--muted); }
.detail-grid .it b { font-size: 14px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 明细子表下方的金额汇总 */
.detail-total {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 28px;
  margin-top: 12px; padding: 12px 16px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
}
.detail-total .tt { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.detail-total .tt span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.detail-total .tt b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.detail-total .tt.grand { padding-left: 28px; border-left: 1px solid var(--line); }
.detail-total .tt.grand b { font-size: 18px; color: var(--primary); }
@media (max-width: 700px) {
  .detail-total { justify-content: flex-start; gap: 10px 20px; }
  .detail-total .tt { align-items: flex-start; }
  .detail-total .tt.grand { padding-left: 0; border-left: 0; }
}

/* 由收款流水接管的字段：只读 + 灰底 */
input.auto[readonly] { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }

/* 详情页的收款进度条 */.pay-strip { margin-top: 10px; padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.pay-strip .ps-top { display: flex; align-items: baseline; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.pay-strip .ps-top b { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; }
.pay-strip .ps-top b.due { color: var(--danger); }
.pay-strip .ps-top .muted { margin-left: auto; }

.pay-bar { height: 7px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.pay-bar i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); border-radius: 99px; transition: width .25s ease; }

/* 收款弹窗 */
/* 高度兜底：内容再长也在视口内滚动，不会顶出屏幕 */
#payMask .modal { width: min(940px, 94vw); max-height: 90vh; overflow: auto; }
.pay-kpi { margin-bottom: 14px; }
.pay-kpi .kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.pay-kpi .kpi { flex: 1 1 0; min-width: 150px; padding: 10px 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; }
.pay-kpi .kpi span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.pay-kpi .kpi b { font-size: 16px; font-variant-numeric: tabular-nums; }
.pay-kpi .kpi.ok b { color: var(--ok); }
.pay-kpi .kpi.warn { background: #fff7ed; border-color: #fed7aa; }
.pay-kpi .kpi.warn b { color: #c2410c; }
.pay-bar-tip { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: right; }

/* 关键：fr 列默认 min-width:auto，会被「左列表格长备注 + 右列外语长标签」的
   min-content 撑破整个弹窗。minmax(0, …) 解除该限制。
   右侧表单固定 260~280px 即可（再宽纯属浪费），其余宽度全给左侧收款表，
   这样 7 列表格在印尼语/英语下也不用横向滚动。 */
.pay-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 280px); gap: 20px; align-items: start; }
.pay-grid > * { min-width: 0; }
.pay-h { margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.pay-table { font-size: 12px; }
.pay-table td, .pay-table th { padding: 6px 6px; }
.pay-table tfoot td { font-weight: 650; background: #f8fafc; }
/* 表单控件解除 min-content（input 默认按 size=20 撑约 170px），
   标签允许折行，按钮组允许换行——三语下都不再溢出 */
#payMask .pay-grid input, #payMask .pay-grid select { min-width: 0; }
#payMask .pay-grid .field > span { overflow-wrap: break-word; }
.pay-quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.empty.sm { padding: 18px; font-size: 13px; background: #fafafa; border: 1px dashed var(--line); border-radius: 8px; }
/* 双列布局需要 modal 撑满 940px 才放得下 7 列表格；视口低于 1000px 时
   94vw 已经不够，直接改单列（表格拿满宽度，反而更好读）。
   实测 850px 单列时中文/印尼语/英语均无溢出、无横向滚动。 */
@media (max-width: 1000px) {
  .pay-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 开票弹窗 */
#invMask .modal { width: min(520px, 94vw); }
.inv-done .inv-rows { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.inv-done .inv-rows > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 12px; background: #f8fafc; border-radius: 8px; font-size: 13px; }
.inv-done .inv-rows span { color: var(--muted); }
.inv-done .inv-rows b { font-variant-numeric: tabular-nums; }

/* 列表页首列（合同编码）横向滚动时固定在左侧，避免操作列被挤出屏幕后找不到入口 */#view-list table.grid th:first-child, #view-list table.grid td:first-child {
  position: sticky; left: 0; background: #fff; z-index: 1;
  box-shadow: 1px 0 0 var(--line-soft);
}
#view-list table.grid th:first-child { background: #f8fafc; z-index: 2; }
#view-list table.grid tbody tr:hover td:first-child { background: #fafcff; }

a.link { color: var(--primary); cursor: pointer; text-decoration: none; font-weight: 600; }
a.link:hover { text-decoration: underline; }
table.grid tbody tr.clickable { cursor: pointer; }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal p { margin: 0; color: var(--text-2); font-size: 13px; }
.modal .form-actions { justify-content: flex-end; }

/* 后端未连接提示 */
.banner {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--warn-soft); border: 1px solid #f2d6a6; color: #7a4a00;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; line-height: 1.6;
}
.banner.hidden { display: none; }
.banner b { font-weight: 650; }
/* 弹窗里的勾选行（如「我方代垫」）：和 .field 一样是竖向排的栅格项，
   这里改成横向，让勾选框和文字并排 */
.chk { display: flex; flex-direction: row; gap: 8px; align-items: center; min-width: 0; }
.chk input[type=checkbox] { width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--primary); }
.chk > span { font-size: 12px; color: var(--text-2); }
.chk.hidden { display: none; }
.banner code {
  background: #fff; padding: 1px 7px; border-radius: 4px;
  border: 1px solid #f0dcb8; font-size: 12px; font-family: ui-monospace, Consolas, monospace;
}

/* ==================== 打印合同模板（A4） ====================
   屏幕上 .print-area 隐藏，点「打印合同」时加 .preview 全屏预览；
   打印时 body 其余元素全部隐藏，只出这一张 A4。 */

.print-area { display: none; }

.print-area.preview {
  display: block; position: fixed; inset: 0; overflow: auto; z-index: 200;
  background: #e9edf2; padding: 16px;
}

/* 预览时的操作条（打印不出现） */
.pt-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  width: 210mm; margin: 0 auto 12px; padding: 10px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

/* ---- 纸张与正文：预览和打印共用 ---- */
.pt-doc {
  /* 预览时 A4 实宽；容器更窄时按容器收，别让纸撑出面板导致右侧内容看不见 */
  width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 12mm 10mm;
  background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.18);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: #000; font-size: 10.5pt; line-height: 1.45; box-sizing: border-box;
}
/* 页头：左 LOGO + 公司信息，右合同标题 */
/* 页头：LOGO 贴左，公司信息压在 LOGO 下方，合同标题严格居中于纸面 */
.pt-head { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4mm; margin-bottom: 3.5mm; }
.pt-head-l { justify-self: start; display: flex; flex-direction: column; align-items: flex-start; gap: 1.6mm; min-width: 0; }
.pt-logo { display: block; height: 15mm; width: auto; }
.pt-head-info { min-width: 0; max-width: 46mm; }
.pt-head-info .pt-co-line:first-child { font-size: 7.5pt; font-weight: 700; letter-spacing: 0; }
.pt-co-line { font-size: 7pt; color: #222; line-height: 1.3; }
.pt-head-r { justify-self: center; text-align: center; }
.pt-title { text-align: center; font-size: 17pt; font-weight: 700; letter-spacing: 5px; white-space: nowrap; }
.pt-sub { text-align: center; font-size: 9.5pt; font-weight: 400; letter-spacing: 1.5px; color: #333; margin-top: 1mm; }
/* 拉丁字母标题比汉字长得多，字号和字距都要收一点，免得挤到 LOGO */
.pt-lang-en .pt-title, .pt-lang-id .pt-title { font-size: 14pt; letter-spacing: .8px; }
.pt-lang-en .pt-sub, .pt-lang-id .pt-sub { font-size: 8.5pt; letter-spacing: .6px; }

/* 抬头信息：左右两栏，标签对齐，值下面带填写线 */
.pt-meta { display: flex; gap: 7mm; border: 1px solid #000; padding: 2.5mm 3mm; margin: 4mm 0 2.5mm; }
.pt-meta-col { flex: 1 1 0; min-width: 0; }
.pt-row { display: flex; align-items: baseline; gap: 1.5mm; margin-bottom: 1.4mm; }
.pt-row:last-child { margin-bottom: 0; }
.pt-row .lb { flex: 0 0 37mm; white-space: nowrap; font-size: 8.5pt; }
.pt-row .vl { flex: 1 1 auto; min-width: 0; border-bottom: 1px solid #000; padding: 0 1mm 0.4mm; min-height: 4.2mm; font-size: 9pt; line-height: 1.3; word-break: break-word; }

/* 明细表 */
.pt-items { width: 100%; border-collapse: collapse; font-size: 8.5pt; table-layout: fixed; }
.pt-items th, .pt-items td { border: 1px solid #000; padding: 1.2mm 1.2mm; word-break: break-word; }
.pt-items th { background: #f0f0f0; font-weight: 600; font-size: 8pt; word-break: normal; overflow-wrap: break-word; }
.pt-items td.c { text-align: center; }
.pt-items td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 8pt; padding-left: 1mm; padding-right: 1mm; }
.pt-items th:first-child, .pt-items th:nth-child(6), .pt-items th:nth-child(7) { white-space: nowrap; }
.pt-items tfoot td { font-weight: 700; }
.pt-items tfoot td.r { white-space: nowrap; }
.pt-items tr { page-break-inside: avoid; }

.pt-remark { margin-top: 1.8mm; font-size: 9pt; }
.pt-remark .line { border-bottom: 1px dotted #999; min-height: 6mm; margin-top: 1.4mm; padding-bottom: 1mm; }
.pt-terms { margin-top: 2.5mm; font-size: 7.5pt; line-height: 1.45; }
.pt-terms ol { margin: 0; padding-left: 5mm; }
.pt-terms li { margin-bottom: 0.8mm; }

/* 签章区 */
.pt-sign { display: flex; gap: 6mm; margin-top: 4mm; font-size: 8.5pt; }
.pt-sign-col { position: relative; flex: 1 1 0; border: 1px solid #000; padding: 2mm 2.5mm; }
.pt-sign-col h4 { margin: 0 0 2mm; font-size: 10pt; text-align: center; letter-spacing: 1px; }
.pt-line { display: flex; align-items: baseline; gap: 1.5mm; margin-bottom: 1.6mm; }
.pt-line span { white-space: nowrap; }
.pt-line i { font-style: normal; flex: 1 1 auto; border-bottom: 1px solid #000; padding-left: 1mm; min-height: 4.2mm; line-height: 1.3; word-break: break-word; }
.pt-seal {
  position: absolute; right: 3mm; top: 10mm; width: 30mm; height: 30mm;
  opacity: .92; mix-blend-mode: multiply; pointer-events: none;
}

/* ---- 形式发票（Proforma Invoice） ---- */
.pt-inv { position: relative; }
.pt-bar-name { font-size: 13px; margin-right: 8px; color: var(--text-2, #555); }
.pt-inv-top { border: 1px solid #000; padding: 2mm 3mm; margin: 3mm 0 2mm; }
.pt-inv-top .pt-row .lb { flex: 0 0 30mm; }
.pt-inv-foot { display: flex; gap: 5mm; margin-top: 2.5mm; align-items: flex-start; font-size: 9pt; break-inside: avoid; }
/* 付款信息区可压缩，把空间让给右侧金额区（数字串长，宁可留白也不能被裁） */
.pt-inv-pay { flex: 1 1 auto; min-width: 0; }
.pt-inv-pay h4 { margin: 0 0 2mm; font-size: 9.5pt; letter-spacing: .3px; }
.pt-inv-pay-row { display: flex; gap: 2mm; margin-bottom: 1.4mm; }
.pt-inv-pay-row span { flex: 0 0 auto; white-space: nowrap; font-size: 8.5pt; }
.pt-inv-pay-row b {
  font-weight: 600; flex: 1 1 auto; min-width: 0; border-bottom: 1px solid #000;
  padding: 0 1mm 0.4mm; min-height: 4.2mm; line-height: 1.3; word-break: break-word;
}
/* 金额区：label 可收缩、数字永不压缩不换行，右侧留 1mm 余量避免贴边被裁 */
.pt-inv-totals { flex: 0 0 74mm; padding-right: 3mm; box-sizing: border-box; }
.pt-inv-total-row {
  display: flex; align-items: baseline; gap: 2mm; padding: 1.1mm 0;
  border-bottom: 1px solid #999; font-variant-numeric: tabular-nums; font-size: 9pt;
}
.pt-inv-total-row span { flex: 0 1 auto; min-width: 0; white-space: nowrap; }
.pt-inv-total-row b {
  flex: 0 0 auto; white-space: nowrap; text-align: right; margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.pt-inv-total-row.grand { border-bottom: 2px solid #000; font-size: 10.5pt; font-weight: 700; }
.pt-inv-remark { margin-top: 2.5mm; color: #333; font-size: 9pt; }
.pt-inv-remark span { display: inline-block; min-width: 90mm; border-bottom: 1px dotted #999; min-height: 5mm; }
.pt-inv-sign { display: flex; justify-content: flex-end; margin-top: 1.5mm; font-size: 9pt; break-inside: avoid; page-break-inside: avoid; }
.pt-inv-sign-r { position: relative; flex: 0 0 66mm; text-align: center; padding-bottom: 6mm; }
.pt-inv-sign-lab { color: #555; font-size: 8.5pt; margin-bottom: 1mm; }
.pt-inv-sign-name { font-weight: 600; margin-bottom: 1mm; }
.pt-inv-sign-line { border-bottom: 1px solid #000; height: 12mm; }
/* 发票的章盖在落款横线右端，避开公司名（合同里那套绝对定位不适用） */
.pt-inv .pt-seal { position: absolute; right: 4mm; bottom: 4mm; width: 26mm; height: 26mm; margin: 0; opacity: .88; }

/* ---- 真正打印时：只留合同，按 A4 出纸 ---- */
@page { size: A4 portrait; margin: 12mm 10mm; }

@media print {
  html, body { width: auto; background: #fff; margin: 0; padding: 0; }
  body > *:not(.print-area) { display: none !important; }
  .print-area, .print-area.preview {
    display: block !important; position: static !important; inset: auto !important;
    overflow: visible !important; background: #fff !important; padding: 0 !important; z-index: auto !important;
  }
  .pt-bar { display: none !important; }
  .pt-doc { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; }
  .pt-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pt-seal { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 内联勾选项（设置页） */
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check-inline input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

/* 形式发票明细：行高收紧，16 行左右也能压进一页 A4 */
.pt-inv .pt-items th, .pt-inv .pt-items td { padding: 1mm 1.2mm; }
.pt-inv .pt-items td.r { padding-left: 1mm; padding-right: 1mm; }
.pt-inv .pt-seal { break-inside: avoid; page-break-inside: avoid; }

/* ---- 附件上传 ---- */
.hidden-file { display: none; }
.upload { display: flex; gap: 6px; align-items: center; }
.upload input { flex: 1; min-width: 0; cursor: default; }
.upload .btn { white-space: nowrap; }
/* 附件框可接收粘贴/拖拽：点过之后高亮，让用户知道 Ctrl+V 会进到这里 */
.upload input { transition: box-shadow .15s, border-color .15s, background .15s; }
.upload.is-active input {
  border-color: var(--primary); background: #f8fbff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}
.upload.is-active input::placeholder { color: var(--primary); opacity: .85; }
.upload.is-drop input {
  border-color: var(--ok); background: #f0fdf4;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .14);
}
/* 上传成功后闪一下，给个明确反馈 */
.upload input.up-ok {
  animation: upOk .6s ease;
}
@keyframes upOk {
  0%   { border-color: var(--ok); background: #dcfce7; box-shadow: 0 0 0 3px rgba(34,197,94,.22); }
  100% { border-color: var(--line); background: #fff; box-shadow: none; }
}
a.lnk { color: var(--color-text-info, #185FA5); text-decoration: none; border-bottom: 0.5px dotted currentColor; }
a.lnk:hover { text-decoration: none; opacity: .75; }

/* 代扣付款前四件套：已上传=可点开的蓝圈，缺失=浅灰圈，一眼看出还差哪件 */
.wh-docs { white-space: nowrap; }
.wh-doc {
  display: inline-block; min-width: 18px; text-align: center; line-height: 18px;
  margin-right: 2px; border-radius: 50%; font-size: 11px;
  border: 1px solid var(--color-text-info, #185FA5); color: var(--color-text-info, #185FA5);
  text-decoration: none;
}
.wh-doc:hover { opacity: .7; }
.wh-doc.miss { border-color: var(--line); color: var(--muted); border-style: dashed; cursor: help; }
.wh-docs .warn { color: var(--danger); font-weight: 600; }

/* 收款表备注过长会把「凭证」列挤出去。原先用 nowrap+省略号，但 nowrap 让
   单元格的 min-content 等于整段文字，直接顶大左列、进而撑破弹窗。
   改成可折行 + anywhere（anywhere 才真正参与 min-content 计算），
   超长无空格文本也不会撑破，长备注自然换行显示，不再需要省略号。 */
.pay-table td.muted { max-width: 150px; white-space: normal; overflow-wrap: anywhere; }
.pay-table th:last-child, .pay-table td:last-child { width: 64px; }
#payList { min-width: 0; }

/* ---- 表格分页 ---- */
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 2px 2px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.pager .grow { flex: 1 1 auto; }
.pager select { width: auto; height: 28px; padding: 0 6px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
.pager .pg-info { font-variant-numeric: tabular-nums; color: var(--text); min-width: 48px; text-align: center; }
.pager .btn { min-width: 30px; padding: 0 8px; height: 28px; }
.pager .btn[disabled] { opacity: .35; cursor: default; }

/* ---- 表格放大（全屏） ---- */
.fs-btn { width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.card-head .fs-btn { margin-left: auto; }
.card-head:has(.fs-btn) .muted { margin-left: 0; }
.card.is-fs { position: fixed; inset: 0; z-index: 900; margin: 0; border: 0; border-radius: 0; background: var(--panel); display: flex; flex-direction: column; padding: 14px 20px 10px; }
.card.is-fs .table-wrap { flex: 1 1 auto; min-height: 0; }
.card.is-fs table.grid th { background: #f8fafc; }
body.fs-lock { overflow: hidden; }

/* ---- 税票 DPP 体检：DPP 未按 11/12 折算的票 ---- */
#dppAlert { margin-bottom: 14px; }
.alert-box {
  border: 1px solid var(--warn);
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.7;
}
.alert-box > b { display: block; margin-bottom: 2px; font-size: 14px; color: var(--warn); }
.alert-box .muted { display: block; margin-bottom: 8px; }
.alert-box ul { margin: 0; padding-left: 18px; }
.alert-box li { margin: 4px 0; font-variant-numeric: tabular-nums; }
.alert-box .neg { color: var(--danger); }
/* 表格内也需要：红=过期/风险，橙=快到期 */
td .neg, .neg { color: var(--danger); font-weight: 600; }
.warn-txt { color: var(--warn); font-weight: 600; }
table.grid td.dpp-bad { color: var(--danger); font-weight: 600; background: #fff5f5; }

/* 财务页多一个 DPP 体检指标，单独排 7 列 */
#financeKpi { grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1400px) { #financeKpi { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* 发票明细金额列：右侧留 2mm 内边距，数字右对齐时不贴表格边框（贴边容易在打印时被切） */
.pt-inv .pt-items th:last-child, .pt-inv .pt-items td:last-child { padding-right: 2.5mm; }
.pt-inv .pt-items th:nth-last-child(2), .pt-inv .pt-items td:nth-last-child(2) { padding-right: 2mm; }

/* 打印表格最后一列（金额）统一留内边距：数字右对齐贴边框时，换字体/换打印机容易被切掉 */
.pt-items th:last-child, .pt-items td:last-child { padding-right: 2mm; }

/* ==================== 报价单打印模板（A4） ====================
   与合同 .pt-doc 同一套纸张参数，页头/信息区/金额区是报价单专用版式。 */
.pqt-doc {
  width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 12mm 10mm;
  background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: #000; font-size: 10.5pt; line-height: 1.45; box-sizing: border-box;
}
.pqt-head {
  display: flex; align-items: center; gap: 4mm; margin-bottom: 3mm;
  padding-bottom: 2mm; border-bottom: 2px solid #000;
}
.pqt-head-txt { min-width: 0; }
.pqt-co-name { font-size: 11pt; font-weight: 700; letter-spacing: .5px; }
.pqt-co-line { font-size: 8pt; color: #222; line-height: 1.35; }
.pqt-draft { font-style: normal; font-size: 9pt; font-weight: 400; color: #999; margin-left: 3mm; letter-spacing: 0; }

.pqt-meta { align-items: stretch; }
.pqt-box { flex: 1 1 0; min-width: 0; }
.pqt-box + .pqt-box { border-left: 1px solid #ddd; padding-left: 3mm; }
.pqt-box-h { font-size: 8pt; color: #666; margin-bottom: 1mm; letter-spacing: .3px; }
.pqt-kv { display: flex; align-items: baseline; gap: 1.5mm; margin-bottom: 1.2mm; font-size: 9pt; }
.pqt-kv span { flex: 0 0 auto; color: #555; }
.pqt-kv b { flex: 1 1 auto; min-width: 0; text-align: right; font-weight: 600; }

/* 金额区：贴右，总额上下加线 */
.pqt-total { margin-top: 2mm; margin-left: auto; width: 78mm; }
.pqt-trow {
  display: flex; align-items: baseline; gap: 2mm; padding: 1.2mm 1mm;
  border-bottom: 1px solid #ccc; font-size: 9pt; font-variant-numeric: tabular-nums;
}
.pqt-trow span { flex: 1 1 auto; }
.pqt-trow b { flex: 0 0 auto; white-space: nowrap; }
.pqt-trow.pqt-grand { border-bottom: 2px solid #000; border-top: 1px solid #000; font-size: 11pt; font-weight: 700; }

/* 签章：两栏并排，公章盖在供方栏 */
.pqt-sign-wrap { display: flex; gap: 8mm; margin-top: 5mm; break-inside: avoid; page-break-inside: avoid; }
.pqt-sign {
  position: relative; flex: 1 1 0; border: 1px solid #000; padding: 2.5mm 3mm;
  min-height: 28mm; font-size: 9pt;
}
.pqt-sign-h { text-align: center; font-weight: 700; font-size: 9.5pt; margin-bottom: 2.5mm; letter-spacing: .5px; }
.pqt-sign-line { margin-bottom: 2.5mm; color: #333; }
.pqt-sign-gap { height: 6mm; }
.pqt-seal {
  position: absolute; right: 4mm; top: 11mm; width: 26mm; height: 26mm;
  opacity: .9; mix-blend-mode: multiply; pointer-events: none;
}

@media print {
  .pqt-doc { width: auto; min-height: 0; margin: 0; padding: 8mm 8mm 6mm; box-shadow: none; }
  .pqt-seal { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pqt-sign-wrap { break-inside: avoid; page-break-inside: avoid; }
}

/* ---------- 产品附图 ---------- */
/* 打印纸：明细表附图列，固定 16mm 高，行高被它撑住，一张 A4 放 20 行仍够 */
.pt-items td.pqt-ph { padding: 1mm; text-align: center; vertical-align: middle; }
.pt-items td.pqt-ph img {
  display: block; width: 22mm; height: 16mm; object-fit: cover;
  border: 1px solid #ddd; border-radius: 1mm; background: #fafafa;
}
.pt-items .pqt-en { display: block; font-size: 7pt; color: #666; margin-top: .5mm; }

/* 录入弹窗：小格子，点一下选图 / 换图 */
.ph-cell { text-align: center; vertical-align: middle; padding: 2px !important; }
.ph-thumb, .ph-add {
  width: 56px; height: 42px; padding: 0; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--line, #d6dae2); background: #fff; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  color: #98a2b3; font-size: 18px; line-height: 1;
}
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-add:hover, .ph-thumb:hover { border-color: var(--accent, #2f6fed); color: var(--accent, #2f6fed); }
.ph-thumb:hover { box-shadow: 0 0 0 2px rgba(47, 111, 237, .18); }
/* 盈亏走势柱状图 */
.profit-chart { padding: 4px 0 2px; overflow-x: auto; }
.profit-chart svg { display: block; }
.profit-chart .empty { padding: 26px 0; text-align: center; color: var(--text-2); }

/* 详情页里的只读小图（不能点，纯展示）。放在行尾，靠 margin:auto 在格子里居中 */
.ph-thumb-sm {
  width: 44px; height: 33px; object-fit: cover; display: block;
  margin: 0 auto;
  border-radius: 4px; border: 1px solid var(--line, #d6dae2); background: #fff;
}

/* 代扣弹窗里的实时计算结果条：DPP / 扣税 / 实付 一排显示 */
.wh-calc {
  display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: baseline;
  margin: 10px 0 6px; padding: 9px 12px;
  border: 1px solid var(--line, #d6dae2); border-radius: var(--border-radius-md, 8px);
  font-size: 13px; min-width: 0;
}
.wh-calc span { color: var(--text-2, #6b7280); }
.wh-calc b { font-weight: 500; color: var(--text, #1f2328); }

/* .hidden 是单类选择器，会被同样单类的 .grid-2 的 display:grid 盖过去；
   招待费清单区就因此在不该出现时也显示，这里用 ID 提权保证隐藏生效 */
#e_ent_box.hidden { display: none; }

@media print {
  .pt-items td.pqt-ph img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- 报价单明细表列宽（11 列固定分配，A4 纵向 210mm - 左右边距） ---------- */
.pqt-items { table-layout: fixed; }
.pqt-items .pq-c-idx   { width: 6mm;  }
.pqt-items .pq-c-name  { width: 26mm; }
.pqt-items .pq-c-spec  { width: 40mm; }
.pqt-items .pq-c-code  { width: 16mm; }
.pqt-items .pq-c-brand { width: 15mm; }
.pqt-items .pq-c-unit  { width: 8mm;  }
.pqt-items .pq-c-qty   { width: 10mm; }
.pqt-items .pq-c-price { width: 20mm; }
.pqt-items .pq-c-amt   { width: 23mm; }
/* 图片列在最后：宽一点，图看得清 */
.pqt-items .pq-c-ph    { width: 23mm; }
/* 明细密排：20 行 + 附图 + 条款 + 签章要压进一页 A4 */
.pqt-items td { padding: .55mm .7mm; font-size: 7.6pt; line-height: 1.18; }
.pqt-items th { padding: .55mm .7mm; font-size: 7pt; line-height: 1.15; }
.pqt-items td.pqt-ph img { width: 20mm; height: 10mm; }
.pqt-items th.pq-c-ph { font-size: 7pt; }

/* 报价单整页压缩：20 行明细 + 附图 + 8 条条款 + 双签章 需压进一页 A4 */
.pqt-doc { padding: 9mm 8mm; }
.pqt-doc .pt-title { margin: 2.5mm 0 2mm; font-size: 16pt; }
.pqt-doc .pt-meta { margin-bottom: 2mm; }
.pqt-doc .pqt-box { padding: 1.6mm 2mm; font-size: 8.5pt; line-height: 1.3; }
.pqt-doc .pqt-kv { font-size: 8.5pt; line-height: 1.35; }
.pqt-doc .pt-terms { margin-top: 2mm; font-size: 6.8pt; line-height: 1.32; }
.pqt-doc .pt-terms li { margin-bottom: .4mm; }
.pqt-doc .pt-terms-h { font-size: 7.5pt; margin-bottom: .8mm; }
.pqt-doc .pqt-sign-wrap { margin-top: 3mm; gap: 6mm; }
.pqt-doc .pqt-sign { min-height: 21mm; padding: 1.8mm 2.4mm; font-size: 8pt; }
.pqt-doc .pqt-sign-h { margin-bottom: 1.6mm; font-size: 8.5pt; }
.pqt-doc .pqt-sign-line { margin-bottom: 1.6mm; }
.pqt-doc .pqt-sign-gap { height: 3mm; }
.pqt-doc .pqt-seal { width: 22mm; height: 22mm; top: 9mm; right: 3mm; }
.pqt-doc .pqt-total { margin-top: 1.5mm; width: 70mm; }
.pqt-doc .pqt-trow { padding: .9mm .8mm; font-size: 8.5pt; }
.pqt-doc .pqt-trow.pqt-grand { font-size: 10pt; }

/* 最后一压：签章区再矮 3mm、条款再紧一点，确保一页装完 */
.pqt-doc { padding: 8mm 8mm 6mm; }
.pqt-doc .pt-terms { font-size: 6.4pt; line-height: 1.28; }
.pqt-doc .pt-terms li { margin-bottom: .2mm; }
.pqt-doc .pqt-sign-wrap { margin-top: 2mm; }
.pqt-doc .pqt-sign { min-height: 17mm; padding: 1.4mm 2.2mm; font-size: 7.5pt; }
.pqt-doc .pqt-sign-h { margin-bottom: 1mm; font-size: 8pt; }
.pqt-doc .pqt-sign-line { margin-bottom: 1mm; }
.pqt-doc .pqt-sign-gap { height: 1mm; }
.pqt-doc .pqt-seal { width: 19mm; height: 19mm; top: 7mm; right: 2.5mm; }
.pqt-doc .pqt-head { margin-bottom: 2mm; padding-bottom: 1.6mm; }
.pqt-doc .pt-title { margin: 2mm 0 1.5mm; font-size: 15pt; }

/* 16 行带图压进一页 A4（v2）：图片再收、页头/条款/签章全面收紧 */
.pqt-doc { padding: 6mm 7mm 5mm; }
.pqt-doc .pt-head { margin-bottom: 1.5mm; padding-bottom: 1.2mm; }
.pqt-doc .pt-head .pt-logo { max-height: 13mm; width: auto; }
.pqt-doc .pqt-co-name { font-size: 10pt; }
.pqt-doc .pqt-co-line { font-size: 7.5pt; line-height: 1.25; }
.pqt-doc .pt-title { margin: 1.6mm 0 1.2mm; font-size: 14pt; }
.pqt-doc .pt-meta { margin-bottom: 1.5mm; }
.pqt-doc .pqt-box { padding: 1.2mm 1.8mm; font-size: 8pt; line-height: 1.25; }
.pqt-doc .pqt-kv { font-size: 8pt; line-height: 1.28; }
.pqt-items td.pqt-ph img { width: 16mm; height: 5.2mm; }
.pqt-items .pq-c-ph { width: 19mm; }
.pqt-items td { padding: .35mm .6mm; font-size: 7.4pt; line-height: 1.12; }
.pqt-items th { padding: .45mm .6mm; font-size: 6.8pt; line-height: 1.12; }
.pqt-doc .pqt-total { margin-top: 1.2mm; width: 66mm; }
.pqt-doc .pqt-trow { padding: .7mm .7mm; font-size: 8pt; }
.pqt-doc .pqt-trow.pqt-grand { font-size: 9.5pt; }
.pqt-doc .pt-remark { margin-top: .8mm; font-size: 7pt; }
.pqt-doc .pt-terms { margin-top: 1mm; font-size: 5.3pt; line-height: 1.17; }
.pqt-doc .pt-terms li { margin-bottom: .15mm; }
.pqt-doc .pt-terms-h { font-size: 7pt; margin-bottom: .6mm; }
.pqt-doc .pqt-sign-wrap { margin-top: 1.8mm; gap: 5mm; }
.pqt-doc .pqt-sign { min-height: 7.5mm; padding: .6mm 1.6mm; font-size: 6.8pt; }
.pqt-doc .pqt-sign-h { margin-bottom: .8mm; font-size: 7.6pt; }
.pqt-doc .pqt-sign-line { margin-bottom: .5mm; }
.pqt-doc .pqt-sign-gap { height: .5mm; }
.pqt-doc .pqt-seal { width: 13mm; height: 13mm; top: 4mm; right: 1.5mm; }

/* 条款 + 签章打包：要么整块留在当前页，要么整块翻到下页，
   绝不出现「条款在本页、签名框孤零零跑到下页」 */
.pqt-foot { break-inside: auto; page-break-inside: auto; }

/* 页脚块（条款+签章）：实测浏览器算得出放得下、Chrome 打印却按取整后的高度分页，
   这里把整块往上收 12mm，确保第 1 页就能装完，不出现只有签名的第 2 页 */
.pqt-foot { margin-top: -2mm; }
.pqt-doc .pt-terms li { line-height: 1.14; }

/* Chrome 打印分页：float/普通流里只要有一点点取整溢出就把整块推到下页。
   页脚块（8 条条款 + 双签章）改为绝对定位贴纸面底部 —— 它不参与分页计算，
   第 1 页必定装完。纸面高度 297mm，页脚约 55mm，故 bottom:5mm 起排。 */
.pqt-doc { position: relative; }
.pqt-doc .pqt-foot {
  margin-top: 0 !important;
}
/* 明细结束后留出页脚空间，避免金额区被页脚压住 */
/* 不能用 margin-bottom 给页脚让位：外边距会把纸面撑高，反而触发分页。
   改用 .pqt-spacer 占位块（高度 = 页脚高度），它本身不产生额外高度溢出。 */
.pqt-doc .pqt-total { margin-bottom: 0; }
/* 页脚在普通流里排，spacer 只补一点点余量，不再用绝对定位
   （绝对定位在 Chrome 打印里会多开一页） */
.pqt-doc .pqt-spacer { height: 0; }

/* 打印时滚动条要彻底消失：否则 Chrome 会按「有滚动条」的宽度排版，
   内容被压窄 → 变高 → 明明算得下也要多分一页。
   scrollbar-gutter 与 overflow 一起钉死，宽度才稳定。 */
@media print {
  html, body { overflow: visible !important; scrollbar-gutter: auto !important; }
  .print-area, .print-area.preview { overflow: visible !important; }
}

/* 申报台账：BPE 回执号是长串（BPE-107489/CT/KPP.2102/2026），做成链接后整表变宽，
   横向滚动时「操作」列会被挤出屏幕。末列固定右侧，按钮始终点得到（同列表页首列的做法）。
   ⚠ 不要改成给 BPE 列加 max-width —— table.grid 的 td 是 white-space:nowrap，
     那样只会把票号截断成「BPE-107489/CT/KPP.2102/20」。 */
#view-tax table.grid:has(#filingBody) td:last-child {
  position: sticky; right: 0; z-index: 1; background: #fff;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, .10);
}
#view-tax table.grid:has(#filingBody) th:last-child {
  position: sticky; right: 0; z-index: 3; background: #f8fafc;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, .10);
}
#view-tax table.grid:has(#filingBody) tbody tr:hover td:last-child { background: #fafcff; }

/* ==================== 收据（Kwitansi）打印版式 ====================
   单据正文固定印尼语（给印尼方看的正式凭条），中文只做旁注。
   🔴 所有颜色都显式给死：.pt-doc 继承的是屏幕色，打印时灰字会发虚。 */
.pt-kw {
  font-family: "Times New Roman", Georgia, serif;
  color: #111; font-size: 10.5pt; line-height: 1.45;
}
.pt-kw .kw-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 5mm; overflow: hidden; }
.pt-kw .kw-brand { max-width: 56%; min-width: 0; }
.pt-kw .kw-co { font-size: 10.5pt; font-weight: 700; letter-spacing: 0; color: #0b2d5c; }
.pt-kw .kw-co-sub { font-size: 8.2pt; color: #555; margin-top: 2px; line-height: 1.35; }
/* 单号必须 nowrap：折成两行比什么都难看 */
.pt-kw .kw-meta { text-align: right; font-size: 9pt; flex: 0 0 auto; white-space: nowrap; padding-left: 4px; }
.pt-kw .kw-meta .no { font-weight: 700; letter-spacing: .3px; }
.pt-kw .kw-rule { border-top: 2.2px solid #0b2d5c; margin-top: 8px; }
.pt-kw .kw-rule2 { border-top: .8px solid #0b2d5c; margin-top: 2px; }

.pt-kw .kw-title { text-align: center; margin: 16px 0 4px; }
.pt-kw .kw-title h1 { font-size: 24pt; letter-spacing: 8px; margin: 0; font-weight: 700; color: #0b2d5c; }
.pt-kw .kw-title .sub { font-size: 8.8pt; letter-spacing: 1.6px; color: #666; margin-top: 4px; text-transform: uppercase; }

.pt-kw .kw-lbl { font-size: 8.2pt; letter-spacing: 1.2px; color: #666; text-transform: uppercase; margin-bottom: 3px; }
.pt-kw .kw-from { border: 1px solid #ccd5e3; background: #fafbfe; padding: 12px 14px; }
.pt-kw .kw-from .nm { font-size: 12pt; font-weight: 700; }
.pt-kw .kw-from .ad { font-size: 8.6pt; color: #444; margin-top: 3px; line-height: 1.35; }

.pt-kw .kw-amount { margin-top: 14px; display: flex; align-items: stretch; border: 1.5px solid #0b2d5c; background: #f6f8fb; }
.pt-kw .kw-amount .k { padding: 13px 15px; font-size: 8.8pt; letter-spacing: 1.2px; color: #0b2d5c; text-transform: uppercase; border-right: 1px solid #b9c6da; display: flex; align-items: center; white-space: nowrap; }
.pt-kw .kw-amount .v { padding: 11px 17px; font-size: 22pt; font-weight: 700; color: #0b2d5c; display: flex; align-items: center; font-variant-numeric: tabular-nums; }

.pt-kw .kw-terbilang { margin-top: 8px; display: flex; align-items: baseline; gap: 10px; border: 1px dashed #b9c6da; background: #fafbfe; padding: 9px 13px; }
.pt-kw .kw-terbilang .k { font-size: 8.6pt; letter-spacing: 1px; color: #666; text-transform: uppercase; white-space: nowrap; }
.pt-kw .kw-terbilang .v { font-weight: 700; font-style: italic; font-size: 12.5pt; color: #0b2d5c; }

.pt-kw .kw-purpose { margin-top: 13px; }
.pt-kw .kw-purpose .txt { border: 1px solid #ccd5e3; padding: 10px 13px; font-size: 10.3pt; text-align: justify; white-space: pre-wrap; }

.pt-kw .kw-pay { margin-top: 11px; font-size: 9.8pt; line-height: 1.5; }
.pt-kw .kw-note { font-size: 8.6pt; color: #555; font-style: italic; margin: 10px 0 0; line-height: 1.45; }

/* 签字区：真签字要留够空间，26mm 写在横线上方 */
.pt-kw .kw-sign { display: flex; justify-content: flex-end; margin-top: 26px; }
.pt-kw .kw-sign .sc { width: 48%; text-align: center; }
.pt-kw .kw-sign .kota { font-size: 10pt; margin-bottom: 4px; }
.pt-kw .kw-sign .role { font-size: 8.4pt; letter-spacing: 1px; color: #666; text-transform: uppercase; }
.pt-kw .kw-sign .space { height: 26mm; }
.pt-kw .kw-sign .line { border-top: 1px solid #333; padding-top: 6px; }
.pt-kw .kw-sign .who { font-weight: 700; font-size: 10.5pt; }
.pt-kw .kw-sign .job { font-size: 8.8pt; color: #555; margin-top: 1px; }

.pt-kw .kw-foot { margin-top: 14px; border-top: .8px solid #ccc; padding-top: 6px; font-size: 7.9pt; color: #777; display: flex; justify-content: space-between; gap: 12px; }
.pt-kw .kw-foot .code { white-space: nowrap; letter-spacing: .5px; }

@media print {
  .pt-kw { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pt-kw .kw-sign, .pt-kw .kw-amount, .pt-kw .kw-terbilang { break-inside: avoid; page-break-inside: avoid; }
}

/* ---- 收据列表：长公司名截断 + 操作列钉在右边 ----
   「收到来自」是公司全称（PT. HUA LONG CONSTRUCTION MACHINERY INDONESIA），
   不截断会把表撑宽，右端的「删除」被挤出屏幕看不见。 */
#view-receipts table.grid td:nth-child(1),
#view-receipts table.grid td:nth-child(2) { white-space: nowrap; }
#view-receipts table.grid td:nth-child(3) { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
#view-receipts table.grid td:nth-child(6) { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
#view-receipts table.grid td:last-child,
#view-receipts table.grid th:last-child {
  position: sticky; right: 0; z-index: 1; background: #fff;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, .10);
}
#view-receipts table.grid th:last-child { z-index: 3; background: #f8fafc; }
#view-receipts table.grid tbody tr:hover td:last-child { background: #fafcff; }
