/* ==================================================================
   帳票（検査報告書 / 写真帳 / 指示書）の見た目。
   画面プレビュー（.report-paper 内）と 印刷（@media print）で共用。
   ================================================================== */

.report-paper {
  --rp-fg: #1a1a1a;
  --rp-line: #999;
  color: var(--rp-fg);
  background: #fff;
  font-family: "Meiryo", メイリオ, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
}
.report-paper .report-page {
  width: 186mm;            /* A4 210mm - 左右余白12mm */
  min-height: 260mm;
  margin: 0 auto 16px;
  padding: 6mm 0;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  box-sizing: content-box;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ページ番号（帳票内・全ページ共通）。各ページの下端に寄せる。 */
.rp-pageno {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 10px;
  color: #555;
  border-top: 1px solid var(--rp-line);
  padding-top: 4px;
  margin-bottom: 0;
}
.rp-pageno-doc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-pageno-num { font-weight: 700; white-space: nowrap; }

.rp-title { font-size: 20px; margin: 0 0 10px; border-bottom: 3px solid var(--rp-fg); padding-bottom: 6px; }
.rp-ledger-sub { font-size: 12px; color: #555; margin-bottom: 10px; }

.rp-meta { border-collapse: collapse; width: 100%; margin-bottom: 12px; font-size: 12px; }
.rp-meta th, .rp-meta td { border: 1px solid var(--rp-line); padding: 5px 8px; text-align: left; }
.rp-meta th { background: #f0f0f0; width: 22%; white-space: nowrap; }

.rp-table { border-collapse: collapse; width: 100%; font-size: 11px; }
.rp-table th, .rp-table td { border: 1px solid var(--rp-line); padding: 5px 6px; vertical-align: top; }
.rp-table th { background: #f0f0f0; text-align: center; white-space: nowrap; }
.rp-table td { word-break: break-word; }
.rp-no { text-align: center; font-weight: 800; white-space: nowrap; }
.rp-no.big { font-size: 22px; display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; }
.rp-empty { color: #666; font-size: 12px; padding: 12px 0; }

.rp-figures { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.rp-figure { border: 1px solid var(--rp-line); padding: 6px; }
.rp-figure-name { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.rp-figure img { display: block; width: 100%; height: auto; }

/* 写真帳 */
.rp-ledger-item { border: 1px solid var(--rp-line); padding: 10px; margin-bottom: 10px; page-break-inside: avoid; break-inside: avoid; }
.rp-ledger-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.rp-ledger-place { font-size: 11px; color: #555; }
.rp-ledger-issue, .rp-ledger-fix { font-size: 12px; margin-top: 2px; }
.rp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rp-pair-col { border: 1px solid #ccc; padding: 6px; }
.rp-pair-label { font-size: 12px; font-weight: 800; text-align: center; padding: 2px 0 6px; }
.rp-pair-label.b { color: #b45309; }
.rp-pair-label.a { color: #15803d; }
.rp-photobox { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.rp-photo { margin: 0; }
.rp-photo img { display: block; max-width: 82mm; max-height: 62mm; width: auto; height: auto; object-fit: contain; border: 1px solid #ddd; }
.rp-photo figcaption { font-size: 10px; color: #666; text-align: center; margin-top: 2px; }
.rp-photo-empty { color: #999; font-size: 12px; padding: 24px 8px; text-align: center; }
.rp-photo-more { font-size: 10px; color: #666; width: 100%; text-align: center; }

/* 横向き帳票 共通 */
.report-paper .report-page.landscape { width: 273mm; min-height: 180mm; }  /* A4横 297 - 左右余白12mm */

/* 表紙（指示書1枚目 / 検査報告書1枚目）: 左=情報+図面 / 右=一覧 */
.ric-cols { display: grid; grid-template-columns: 42% 58%; gap: 12px; align-items: start; }
.ric-left .rp-title { font-size: 16px; }
.ric-left .rp-figures { margin-bottom: 0; }
.ric-left .rp-figure img { max-height: 120mm; width: auto; margin: 0 auto; }
.ric-right-title { font-size: 14px; font-weight: 800; border-left: 4px solid var(--rp-fg); padding-left: 6px; margin-bottom: 6px; }
.ric-right .rp-table td:nth-child(2) { min-width: 60mm; }
.ric-right .rp-table { font-size: 10px; }

/* 検査報告書1枚目: 情報は2段程度・図面を大きく */
.rp-metastrip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px 8px; margin: 6px 0 8px; }
.rp-metacell { display: flex; gap: 5px; font-size: 11px; border-bottom: 1px solid var(--rp-line); padding: 3px 2px; }
.rp-metak { color: #555; white-space: nowrap; }
.rp-metav { font-weight: 700; }
.rp-insp-cover .ric-left .rp-figure img { max-height: 150mm; }

/* 是正確認写真帳（横向き・1ページ2件） */
.rl2-head { font-size: 12px; font-weight: 700; border-bottom: 2px solid var(--rp-fg); padding-bottom: 4px; margin-bottom: 8px; }
.rl2-items { display: flex; flex-direction: column; gap: 10px; }
.rl2-item { border: 1px solid var(--rp-line); padding: 8px; page-break-inside: avoid; break-inside: avoid; }
.rl2-no { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rl2-place { font-size: 11px; color: #555; }
.rl2-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rl2-col { border: 1px solid #ccc; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.rl2-label { font-size: 12px; font-weight: 800; text-align: center; }
.rl2-label.b { color: #b45309; }
.rl2-label.a { color: #15803d; }
.rl2-col .rp-photobox { min-height: 0; }
.rl2-col .rp-photo img { max-width: 100%; max-height: 62mm; }
.rl2-col .rp-photo-empty { padding: 18px 8px; }
.rl2-text { font-size: 11px; line-height: 1.4; border-top: 1px dashed var(--rp-line); padding-top: 4px; }

/* 2枚目以降: 指示カード6件（3列×2段） */
.rig-head { font-size: 12px; font-weight: 700; border-bottom: 2px solid var(--rp-fg); padding-bottom: 4px; margin-bottom: 6px; }
.rig-cards { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, auto); gap: 7px; }
.rig-card { border: 1px solid var(--rp-line); padding: 7px; display: flex; flex-direction: column; gap: 5px; page-break-inside: avoid; break-inside: avoid; height: 86mm; overflow: hidden; }
.rig-card-head { display: flex; gap: 8px; align-items: flex-start; }
.rig-card-title { font-size: 11px; font-weight: 700; line-height: 1.35; }
.rig-card-meta { font-size: 10px; color: #333; display: flex; flex-direction: column; gap: 2px; }
.rig-k { display: inline-block; min-width: 5em; color: #666; }
.rig-card-photo { margin-top: auto; text-align: center; }
.rig-card-photo .rp-photo img { max-width: 100%; max-height: 42mm; }
.rig-card-photo .rp-photo-empty { padding: 8px; }

@media screen {
  #report-print-root { display: none; }
}

@media print {
  html, body { background: #fff !important; }
  body > .app-root, body > .savebar, body > .toast-host, body > .devsw,
  body > .sheet-overlay, body > .lightbox-overlay { display: none !important; }
  #report-print-root { display: block !important; }
  @page { size: A4 portrait; margin: 12mm; }
  @page landscapePage { size: A4 landscape; margin: 12mm; }
  .report-paper .report-page {
    width: auto; min-height: 258mm; margin: 0; padding: 0; box-shadow: none;
    page-break-after: always; break-after: page;
  }
  .report-paper .report-page.landscape { page: landscapePage; min-height: 172mm; }
  .report-paper .report-page:last-child { page-break-after: auto; break-after: auto; }
  .rp-photo img { max-width: 84mm; max-height: 64mm; }
  .rp-pageno { border-top: 1px solid #999; }
}
