.sheet-print-root { display: none; }
/* A sheet laid out at the printed width, out of sight, to place the page breaks (paginateQuick, 15.645) */
.sheet-measure { position: absolute; left: -10000px; top: 0; width: 182mm; visibility: hidden; pointer-events: none; }
/* The sheet takes the printed width exactly (15.660: at its screen width of 210 mm the blocks measured lower than on
   paper and the breaks fell late) */
.sheet-measure .sheet { width: auto; max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.sheet-measure .sheet-cover { aspect-ratio: auto; height: 269mm; margin: 0; }

@media print {
  @page { size: A4; margin: 14mm; }

  html, body {
    height: auto !important;
    overflow: visible !important;
    background: var(--sheet-bg) !important;
  }

  body.sheet-printing > *:not(.sheet-print-root) { display: none !important; }
  body.sheet-printing .sheet-print-root { display: block !important; }

  .sheet-print-root .sheet {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  /* The multi-order proposal prints at the page's width, as its breaks were measured (15.660): at its screen width of
     210 mm the browser shrank it into the 182 mm of the page and the breaks no longer matched */
  .sheet-print-root .sheet.sheet-quick { width: auto; }
  .sheet-print-root .sheet-print-page:has(> tbody > tr > td > .sheet-quick) { table-layout: fixed; }
  /* Its cover keeps the screen's layout, fitted into the page's width: a masthead fitted to the cover stays whole */
  .sheet-print-root .sheet.sheet-quick > .sheet-cover { width: 210mm; height: 297mm; zoom: .8667; }
  /* 15.697: the cover takes a page of its own without margins — the whole sheet, at its screen layout */
  @page cover { margin: 0; }
  .sheet-print-root > .sheet.sheet-print-cover { page: cover; width: 210mm; }
  .sheet-print-root > .sheet.sheet-quick.sheet-print-cover > .sheet-cover { height: 296.9mm; margin: 0; zoom: 1;
                                                                             border-radius: 0; overflow: hidden; }
  /* A long page has no margins (sheetprint.js): the sheet keeps the 14 mm of a page itself, the cover runs out to the
     page's edges (its height counted so, longQuick) */
  .sheet-print-root.sheet-print-long .sheet.sheet-quick { padding: 14mm; }
  .sheet-print-root.sheet-print-long .sheet.sheet-quick > .sheet-cover:first-child { margin: -14mm -14mm 14mm; zoom: 1;
                                                                                     border-radius: 0; }

  .sheet-block { break-inside: avoid; page-break-inside: avoid; }
  /* A totals block taller than a page goes on over pages, but its rows are never cut: a product's sums and its
     variants' names stay on one page (15.714: «обрезаются итоги почему-то») */
  .qv-summary :is(tr, li, .mx > *, .sum, .pickbox, [class$="-row"], [class$="-item"], [class$="-card"], [class*="-prod"],
                  [class$="-tile"], [class$="-v"], [class$="-opt"], [class$="-chip"]) {
    break-inside: avoid; page-break-inside: avoid;
  }

  .sheet-print-root .sheet-print-page { width: 100%; border-collapse: collapse; }
  .sheet-print-root .sheet-print-page > tfoot { display: table-footer-group; }
  .sheet-print-root .sheet-print-page > tbody > tr > td,
  .sheet-print-root .sheet-print-page > tfoot > tr > td { padding: 0; border: 0; }
  .sheet-print-root .sheet-signature {
    position: static;
    margin: 0;
    padding-top: var(--sheet-4);
    background: var(--sheet-bg);
  }
  .sheet-spec, .sheet-compare { break-inside: auto; page-break-inside: auto; }
  .sheet-variant-h { break-after: avoid; page-break-after: avoid; }
  .sheet-multi-full .sheet-block.sheet-order-product,
  .sheet-multi-form .sheet-block.sheet-order-product {
    break-before: page; page-break-before: always; margin-top: 0;
    break-inside: auto; page-break-inside: auto;
  }
  .sheet-order-title { break-after: avoid; page-break-after: avoid; }
  .sheet-table tr { break-inside: avoid; page-break-inside: avoid; }
  .sheet-table thead { display: table-header-group; }

  @page numbered {
    @bottom-right {
      content: "Страница " counter(page) " из " counter(pages);
      font: 400 8pt/1.2 Inter, system-ui, sans-serif;
      color: #6B675E;
    }
  }
  .sheet-print-root.sheet-print-numbered .sheet-print-page { page: numbered; }
  /* One long page (15.646): nothing breaks it */
  .sheet-print-root.sheet-print-long, .sheet-print-root.sheet-print-long * {
    break-before: auto !important; break-after: auto !important; break-inside: auto !important;
    page-break-before: auto !important; page-break-after: auto !important; page-break-inside: auto !important;
  }
}

