/* Print-to-PDF Styles */
@media print {
  :root {
    /* Paper is denser than a phone in a glove: put the small steps back
       to their pre-Night-Shift print sizes so PDFs keep their layout. */
    --fs-sm: 0.78rem;
    --bg-dark: #ffffff;
    --input-border: #6b7280;
    --on-accent: #ffffff;
    --on-primary: #ffffff;
    --card-dark: #f3f4f6;
    --bg-card: #f3f4f6;
    --primary: #0369a1;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --text-main: #111827;
    --text-muted: #4b5563;
    --border: #d1d5db;
    --input-bg: #ffffff;
    --ir-accent: #0f766e;
    --load-accent: #6d28d9;
  }
  body {
    background: #fff;
    color: #000;
  }
  .report-powered {
    display: none !important;
  }
  /* Print letterhead logo (2.4.37): the 160x40px slot from the
     Batch G cap becomes a FILLED slot - fixed size, cover-cropped,
     no white letterboxing on the printed page. The body prefix
     gives this rule the specificity to win over the generic
     print-photo logo rule in styles-polish.css (which caps the
     logo at 160x40 but keeps object-fit:contain). */
  body .report-letterhead-logo {
    width: 160px !important;
    height: 40px !important;
    max-width: 160px !important;
    max-height: 40px !important;
    object-fit: cover !important;
  }
  /* App chrome. A pending-approvals banner, the view-only badge and
     update/plan notices sit above the report and were printing on
     page 1 of customer PDFs. */
  #pendingChangesBadge,
  #supervisorBadge,
  #reauthBanner,
  #planBanner,
  #appUpdateBanner,
  #syncStatus,
  .status-badge {
    display: none !important;
  }
  /* A browser print of the open daily activity report must not include
     the blank New form: date, project, vessel, day type, or the Work
     Day / Standby / Waiting On Weather toggles. TODAY SO FAR stays. */
  #formView > .btn-back,
  #formView > .tab-row,
  #formView > #formHeading,
  #logFormTabNew > .grid-2,
  #logFormTabNew > .form-group,
  #logFormTabNew > .btn,
  #logFormTabNew > #darAddBlockPanel {
    display: none !important;
  }
  [id$='PrintFooter'] {
    break-before: avoid;
    page-break-before: avoid;
  }
  [id$='PrintFooter'] {
    margin-top: 10px !important;
  }
  .btn,
  .action-tray,
  .btn-folder-toggle,
  #syncBtn,
  .app-logo,
  .header,
  .search-box,
  .log-list,
  .form-panel {
    display: none !important;
  }
  /* The screen the person is actually on prints. Forcing #viewPanel
     used to put a blank Generator Service Report over the monthly
     report, the handover and every other open page. */
  .form-panel.active {
    display: block !important;
  }
  #viewPanel {
    border: none;
  }
  #viewPanel:not(.active) {
    display: none !important;
  }
  .view-data-point {
    border: 1px solid #ccc;
    color: #000;
  }
  .section-title {
    color: #000;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
  }
  .status-pill {
    border: 1px solid currentColor;
  }
  #printLetterhead,
  #printFooter {
    display: none !important;
  }
  #viewPanel.active #printLetterhead,
  #viewPanel.active #printFooter {
    display: block !important;
  }
  body.printing-stock #dashboardView,
  body.printing-stock #formView,
  body.printing-stock #viewPanel,
  body.printing-stock #stockCheckView,
  body.printing-stock body.printing-stock #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-stock #printStockList {
    display: block !important;
  }
  body.printing-equipment #dashboardView,
  body.printing-equipment #formView,
  body.printing-equipment #viewPanel,
  body.printing-equipment #stockCheckView,
  body.printing-equipment body.printing-equipment #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-equipment #printEquipmentList {
    display: block !important;
  }
  body.printing-service-summary #dashboardView,
  body.printing-service-summary #formView,
  body.printing-service-summary #viewPanel,
  body.printing-service-summary #stockCheckView,
  body.printing-service-summary #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-service-summary,
  body.printing-service-summary #appInterface {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.printing-service-summary #printServiceSummary {
    display: block !important;
  }
  /* Portrait fallback for iOS - see isLandscapePrintUnreliable() in app.js.
     Same table, same columns, just scaled down enough to hold together on
     genuine portrait paper instead of the landscape width it's normally
     built for. Shrinking the font alone isn't enough: buildServiceSummaryHtml()
     sets white-space:nowrap inline on several columns (Asset ID, Hrs, Last
     Svc, Next Due, Remaining, Status) and every header, because that's
     correct for the landscape layout it's normally printed in. Squeezed
     into a portrait-width column, nowrap text doesn't get clipped - table
     cells overflow visibly by default - so it just spills across into
     whichever column comes next ("DUE SOON" printing on top of the
     location next to it). Forcing normal/break-word here, with !important
     so it wins over those inline styles, makes it wrap onto a second line
     inside its own column instead. */
  body.printing-service-summary-compact #printServiceSummary table {
    font-size: 0.62rem !important;
  }
  body.printing-service-summary-compact #printServiceSummary th,
  body.printing-service-summary-compact #printServiceSummary td {
    padding: 4px 3px !important;
    font-size: 0.6rem !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    letter-spacing: 0 !important;
  }
  body.printing-stockcheck #dashboardView,
  body.printing-stockcheck #formView,
  body.printing-stockcheck #viewPanel,
  body.printing-stockcheck #stockCheckView,
  body.printing-stockcheck body.printing-stockcheck #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-stockcheck #printStockCheckReport {
    display: block !important;
  }
  body.printing-ppe #dashboardView,
  body.printing-ppe #formView,
  body.printing-ppe #viewPanel,
  body.printing-ppe #stockCheckView,
  body.printing-ppe #gatekeeperOverlay,
  body.printing-ppe .app-modal-overlay {
    display: none !important;
  }
  body.printing-ppe #printPpeSheet {
    display: block !important;
  }
  body.printing-commissioning-report #dashboardView,
  body.printing-commissioning-report #formView,
  body.printing-commissioning-report #viewPanel,
  body.printing-commissioning-report #stockCheckView,
  body.printing-commissioning-report #commissioningView,
  body.printing-commissioning-report #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-commissioning-report #commissioningViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-commissioning-report #commissioningPrintLetterhead,
  body.printing-commissioning-report #commissioningPrintFooter {
    display: block !important;
  }
  body.printing-fault-report #dashboardView,
  body.printing-fault-report #formView,
  body.printing-fault-report #viewPanel,
  body.printing-fault-report #stockCheckView,
  body.printing-fault-report #commissioningView,
  body.printing-fault-report #commissioningViewPanel,
  body.printing-fault-report #faultReportView,
  body.printing-fault-report #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-fault-report #faultReportViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-fault-report #faultReportPrintLetterhead,
  body.printing-fault-report #faultReportPrintFooter {
    display: block !important;
  }
  body.printing-fault-report #frViewHeaderPlant,
  body.printing-fault-report #frViewHeaderDate {
    display: none !important;
  }
  body.printing-fault-report .report-letterhead {
    border-color: #cbd5e1;
    break-inside: avoid;
  }
  body.printing-fault-report .report-photo img {
    height: auto;
    max-height: 220px;
    object-fit: contain;
  }
  body.printing-fault-report .report-photo-grid,
  body.printing-fault-report .report-severity,
  body.printing-fault-report .report-summary {
    break-inside: avoid;
  }
  body.printing-service-report #dashboardView,
  body.printing-service-report #formView,
  body.printing-service-report #viewPanel,
  body.printing-service-report #stockCheckView,
  body.printing-service-report #commissioningView,
  body.printing-service-report #commissioningViewPanel,
  body.printing-service-report #faultReportView,
  body.printing-service-report #faultReportViewPanel,
  body.printing-service-report #serviceReportView,
  body.printing-service-report #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-service-report #serviceReportViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-service-report #serviceReportPrintLetterhead,
  body.printing-service-report #serviceReportPrintFooter {
    display: block !important;
  }
  body.printing-job-report #dashboardView,
  body.printing-job-report #formView,
  body.printing-job-report #viewPanel,
  body.printing-job-report #stockCheckView,
  body.printing-job-report #commissioningView,
  body.printing-job-report #commissioningViewPanel,
  body.printing-job-report #faultReportView,
  body.printing-job-report #faultReportViewPanel,
  body.printing-job-report #serviceReportView,
  body.printing-job-report #serviceReportViewPanel,
  body.printing-job-report #jobReportView,
  body.printing-job-report #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-job-report #jobReportViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-job-report #jobReportPrintLetterhead,
  body.printing-job-report #jobReportPrintFooter {
    display: block !important;
  }
  body.printing-electrical-test #dashboardView,
  body.printing-electrical-test #formView,
  body.printing-electrical-test #viewPanel,
  body.printing-electrical-test #stockCheckView,
  body.printing-electrical-test #commissioningView,
  body.printing-electrical-test #commissioningViewPanel,
  body.printing-electrical-test #faultReportView,
  body.printing-electrical-test #faultReportViewPanel,
  body.printing-electrical-test #serviceReportView,
  body.printing-electrical-test #serviceReportViewPanel,
  body.printing-electrical-test #electricalTestView,
  body.printing-electrical-test #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-electrical-test #electricalTestViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-electrical-test #electricalTestPrintLetterhead,
  body.printing-electrical-test #electricalTestPrintFooter {
    display: block !important;
  }
  body.printing-load-test #dashboardView,
  body.printing-load-test #formView,
  body.printing-load-test #viewPanel,
  body.printing-load-test #stockCheckView,
  body.printing-load-test #commissioningView,
  body.printing-load-test #commissioningViewPanel,
  body.printing-load-test #faultReportView,
  body.printing-load-test #faultReportViewPanel,
  body.printing-load-test #serviceReportView,
  body.printing-load-test #serviceReportViewPanel,
  body.printing-load-test #electricalTestView,
  body.printing-load-test #electricalTestViewPanel,
  body.printing-load-test #loadTestView,
  body.printing-load-test #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-load-test #loadTestViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-load-test #loadTestPrintLetterhead,
  body.printing-load-test #loadTestPrintFooter {
    display: block !important;
  }
  /* The step table carries ~22 columns of readings. Left at the app's
     on-screen size it runs off the right edge of A4 and the tail columns
     (ambient, fuel, battery) simply never print. Full-bleed plus a small
     fixed size keeps the whole row on the page; printLoadTest() injects
     the landscape @page rule for this print only, same approach as the
     DAR sheet above. */
  body.printing-load-test,
  body.printing-load-test #appInterface {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.printing-load-test #ltvSteps table {
    font-size: 7.5px !important;
    table-layout: fixed;
    width: 100%;
  }
  body.printing-load-test #ltvSteps th,
  body.printing-load-test #ltvSteps td {
    padding: 2px 3px !important;
    border: 1px solid #999;
    white-space: normal !important;
    overflow-wrap: break-word;
  }
  body.printing-load-test #ltvSteps th {
    background: #e5e7eb;
    font-weight: 700;
  }
  /* Portrait fallback for iOS - see isLandscapePrintUnreliable() in
     app.js. Still the landscape layout in miniature, just small enough
     to stay legible on a portrait sheet rather than overlapping. */
  body.printing-load-test-compact #ltvSteps table {
    font-size: 6px !important;
  }
  body.printing-load-test-compact #ltvSteps th,
  body.printing-load-test-compact #ltvSteps td {
    padding: 1px 2px !important;
    font-size: 6px !important;
  }
  body.printing-general-inspection #dashboardView,
  body.printing-general-inspection #formView,
  body.printing-general-inspection #viewPanel,
  body.printing-general-inspection #stockCheckView,
  body.printing-general-inspection #commissioningView,
  body.printing-general-inspection #commissioningViewPanel,
  body.printing-general-inspection #faultReportView,
  body.printing-general-inspection #faultReportViewPanel,
  body.printing-general-inspection #serviceReportView,
  body.printing-general-inspection #serviceReportViewPanel,
  body.printing-general-inspection #electricalTestView,
  body.printing-general-inspection #electricalTestViewPanel,
  body.printing-general-inspection #loadTestView,
  body.printing-general-inspection #loadTestViewPanel,
  body.printing-general-inspection #generalInspectionView,
  body.printing-general-inspection #pdiView,
  body.printing-general-inspection #pdiViewPanel,
  body.printing-general-inspection #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-general-inspection #generalInspectionViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-general-inspection #generalInspectionPrintLetterhead,
  body.printing-general-inspection #generalInspectionPrintFooter {
    display: block !important;
  }
  body.printing-pdi #dashboardView,
  body.printing-pdi #formView,
  body.printing-pdi #viewPanel,
  body.printing-pdi #stockCheckView,
  body.printing-pdi #commissioningView,
  body.printing-pdi #commissioningViewPanel,
  body.printing-pdi #faultReportView,
  body.printing-pdi #faultReportViewPanel,
  body.printing-pdi #serviceReportView,
  body.printing-pdi #serviceReportViewPanel,
  body.printing-pdi #electricalTestView,
  body.printing-pdi #electricalTestViewPanel,
  body.printing-pdi #loadTestView,
  body.printing-pdi #loadTestViewPanel,
  body.printing-pdi #generalInspectionView,
  body.printing-pdi #generalInspectionViewPanel,
  body.printing-pdi #pdiView,
  body.printing-pdi #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-pdi #pdiViewPanel {
    display: block !important;
    border: none;
  }
  body.printing-pdi #pdiPrintLetterhead,
  body.printing-pdi #pdiPrintFooter {
    display: block !important;
  }
  body.printing-daily-activity-report #dashboardView,
  body.printing-daily-activity-report #formView,
  body.printing-daily-activity-report #viewPanel,
  body.printing-daily-activity-report #stockCheckView,
  body.printing-daily-activity-report #commissioningView,
  body.printing-daily-activity-report #commissioningViewPanel,
  body.printing-daily-activity-report #faultReportView,
  body.printing-daily-activity-report #faultReportViewPanel,
  body.printing-daily-activity-report #serviceReportView,
  body.printing-daily-activity-report #serviceReportViewPanel,
  body.printing-daily-activity-report #electricalTestView,
  body.printing-daily-activity-report #electricalTestViewPanel,
  body.printing-daily-activity-report #gatekeeperOverlay {
    display: none !important;
  }
  body.printing-daily-activity-report #darCompletedDayPanel {
    display: block !important;
    border: none;
    /* Full-bleed for the sheet: without stripping the app's card
       chrome the log gets squeezed into a phone-width panel in the
       middle of the page. */
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
    box-shadow: none;
    border-radius: 0;
  }
  body.printing-daily-activity-report,
  body.printing-daily-activity-report #appInterface {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.printing-daily-activity-report #darCompletedDayPanel > *:not(#darPrintArea) {
    display: none !important;
  }
  body.printing-daily-activity-report #darPrintArea {
    display: block !important;
  }
  /* The DAR print sheet as a log of the day (2.4.108), mirroring
     the filed PDF and the emailed DAR: a summary strip — big figure
     over a small caps label, hairlines between cells, a navy rule
     under — then one row per block, times and duration leading on
     the left, the entry to the right, a hairline under each row.
     Single column, portrait A4: the @page portrait rule itself is
     injected by printCompletedDay() for this print only - named
     @page rules proved unreliable across browsers. */
  .dar-print-strip {
    display: flex;
    border-top: 1px solid #cbd5e1;
    border-bottom: 1.5px solid #0f172a;
    margin-bottom: 6px;
  }
  /* The split-by-assignment strip (cross-project day) sits under
     the kind strip without the heavy bottom rule - the log rows
     close the summary block. */
  .dar-print-strip-assign {
    border-bottom: 0.5px solid #cbd5e1;
  }
  .dar-print-strip-label {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #475569;
    text-transform: uppercase;
    margin: 2px 0 4px;
  }
  .dar-print-cell {
    flex: 1 1 0;
    padding: 8px 10px 8px 8px;
    border-left: 0.5px solid #cbd5e1;
    min-width: 0;
  }
  .dar-print-cell:first-child {
    border-left: none;
    padding-left: 0;
  }
  .dar-print-big {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.25;
  }
  .dar-print-cap {
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    color: #475569;
    margin-top: 3px;
  }
  .dar-print-row {
    display: flex;
    border-bottom: 0.5px solid #cbd5e1;
    padding: 9px 0;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .dar-print-times {
    flex: 0 0 118px;
    padding-right: 12px;
  }
  .dar-print-time {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
  }
  .dar-print-duration {
    font-size: 11.5px;
    font-weight: 700;
    color: #0284c7;
    margin-top: 1px;
  }
  .dar-print-entry {
    flex: 1 1 auto;
    min-width: 0;
  }
  .dar-print-heading {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
  }
  .dar-print-substance {
    font-size: 12.5px;
    color: #0f172a;
    line-height: 1.45;
    margin-top: 2px;
  }
  .dar-print-with {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-top: 2px;
  }
  .dar-print-ref {
    font-size: 12px;
    font-weight: 600;
    color: #0284c7;
    margin-top: 4px;
  }
  .dar-print-ref-fault {
    color: #b91c1c;
  }
  .dar-print-empty {
    font-size: 12.5px;
    color: #475569;
    font-style: italic;
  }
  #printStockList table,
  #printEquipmentList table,
  #printStockCheckReport table,
  #printPpeSheet table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-xs);
  }
  #printStockList th,
  #printEquipmentList th,
  #printStockCheckReport th,
  #printPpeSheet th {
    text-align: left;
    padding: 6px 4px;
    border-bottom: 2px solid #000;
  }
  #printStockList td,
  #printEquipmentList td,
  #printStockCheckReport td,
  #printPpeSheet td {
    padding: 6px 4px;
    border-bottom: 1px solid #ccc;
  }
  #frRepeatWrap {
    display: none !important;
  }
  @page {
    margin: 14mm;
  }
}
