
.reports-page {
  min-height: 0;
}

.reports-toolbar {
  grid-template-columns:
    minmax(260px, 1.35fr)
    120px
    170px
    170px
    minmax(180px, .9fr)
    150px
    auto;
  align-items: end;
}

.date-filter label {
  display: block;
  margin: 0 0 6px 3px;
  color: #4d6682;
  font-size: .72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.date-filter > div {
  position: relative;
}

.date-filter .control {
  padding-right: 39px;
}

.clear-date {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 34px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: #edf5fd;
  color: #0965bd;
  font-size: 1.2rem;
  cursor: pointer;
}

.pending-filter {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid #d2e2f2;
  border-radius: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #193f69;
  font-size: .82rem;
  font-weight: 800;
}

.reports-table {
  min-width: 1320px;
}

.col-register { width: 7%; }
.col-farm { width: 22%; }
.col-origin { width: 10%; }
.col-date { width: 9%; }
.col-type { width: 14%; }
.col-quantity { width: 8%; }
.col-sent { width: 6%; }
.col-open { width: 5%; }

.report-farm {
  min-width: 0;
}

.report-farm strong,
.report-farm small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-farm strong {
  color: #0a315f;
}

.report-farm small {
  margin-top: 4px;
  color: #70859e;
}

.send-status-button,
.open-report-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.25rem;
}

.send-status-button.sent {
  background: #e6f8ea;
  color: #3c9e32;
}

.send-status-button.pending {
  background: #fff0ef;
  color: #d33d35;
}

.open-report-button {
  background: #e9f4ff;
  color: #0d6dc9;
  font-size: 1.45rem;
}

.send-status-button:hover,
.open-report-button:hover {
  box-shadow: 0 0 0 3px rgba(15, 109, 201, .11);
}

.send-modal-card {
  width: min(520px, calc(100vw - 30px));
}

.report-preview-backdrop {
  z-index: 500;
  padding: 8px;
}

.report-preview-shell {
  width: calc(100vw - 16px);
  height: calc(100vh - 16px);
  overflow: hidden;
  border-radius: 18px;
  background: #eef4fa;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  box-shadow: 0 24px 70px rgba(7, 43, 80, .3);
}

.report-preview-toolbar {
  min-height: 76px;
  padding: 13px 18px;
  background: #fff;
  border-bottom: 1px solid #d7e4f1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.report-preview-toolbar h2 {
  margin: 0;
  color: #092f61;
  font-size: 1.05rem;
}

.report-preview-toolbar p {
  margin: 5px 0 0;
  color: #71849c;
  font-size: .8rem;
}

.report-preview-actions {
  display: flex;
  gap: 9px;
}

.report-preview-scroll {
  overflow: auto;
  padding: 22px;
}

#printArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.a4-report-page {
  width: 210mm;
  min-height: 297mm;
  padding: 12mm 12mm 11mm;
  box-sizing: border-box;
  background: #fff;
  color: #142d49;
  box-shadow: 0 8px 30px rgba(28, 66, 102, .2);
  position: relative;
  font-family: Arial, Helvetica, sans-serif;
}

.report-page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding-bottom: 8mm;
}

.report-client-data {
  font-size: 10pt;
  line-height: 1.75;
}

.report-client-data strong {
  font-weight: 800;
}

.report-logo-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.report-logo {
  width: 115px;
  max-height: 48px;
  object-fit: contain;
}

.report-header-actions {
  display: none;
}

.report-lab-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 8.5pt;
}

