/* =====================================================================
   Invoice Generator — form extras and the A4 invoice templates.
   The .paper base (A4 size, white page, print margins) comes from
   documents.css; this file only adds the invoice layout.
   ===================================================================== */

/* ---------- Form ---------- */
.tp-inv-minimal { background: linear-gradient(#334155, #334155) 12% 18% / 34% 7% no-repeat, linear-gradient(#94a3b8, #94a3b8) 88% 18% / 26% 7% no-repeat, linear-gradient(#334155, #334155) 50% 40% / 84% 1px no-repeat, repeating-linear-gradient(#fff 0 7px, #e2e8f0 7px 8px) 50% 82% / 84% 38% no-repeat, #fff !important; }

.inv-item-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.inv-item-grid .inv-col-desc { grid-column: 1 / -1; }
.inv-item-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin: -6px 0 8px; }
.inv-item-amount { font-size: .875rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inv-supply-hint { margin: -6px 0 16px; }
.inv-total-pill { font-size: .9rem; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.inv-total-pill strong { color: var(--text); font-size: 1.05rem; margin-left: 4px; }
.inv-pdf-hint { margin: -4px 4px 0; }
#inv-logo-notice { margin-top: 10px; }

@media (max-width: 1240px) and (min-width: 1024px) {
  .inv-item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .inv-item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Invoice paper ---------- */
.paper.invoice { --fs: 9.5pt; line-height: 1.4; color: #1f2937; }
.invoice .ph { color: #9ca3af; }
.invoice .iv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; padding-bottom: 5mm; margin-bottom: 5mm; }
.invoice .iv-from { flex: 1; min-width: 0; }
.invoice .iv-logo { display: block; max-width: 45mm; max-height: 18mm; width: auto; height: auto; object-fit: contain; margin-bottom: 3mm; }
.invoice .iv-biz { font-size: 1.5em; font-weight: 700; line-height: 1.2; color: #111827; }
.invoice .iv-lines { margin-top: 1mm; font-size: .92em; color: #4b5563; }
.invoice .iv-lines p { white-space: pre-line; }
.invoice .iv-title-block { flex: none; max-width: 75mm; text-align: right; }
.invoice .iv-title { font-size: 2em; font-weight: 800; line-height: 1.1; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.invoice .iv-no { margin-top: 1.5mm; font-weight: 600; color: #374151; }

.invoice .iv-parties { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; margin-bottom: 6mm; }
.invoice .iv-billto { flex: 1; min-width: 0; }
.invoice .iv-label { font-size: .78em; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 1.2mm; }
.invoice .iv-party-name { font-size: 1.1em; font-weight: 700; color: #111827; }
.invoice .iv-billto .iv-lines { font-size: .92em; }
.invoice .iv-meta { flex: none; width: 74mm; margin: 0; }
.invoice .iv-meta div { display: flex; justify-content: space-between; gap: 4mm; padding: .5mm 0; }
.invoice .iv-meta dt { flex: none; color: #6b7280; }
.invoice .iv-meta dd { min-width: 0; margin: 0; text-align: right; font-weight: 600; color: #111827; }

.invoice table { border-collapse: collapse; }
.invoice .iv-items { width: 100%; table-layout: fixed; font-size: .92em; }
.invoice .iv-items col.c-n { width: 7mm; }
.invoice .iv-items col.c-hsn { width: 17mm; }
.invoice .iv-items col.c-qty { width: 15mm; }
.invoice .iv-items col.c-rate { width: 23mm; }
.invoice .iv-items col.c-gst { width: 13mm; }
.invoice .iv-items col.c-amt { width: 27mm; }
.invoice .iv-items thead { display: table-header-group; }
.invoice .iv-items th { padding: 2mm 1.5mm; text-align: left; font-size: .9em; font-weight: 700; }
.invoice .iv-items td { padding: 1.8mm 1.5mm; vertical-align: top; border-bottom: .25mm solid #e5e7eb; }
.invoice .iv-items tr { break-inside: avoid; page-break-inside: avoid; }
.invoice .iv-items .num { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.invoice .iv-items .c-desc { white-space: pre-line; overflow-wrap: anywhere; }
.invoice .iv-items .empty td { color: #9ca3af; text-align: center; padding: 6mm 0; }

.invoice .iv-summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 8mm; margin-top: 5mm; break-inside: avoid; page-break-inside: avoid; }
.invoice .iv-summary-left { flex: 1; min-width: 0; }
.invoice .iv-tax { width: 100%; font-size: .84em; }
.invoice .iv-tax th, .invoice .iv-tax td { padding: 1.1mm 1.4mm; text-align: right; border-bottom: .25mm solid #e5e7eb; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.invoice .iv-tax th:first-child, .invoice .iv-tax td:first-child { text-align: left; }
.invoice .iv-tax thead th { color: #6b7280; font-weight: 600; }
.invoice .iv-tax tfoot td { font-weight: 700; border-bottom: 0; }
.invoice .iv-totals { flex: none; width: 72mm; }
.invoice .iv-totals th { padding: 1.1mm 0; text-align: left; font-weight: 500; color: #4b5563; }
.invoice .iv-totals td { padding: 1.1mm 0 1.1mm 3mm; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: #111827; }
.invoice .iv-totals .iv-grand th, .invoice .iv-totals .iv-grand td { padding: 2.2mm 2mm; font-size: 1.12em; font-weight: 800; color: #111827; }
.invoice .iv-words { margin-top: 4mm; }
.invoice .iv-words p { font-weight: 600; color: #111827; }

.invoice .iv-extra { margin-top: 6mm; }
.invoice .iv-extra > div + div { margin-top: 3.5mm; }
.invoice .iv-extra p, .invoice .iv-bank p { white-space: pre-line; color: #374151; font-size: .92em; }
.invoice .iv-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 8mm; margin-top: 8mm; break-inside: avoid; page-break-inside: avoid; }
.invoice .iv-bank { flex: 1; min-width: 0; }
.invoice .iv-sign { flex: none; width: 62mm; margin-left: auto; text-align: center; }
.invoice .iv-sign .iv-for { font-weight: 700; color: #111827; overflow-wrap: anywhere; }
.invoice .iv-sign-space { height: 15mm; }
.invoice .iv-sign-line { border-top: .3mm solid #374151; padding-top: 1.5mm; font-size: .88em; color: #374151; }
.invoice .iv-sign-name { font-size: .92em; color: #111827; font-weight: 600; margin-top: .5mm; }
.invoice .iv-empty { margin: 20mm 0; text-align: center; color: #9ca3af; }

/* Classic: ruled header, grey table head, tinted grand total */
.invoice.tpl-classic .iv-head { border-bottom: .6mm solid #111827; }
.invoice.tpl-classic .iv-items th { background: #f3f4f6; color: #111827; border-top: .4mm solid #111827; border-bottom: .4mm solid #111827; }
.invoice.tpl-classic .iv-totals .iv-grand th, .invoice.tpl-classic .iv-totals .iv-grand td { background: color-mix(in srgb, var(--accent) 12%, #fff); }

/* Modern: coloured header band, coloured table head */
.invoice.tpl-modern .iv-head { margin: calc(var(--pad) * -1) calc(var(--pad) * -1) 6mm; padding: 10mm var(--pad) 8mm; background: var(--accent); color: #fff; }
.invoice.tpl-modern .iv-biz, .invoice.tpl-modern .iv-title, .invoice.tpl-modern .iv-no { color: #fff; }
.invoice.tpl-modern .iv-head .iv-lines { color: rgba(255, 255, 255, .9); }
.invoice.tpl-modern .iv-head .ph { color: rgba(255, 255, 255, .65); }
.invoice.tpl-modern .iv-items th { background: var(--accent); color: #fff; }
.invoice.tpl-modern .iv-items tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--accent) 5%, #fff); }
.invoice.tpl-modern .iv-totals .iv-grand th, .invoice.tpl-modern .iv-totals .iv-grand td { background: var(--accent); color: #fff; }

/* Minimal: hairlines only, accent used sparingly */
.invoice.tpl-minimal .iv-head { border-bottom: .25mm solid #d1d5db; }
.invoice.tpl-minimal .iv-title { color: #111827; font-weight: 300; letter-spacing: .14em; }
.invoice.tpl-minimal .iv-label { color: #6b7280; }
.invoice.tpl-minimal .iv-items th { color: #6b7280; font-weight: 600; border-bottom: .35mm solid #111827; }
.invoice.tpl-minimal .iv-totals .iv-grand th, .invoice.tpl-minimal .iv-totals .iv-grand td { border-top: .35mm solid #111827; color: var(--accent); }

@media print {
  .paper.invoice { width: auto; min-height: 0; padding: 0; --pad: 0mm; }
  .invoice.tpl-modern .iv-head { margin: 0 0 6mm; padding: 7mm 8mm 6mm; border-radius: 2mm; }
}
