/* The same branded label is previewed in the dialog and isolated for printing.
   The logo stays outside the code; the white frame provides a quiet zone. */
.modal-template#qr-dialog { max-width: 440px; margin: auto; }
#qr-poster { padding: 25px 20px 20px; border: 1px solid #dce5d8; border-radius: 18px; background: #fff; color: #194e3c; break-inside: avoid; }
#qr-poster .qr-brand { display: block; width: 170px; height: auto; max-width: 70%; margin: 0 auto 20px; }
#qr-poster .qr-tagline { font-size: 28px; font-weight: 700; line-height: 1.3; margin: 0 0 6px; color: #194e3c; }
#qr-poster .qr-instruction { font-size: 12px; margin: 0; color: #63745f; }
#qr-poster .qr-frame { width: min(100%, 280px); padding: 20px; margin: 18px auto; border: 1px solid #e2e8dc; border-radius: 12px; background: #fff; }
#qr-poster #qr-code { display: block; width: 100%; margin: 0; aspect-ratio: 1; }
#qr-code canvas, #qr-code img { width: 100%; height: auto; max-width: 100%; }
#qr-poster #qr-title { font-size: 20px; line-height: 1.4; margin: 0 0 7px; overflow-wrap: anywhere; }
#qr-poster #qr-connector { display: inline-block; font-size: 16px; font-weight: 650; padding: 5px 16px; margin: 0 0 9px; border: 1px solid #cad9bd; border-radius: 9px; }
#qr-poster #qr-equipment { font-size: 10px; line-height: 1.6; margin: 0 0 12px; overflow-wrap: anywhere; }
#qr-poster #qr-local-note { font-size: 10px; line-height: 1.6; margin: 0 0 8px; }
#qr-poster.qr-is-local #qr-local-note { color: #856337; }
#qr-poster #qr-url { font-size: 9px; line-height: 1.6; margin: 0; overflow-wrap: anywhere; color: #63745f; }
.qr-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.qr-actions .button { min-height: 44px; }
@media (max-width: 420px) {
  #qr-poster { padding: 20px 12px 16px; }
  #qr-poster .qr-tagline { font-size: 24px; }
  #qr-poster .qr-instruction { font-size: 10px; }
  #qr-poster .qr-frame { padding: 16px; }
  #qr-poster #qr-title { font-size: 18px; }
}
/* The brand plate covers only the centre. QR generation uses the matching
   high-error-correction setting; finder patterns and the quiet zone stay clear. */
#qr-poster #qr-code { position: relative; }
#qr-code img.qr-watermark { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1; display: block; width: 20%; height: 20%; max-width: 20%; padding: 2%; margin: 0; box-sizing: border-box; border: 0; border-radius: 2px; background: #fff; object-fit: contain; pointer-events: none; }
/* The preview has a real height budget. The square shrinks before metadata or
   actions need to scroll; print below keeps its independent physical sizes. */