.report-lab-table th,
.report-lab-table td {
  border: 1px solid #243649;
  padding: 3px 5px;
  text-align: center;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.report-lab-table th {
  background: #9dccec;
  color: #122f4e;
  font-weight: 850;
  text-transform: uppercase;
}

.report-lab-table th:nth-child(1) { width: 19%; }
.report-lab-table th:nth-child(2) { width: 12%; }
.report-lab-table th:nth-child(3) { width: 31%; }
.report-lab-table th:nth-child(4) { width: 28%; }
.report-lab-table th:nth-child(5) { width: 10%; }

.report-pathogen.italic {
  font-style: italic;
}

.report-ufc-note {
  margin: 7mm 0 4mm;
  font-size: 9pt;
  font-weight: 800;
}

.report-chart-wrap {
  margin-top: 4mm;
  padding: 6mm 5mm;
  border: 1px solid #8abfe8;
  background: linear-gradient(#fff, #e9fbff);
}

.report-chart-title {
  margin: 0 0 5mm;
  color: #52738f;
  text-align: center;
  font-size: 9pt;
  font-weight: 500;
}

.report-chart {
  width: 100%;
}

.chart-row {
  display: grid;
  grid-template-columns: 42mm minmax(0, 1fr) 18mm;
  align-items: center;
  gap: 3mm;
  margin: 3.5mm 0;
  font-size: 7.5pt;
}

.chart-label {
  text-align: right;
  overflow-wrap: anywhere;
}

.chart-track {
  height: 8mm;
  border-left: 1px solid #9fb5c9;
  background-image: linear-gradient(to right, rgba(121, 153, 180, .35) 1px, transparent 1px);
  background-size: 20% 100%;
}

.chart-bar {
  min-width: 2px;
  height: 100%;
  background: #69b1e5;
}

.chart-percent {
  color: #64788b;
}

.report-page-number {
  position: absolute;
  right: 12mm;
  bottom: 6mm;
  color: #77899b;
  font-size: 8pt;
}

.report-no-data {
  padding: 25mm 0;
  text-align: center;
  color: #6c8198;
}

@media (max-width: 1250px) {
  .reports-toolbar {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }

  .reports-toolbar .search-box {
    grid-column: 1 / -1;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body > * {
    display: none !important;
  }

  #reportModal {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: transparent !important;
  }

  #reportModal .report-preview-shell {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  #reportModal .report-preview-toolbar {
    display: none !important;
  }

  #reportModal .report-preview-scroll {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  #printArea {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .a4-report-page {
    display: block !important;
    position: relative !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 12mm 12mm 11mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #fff !important;
    box-shadow: none !important;
    break-after: page !important;
    page-break-after: always !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .a4-report-page:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  .report-measure-page {
    display: none !important;
  }
}


.report-event,
.report-pathogen {
  text-align: center;
  line-height: 1.25;
}

.report-event i,
.report-pathogen i {
  font-style: italic;
}

.report-chart-wrap {
  break-inside: avoid;
  page-break-inside: avoid;
}

.report-lab-table {
  break-inside: auto;
}

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


/* Página temporária usada apenas para medir se tabela e gráfico cabem juntos */
.report-measure-page {
  position: fixed !important;
  left: -10000px !important;
  top: 0 !important;
  width: 210mm !important;
  height: 297mm !important;
  min-height: 297mm !important;
  max-height: 297mm !important;
  overflow: hidden !important;
  visibility: hidden !important;
  pointer-events: none !important;
  box-shadow: none !important;
}


/* Fundo degradê da folha A4 */
.a4-report-page {
  background:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #ffffff 58%,
      #f4ffff 76%,
      #ddfbfb 90%,
      #c8f5f3 100%
    ) !important;

  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

/* Mantém o degradê também na impressão e no PDF */
@media print {
  .a4-report-page {
    background:
      linear-gradient(
        180deg,
        #ffffff 0%,
        #ffffff 58%,
        #f4ffff 76%,
        #ddfbfb 90%,
        #c8f5f3 100%
      ) !important;

    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}


/* =========================================================
   GRÁFICO DE PATÓGENOS — CORREÇÃO FINAL
   ========================================================= */

.report-chart-wrap {
  margin-top: 4mm;
  padding: 6mm 5mm;

  border: 1.5px solid #8abfe8 !important;
  border-radius: 0 !important;

  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #f6ffff 52%,
    #e1fbfb 100%
  );

  break-inside: avoid;
  page-break-inside: avoid;
}

.report-chart-title {
  margin: 0 0 5mm;

  color: #202020;
  text-align: center;
  font-size: 17pt;
  font-weight: 500;
}

.report-chart {
  width: 100%;
}

.chart-row {
  display: grid;
  grid-template-columns: 55mm minmax(0, 1fr);
  align-items: center;
  gap: 3mm;

  min-height: 9mm;
  margin: 1.5mm 0;

  font-size: 8.5pt;
}

.chart-label {
  min-width: 0;

  overflow-wrap: anywhere;

  color: #898989;
  text-align: right;
  line-height: 1.25;
}

.chart-track {
  position: relative;

  width: 100%;
  height: 8mm;

  overflow: visible;

  border-left: 1px solid #8d8d8d;

  background-image:
    linear-gradient(
      to right,
      rgba(105,105,105,.55) 1px,
      transparent 1px
    );

  background-size: 20% 100%;
}

.chart-bar {
  position: absolute;
  top: 1.2mm;
  left: .7mm;

  height: 5.6mm;
  min-width: 1px;

  border: 0 !important;
  border-radius: 0 !important;

  background: #63a9e3 !important;
  box-shadow: none !important;
}

.chart-percent {
  position: absolute;
  top: 50%;

  color: #898989;
  font-size: 8.5pt;
  line-height: 1;
  white-space: nowrap;

  transform: translateY(-50%);
}

/* Preserva o padrão também na impressão. */
@media print {
  .report-chart-wrap {
    border: 1.5px solid #8abfe8 !important;
    border-radius: 0 !important;

    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .chart-bar {
    border-radius: 0 !important;
    background: #63a9e3 !important;

    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .chart-track {
    background-image:
      linear-gradient(
        to right,
        rgba(105,105,105,.55) 1px,
        transparent 1px
      ) !important;

    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}



/* =========================================================
   CORREÇÃO DA IMPRESSÃO
   Imprime exclusivamente as folhas dentro de #printArea.
   ========================================================= */

@media print {
  body > :not(#reportModal) {
    display: none !important;
  }

  #reportModal,
  #reportModal .report-preview-shell,
  #reportModal .report-preview-scroll {
    display: contents !important;

    position: static !important;
    inset: auto !important;

    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: visible !important;

    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;

    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    opacity: 1 !important;
    transform: none !important;
  }

  #reportModal .report-preview-toolbar {
    display: none !important;
  }

  #printArea {
    display: block !important;
    position: static !important;

    width: 210mm !important;
    height: auto !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: visible !important;

    background: transparent !important;
  }

  .report-preview-backdrop {
    background: transparent !important;

    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
