/* Tiliso — invoice & estimate documents (shared/invoice-template.js).
   Loaded by the app and inlined into every server PDF. Colours are fixed
   (a document is printed on white paper whatever the app theme is). */

.ivd {
  --ivd-ink: #111827;
  --ivd-ink-2: #374151;
  --ivd-muted: #6b7280;
  --ivd-faint: #9ca3af;
  --ivd-rule: #e5e7eb;
  --ivd-rule-strong: #d1d5db;
  --ivd-pad: 44px;
  --ivd-fs: 11.5px;
  position: relative;
  max-width: 860px;
  margin: 0 auto;
  padding: var(--ivd-pad) calc(var(--ivd-pad) + 4px);
  background: #fff;
  color: var(--ivd-ink);
  font-size: var(--ivd-fs);
  line-height: 1.5;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 8px 28px rgba(17, 24, 39, .08);
  overflow: hidden;
  text-align: left;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.ivd *, .ivd *::before, .ivd *::after { box-sizing: border-box; }
.ivd-font-sans { font-family: 'Plus Jakarta Sans', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
.ivd-font-clean { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
.ivd-font-serif { font-family: Georgia, 'Times New Roman', Times, serif; }
.ivd .ivd-mono { font-family: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace; font-size: .95em; }
.ivd .ivd-strong { font-weight: 700; color: var(--ivd-ink); }
.ivd .ivd-sub { color: var(--ivd-muted); font-size: .88em; }
.ivd a { color: var(--ivd-accent); text-decoration: none; }
.ivd dl { margin: 0; }
.ivd .ivd-label {
  font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ivd-muted); margin-bottom: 5px;
}

/* ---- header ---- */
.ivd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; padding-bottom: 18px; }
.ivd-head-flip { flex-direction: row-reverse; }
.ivd-head-flip .ivd-titlebox { text-align: left; }
.ivd-brand { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.ivd-logo { flex: none; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.ivd-logo-S .ivd-logo { width: 40px; height: 40px; }
.ivd-logo-L .ivd-logo { width: 84px; height: 84px; }
.ivd-logo img { width: 100%; height: 100%; object-fit: contain; }
.ivd-logo-mark { background: var(--ivd-accent); color: var(--ivd-accent-ink); font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.ivd-org-name { font-size: 15.5px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.ivd-org-lines { margin-top: 4px; color: var(--ivd-muted); font-size: 10.5px; line-height: 1.6; }
.ivd-org-lines strong { color: var(--ivd-ink-2); font-weight: 650; }
.ivd-titlebox { text-align: right; flex: none; }
.ivd-copy { font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ivd-muted); margin-bottom: 4px; }
.ivd-title { font-size: 26px; font-weight: 800; letter-spacing: .01em; text-transform: uppercase; line-height: 1.05; color: var(--ivd-accent); }
.ivd-number { margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--ivd-ink-2); font-family: ui-monospace, 'SF Mono', Consolas, monospace; }

/* ---- parties & details ---- */
.ivd-parties {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-top: 1px solid var(--ivd-rule); border-bottom: 1px solid var(--ivd-rule);
}
.ivd-parties.has-ship { grid-template-columns: 1fr 1fr 1.05fr; }
.ivd-party, .ivd-details { padding: 13px 18px 13px 0; }
.ivd-party + .ivd-party, .ivd-party + .ivd-details { padding-left: 18px; border-left: 1px solid var(--ivd-rule); }
.ivd-party-name { font-size: 13px; font-weight: 750; margin-bottom: 3px; }
.ivd-party-lines { color: var(--ivd-ink-2); font-size: 10.5px; line-height: 1.5; }
.ivd-party-lines strong { font-weight: 650; }
.ivd-details { padding-right: 0; }
.ivd-details dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; }
.ivd-details dt { color: var(--ivd-muted); font-size: 10.5px; }
.ivd-details dd { margin: 0; text-align: right; font-weight: 650; font-size: 10.5px; }

/* ---- items ---- */
.ivd-items { width: 100%; border-collapse: collapse; margin-top: 16px; }
.ivd-items th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ivd-ink-2);
  text-align: left; padding: 9px 8px; background: var(--ivd-accent-soft); border-bottom: 1.5px solid var(--ivd-accent);
}
.ivd-items td { padding: 8px 8px; border-bottom: 1px solid var(--ivd-rule); vertical-align: top; }
.ivd-items .r { text-align: right; white-space: nowrap; }
.ivd-items .ivd-c-num { width: 28px; color: var(--ivd-faint); }
.ivd-items .ivd-c-hsn { color: var(--ivd-ink-2); white-space: nowrap; }
.ivd-items .ivd-amount { font-weight: 700; }
.ivd-items tfoot td { font-weight: 700; border-bottom: 0; }
.ivd-item-name { font-weight: 650; }
.ivd-item-desc { color: var(--ivd-muted); font-size: 10.5px; margin-top: 2px; }
.ivd-unit { color: var(--ivd-faint); }
.ivd-items tr { page-break-inside: avoid; }

