/**
 * EC Desk pad print — one A4 page only. Header + footer fixed; central writing
 * area capped. Sheet height accounts for accent strip (pad must not be 100%).
 */
@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  /* —— A4 letterhead-theme pads —— */
  html.pad-a4-full {
    height: 283mm !important;
    overflow: hidden !important;
  }
  html.pad-a4-full body {
    height: 283mm !important;
    max-height: 283mm !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  html.pad-a4-full .sheet {
    width: 210mm !important;
    height: 283mm !important;
    min-height: 283mm !important;
    max-height: 283mm !important;
    margin: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    page-break-after: avoid !important;
    break-after: avoid-page !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }
  html.pad-a4-full .accent-edge,
  html.pad-a4-full .accent-edge-thin {
    flex-shrink: 0 !important;
  }
  html.pad-a4-full .pad {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding-top: 3mm !important;
    padding-bottom: 2mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  /* Shrink central white / writing zone only */
  html.pad-a4-full .body-area,
  html.pad-a4-full .body-spacer {
    min-height: 0 !important;
    flex: 0 1 auto !important;
  }
  html.pad-a4-full .sheet[data-layout="top"] .body-area {
    max-height: 136mm !important;
  }
  html.pad-a4-full .sheet[data-layout="left"] .body-area {
    max-height: 126mm !important;
  }
  html.pad-a4-blank .body-area {
    max-height: 140mm !important;
  }
  html.pad-a4-full .body-spacer {
    max-height: 4mm !important;
    flex: 0 0 4mm !important;
  }
  html.pad-a4-full .foot {
    flex-shrink: 0 !important;
    margin-top: auto !important;
  }
  html.pad-a4-full .contacts {
    padding-top: 1.8mm !important;
    padding-bottom: 1.2mm !important;
  }
  html.pad-a4-full .slogan-bar {
    padding-top: 1.4mm !important;
    padding-bottom: 1.4mm !important;
    margin-left: -12mm !important;
    margin-right: -12mm !important;
  }
  html.pad-a4-blank .slogan-bar {
    margin-left: -14mm !important;
    margin-right: -14mm !important;
  }

  /* —— MOM register pads (multi-page; never clip html/body) —— */
  html.pad-mom {
    --mom-print-h: 277mm;
    --mom-print-w: 210mm;
  }
  html.pad-mom[data-paper="a5"] { --mom-print-w: 148mm; --mom-print-h: 196mm; }
  html.pad-mom[data-paper="letter"] { --mom-print-w: 215.9mm; --mom-print-h: 269mm; }
  html.pad-mom[data-paper="legal"] { --mom-print-w: 215.9mm; --mom-print-h: 345mm; }
  html.pad-mom,
  html.pad-mom body {
    height: auto !important;
    overflow: visible !important;
  }
  html.pad-mom .sheet {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    width: var(--mom-print-w) !important;
    height: var(--mom-print-h) !important;
    min-height: var(--mom-print-h) !important;
    max-height: var(--mom-print-h) !important;
    overflow: hidden !important;
    page-break-after: auto !important;
    break-after: auto !important;
    page-break-before: always;
    break-before: page;
  }
  html.pad-mom .sheet:first-of-type {
    page-break-before: auto !important;
    break-before: auto !important;
  }
  html.pad-mom .accent-edge,
  html.pad-mom .accent-edge-thin,
  html.pad-mom .brand,
  html.pad-mom .banner,
  html.pad-mom .foot-bar,
  html.pad-mom .sign-stamp {
    flex-shrink: 0 !important;
  }
  html.pad-mom .pad {
    position: relative !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    padding-top: 2mm !important;
    padding-bottom: 2mm !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  html.pad-mom .grow {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  html.pad-mom .ruled-block.sm { max-height: 16mm !important; overflow: hidden !important; }
  html.pad-mom .ruled-block.md { max-height: 22mm !important; overflow: hidden !important; }
  html.pad-mom .ruled-block.lg { max-height: 24mm !important; overflow: hidden !important; }
  html.pad-mom .grow .ruled-block.xl,
  html.pad-mom .grow .ruled-block.xxl {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
  }
  html.pad-mom .sign-stamp {
    margin-top: auto !important;
    flex-shrink: 0 !important;
  }
  html.pad-mom .sign-stamp .box {
    min-height: 20mm !important;
  }
  html.pad-mom .foot-bar {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 1.2mm 8mm !important;
    z-index: 2 !important;
    flex: 0 0 auto !important;
  }
  html.pad-mom .sign-row { margin-top: 1.5mm !important; }
  html.pad-mom .banner { margin-bottom: 0.8mm !important; padding: 1mm 3mm !important; }
  html.pad-mom .sheet { isolation: isolate !important; }
  html.pad-mom .wm,
  html.pad-mom img.wm {
    z-index: 3 !important;
    opacity: 0.7 !important;
    mix-blend-mode: multiply !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  html.pad-mom .pad,
  html.pad-mom .section,
  html.pad-mom .grow,
  html.pad-mom .ruled-block {
    background: transparent !important;
  }
  html.pad-mom table.res-table,
  html.pad-mom table.res-table thead,
  html.pad-mom table.res-table tbody,
  html.pad-mom table.res-table tfoot,
  html.pad-mom table.res-table tr,
  html.pad-mom table.res-table td {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
  }
  html.pad-mom table.res-table th {
    background: rgba(232, 238, 246, 0.35) !important;
    background-color: rgba(232, 238, 246, 0.35) !important;
    color: #0b2a56 !important;
  }

  /* —— Envelope faces —— */
  html.envelope-pad,
  html.envelope-pad body {
    width: var(--sheet-w) !important;
    height: var(--sheet-h) !important;
    max-width: var(--sheet-w) !important;
    max-height: var(--sheet-h) !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  html.envelope-pad .sheet {
    width: var(--sheet-w) !important;
    height: var(--sheet-h) !important;
    min-height: var(--sheet-h) !important;
    max-height: var(--sheet-h) !important;
    max-width: var(--sheet-w) !important;
    overflow: hidden !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }
  html.envelope-pad .pad {
    box-sizing: border-box !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  html.envelope-pad .foot {
    flex-shrink: 0 !important;
  }

  /* —— Cash receipt booklet —— */
  html.pad-receipt body {
    overflow: hidden !important;
  }
  html.pad-receipt .sheet-viewport .sheet {
    aspect-ratio: 210 / 283 !important;
    max-height: 283mm !important;
    page-break-after: avoid !important;
  }
  html.pad-receipt .fields {
    flex: 0 1 auto !important;
    max-height: 54% !important;
  }
  html.pad-receipt .r-foot {
    flex-shrink: 0 !important;
  }
  html.pad-receipt .sign .space {
    height: 3.5mm !important;
  }
}
