/* AMSPEC v386 - FERTILIZER REPORT ONLY
   Pagination, official header/footer, quality matrix and manual highlighting. */

.fert-report-builder-v3 .fert-step-nav {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.fert-sheet-header {
  grid-template-columns: 1.55fr 5.4fr .9fr !important;
  align-items: center !important;
}
.fert-sheet-corporate-mark {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-width: 0;
  height: 100%;
  padding-top: 1mm;
}
.fert-sheet-corporate-mark img {
  display: block;
  width: 14mm;
  max-height: 14mm;
  object-fit: contain;
}

.fert-quantity-sheet .fert-total-row td,
.fert-quantity-sheet .fert-total-row td.fert-total-stowage {
  text-align: center !important;
  vertical-align: middle !important;
}

.fert-highlight-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(130px, .8fr) 110px 110px auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin: 10px 0;
  border: 1px solid #d9e0e7;
  border-radius: 10px;
  background: #f8fafc;
}
.fert-highlight-editor > div small { display:block; margin-top:3px; color:#607084; }
.fert-highlight-editor label { display:grid; gap:5px; font-size:.78rem; font-weight:700; }
.fert-highlight-editor input[type="color"] { min-height:38px; width:100%; padding:3px; }

.fert-detail-paragraph.is-fert-defect,
.fert-summary-sheet tr.is-fert-defect td,
.fert-final-analysis-table td.is-off-spec,
.fert-quality-editor-table td.is-off-spec {
  background: #fce8e8 !important;
  color: #8a2a2b !important;
}
.fert-detail-paragraph[style*="background"] {
  padding: 1.1mm 1.4mm;
  border-radius: 1.2mm;
}

.fert-quality-editor-shell { min-width: 0; }
.fert-quality-status {
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f1f4f7;
  color: #405268;
  font-size: .82rem;
}
.fert-quality-scroll { max-height: 58vh; border: 1px solid #d6dde5; border-radius: 8px; }
.fert-quality-empty { padding: 24px; text-align:center; color:#607084; }
.fert-quality-editor-table,
.fert-final-analysis-table { border-collapse: collapse; width:100%; table-layout: fixed; }
.fert-quality-editor-table { min-width: 920px; }
.fert-quality-editor-table th,
.fert-quality-editor-table td { border:1px solid #a9b2bc; padding:4px; vertical-align:middle; }
.fert-quality-editor-table th { background:#8a2a2b; color:#fff; font-size:.7rem; }
.fert-quality-editor-table th:first-child { width:160px; }
.fert-quality-editor-table th:nth-child(2) { width:75px; }
.fert-quality-editor-table th:nth-child(3),
.fert-quality-editor-table th:nth-child(4) { width:65px; }
.fert-quality-editor-table input { width:100%; min-width:65px; padding:5px; font-size:.75rem; }
.fert-quality-editor-table input[readonly] { background:#eef2f5; color:#324358; font-weight:700; }
.fert-quality-editor-table small { display:block; font-size:.58rem; opacity:.82; margin-top:2px; }
.fert-quality-editor-table button { border:0; background:transparent; color:inherit; font-weight:900; cursor:pointer; }

.fert-quality-report-block { break-inside: avoid; }
.fert-quality-subtitle {
  text-align:center;
  font-weight:700;
  font-size:6.7pt;
  margin:-1mm 0 1.4mm;
  color:#25364a;
}
.fert-final-analysis-table { font-size:5.8pt !important; }
.fert-final-analysis-table th,
.fert-final-analysis-table td {
  border: .25mm solid #1e2228 !important;
  padding: .65mm .45mm !important;
  text-align:center !important;
  vertical-align:middle !important;
  line-height:1.16 !important;
  overflow-wrap:anywhere;
}
.fert-final-analysis-table th { background:#e6e9ec !important; color:#111827 !important; font-weight:800; }
.fert-final-analysis-table thead tr:first-child th { background:#d8dde2 !important; }
.fert-final-analysis-table td:first-child { text-align:left !important; font-weight:700; }

.fert-photo-color-tools {
  position:absolute;
  z-index:4;
  top:5px;
  left:5px;
  display:flex;
  align-items:center;
  gap:5px;
  padding:4px 6px;
  border-radius:6px;
  background:rgba(255,255,255,.94);
  box-shadow:0 2px 8px rgba(16,24,40,.18);
  font-size:.62rem;
}
.fert-photo-color-tools label { display:flex; align-items:center; gap:3px; }
.fert-photo-color-tools input { width:22px; height:20px; padding:0; border:0; }
.fert-photo-color-tools button { border:0; background:#eef2f5; border-radius:4px; cursor:pointer; font-size:.62rem; }
.fert-photo-card { position:relative; }
.fert-photo-card figcaption[style*="background"] { padding:1.1mm !important; }

/* Pagination v386: the JS packer is authoritative. It measures the real page body,
   includes section bands, and semantically splits only blocks that cannot fit alone. */
.fert-report-page.fert-report-packed-page,
.fert-report-measure .fert-report-page {
  overflow: hidden !important;
}
.fert-report-page .fert-page-body {
  min-height: 0 !important;
  overflow: hidden !important;
}
.fert-report-page .fert-block,
.fert-report-page table,
.fert-report-page tr,
.fert-report-page .fert-detail-paragraph {
  break-inside: avoid;
  page-break-inside: avoid;
}
.fert-report-measure {
  position: fixed !important;
  left: -200vw !important;
  top: 0 !important;
  width: 210mm !important;
  visibility: hidden !important;
  pointer-events: none !important;
  z-index: -9999 !important;
}
.fert-terms-text small {
  display:block;
  line-height:1.18 !important;
  font-size:4.55pt !important;
  text-align:justify;
}

@media (max-width: 1050px) {
  .fert-report-builder-v3 .fert-step-nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .fert-highlight-editor { grid-template-columns: 1fr 1fr; }
  .fert-highlight-editor > div { grid-column:1/-1; }
}

@media print {
  .fert-photo-color-tools,
  .fert-highlight-editor,
  .fert-quality-editor-shell .inline-actions { display:none !important; }
  .fert-sheet-corporate-mark img { print-color-adjust:exact; -webkit-print-color-adjust:exact; }
  .fert-detail-paragraph.is-fert-defect,
  .fert-summary-sheet tr.is-fert-defect td,
  .fert-final-analysis-table td.is-off-spec {
    print-color-adjust:exact !important;
    -webkit-print-color-adjust:exact !important;
  }
}
