@page {
  size: A4;
  margin: 10mm;
}

.a4-preview {
  width: 210mm;
  height: 297mm;
  margin: 0 auto;
  border: 1px solid #ccc;
  padding: 10mm;
  box-sizing: border-box;
  background: white;
}

.print-grid {
  display: grid;
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fit, minmax(var(--plate-width, 100mm), 1fr));
  gap: 8mm;
  justify-content: flex-start;
  align-content: flex-start;
  justify-items: start;
}

.plate {
  break-inside: avoid;
  page-break-inside: avoid;
  display: block;
}

@media print {
  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-grid {
    gap: 8mm;
    justify-content: flex-start;
    align-content: flex-start;
  }
  .plate {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  header,
  .no-print {
    display: none !important;
  }
  .a4-preview {
    width: auto;
    height: auto;
    border: none;
    padding: 0;
    margin: 0;
  }
}
