/* TG-HisaabBook — printable invoice.
   One HTML structure, 7 layouts (.l-*), 4 table styles (.ts-*), and design variables set inline:
   --c accent · --c2/--c3 soft accents · --band banner/sidebar colour · --t text · --hf/--bf fonts · --fs size · --logo · --rad */
.inv {
  --c: #c2410c; --c2: #fbe6d4; --c3: #fdf3ea; --band: #14213d; --band-ink: #fff; --c-ink: #fff; --t: #1b1f2a; --m: #6b7280; --r: #e5e7eb;
  --hf: 'Fraunces', Georgia, serif; --bf: 'Inter', system-ui, sans-serif; --fs: 10.5pt; --logo: 64px; --rad: 6px;
  width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: var(--t);
  padding: 13mm 13mm 16mm; font: var(--fs)/1.45 var(--bf); position: relative; overflow: hidden;
  box-shadow: 0 10px 40px -12px rgba(0,0,0,.25);
}
.inv * { box-sizing: border-box; }
.inv h1, .inv h4 { margin: 0; }
.inv .small { font-size: .85em; }

/* ---------- shared blocks ---------- */
.inv-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.inv-from { max-width: 58%; }
.inv-logo { max-height: var(--logo); max-width: calc(var(--logo) * 3); margin-bottom: 8px; display: block; }
.inv-tg { margin-bottom: 8px; }
.inv-co { font: 700 1.6em/1.15 var(--hf); }
.inv-from .addr { color: var(--m); font-size: .9em; margin-top: 4px; white-space: pre-line; }
.inv-from .gst { margin-top: 6px; font-size: .9em; }
.inv-right { text-align: right; }
.inv-title h1 { font: 700 1.9em/1.05 var(--hf); color: var(--c); text-transform: uppercase; letter-spacing: .02em; }
.inv-copy { font-size: .75em; text-transform: uppercase; letter-spacing: .14em; color: var(--m); margin-top: 5px; }
.inv-meta { margin-top: 10px; margin-left: auto; border-collapse: collapse; font-size: .9em; }
.inv-meta td { padding: 2px 0 2px 14px; text-align: right; vertical-align: top; }
.inv-meta td:first-child { color: var(--m); white-space: nowrap; }
.inv-meta td:last-child { font-weight: 600; }
.inv-metagrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--r); border: 1px solid var(--r); border-radius: var(--rad); overflow: hidden; margin-top: 14px; font-size: .9em; }
.inv-metagrid > div { background: #fff; padding: 6px 10px; }
.inv-metagrid span { display: block; font-size: .78em; text-transform: uppercase; letter-spacing: .08em; color: var(--m); }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.inv-parties.one { grid-template-columns: 1fr; }
.inv-box { border: 1px solid var(--r); border-radius: var(--rad); padding: 10px 12px; font-size: .9em; }
.inv-box h4 { font-size: .75em; text-transform: uppercase; letter-spacing: .12em; color: var(--c); margin-bottom: 4px; }
.inv-box .nm { font-weight: 700; font-size: 1.12em; }
.inv-box .addr { color: var(--m); white-space: pre-line; }
.inv-lines { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: .9em; }
.inv-lines th { font-weight: 600; font-size: .78em; text-transform: uppercase; letter-spacing: .05em; padding: 7px 6px; text-align: left; }
.inv-lines td { padding: 7px 6px; vertical-align: top; }
.inv-lines .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-lines .desc { color: var(--m); font-size: .9em; }
.inv-bottom { display: grid; grid-template-columns: 1fr 270px; gap: 18px; margin-top: 14px; }
.inv-words { font-size: .92em; } .inv-words b { display: block; font-size: .78em; text-transform: uppercase; letter-spacing: .1em; color: var(--m); }
.inv-taxsum { width: 100%; border-collapse: collapse; font-size: .82em; margin-top: 10px; }
.inv-taxsum th, .inv-taxsum td { border: 1px solid var(--r); padding: 4px 6px; text-align: right; }
.inv-taxsum th { background: var(--c3); font-weight: 600; }
.inv-taxsum td:first-child, .inv-taxsum th:first-child { text-align: left; }
.inv-bank { display: flex; gap: 14px; margin-top: 12px; align-items: flex-start; font-size: .86em; }
.inv-bank h4 { font-size: .78em; text-transform: uppercase; letter-spacing: .12em; color: var(--c); margin-bottom: 3px; }
.inv-qr { text-align: center; font-size: .72em; color: var(--m); }
.inv-qr div img, .inv-qr div canvas { width: 84px !important; height: 84px !important; }
.inv-notes { margin-top: 10px; font-size: .84em; color: var(--m); white-space: pre-line; }
.inv-notes b { color: var(--t); font-size: .9em; text-transform: uppercase; letter-spacing: .1em; display: block; }
.inv-totals { font-size: .95em; }
.inv-totals .r { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.inv-totals .r.disc span:last-child { color: #b91c1c; }
.inv-totals .r.sub { border-top: 1px solid var(--r); margin-top: 2px; padding-top: 6px; font-weight: 600; }
.inv-totals .r.g { border-top: 2px solid var(--t); margin-top: 6px; padding-top: 8px; font: 700 1.35em var(--hf); }
.inv-totals .r.g span:last-child { color: var(--c); }
.inv-totals .r.due { background: var(--c2); padding: 6px 8px; border-radius: 4px; margin-top: 6px; font-weight: 700; }
.inv-totals .note { font-size: .8em; color: var(--m); text-align: right; }
.inv-sign { margin-top: 26px; text-align: right; font-size: .9em; }
.inv-sign img { max-height: 50px; max-width: 160px; display: block; margin: 6px 0 4px auto; }
.inv-sign .sp { height: 46px; }
.inv-sign .ln { border-top: 1px solid var(--t); display: inline-block; padding-top: 3px; min-width: 160px; text-align: center; color: var(--m); font-size: .82em; }
.inv-foot { position: absolute; bottom: 7mm; left: 13mm; right: 13mm; text-align: center; font-size: .72em; color: var(--m); z-index: 1; }
.inv-stamp { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font: 700 64pt var(--hf); color: rgba(185,28,28,.13); border: 6px solid rgba(185,28,28,.13); padding: 4px 26px; border-radius: 14px; pointer-events: none; z-index: 2; }
.inv-stamp.paid { color: rgba(21,128,61,.13); border-color: rgba(21,128,61,.13); }
.inv-wm { position: absolute; inset: 0; display: grid; place-items: center; opacity: .05; pointer-events: none; z-index: 0; }
.inv-wm img { width: 60%; }
.inv-head, .inv-parties, .inv-lines, .inv-bottom, .inv-sign, .inv-titleband, .inv-metagrid, .inv-sb, .inv-lh-title, .inv-lh-grid { position: relative; z-index: 1; }

/* ---------- table styles ---------- */
.ts-filled .inv-lines th { background: var(--c); color: var(--c-ink); }
.ts-filled .inv-lines td { border-bottom: 1px solid var(--r); }
.ts-lined .inv-lines th { color: var(--c); border-top: 1.5px solid var(--c); border-bottom: 1.5px solid var(--c); }
.ts-lined .inv-lines td { border-bottom: 1px solid var(--r); }
.ts-striped .inv-lines th { background: var(--c2); color: var(--t); }
.ts-striped .inv-lines tbody tr:nth-child(even) td { background: var(--c3); }
.ts-grid .inv-lines th { background: var(--c3); color: var(--t); border: 1px solid var(--t); }
.ts-grid .inv-lines td { border: 1px solid var(--t); }

/* ---------- options ---------- */
.inv.has-topbar { padding-top: 0; }
.inv.has-topbar::before { content: ''; display: block; height: 9mm; margin: 0 -13mm 10mm; background: linear-gradient(90deg, var(--c), var(--c2)); position: relative; z-index: 1; }
.inv.frame::after { content: ''; position: absolute; inset: 6mm; border: 1.2px solid var(--c); outline: .5px solid var(--c2); outline-offset: -4px; pointer-events: none; z-index: 1; }

/* ---------- layout: centered ---------- */
.l-centered .inv-head { justify-content: center; text-align: center; }
.l-centered .inv-from { max-width: 80%; }
.l-centered .inv-logo, .l-centered .inv-tg { margin-left: auto; margin-right: auto; }
.l-centered .inv-titleband { margin: 14px -13mm 0; padding: 8px 13mm; background: var(--c); color: var(--c-ink); display: flex; justify-content: center; }
.l-centered .inv-titleband .inv-title { text-align: center; }
.l-centered .inv-titleband h1 { color: var(--c-ink); font-size: 1.6em; letter-spacing: .2em; }
.l-centered .inv-titleband .inv-copy { color: var(--c-ink); opacity: .8; }

/* ---------- layout: banner ---------- */
.l-banner { padding-top: 0; }
.l-banner .inv-head.band { background: var(--band); color: var(--band-ink); margin: 0 -13mm; padding: 11mm 13mm 9mm; border-radius: 0 0 var(--rad) var(--rad); }
.l-banner .inv-head.band .addr, .l-banner .inv-head.band .inv-meta td:first-child, .l-banner .inv-head.band .inv-copy { color: var(--band-ink); opacity: .72; }
.l-banner .inv-head.band .inv-title h1 { color: var(--c); }

/* ---------- layout: sidebar ---------- */
.l-sidebar { padding: 0; }
.l-sidebar .inv-sb { display: grid; grid-template-columns: 64mm 1fr; min-height: 297mm; }
.l-sidebar .inv-side { background: var(--band); color: var(--band-ink); padding: 13mm 8mm; display: flex; flex-direction: column; gap: 14px; }
.l-sidebar .inv-side .inv-from { max-width: none; }
.l-sidebar .inv-side .addr, .l-sidebar .inv-side .gst { color: var(--band-ink); opacity: .85; }
.l-sidebar .inv-side .inv-box { border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.06); }
.l-sidebar .inv-side .inv-box h4, .l-sidebar .inv-side .inv-bank h4 { color: var(--band-ink); opacity: .7; }
.l-sidebar .inv-side .inv-bank { flex-direction: column; color: var(--band-ink); }
.l-sidebar .inv-side .inv-qr { background: #fff; padding: 6px; border-radius: 6px; color: #333; }
.l-sidebar .inv-main { padding: 13mm 11mm 18mm; }
.l-sidebar .inv-main .inv-metagrid { grid-template-columns: repeat(3, 1fr); }
.l-sidebar .inv-bottom { grid-template-columns: 1fr 230px; }
.l-sidebar .inv-foot { left: 70mm; }

/* ---------- layout: boxed (classic Tally-style GST) ---------- */
.l-boxed .inv-head { border: 1.5px solid var(--t); padding: 10px; border-bottom: 0; }
.l-boxed .inv-title h1 { color: var(--t); font-size: 1.4em; }
.l-boxed .inv-parties { margin: 0; gap: 0; border: 1.5px solid var(--t); }
.l-boxed .inv-box { border: 0; border-radius: 0; }
.l-boxed .inv-box + .inv-box { border-left: 1.5px solid var(--t); }
.l-boxed .inv-box h4 { color: var(--t); }
.l-boxed .inv-lines { margin: 0; border: 1.5px solid var(--t); border-top: 0; }
.l-boxed .inv-bottom { margin: 0; border: 1.5px solid var(--t); border-top: 0; padding: 10px; gap: 0; }
.l-boxed .inv-totals { border-left: 1px solid var(--t); padding-left: 10px; }
.l-boxed .inv-sign { border: 1.5px solid var(--t); border-top: 0; margin: 0; padding: 10px; }
.l-boxed .inv-totals .r.g span:last-child { color: var(--t); }

/* ---------- layout: letterhead ---------- */
.l-letterhead { padding-top: 15mm; }
.l-letterhead .inv-head { justify-content: center; text-align: center; border-bottom: 3px double var(--c); padding-bottom: 10px; }
.l-letterhead .inv-from { max-width: 90%; }
.l-letterhead .inv-logo, .l-letterhead .inv-tg { margin-left: auto; margin-right: auto; }
.l-letterhead .inv-co { font-size: 2em; }
.l-letterhead .inv-lh-title { text-align: center; margin-top: 12px; }
.l-letterhead .inv-lh-title h1 { font-style: italic; text-transform: none; font-size: 1.9em; }
.l-letterhead .inv-lh-grid { display: grid; grid-template-columns: 1fr 230px; gap: 14px; margin-top: 12px; }
.l-letterhead .inv-lh-grid .inv-parties { margin: 0; }
.l-letterhead .inv-box.meta .inv-meta { margin: 0; width: 100%; }
.l-letterhead .inv-box.meta .inv-meta td { padding-left: 6px; }

/* ---------- layout: thermal receipt (80 mm) ---------- */
.l-thermal { width: 80mm; min-height: 0; padding: 5mm 4mm 6mm; --fs: 8.5pt; --r: #000; }
.l-thermal .inv-head { flex-direction: column; align-items: center; text-align: center; gap: 4px; border-bottom: 1px dashed #000; padding-bottom: 6px; }
.l-thermal .inv-from { max-width: none; }
.l-thermal .inv-logo, .l-thermal .inv-tg { margin: 0 auto 4px; }
.l-thermal .inv-tg { width: 46px !important; height: 46px !important; }
.inv-tg { display: block; object-fit: contain; }
.l-thermal .inv-right { text-align: center; }
.l-thermal .inv-title h1 { font-size: 1.15em; color: #000; }
.l-thermal .inv-meta { margin: 4px auto 0; }
.l-thermal .inv-meta td { padding: 0 4px; }
.l-thermal .inv-copy, .l-thermal .ship, .l-thermal .inv-taxsum, .l-thermal .col-hsn, .l-thermal .col-unit, .l-thermal .col-disc, .l-thermal .col-tax, .l-thermal .col-sn { display: none; }
.l-thermal .inv-parties { grid-template-columns: 1fr; margin-top: 6px; }
.l-thermal .inv-box { border: 0; padding: 0; }
.l-thermal .inv-lines th { background: none !important; color: #000 !important; border: 0 !important; border-top: 1px dashed #000 !important; border-bottom: 1px dashed #000 !important; padding: 3px 2px; }
.l-thermal .inv-lines td { border: 0 !important; padding: 3px 2px; background: none !important; }
.l-thermal .inv-bottom { grid-template-columns: 1fr; border-top: 1px dashed #000; }
.l-thermal .inv-bottom > .inv-totals { order: -1; }
.l-thermal .inv-totals .r.g { font-size: 1.15em; border-top: 1px dashed #000; }
.l-thermal .inv-bank { justify-content: center; }
.l-thermal .inv-bank > div:first-child { display: none; }
.l-thermal .inv-sign { text-align: center; margin-top: 10px; }
.l-thermal .inv-foot { position: static; margin-top: 8px; }
.l-thermal .inv-stamp { font-size: 28pt; border-width: 3px; }

/* design picker swatches */
.theme-pick button i { display: block; height: 16px; }

@media print {
  @page { size: A4; margin: 0; }
  .inv { box-shadow: none; margin: 0; width: 210mm; min-height: 296mm; }
  .inv.l-thermal { width: 80mm; min-height: 0; }
  .inv-lines tr { page-break-inside: avoid; }
}
