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

.a4-preview {
  width: 100%;
  max-width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  border: 1px solid #ccc;
  padding: 5mm;
  box-sizing: border-box;
  background: white;
  overflow-x: auto;
}

@media (min-width: 800px) {
  .a4-preview {
    width: 210mm;
    padding: 10mm;
  }
}

.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 {
  html, body, #root {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  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;
    min-height: 0;
    border: none;
    padding: 0;
    margin: 0;
  }
  .container {
    padding: 0 !important;
    margin: 0 !important;
  }
}
