/* 報價單、估價單、請款單三頁共用樣式；共用元件（.tool .calc .qr-field .btn）沿用 site.css */
#bd-form [hidden], #bd-pv [hidden] { display: none !important; }
.calc .qr-field input[type=text], .calc .qr-field input[type=date], .calc .qr-field select, .calc .qr-field textarea { min-width: 0; }
.bd-warn { list-style: none; margin: 12px 0 0; padding: 10px 14px; background: #fff7e6; border-left: 4px solid var(--warn); border-radius: 6px; font-size: 1rem; }
.bd-warn li + li { margin-top: .35rem; }

/* 品項列：手機上每列是一張小卡，桌機排成一行 */
.bd-items { display: grid; gap: 12px; margin: 8px 0; }
.bd-item { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg, #fff); }
.bd-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .95rem; }
.bd-f.name, .bd-f.spec { grid-column: 1 / -1; }
.bd-fl { font-weight: 600; }
.bd-f input { width: 100%; min-width: 0; box-sizing: border-box; }
.bd-f.sub output { font-weight: 700; padding: 8px 0; overflow-wrap: anywhere; }
.bd-del { align-self: end; }
.bd-add-row { margin: 4px 0 8px; }
@media (min-width: 900px) {
  .bd-item { grid-template-columns: 1.6fr 1.6fr .7fr .6fr .9fr .9fr auto; align-items: end; }
  .bd-f.name, .bd-f.spec { grid-column: auto; }
}

#bd-pv h2 { margin-top: 1.5rem; }
.pv-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.pv-bar .btn { width: 100%; text-align: center; }
.pv-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #e9ecf1; margin: 10px 0; }
.bd-pages { width: 210mm; transform-origin: 0 0; }
.bd-page {
  width: 210mm; min-height: 290mm; padding: 14mm 14mm 12mm; background: #fff; color: #000; box-sizing: border-box;
  font-family: "標楷體", "DFKai-SB", "BiauKai", "Noto Serif TC", "PMingLiU", serif; font-size: 10.5pt; line-height: 1.45;
}
.bd-head { display: grid; grid-template-columns: auto 1fr auto; gap: 3mm; white-space: nowrap; align-items: baseline; margin-bottom: 4mm; }
.bd-title { font-size: 22pt; font-weight: 700; letter-spacing: .25em; text-align: center; }
.bd-date { text-align: right; }
.bd-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; margin-bottom: 3mm; }
.bd-party { border: 1px solid #222; padding: 2mm 3mm; min-width: 0; }
.bd-party-h { font-weight: 700; border-bottom: 1px solid #999; margin-bottom: 1mm; }
.bd-party-n { font-size: 12pt; font-weight: 700; overflow-wrap: anywhere; }
.bd-party-l, .bd-meta-l { display: flex; gap: 2mm; }
.bd-k { font-weight: 700; flex: none; }
.bd-k::after { content: "："; }
.bd-v { overflow-wrap: anywhere; min-width: 0; }
.bd-pre { white-space: pre-wrap; }
.bd-meta { margin-bottom: 3mm; }
.bd-table { width: 100%; border-collapse: collapse; margin: 2mm 0 3mm; table-layout: fixed; }
.bd-table th, .bd-table td { border: 1px solid #222; padding: .6mm 1.5mm; overflow-wrap: anywhere; vertical-align: top; }
.bd-table th { background: #eee; font-weight: 700; }
.bd-table th:nth-child(1), .bd-table td:nth-child(1) { width: 8mm; }
.bd-table th:nth-child(4), .bd-table td:nth-child(4) { width: 17mm; }
.bd-table th:nth-child(5), .bd-table td:nth-child(5) { width: 13mm; }
.bd-table th:nth-child(6), .bd-table td:nth-child(6) { width: 24mm; }
.bd-table th:nth-child(7), .bd-table td:nth-child(7) { width: 28mm; }
.bd-table tr { break-inside: avoid; page-break-inside: avoid; }
.bd-table .num { text-align: right; }
.bd-table .ctr { text-align: center; }
.bd-empty { text-align: center; color: #666; }
.bd-sums { margin-left: auto; width: 100mm; max-width: 100%; margin-bottom: 3mm; break-inside: avoid; page-break-inside: avoid; }
.bd-sum { display: flex; justify-content: space-between; gap: 4mm; border-bottom: 1px solid #999; padding: .6mm 0; }
.bd-sum .bd-k::after { content: ""; }
.bd-sum .bd-v { text-align: right; }
.bd-sum.strong { font-weight: 700; font-size: 12pt; border-bottom: 2px solid #222; }
.bd-block { border: 1px solid #222; padding: 1.5mm 3mm; margin-bottom: 2.5mm; break-inside: avoid; page-break-inside: avoid; }
.bd-block-h { font-weight: 700; border-bottom: 1px solid #999; margin-bottom: 1mm; }
.bd-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; margin-top: 5mm; break-inside: avoid; page-break-inside: avoid; }
.bd-sign { border: 1px solid #222; height: 22mm; padding: 2mm 3mm; }
.bd-sign-t { font-weight: 700; }

@media (max-width: 480px) {
  .pv-bar { grid-template-columns: 1fr; }
}

@media print {
  /* 邊界交給 @page：每一頁（含第 2 頁起）上下左右都留白；內文寬 210 - 28 = 182mm，與預覽的內文寬相同 */
  @page { size: A4; margin: 14mm 14mm 12mm; }
  html, body { background: #fff; }
  .site-header, .site-footer { display: none !important; }
  main.wrap { max-width: none; padding: 0; margin: 0; }
  main.wrap > * { display: none !important; }
  main.wrap > #bd-main { display: block !important; border: 0; border-radius: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
  #bd-main > #bd-form { display: none !important; }
  #bd-pv h2, #bd-pv .pv-bar, #bd-pv .pv-hint, #bd-pv .status { display: none !important; }
  .pv-wrap { border: 0; background: none; overflow: visible; height: auto !important; margin: 0; border-radius: 0; }
  .bd-pages { transform: none !important; width: 182mm; }
  .bd-page { margin: 0 !important; min-height: 0; width: 182mm; padding: 0; }
}
