/*
 * PDF 帳票専用のスタイル。画面の Tailwind とは独立している。
 * (帳票は Chromium が印刷するもので、画面とは要求が違う: 紙のサイズ・改ページ・
 *  背景の印刷・日本語フォントの指定など)
 *
 * 旧 icefox から踏襲。顧客に送ってきた帳票と見た目を合わせるため、意図的に変えていない。
 */
/* Page */
@page {
  size: A4;
  margin: 4mm;
}

/* Tokens */
:root {
  --pdf-text-color: #1f2933;
  --pdf-accent: #0a1b2f;
  --pdf-accent-dark: #102844;
  --pdf-accent-muted: #1a3a60;
  --pdf-border: #c9d5df;
  --pdf-panel-border: #8ea5b7;
  --pdf-head-bg: #edf2f7;
  --pdf-total-bg: #dce6f1;
  --pdf-lines-bg: #f2f4f6;
  --pdf-photo-bg: #f8f9fa;
  --pdf-font-family: "Noto Sans CJK JP", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

/* Base */
body {
  margin: 0;
  color: var(--pdf-text-color);
  font-family: var(--pdf-font-family);
  font-size: 12px;
  line-height: 1.45;
}

.report {
  width: 100%;
}

.report-page {
  min-height: 285mm;
}

.page-break-before {
  page-break-before: always;
}

/* Header */
.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.report-header h1 {
  margin: 0;
  color: var(--pdf-accent);
  font-size: 28px;
  letter-spacing: 0.08em;
}

.header-meta {
  border-collapse: collapse;
  font-size: 11px;
}

.header-meta th,
.header-meta td {
  padding: 2px 0 2px 10px;
  white-space: nowrap;
  border: 0;
}

.header-meta th {
  color: var(--pdf-accent-muted);
  text-align: right;
}

/* Top panels */
.report-top-grid {
  display: grid;
  grid-template-columns: 52% 48%;
  gap: 14px;
  margin-bottom: 10px;
}

.recipient-panel {
  border: 1px solid var(--pdf-panel-border);
  padding: 10px;
  min-height: 135px;
}

.acceptance-signer-panel {
  min-height: 180px;
}

.recipient-line {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 14px;
}

.recipient-panel p,
.issuer-panel p {
  margin: 0 0 4px;
}

.issuer-panel {
  position: relative;
  padding: 2px 10px;
}

.issuer-name {
  font-weight: 700;
  font-size: 13px;
}

.bank-account-line {
  margin-top: 6px;
  margin-bottom: 2px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  gap: 2px;
}

.bank-account-holder-line {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  gap: 2px;
}

.bank-account-label,
.bank-account-label-spacer {
  display: inline-block;
  width: 4.6em;
  flex: 0 0 4.6em;
}

.company-logo {
  max-height: 44px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 0;
}

.company-seal {
  position: absolute;
  right: 24px;
  top: 36px;
  max-width: 76px;
  max-height: 76px;
  width: auto;
  height: auto;
  z-index: 2;
  pointer-events: none;
  opacity: 0.85;
}

.amount-box {
  margin-top: 10px;
  border-bottom: 2px solid var(--pdf-panel-border);
  color: var(--pdf-accent-dark);
  padding: 4px 0;
}

.amount-box strong {
  margin-left: 12px;
  font-size: 20px;
}

.greeting-text {
  margin: 8px 0 4px;
  color: var(--pdf-accent-dark);
  font-size: 11px;
}

/* Tables */
.report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.report-table th,
.report-table td {
  border: 1px solid var(--pdf-border);
  padding: 6px;
  vertical-align: middle;
  word-break: break-word;
}

.report-table th {
  width: 28%;
  background: var(--pdf-head-bg);
  text-align: left;
  font-weight: 700;
}

.report-table tr {
  page-break-inside: avoid;
}

.memo-cell {
  min-height: 48px;
  white-space: pre-wrap;
}

.lines-table th,
.lines-table td {
  text-align: right;
}

.lines-table th {
  background: var(--pdf-accent);
  border-color: var(--pdf-accent);
  color: #fff;
  width: auto;
  text-align: center;
  font-weight: 600;
  font-size: 11px;
  padding-top: 3px;
  padding-bottom: 3px;
}

.lines-table tbody td {
  background: var(--pdf-lines-bg);
}

.lines-table tbody tr {
  height: 24px;
}

.lines-table tbody tr.blank-line td {
  color: transparent;
}

.lines-table .col-name,
.lines-table td:first-child {
  text-align: left;
}

.lines-table .col-line-no {
  width: 6%;
}

.lines-table .col-name {
  width: 38%;
}

.lines-table .col-qty {
  width: 8%;
}

.lines-table .col-unit {
  width: 7%;
}

.lines-table .col-price-unit,
.lines-table .col-hours-unit {
  width: 10%;
}

.lines-table .col-price,
.lines-table .col-total {
  width: 14%;
}

.lines-table .col-unit-value {
  text-align: center;
  font-size: 10px;
}

.lines-table .col-tax-rate {
  width: 8%;
}

.invoice-lines-table .col-line-no {
  width: 8%;
}

.invoice-lines-table .col-name {
  width: 64%;
}

.invoice-lines-table .col-total {
  width: 28%;
}

.invoice-lines-table td:first-child,
.invoice-lines-table th:first-child {
  text-align: center;
}

.invoice-lines-table td:nth-child(2),
.invoice-lines-table th:nth-child(2) {
  text-align: left;
}

.invoice-lines-table td:nth-child(3),
.invoice-lines-table th:nth-child(3) {
  text-align: right;
}

.summary-lines-table th {
  width: auto;
  background: var(--pdf-accent);
  border-color: var(--pdf-accent);
  color: #fff;
  text-align: center;
}

.summary-lines-table .col-item-name {
  width: 35%;
}

.summary-lines-table .col-item-overview {
  width: 65%;
}

.summary-lines-table td:first-child,
.summary-lines-table th:first-child,
.summary-lines-table td:nth-child(2),
.summary-lines-table th:nth-child(2) {
  text-align: left;
}

.report-item-block {
  margin-bottom: 10px;
  border: 1px solid var(--pdf-border);
  border-radius: 2px;
  padding: 6px;
  background: #fff;
  page-break-inside: avoid;
}

.report-item-block:first-of-type {
  margin-top: 6px;
}

.item-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.item-title {
  color: var(--pdf-accent-dark);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.item-meta-table th {
  width: 18%;
}

.item-summary-row td {
  background: #eef3f8;
  font-weight: 600;
}

.item-summary-row td:first-child {
  text-align: right;
}

.item-summary-total td {
  background: #dce6f1;
  font-weight: 700;
}

.totals-table {
  margin-left: auto;
  width: 42%;
}

.totals-table th {
  width: 58%;
  background: var(--pdf-head-bg);
  text-align: left;
}

.totals-table td {
  text-align: right;
}

.totals-table tr:last-child th,
.totals-table tr:last-child td {
  font-weight: 700;
  background: var(--pdf-total-bg);
}

/* Photos */
.report-photos-section {
  margin-top: 18px;
}

.report-photos-section h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.report-photos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.report-photo-item {
  margin: 0;
  border: 1px solid var(--pdf-border);
  padding: 6px;
  page-break-inside: avoid;
}

.report-photo-image {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
  background: var(--pdf-photo-bg);
}

.report-photo-item figcaption {
  margin-top: 6px;
  font-size: 11px;
  word-break: break-all;
}

.stamp-area {
  margin-top: 12px;
  width: 120px;
  height: 120px;
  border: 1px dashed var(--pdf-panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pdf-accent-muted);
  font-size: 11px;
}