/* 印刷用スタイル（A4縦） */
html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.only-print { display: none !important; }

@media print {
  @page { size: A4 portrait; margin: 10mm 8mm 10mm 8mm; }

  /* 画面UIは隠す */
  header, nav, footer, .navbar, .alert, .pagination,
  .nav, .nav-tabs, .nav-pills, .badge, .hide-print,
  form, .btn, .btn-link { display: none !important; }

  /* スマホ版は印刷しない／PC表を強制 */
  .d-sm-none { display: none !important; }
  .d-none.d-sm-block { display: block !important; }

  /* 表＋印刷ヘッダだけを可視化（版面上部に詰める） */
  body * { visibility: hidden; }
  .table-responsive, .table-responsive * { visibility: visible; }
  .only-print, .only-print * { visibility: visible; }
  .table-responsive { position: relative; top: 0; margin-top: 0 !important; overflow: visible !important; }

  /* 表の安定化 */
  .list-table { table-layout: fixed; width: 100% !important; border-collapse: collapse !important; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr, td, th { page-break-inside: avoid; }
  .list-table th, .list-table td { padding: 6px 8px; vertical-align: top; }

  body { font-size: 12px; }
  h2 { margin: 0 0 6px 0; }
  .print-header h3 { margin: 0 0 6px 0; font-size: 14px; }

  /* 列幅の基準（申請者列あり/なし双方で無難） */
  .list-table th:nth-child(1), .list-table td:nth-child(1) { width: 12%; } /* 申請者 or 日付 */
  .list-table th:nth-child(2), .list-table td:nth-child(2) { width: 12%; } /* 日付 or 出発 */
  .list-table th:nth-child(3), .list-table td:nth-child(3) { width: 12%; } /* 出発 */
  .list-table th:nth-child(4), .list-table td:nth-child(4) { width: 12%; } /* 到着 */
  .list-table th:nth-child(5), .list-table td:nth-child(5) { width: 10%; text-align: right !important; } /* 金額 */

  /* 日付列を少し広めに（申請者列の有無に対応） */
  .list-table.has-user-col th:nth-child(2),
  .list-table.has-user-col td:nth-child(2),
  .list-table:not(.has-user-col) th:nth-child(1),
  .list-table:not(.has-user-col) td:nth-child(1) {
    width: 18% !important;  /* 必要なら 16〜20% に調整 */
  }

  /* 領収書／状態・操作／最終確認 はPDFでは非表示 */
  .list-table th:nth-last-child(3), .list-table td:nth-last-child(3),
  .list-table th:nth-last-child(2), .list-table td:nth-last-child(2),
  .list-table th:last-child,        .list-table td:last-child { display: none !important; }

  /* メモ欄（最後に残る列）を広く・折返し優先に */
  .list-table th, .list-table td { white-space: normal !important; }
  .list-table td.text-end { text-align: right !important; }
  .list-table th:last-of-type, .list-table td:last-of-type {
    width: auto; overflow-wrap: anywhere; word-break: break-word; line-break: strict; line-height: 1.35;
  }

  /* 合計などは分割しない */
  tfoot tr, tfoot td, tfoot th { page-break-inside: avoid; }
}