/* ---- summary ---- */
.ivd-summary { display: grid; grid-template-columns: 1fr 290px; gap: 32px; margin-top: 14px; align-items: start; }
.ivd-summary-side > * + * { margin-top: 14px; }
.ivd-text { color: var(--ivd-ink-2); white-space: pre-line; font-size: 10.5px; }
.ivd-words .ivd-text { font-weight: 650; color: var(--ivd-ink); }
.ivd-totals { font-size: 11px; }
.ivd-trow { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.ivd-trow span:last-child { font-weight: 650; white-space: nowrap; }
.ivd-trow.ivd-total { margin-top: 6px; padding: 10px 0 8px; border-top: 1.5px solid var(--ivd-ink); font-size: 14px; font-weight: 800; }
.ivd-trow.ivd-total span:last-child { font-weight: 800; }
.ivd-trow.ivd-paid { color: #047857; }
.ivd-trow.ivd-muted { color: var(--ivd-muted); }
.ivd-trow.ivd-balance {
  margin-top: 6px; padding: 10px 12px; border-radius: 6px; background: var(--ivd-accent-soft);
  font-size: 13px; font-weight: 800; color: var(--ivd-ink);
}

/* ---- payment ---- */
.ivd-pay { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 36px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--ivd-rule); border-radius: 8px; page-break-inside: avoid; }
.ivd-pay dl { display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-size: 10.5px; }
.ivd-pay dt { color: var(--ivd-muted); }
.ivd-pay dd { margin: 0; font-weight: 600; }
.ivd-pay-upi { display: flex; gap: 12px; align-items: center; }
.ivd-pay-upi svg, .ivd-pay-upi img { flex: none; border: 1px solid var(--ivd-rule); border-radius: 6px; background: #fff; }
.ivd-pay-paypal { min-width: 140px; }

/* ---- HSN summary ---- */
.ivd-taxsum { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 10px; page-break-inside: avoid; }
.ivd-taxsum th, .ivd-taxsum td { padding: 5px 8px; border: 1px solid var(--ivd-rule); }
.ivd-taxsum th { background: #f9fafb; text-align: left; font-weight: 700; color: var(--ivd-ink-2); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.ivd-taxsum .r { text-align: right; white-space: nowrap; }
.ivd-taxsum tfoot td { font-weight: 700; background: #f9fafb; }

/* ---- footer ---- */
.ivd-foot { display: grid; grid-template-columns: 1fr 230px; gap: 32px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--ivd-rule); align-items: end; page-break-inside: avoid; }
.ivd-sign { text-align: center; font-size: 10.5px; }
.ivd-sign-for { font-weight: 700; color: var(--ivd-ink-2); }
.ivd-sign-space { height: 40px; }
.ivd-sign-img { display: block; max-width: 160px; max-height: 56px; margin: 6px auto 0; object-fit: contain; }
.ivd-sign-line { border-top: 1px solid var(--ivd-ink-2); margin: 4px 12px 5px; }
.ivd-sign-name { font-weight: 650; }
.ivd-sign-label { color: var(--ivd-muted); font-size: 9.5px; letter-spacing: .04em; }
.ivd-footer { margin-top: 12px; text-align: center; color: var(--ivd-faint); font-size: 9.5px; line-height: 1.6; }

/* ---- stamps ---- */
.ivd-stamp {
  display: inline-block; margin-top: 10px; transform: rotate(-5deg);
  padding: 3px 12px; border: 2px solid currentColor; border-radius: 6px; background: #fff;
  font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; line-height: 1.4;
}
.ivd-stamp-paid { color: #059669; }
.ivd-stamp-overdue { color: #dc2626; }
.ivd-watermark {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 110px; font-weight: 800; letter-spacing: .12em; color: rgba(220, 38, 38, .07); transform: rotate(-24deg);
}

/* =================================================================== layouts */

/* ---- modern: a coloured header band ---- */
.ivd--modern { padding-top: 0; }
.ivd--modern .ivd-head {
  margin: 0 calc(-1 * (var(--ivd-pad) + 4px)) 22px; padding: 30px calc(var(--ivd-pad) + 4px) 26px;
  background: var(--ivd-accent); color: var(--ivd-accent-ink);
}
.ivd--modern .ivd-org-lines, .ivd--modern .ivd-org-lines strong, .ivd--modern .ivd-copy, .ivd--modern .ivd-number { color: var(--ivd-accent-ink); opacity: .85; }
.ivd--modern .ivd-title { color: var(--ivd-accent-ink); font-size: 30px; text-transform: none; letter-spacing: -.02em; }
.ivd--modern .ivd-logo { background: #fff; padding: 4px; }
.ivd--modern .ivd-logo-mark { background: rgba(255, 255, 255, .18); color: var(--ivd-accent-ink); }
.ivd--modern .ivd-parties { border: 0; gap: 14px; }
.ivd--modern .ivd-party, .ivd--modern .ivd-details { padding: 14px 16px; border: 0 !important; background: #f8fafc; border-radius: 8px; }
.ivd--modern .ivd-items th { background: transparent; border-bottom: 2px solid var(--ivd-ink); }
.ivd--modern .ivd-trow.ivd-total { border-top-color: var(--ivd-accent); }
.ivd--modern .ivd-trow.ivd-balance, .ivd--modern .ivd-trow.ivd-total:last-child {
  background: var(--ivd-accent); color: var(--ivd-accent-ink); padding: 11px 12px; border-radius: 6px; border-top: 0;
}

/* ---- classic: a ruled grid, like a printed tax-invoice pad ---- */
.ivd--classic { --ivd-rule: #9ca3af; --ivd-pad: 32px; border-radius: 0; }
.ivd--classic .ivd-head { border: 1px solid var(--ivd-ink); border-bottom: 0; padding: 14px 16px; margin: 0; }
.ivd--classic .ivd-title { color: var(--ivd-ink); font-size: 20px; letter-spacing: .12em; }
.ivd--classic .ivd-titlebox { text-align: center; border-left: 1px solid var(--ivd-ink); padding-left: 18px; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.ivd--classic .ivd-head-flip .ivd-titlebox { border-left: 0; border-right: 1px solid var(--ivd-ink); padding: 0 18px 0 0; }
.ivd--classic .ivd-parties { border: 1px solid var(--ivd-ink); }
.ivd--classic .ivd-party, .ivd--classic .ivd-details { padding: 10px 12px; }
.ivd--classic .ivd-party + .ivd-party, .ivd--classic .ivd-party + .ivd-details { border-left: 1px solid var(--ivd-ink); }
.ivd--classic .ivd-items { margin-top: 0; }
.ivd--classic .ivd-items th, .ivd--classic .ivd-items td { border: 1px solid var(--ivd-ink); padding: 6px 7px; }
.ivd--classic .ivd-items th { background: #f3f4f6; color: var(--ivd-ink); border-top: 0; }
.ivd--classic .ivd-summary { margin: 0; gap: 0; border: 1px solid var(--ivd-ink); border-top: 0; grid-template-columns: 1fr 290px; }
.ivd--classic .ivd-summary-side { padding: 10px 12px; }
.ivd--classic .ivd-totals { border-left: 1px solid var(--ivd-ink); }
.ivd--classic .ivd-trow { padding: 5px 10px; border-bottom: 1px solid var(--ivd-rule); margin: 0; }
.ivd--classic .ivd-trow.ivd-total { border-top: 0; border-bottom: 1px solid var(--ivd-ink); background: #f3f4f6; font-size: 13px; }
.ivd--classic .ivd-trow.ivd-balance { border-radius: 0; background: #f3f4f6; }
.ivd--classic .ivd-pay { margin: 0; border: 1px solid var(--ivd-ink); border-top: 0; border-radius: 0; padding: 10px 12px; }
.ivd--classic .ivd-taxsum { margin-top: 0; }
.ivd--classic .ivd-taxsum th, .ivd--classic .ivd-taxsum td { border-color: var(--ivd-ink); border-top: 0; }
.ivd--classic .ivd-foot { margin-top: 0; padding: 10px 12px; border: 1px solid var(--ivd-ink); border-top: 0; }
.ivd--classic .ivd-label { color: var(--ivd-ink-2); }

/* ---- minimal: no fills, thin rules ---- */
.ivd--minimal { --ivd-pad: 56px; }
.ivd--minimal .ivd-title { color: var(--ivd-ink); font-weight: 300; font-size: 34px; letter-spacing: .06em; }
.ivd--minimal .ivd-logo-mark { background: var(--ivd-ink); color: #fff; }
.ivd--minimal .ivd-parties { border-top: 0; border-bottom: 0; margin-top: 8px; }
.ivd--minimal .ivd-party + .ivd-party, .ivd--minimal .ivd-party + .ivd-details { border-left: 0; }
.ivd--minimal .ivd-items th { background: transparent; border-bottom: 1px solid var(--ivd-ink); color: var(--ivd-muted); font-weight: 600; }
.ivd--minimal .ivd-trow.ivd-total { border-top: 1px solid var(--ivd-ink); }
.ivd--minimal .ivd-trow.ivd-balance { background: transparent; padding: 10px 0; border-top: 1px solid var(--ivd-rule); border-radius: 0; }
.ivd--minimal .ivd-pay { border: 0; padding: 0; }
.ivd--minimal .ivd-foot { border-top: 0; }

/* ---- compact: small type, tight rows ---- */
.ivd--compact { --ivd-pad: 30px; --ivd-fs: 10px; }
.ivd--compact .ivd-head { padding-bottom: 14px; }
.ivd--compact .ivd-title { font-size: 20px; }
.ivd--compact .ivd-org-name { font-size: 13.5px; }
.ivd--compact .ivd-party, .ivd--compact .ivd-details { padding-top: 10px; padding-bottom: 10px; }
.ivd--compact .ivd-items { margin-top: 12px; }
.ivd--compact .ivd-items th { padding: 6px 6px; }
.ivd--compact .ivd-items td { padding: 5px 6px; }
.ivd--compact .ivd-item-desc { font-size: 9.5px; margin-top: 0; }
.ivd--compact .ivd-summary { margin-top: 10px; gap: 22px; grid-template-columns: 1fr 260px; }
.ivd--compact .ivd-trow { padding: 3px 0; }
.ivd--compact .ivd-foot { margin-top: 16px; padding-top: 12px; }

/* ---- bold: an accent rail and a big amount-due panel ---- */
.ivd--bold { padding-left: calc(var(--ivd-pad) + 16px); }
.ivd-rail { position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--ivd-accent); }
.ivd--bold .ivd-title { font-size: 40px; letter-spacing: -.02em; color: var(--ivd-ink); text-transform: none; }
.ivd--bold .ivd-due-panel { margin-top: 14px; padding: 12px 16px; border-radius: 10px; background: var(--ivd-accent); color: var(--ivd-accent-ink); text-align: right; }
.ivd--bold .ivd-due-label { font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.ivd--bold .ivd-due-amount { font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.ivd--bold .ivd-due-date { font-size: 10px; opacity: .85; }
.ivd--bold .ivd-items th { background: var(--ivd-ink); color: #fff; border-bottom: 0; }
.ivd--bold .ivd-trow.ivd-total { border-top: 3px solid var(--ivd-accent); }

/* =================================================================== screen sizes & print */
@media screen and (max-width: 720px) {
  .ivd { --ivd-pad: 20px; }
  .ivd-head { flex-direction: column; }
  .ivd-head-flip { flex-direction: column; }
  .ivd-titlebox { text-align: left; }
  .ivd-parties, .ivd-parties.has-ship { grid-template-columns: 1fr; }
  .ivd-party + .ivd-party, .ivd-party + .ivd-details { border-left: 0 !important; padding-left: 0; border-top: 1px solid var(--ivd-rule); }
  .ivd--modern .ivd-party + .ivd-party, .ivd--modern .ivd-party + .ivd-details { padding-left: 16px; }
  .ivd-items { display: block; overflow-x: auto; }
  .ivd-summary, .ivd-foot { grid-template-columns: 1fr; }
}

/* Scaled-down previews in the template gallery. */
.ivd-thumb { position: relative; height: 300px; overflow: hidden; background: #eef0f4; border-radius: 10px; }
.ivd-thumb > .ivd-thumb-inner { position: absolute; left: 50%; top: 14px; width: 820px; transform: translateX(-50%) scale(.3); transform-origin: top center; pointer-events: none; }
.ivd-thumb .ivd { max-width: none; }

/* ---- export endorsement (shared/invoice-template.js) ---- */
.ivd-export {
  margin-top: 14px; padding: 9px 12px; border: 1px dashed var(--ivd-accent-line); border-radius: 6px;
  background: var(--ivd-accent-soft); color: var(--ivd-ink); font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.ivd--classic .ivd-export { margin: 0; border: 1px solid var(--ivd-ink); border-top: 0; border-radius: 0; }
.ivd--minimal .ivd-export { background: transparent; border-style: solid; border-color: var(--ivd-rule); }
