/* 報價單、估價單、請款單三頁共用樣式；共用元件（.tool #of-form .qr-field .btn）沿用 site.css */
#of-form [hidden], #of-pv [hidden] { display: none !important; }
#of-form .qr-field input[type=text], #of-form .qr-field input[type=date], #of-form .qr-field select, #of-form .qr-field textarea { min-width: 0; }
.of-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; }
.of-warn li + li { margin-top: .35rem; }

/* 品項列：手機上每列是一張小卡，桌機排成一行 */
.of-items { display: grid; gap: 12px; margin: 8px 0; }
.of-item { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg, #fff); }
.of-f { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .95rem; }
.of-f.of-name, .of-f.of-spec { grid-column: 1 / -1; }
.of-fl { font-weight: 600; }
.of-f input { width: 100%; min-width: 0; box-sizing: border-box; }
.of-f.of-sub output { font-weight: 700; padding: 8px 0; overflow-wrap: anywhere; }
.of-del { align-self: end; }
.of-add-row { margin: 4px 0 8px; }
@media (min-width: 900px) {
  .of-item { grid-template-columns: 1.6fr 1.6fr .7fr .6fr .9fr .9fr auto; align-items: end; }
  .of-f.of-name, .of-f.of-spec { grid-column: auto; }
}

#of-pv h2 { margin-top: 1.5rem; }
.of-pv-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.of-pv-bar .btn { width: 100%; text-align: center; }
.of-pv-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #e9ecf1; margin: 10px 0; }
.of-pages { width: 210mm; transform-origin: 0 0; }
.of-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;
}
.of-head { display: grid; grid-template-columns: auto 1fr auto; gap: 3mm; white-space: nowrap; align-items: baseline; margin-bottom: 4mm; }
.of-title { font-size: 22pt; font-weight: 700; letter-spacing: .25em; text-align: center; }
.of-date { text-align: right; }
.of-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; margin-bottom: 3mm; }
.of-party { border: 1px solid #222; padding: 2mm 3mm; min-width: 0; }
.of-party-h { font-weight: 700; border-bottom: 1px solid #999; margin-bottom: 1mm; }
.of-party-n { font-size: 12pt; font-weight: 700; overflow-wrap: anywhere; }
.of-party-l, .of-meta-l { display: flex; gap: 2mm; }
.of-k { font-weight: 700; flex: none; }
.of-k::after { content: "："; }
.of-v { overflow-wrap: anywhere; min-width: 0; }
.of-pre { white-space: pre-wrap; }
.of-meta { margin-bottom: 3mm; }
.of-table { width: 100%; border-collapse: collapse; margin: 2mm 0 3mm; table-layout: fixed; }
.of-table th, .of-table td { border: 1px solid #222; padding: .6mm 1.5mm; overflow-wrap: anywhere; vertical-align: top; }
.of-table th { background: #eee; font-weight: 700; }
.of-table th:nth-child(1), .of-table td:nth-child(1) { width: 8mm; }
.of-table th:nth-child(4), .of-table td:nth-child(4) { width: 17mm; }
.of-table th:nth-child(5), .of-table td:nth-child(5) { width: 13mm; }
.of-table th:nth-child(6), .of-table td:nth-child(6) { width: 24mm; }
.of-table th:nth-child(7), .of-table td:nth-child(7) { width: 28mm; }
.of-table tr { break-inside: avoid; page-break-inside: avoid; }
.of-table .of-num { text-align: right; }
.of-table .of-ctr { text-align: center; }
.of-empty { text-align: center; color: #666; }
.of-sums { margin-left: auto; width: 100mm; max-width: 100%; margin-bottom: 3mm; break-inside: avoid; page-break-inside: avoid; }
.of-sum { display: flex; justify-content: space-between; gap: 4mm; border-bottom: 1px solid #999; padding: .6mm 0; }
.of-sum .of-k::after { content: ""; }
.of-sum .of-v { text-align: right; }
.of-sum.of-strong { font-weight: 700; font-size: 12pt; border-bottom: 2px solid #222; }
.of-block { border: 1px solid #222; padding: 1.5mm 3mm; margin-bottom: 2.5mm; break-inside: avoid; page-break-inside: avoid; }
.of-block-h { font-weight: 700; border-bottom: 1px solid #999; margin-bottom: 1mm; }
.of-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; margin-top: 5mm; break-inside: avoid; page-break-inside: avoid; }
.of-sign { border: 1px solid #222; height: 22mm; padding: 2mm 3mm; }
.of-sign-t { font-weight: 700; }

@media (max-width: 480px) {
  .of-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 > #of-main { display: block !important; border: 0; border-radius: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
  #of-main > #of-form { display: none !important; }
  #of-pv h2, #of-pv .of-pv-bar, #of-pv .of-pv-hint, #of-pv .status { display: none !important; }
  .of-pv-wrap { border: 0; background: none; overflow: visible; height: auto !important; margin: 0; border-radius: 0; }
  .of-pages { transform: none !important; width: 182mm; }
  .of-page { margin: 0 !important; min-height: 0; width: 182mm; padding: 0; }
}

.of-actions { display:flex; flex-wrap:wrap; gap:6px; grid-column:1 / -1; }
.of-head { white-space:normal; grid-template-columns:1fr; }
.of-no, .of-date { text-align:right; overflow-wrap:anywhere; }
.of-title { grid-row:1; }
#of-form [hidden] { display:none !important; }
.of-item input { padding:8px; border:1px solid var(--line); border-radius:6px; }
.of-kind { display:flex; flex-wrap:wrap; gap:18px; }
.of-kind input { width:auto; }
@media print { #of-main > :not(#of-pv) { display:none !important; } }
