/* The A4 tax invoice: the same markup is shown on screen as a preview and sent to the printer. */

.sheet-host { overflow-x: auto; padding-bottom: 8px; }

.sheet {
  --rule: #7f8c99;
  --band: #e4ebf3;
  width: 210mm;
  min-height: 295mm;
  padding: 5mm 9mm 5mm 14mm;
  background: #fff;
  color: #111;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 10pt;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  box-shadow: 0 2px 14px rgba(0, 0, 0, .18);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { padding: 1.1mm 1.6mm; vertical-align: top; text-align: left; font-weight: normal; }
.sheet .r { text-align: right; }
.sheet .c { text-align: center; }
.sheet p { margin: 0; }
.sheet .band { background: var(--band); font-weight: bold; padding: 1.1mm 1.6mm; }

/* letterhead */
.inv-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 2mm; border-bottom: 0.3mm solid var(--rule); }
.inv-logo { height: 19mm; filter: drop-shadow(0 0.2mm 0.35mm rgba(0, 0, 0, .55)); }
.inv-contact { text-align: right; font-size: 10pt; line-height: 1.45; color: #1f3247; }

.inv-title { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 2mm 0 1.5mm; }
.inv-title h1 { margin: 0; font-size: 15pt; letter-spacing: .06em; font-weight: bold; }
.inv-title .copy { text-align: right; font-size: 8.5pt; font-weight: bold; }

/* customer and invoice reference */
.inv-meta { display: grid; grid-template-columns: 52% 48%; align-items: start; position: relative; border: 0.25mm solid var(--rule); }
.inv-meta::after { content: ""; position: absolute; top: 0; bottom: 0; left: 52%; border-left: 0.25mm solid var(--rule); }
.inv-meta .party th { width: 19mm; color: #333; white-space: nowrap; }
.inv-meta .ref th { width: 19mm; color: #333; white-space: nowrap; }
.inv-meta .ref th.band { color: #111; }
.inv-meta .ref tr:nth-child(2) th, .inv-meta .ref tr:nth-child(2) td { padding-bottom: 2mm; }
.inv-meta .desc { font-weight: bold; padding-top: 1.8mm; }

/* line items */
.items { margin-top: 2.5mm; border: 0.25mm solid var(--rule); }
.items thead th { background: var(--band); font-weight: bold; text-align: center; border: 0.25mm solid var(--rule); }
.items tbody td { border-left: 0.25mm solid var(--rule); border-right: 0.25mm solid var(--rule); }
.items .sumrow td { border-top: 0.25mm solid var(--rule); }
.items .sumrow td:first-child { font-weight: bold; }
.items .total td { border-top: 0.25mm solid var(--rule); background: var(--band); font-weight: bold; font-size: 11pt; }
.items tr.filler td { padding: 0; }

.words { display: flex; gap: 3mm; border: 0.25mm solid var(--rule); border-top: 0; padding: 1.4mm 1.6mm; }
.words span { white-space: nowrap; color: #333; }

/* tax summary by HSN */
.hsn { margin-top: 2.5mm; }
.hsn th, .hsn td { border: 0.25mm solid var(--rule); }
.hsn thead th { background: var(--band); font-weight: bold; text-align: center; vertical-align: middle; }
.hsn .total td { font-weight: bold; }

/* bank, terms, signature */
.inv-foot { display: grid; grid-template-columns: 64% 36%; margin-top: 2.5mm; border: 0.25mm solid var(--rule); }
.foot-left { border-right: 0.25mm solid var(--rule); }
.bank { display: flex; justify-content: space-between; align-items: center; padding: 1mm 0; }
.bank table { width: auto; }
.bank th { width: 26mm; color: #333; }
.bank td { font-weight: bold; }
.bank .qr { height: 27mm; margin-right: 6mm; }
.terms { padding: 1.2mm 1.6mm; font-size: 8pt; line-height: 1.3; }
.terms p + p { margin-top: 1.2mm; }
.foot-right { display: flex; flex-direction: column; padding: 1.6mm 2mm; text-align: center; }
.foot-right .cert { font-size: 8.5pt; }
.foot-right .for { margin-top: 5mm; font-weight: bold; }
.foot-right .stamp { flex: 1; min-height: 26mm; display: flex; align-items: center; justify-content: center; }
.foot-right .stamp img { max-width: 52mm; max-height: 36mm; }
.foot-right .sign { font-weight: bold; }

.inv-address { margin-top: auto; padding-top: 2mm; border-top: 0.3mm solid var(--rule); text-align: center; font-size: 9pt; color: #1f3247; }
.inv-foot + .inv-address { margin-top: auto; }

@page { size: A4; margin: 0; }

@media print {
  .no-print { display: none !important; }
  html, body { background: #fff; }
  main { max-width: none; margin: 0; padding: 0; }
  .sheet-host { display: block; overflow: visible; padding: 0; }
  /* on screen a narrow window draws the page smaller; paper always gets the full size */
  .sheet { box-shadow: none; margin: 0; zoom: 1 !important; }
  /* several invoices opened together: one per page */
  .sheet-host.batch .sheet { break-after: page; }
  .sheet-host.batch .sheet:last-child { break-after: auto; }
}
.sheet-host.batch .sheet { margin-bottom: 16px; }