@media screen {
  .swal2-container:has(> .bpay-qr-panel) { padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); overflow: visible; }
  .swal2-popup.kkm-panel.bpay-qr-panel {
    --qr-preview-reserve: 450px;
    --qr-preview-frame: min(330px, max(156px, calc(100dvh - var(--qr-preview-reserve) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px))), calc(100vw - 64px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    position: relative; display: flex !important; flex-direction: column;
    width: min(520px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))) !important;
    max-width: none; height: auto; min-height: 0;
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    padding: 8px; margin: 0; overflow: visible;
  }
  .bpay-qr-panel > .swal2-close { position: absolute; inset: 8px 8px auto auto; width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0; padding: 0; border-radius: 50%; background: #fff; font-size: 30px; line-height: 1; }
  .swal2-popup.kkm-panel.bpay-qr-panel > .swal2-html-container { width: 100%; min-height: 0; max-height: none; overflow: visible; margin: 0; padding: 0; }
  .bpay-qr-panel .modal-template#qr-dialog { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: none; min-height: 0; padding: 0; margin: 0; }
  .bpay-qr-panel #qr-poster { display: flex; flex-direction: column; align-items: center; width: 100%; min-width: 0; padding: 12px; margin: 0; border-radius: 14px; }
  .bpay-qr-panel #qr-poster .qr-brand { width: auto; height: 36px; max-width: calc(100% - 88px); margin: 0 auto 8px; object-fit: contain; }
  .bpay-qr-panel #qr-poster .qr-tagline { font-size: 26px; line-height: 1.25; margin: 0; }
  .bpay-qr-panel #qr-poster .qr-instruction { font-size: 11px; line-height: 1.4; margin: 0; }
  .bpay-qr-panel #qr-poster .qr-frame { flex: 0 0 auto; width: var(--qr-preview-frame); max-width: 100%; aspect-ratio: 1; padding: calc(var(--qr-preview-frame) * .11); margin: 8px auto; border-radius: 9px; background: #fff; }
  .bpay-qr-panel #qr-poster #qr-code { width: 100%; min-width: 0; aspect-ratio: 1; margin: 0; }
  .bpay-qr-panel #qr-poster #qr-code canvas, .bpay-qr-panel #qr-poster #qr-code img { width: 100%; height: auto; max-width: 100%; margin: 0; }
  .bpay-qr-panel #qr-poster #qr-code img.qr-watermark { width: 20%; height: 20%; max-width: 20%; padding: 2%; margin: 0; }
  .bpay-qr-panel #qr-poster #qr-title { width: 100%; min-width: 0; padding: 0; margin: 0 0 4px; font-size: 18px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
  .bpay-qr-panel #qr-poster #qr-connector { max-width: 100%; margin: 0 0 4px; padding: 4px 12px; font-size: 15px; line-height: 1.4; }
  .bpay-qr-panel #qr-poster #qr-equipment { width: 100%; min-width: 0; margin: 0 0 4px; font-size: 11px; line-height: 1.35; }
  .bpay-qr-panel #qr-equipment .qr-equipment-label { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bpay-qr-panel #qr-equipment .qr-equipment-separator { display: none; }
  .bpay-qr-panel #qr-equipment .qr-equipment-serial { display: block; width: 100%; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
  .bpay-qr-panel #qr-poster #qr-local-note { width: 100%; min-width: 0; margin: 0 0 4px; font-size: 10.5px; line-height: 1.4; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
  .bpay-qr-panel #qr-poster #qr-url { width: 100%; min-width: 0; margin: 0; font-size: 9.5px; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
  .bpay-qr-panel #qr-dialog .qr-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; margin: 0; }
  .bpay-qr-panel #qr-dialog .qr-actions .button { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; height: 44px; padding: 7px 9px; margin: 0; font-size: 14px; line-height: 1.4; white-space: nowrap; }
}
@media screen and (max-height: 700px) {
  .swal2-popup.kkm-panel.bpay-qr-panel { --qr-preview-reserve: 410px; }
  .bpay-qr-panel #qr-poster .qr-brand { height: 28px; margin-bottom: 6px; }
  .bpay-qr-panel #qr-poster .qr-tagline { font-size: 22px; }
  .bpay-qr-panel #qr-poster .qr-instruction { font-size: 10px; }
  .bpay-qr-panel #qr-poster #qr-title { font-size: 16px; }
  .bpay-qr-panel #qr-poster #qr-connector { font-size: 14px; }
  .bpay-qr-panel #qr-poster #qr-equipment { font-size: 10px; line-height: 1.3; }
  .bpay-qr-panel #qr-poster #qr-local-note { font-size: 10px; line-height: 1.3; }
  .bpay-qr-panel #qr-poster #qr-url { font-size: 9px; }
}
@media screen and (max-height: 600px) {
  .swal2-popup.kkm-panel.bpay-qr-panel { --qr-preview-reserve: 350px; padding: 6px; }
  .bpay-qr-panel .modal-template#qr-dialog { gap: 6px; }
  .bpay-qr-panel #qr-poster { padding: 8px; }
  .bpay-qr-panel #qr-poster .qr-brand { height: 20px; margin-bottom: 2px; }
  .bpay-qr-panel #qr-poster .qr-tagline { font-size: 18px; line-height: 1.15; }
  .bpay-qr-panel #qr-poster .qr-instruction { font-size: 9px; line-height: 1.2; }
  .bpay-qr-panel #qr-poster .qr-frame { margin-block: 4px; }
  .bpay-qr-panel #qr-poster #qr-title { margin-bottom: 2px; font-size: 14px; line-height: 1.2; }
  .bpay-qr-panel #qr-poster #qr-connector { margin-bottom: 2px; padding-block: 2px; font-size: 12px; line-height: 1.2; }
  .bpay-qr-panel #qr-poster #qr-equipment { margin-bottom: 2px; line-height: 1.2; }
  .bpay-qr-panel #qr-poster #qr-local-note { margin-bottom: 2px; font-size: 9px; line-height: 1.2; }
  .bpay-qr-panel #qr-poster #qr-url { font-size: 8px; line-height: 1.25; }
}
/* Landscape phones have width to keep a larger code beside the label. */
@media screen and (max-height: 430px) and (min-width: 600px) {
  .swal2-popup.kkm-panel.bpay-qr-panel {
    --qr-preview-frame: 200px;
    width: min(700px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px))) !important;
  }
  .bpay-qr-panel #qr-poster { display: grid; grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: repeat(8, auto); column-gap: 18px; row-gap: 3px; align-items: center; padding: 12px; }
  .bpay-qr-panel #qr-poster > :not(.qr-frame) { grid-column: 2; min-width: 0; }
  .bpay-qr-panel #qr-poster .qr-frame { grid-column: 1; grid-row: 1 / span 8; align-self: center; width: var(--qr-preview-frame); margin: 0; }
  .bpay-qr-panel #qr-poster .qr-brand { justify-self: center; margin: 0; }
  .bpay-qr-panel #qr-poster #qr-title, .bpay-qr-panel #qr-poster #qr-connector, .bpay-qr-panel #qr-poster #qr-equipment, .bpay-qr-panel #qr-poster #qr-local-note { margin: 0; }
  .bpay-qr-panel #qr-poster #qr-connector { justify-self: center; }
}
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  html, body.printing-qr { background: #fff !important; height: auto !important; overflow: visible !important; }
  body.printing-qr { padding: 0 !important; margin: 0 !important; }
  body.printing-qr > .swal2-container { display: block !important; position: static !important; padding: 0 !important; margin: 0 !important; height: auto !important; overflow: visible !important; }
  .printing-qr .swal2-popup { position: static !important; transform: none !important; padding: 0 !important; margin: 0 !important; max-width: none !important; height: auto !important; animation: none !important; }
  .printing-qr .swal2-popup > :not(.swal2-html-container) { display: none !important; }
  .printing-qr .swal2-html-container { display: block !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; max-height: none !important; }
  .printing-qr #qr-dialog { display: block !important; width: auto !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  .printing-qr #qr-poster { width: 110mm; max-width: 100%; margin: 0 auto; padding: 9mm 7mm; border: .3mm solid #b7c6af; border-radius: 4mm; }
  .printing-qr #qr-poster .qr-brand { width: 45mm; margin-bottom: 6mm; }
  .printing-qr #qr-poster .qr-tagline { font-size: 22pt; }
  .printing-qr #qr-poster .qr-instruction { font-size: 9pt; }
  .printing-qr #qr-poster .qr-frame { width: 74mm; padding: 5mm; margin: 6mm auto; border: 0; border-radius: 0; }
  .printing-qr #qr-poster #qr-title { font-size: 16pt; }
  .printing-qr #qr-poster #qr-connector { font-size: 13pt; margin-bottom: 3mm; }
  .printing-qr #qr-poster #qr-equipment { font-size: 8pt; }
  .printing-qr #qr-poster #qr-url { font-size: 7pt; }
  .printing-qr #qr-local-note, .printing-qr #qr-url { display: none !important; }
  .printing-qr .qr-actions, .printing-qr #close-qr { display: none !important; }
}
