/* ===========================================================================
 * ウリカイ - T3 納品書 / T4 請求書（画面 + 印刷）
 * 画面のレイアウトは quotes.css の .q-* を共用。ここでは固有部分のみ。
 * =========================================================================== */

/* ---- ステータス・区分バッジ ---- */
.doc-status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.doc-status-issued   { background: #FAEEDA; color: #854F0B; }
.doc-status-invoiced { background: var(--color-success-bg); color: var(--color-success); }
.doc-status-single   { background: #EEF0F3; color: var(--color-text-sub); }
.doc-status-bulk     { background: #E6F1FB; color: #0C447C; }
.doc-status-paid     { background: var(--color-success-bg); color: var(--color-success); }
.doc-status-partial  { background: #FAEEDA; color: #854F0B; }
.doc-status-unpaid   { background: #FCEBEB; color: var(--color-danger); }
.i-paid-date { padding: 7px 9px; font-family: inherit; font-size: 13px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); background: #fff; }
.i-client-name { font-size: 13px; color: var(--color-text-muted); margin-left: 10px; }
.i-client-name.is-set { color: var(--color-primary); font-weight: 700; }

.doc-lock-note {
  border: 1px solid var(--color-border-strong); background: #F2F4F7;
  border-radius: 9px; padding: 10px 14px; margin-bottom: 16px;
  font-size: 13px; color: var(--color-text-sub);
}
.doc-source-note {
  font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 12px;
}
.i-pick-row td { vertical-align: middle; }

/* ===========================================================================
 * 印刷帳票（#print-root）
 * 画面では非表示。@media print のときだけ表示してアプリ本体を隠す。
 * =========================================================================== */
#print-root { display: none; }

.pr-doc {
  font-size: 12px; color: #111; line-height: 1.6;
}
.pr-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 22px;
}
.pr-title {
  font-size: 26px; font-weight: 700; letter-spacing: 0.3em;
  margin: 0; padding-bottom: 6px; border-bottom: 3px solid #111;
}
.pr-company { text-align: right; font-size: 11px; line-height: 1.7; position: relative; }
.pr-co-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.pr-co-regno { margin-top: 2px; }
.pr-orderer-label { font-size: 10px; color: #555; margin-bottom: 2px; }
.pr-seal {
  position: absolute; right: 0; bottom: -46px;
  width: 42px; height: 42px; border: 1px solid #c00; color: #c00;
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; opacity: 0.6;
}
/* 角印（社印）画像。白背景でも mix-blend-mode: multiply で朱色の印影だけが
   会社名に重なって見える。位置・大きさは下の top/right/width で微調整可能。 */
.pr-seal-img {
  position: absolute; top: -6px; right: -8px;
  width: 82px; height: 82px; object-fit: contain;
  mix-blend-mode: multiply;
  pointer-events: none;
}
/* 印刷でも色が確実に出るように（背景/色の印刷を強制） */
@media print {
  .pr-seal-img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.pr-parties {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; margin-bottom: 16px;
}
.pr-addressee { flex: 1; }
.pr-addressee-name {
  font-size: 18px; font-weight: 700;
  border-bottom: 1px solid #111; padding-bottom: 6px; margin-bottom: 8px;
}
.pr-addressee-name span { font-size: 13px; font-weight: 500; }
.pr-subject { font-size: 12px; margin-bottom: 4px; }
.pr-lead { font-size: 11px; color: #444; }
.pr-billamount {
  margin-top: 10px; font-size: 14px; border: 1px solid #111;
  padding: 8px 12px; display: inline-block;
}
.pr-billamount strong { font-size: 20px; }

.pr-meta { font-size: 11px; min-width: 200px; }
.pr-meta > div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.pr-meta span { color: #555; }
.pr-meta strong { font-weight: 600; }

.pr-items { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.pr-items th, .pr-items td { border: 1px solid #999; padding: 5px 8px; font-size: 11px; }
.pr-items thead th { background: #f0f0f0; font-weight: 700; text-align: center; }
.pr-c-name { text-align: left; }
.pr-c-qty, .pr-c-price, .pr-c-amt { text-align: right; white-space: nowrap; }
.pr-c-unit, .pr-c-date { text-align: center; white-space: nowrap; }
.pr-item-code { color: #666; font-size: 10px; margin-left: 8px; }
.pr-item-type { color: #666; font-size: 10px; margin-left: 6px; }
.pr-filler td { height: 22px; }

.pr-foot { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.pr-foot-left { flex: 1; }
.pr-note { font-size: 11px; margin-bottom: 12px; }
.pr-note-title { font-weight: 700; margin-bottom: 2px; }
.pr-bank { font-size: 11px; border: 1px solid #999; padding: 8px 10px; }
.pr-bank-title { font-weight: 700; margin-bottom: 3px; }

.pr-totals { min-width: 240px; }
.pr-total-row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 8px; font-size: 12px; }
.pr-total-grand {
  border-top: 2px solid #111; margin-top: 4px; padding-top: 8px;
  font-size: 15px; font-weight: 700;
}

/* ========================================================================
 * フォーム帳票（見積書 / 発注書）— 添付フォーマット準拠
 * ====================================================================== */
.prf-doc { font-size: 12px; color: #111; line-height: 1.6; }
.prf-title {
  text-align: center; font-size: 26px; font-weight: 700;
  letter-spacing: 0.5em; padding-left: 0.5em; margin: 0 0 22px;
}
.prf-top { display: flex; justify-content: space-between; gap: 22px; margin-bottom: 14px; align-items: flex-start; }
.prf-left { width: 54%; }
.prf-right { width: 43%; }

.prf-addr-name {
  font-size: 18px; font-weight: 400;
  border-bottom: 1px solid #111; padding-bottom: 4px; margin-bottom: 8px;
}
.prf-addr-name > span { font-size: 13px; font-weight: 500; margin-left: 6px; }
.prf-addr-person { font-size: 12px; margin: -2px 0 8px; }
.prf-orderer { border-bottom: none; }
/* 発注書の発注者（得意先）ブロック。企業名／発注者記入欄（氏名＋丸印）／住所の順に縦に並べる */
.prf-orderer-name { margin-bottom: 4px; }
.prf-orderer-person { display: flex; align-items: center; gap: 6px; margin: 2px 0 6px; font-size: 12px; }
.prf-orderer-person-label { white-space: nowrap; }
.prf-orderer-person-line { flex: 1; min-width: 96px; border-bottom: 1px solid #888; align-self: flex-end; height: 1.4em; }
.prf-orderer-addr { font-size: 11px; color: #333; margin: -2px 0 8px; }
.prf-lead { font-size: 11px; margin-bottom: 10px; }

/* 角丸テーブル共通の考え方: border-collapse: collapse では border-radius が
   効かないため separate にし、罫線はセルの上・右のみ＋外周は table の border で描く */
.prf-meta { border-collapse: separate; border-spacing: 0; width: 100%; margin-bottom: 12px; border: 1px solid #bbb; border-radius: 4px; }
.prf-meta th, .prf-meta td { border: none; padding: 5px 8px; font-size: 11px; }
.prf-meta th { background: #6b7280; color: #fff; font-weight: 500; width: 88px; text-align: center; white-space: nowrap; border-right: 1px solid #bbb; }
.prf-meta td { text-align: left; }
.prf-meta tr + tr th, .prf-meta tr + tr td { border-top: 1px solid #bbb; }
.prf-meta tr:first-child th { border-top-left-radius: 3px; }
.prf-meta tr:last-child th { border-bottom-left-radius: 3px; }

.prf-grand { display: flex; border: 2px solid #444; border-radius: 4px; overflow: hidden; }
.prf-grand-label { background: #6b7280; color: #fff; padding: 10px 16px; font-size: 14px; display: flex; align-items: center; white-space: nowrap; }
.prf-grand-val { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 22px; font-weight: 400; }
.prf-grand-val > span { font-size: 12px; font-weight: 500; }

.prf-nobox { border-collapse: separate; border-spacing: 0; margin: 0 0 12px auto; border: 1px solid #bbb; border-radius: 4px; }
.prf-nobox th, .prf-nobox td { border: none; padding: 3px 10px; font-size: 11px; }
.prf-nobox th { background: #6b7280; color: #fff; font-weight: 500; text-align: center; white-space: nowrap; border-right: 1px solid #bbb; }
.prf-nobox td { min-width: 96px; text-align: left; }
.prf-nobox tr + tr th, .prf-nobox tr + tr td { border-top: 1px solid #bbb; }
.prf-nobox tr:first-child th { border-top-left-radius: 3px; }
.prf-nobox tr:last-child th { border-bottom-left-radius: 3px; }

.prf-issuer { display: flex; justify-content: flex-end; font-size: 11px; line-height: 1.75; }
.prf-issuer-main { position: relative; display: inline-block; text-align: left; word-break: keep-all; overflow-wrap: anywhere; }
.prf-logo-img {
  display: block; max-width: 148px; max-height: 38px;
  object-fit: contain; margin-bottom: 6px;
}
.prf-co-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; letter-spacing: 0.02em; }
.prf-regno { margin-bottom: 4px; }
.prf-seal-wrap { position: absolute; top: 20px; right: -8px; }
.prf-seal-img {
  width: 72px; height: 72px;
  object-fit: contain; mix-blend-mode: multiply; pointer-events: none;
}
.prf-seal-box {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 1px solid #c00; color: #c00;
  border-radius: 4px; font-size: 11px; opacity: 0.6;
}
/* 発注書の発注者「担当者印」枠。角印より小さめの丸型・破線で押印位置を示す。 */
.prf-clerk-seal {
  display: inline-flex; flex: none; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px dashed #999; color: #999;
  border-radius: 50%; font-size: 10px; opacity: 0.8;
}

.prf-items { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid #888; border-radius: 4px; }
.prf-items th { background: #6b7280; color: #fff; font-weight: 500; font-size: 11px; padding: 6px 8px; border: none; border-right: 1px solid #888; }
.prf-items td { border: none; border-top: 1px solid #bbb; border-right: 1px solid #bbb; padding: 5px 8px; font-size: 11px; height: 22px; }
.prf-items th:last-child, .prf-items td:last-child { border-right: none; }
.prf-items thead th:first-child { border-top-left-radius: 3px; }
.prf-items thead th:last-child { border-top-right-radius: 3px; }
.prf-c-date { text-align: center; width: 64px; white-space: nowrap; }
.prf-c-desc { text-align: left; }
.prf-c-qty { text-align: right; width: 56px; }
.prf-c-price, .prf-c-amt { text-align: right; width: 92px; }
.prf-period { color: #555; font-size: 10px; white-space: nowrap; }
.prf-price-unit { color: #777; font-size: 9px; margin-left: 1px; }
/* レンタル見積専用テーブルの追加列 */
.prf-c-subject { text-align: center; width: 64px; white-space: nowrap; }
.prf-c-unit { text-align: center; width: 40px; white-space: nowrap; }
.prf-c-period { text-align: center; width: 56px; white-space: nowrap; }
.prf-items-rental .prf-c-qty { width: 48px; }
.prf-items-rental .prf-c-price, .prf-items-rental .prf-c-amt { width: 84px; }
/* ご請求明細「賃貸料」テーブル（延べ台数の内訳＋単価・金額） */
.prf-items-basis th { white-space: nowrap; }   /* 見出し（延べ数量など）を折り返さず1行に */
.prf-items-basis .prf-c-period { width: 130px; text-align: center; white-space: nowrap; }
.prf-items-basis .prf-c-qty { width: 60px; }
.prf-items-basis .prf-c-price { width: 72px; }
.prf-items-basis .prf-c-amt { width: 96px; }
/* ご請求明細「お借入実績」テーブル（継続 → 借入/返却イベント → 期末）。
   請求金額の表ではなく実績（参考情報）のため、見出しをライトグレーにして請求系の表と区別する */
/* 見出しが薄色のため、バーにも枠線を付けて表全体の縁取りをはっきりさせる（下辺は表の上枠と共有） */
.prf-remark-bar.prf-moves-bar { background: #e5e7eb; color: #374151; border: 1px solid #888; border-bottom: none; }
.prf-items-moves th { background: #e5e7eb; color: #374151; border-right-color: #bbb; border-bottom: 1px solid #888; }
.prf-items-moves tbody tr:first-child td { border-top: none; }   /* 見出し行の下枠と二重にしない */
.prf-items-moves .prf-c-date { width: 72px; }
.prf-items-moves .prf-c-qty { width: 64px; }
/* 縦結合（rowspan）がある表では「行の最後のセル＝最終列」とは限らないため、
   行末セルの右罫線を復活させ、真の最終列（金額/期末台数）だけ外周と重ならないよう消す */
.prf-items-basis td:last-child { border-right: 1px solid #bbb; }
.prf-items-basis td.prf-c-amt { border-right: none; }
.prf-items-moves td:last-child { border-right: 1px solid #bbb; }
.prf-items-moves td.prf-c-close { border-right: none; }
/* ご請求明細「その他」テーブル */
.prf-items-other .prf-c-qty { width: 64px; }
.prf-items-other .prf-c-price { width: 90px; }
.prf-items-other .prf-c-amt { width: 96px; }
/* 全帳票の明細テーブルは見出し行（グレー部分）のみ中央揃え。本文セルは各列既定の配置のまま */
.prf-items th { text-align: center; }
/* 請求書2ページ目「ご請求明細」は改ページして先頭から */
.prf-page2 { break-before: page; page-break-before: always; }

.prf-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 10px; }
.prf-taxbreak { border-collapse: collapse; }
.prf-taxbreak th, .prf-taxbreak td { padding: 3px 14px; font-size: 11px; text-align: right; }
.prf-taxbreak th { color: #555; font-weight: 500; border-bottom: 1px solid #bbb; }
.prf-taxbreak th:first-child, .prf-taxbreak td:first-child { text-align: left; }
.prf-totals { border-collapse: separate; border-spacing: 0; min-width: 300px; border: 1px solid #888; border-radius: 4px; }
.prf-totals th { background: #6b7280; color: #fff; font-weight: 500; padding: 6px 14px; font-size: 12px; border: none; border-right: 1px solid #888; width: 130px; text-align: center; }
.prf-totals td { border: none; padding: 6px 14px; text-align: right; font-size: 12px; }
.prf-totals tr + tr th, .prf-totals tr + tr td { border-top: 1px solid #bbb; }
.prf-totals tr:first-child th { border-top-left-radius: 3px; }
.prf-totals tr:last-child th { border-bottom-left-radius: 3px; }
.prf-totals .prf-grandrow th, .prf-totals .prf-grandrow td { font-size: 15px; font-weight: 400; }

.prf-remark-bar { background: #6b7280; color: #fff; text-align: center; padding: 4px; font-size: 11px; margin-top: 16px; border-radius: 4px 4px 0 0; }
.prf-remark-body { border: 1px solid #bbb; border-top: none; min-height: 56px; padding: 8px; font-size: 11px; border-radius: 0 0 4px 4px; }
/* 見出しバー（賃貸料/その他）直下のテーブルは上角を直角にしてバーと繋げる */
.prf-remark-bar + .prf-items { border-top-left-radius: 0; border-top-right-radius: 0; }
.prf-remark-bar + .prf-items thead th:first-child { border-top-left-radius: 0; }
.prf-remark-bar + .prf-items thead th:last-child { border-top-right-radius: 0; }
.prf-bank { margin-top: 10px; border: 1px solid #bbb; padding: 8px 10px; font-size: 11px; line-height: 1.6; border-radius: 4px; }
.prf-bank-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 700; margin-bottom: 4px; border-bottom: 1px solid #ddd; padding-bottom: 3px; }
.prf-bank-table { width: 100%; border-collapse: collapse; }
.prf-bank-table td { padding: 1px 0; vertical-align: top; white-space: nowrap; }
.prf-bank-name { width: 100%; }
.prf-bank-type { padding-left: 10px !important; text-align: right; }
.prf-bank-no { padding-left: 8px !important; text-align: right; font-variant-numeric: tabular-nums; }
.prf-bank-holder { font-weight: 500; white-space: nowrap; }
.prf-bank-note-inline { display: block; font-weight: 400; font-size: 9px; margin-top: 1px; }
.prf-bank-note { margin-top: 5px; padding-top: 4px; border-top: 1px solid #ddd; font-size: 10px; color: #444; }

@media print {
  /* アプリ本体を隠し、帳票だけを印刷 */
  body.is-printing > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  /* 背景色（灰色ラベル等）と色を確実に印刷する */
  #print-root, #print-root * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* @page の余白を 0 にすると、ブラウザ既定のヘッダー/フッター
     （URL・日付・ページ番号・タイトル）が余白に描画されず消える。
     体裁用の余白は #print-root の padding で確保する。 */
  @page { size: A4; margin: 0; }
  #print-root { padding: 14mm 12mm; }
  html, body { background: #fff !important; }
  /* ルートの padding-top は1ページ目先頭のみに効くため、2ページ目に上余白を補う */
  .prf-page2 { padding-top: 12mm; }
}
