/* The printed document: live preview, downloaded PDF and the 14 themes.
   Colours and fonts are pinned here so changes to the app interface never
   change what the customer receives. */

.print-page {
  --navy: #0c1222;
  --muted: #64748b;
  --line: #d7e0ea;
  --mono: "JetBrains Mono", Consolas, monospace;
  --doc-accent: var(--navy);
  --doc-soft: #e8eef4;
  --doc-total: #f0f9ff;
  font-family: Outfit, "Segoe UI", sans-serif;
  color: #1a2f4a;
  line-height: 1.5;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  min-height: 640px;
}

.print-page .muted { color: var(--muted); }
.print-page p { margin: 0; }

.letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 3px solid var(--navy);
  padding-bottom: 12px;
  margin-bottom: 18px;
}

.letterhead .logo { font-size: 22px; font-weight: 800; color: var(--navy); }
.letterhead .tag { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.document-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.document-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 8px;
}

.doc-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.doc-head h1 { font-size: 28px; line-height: 1.2; margin: 0; letter-spacing: 0; }
.meta { text-align: right; color: var(--muted); font-size: 13px; }
.meta strong { color: var(--navy); }

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.party-label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.party-name { font-weight: 800; color: var(--navy); }

.print-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.print-table th, .print-table td { border: 1px solid #94a3b8; padding: 8px 10px; text-align: left; }
.print-table th { background: #e8eef4; color: var(--navy); text-transform: uppercase; font-size: 11px; }
.print-page .amount { text-align: right; white-space: nowrap; }
.total-row { font-weight: 800; background: #f0f9ff; }

.bank-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-left: 4px solid var(--navy);
  padding: 12px 14px;
  margin: 8px 0 16px;
  font-size: 13px;
}

/* A4 at 96dpi. The preview stage scales this box to fit narrow screens. */
.page-scaler { width: 794px; transform-origin: top left; }
.page-scaler .print-page { width: 794px; min-height: 1122px; }

/* html2canvas renders an empty canvas for elements parked off-screen, so the
   capture sits at the top of the document behind the page background. */
.pdf-capture {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  width: 794px;
  background: #fff;
}
.pdf-capture .print-page {
  width: 794px;
  min-height: 0;
  box-shadow: none;
}

/* Printable document themes */
.print-page .letterhead { border-color: var(--doc-accent); }
.print-page .letterhead .logo,
.print-page .doc-head h1,
.print-page .meta strong,
.print-page .party-name { color: var(--doc-accent); }
.print-page .print-table th { background: var(--doc-soft); color: var(--doc-accent); }
.print-page .total-row { background: var(--doc-total); }
.print-page .bank-box { border-left-color: var(--doc-accent); }

.theme-modern {
  --doc-accent: #2563eb;
  --doc-soft: #dbeafe;
  --doc-total: #eff6ff;
  border-top: 10px solid #2563eb;
}
.theme-modern .letterhead { border-bottom-width: 1px; }
.theme-modern .doc-head h1 {
  background: #2563eb;
  color: #fff;
  padding: 7px 14px;
  border-radius: 6px;
  letter-spacing: .04em;
}
.theme-modern .print-table th, .theme-modern .print-table td { border-color: #bfdbfe; }

.theme-elegant {
  --doc-accent: #6b4f3a;
  --doc-soft: #f2ebe3;
  --doc-total: #faf7f2;
  font-family: Georgia, "Times New Roman", serif;
  border-color: #c9b8a7;
}
.theme-elegant .letterhead { border-bottom: 1px solid #6b4f3a; }
.theme-elegant .letterhead .logo { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.theme-elegant .doc-head h1 { font-weight: 500; letter-spacing: .12em; }
.theme-elegant .print-table th { letter-spacing: .08em; }
.theme-elegant .print-table th, .theme-elegant .print-table td { border-color: #c9b8a7; }

.theme-minimal {
  --doc-accent: #111827;
  --doc-soft: #fff;
  --doc-total: #f9fafb;
  border: 0;
  border-radius: 0;
}
.theme-minimal .letterhead { border-bottom: 1px solid #111827; }
.theme-minimal .print-table th,
.theme-minimal .print-table td {
  border-width: 0 0 1px;
  border-color: #d1d5db;
}
.theme-minimal .print-table th { text-align: left; }
.theme-minimal .bank-box { background: #fff; border-width: 1px 0; border-color: #d1d5db; }

.theme-forest {
  --doc-accent: #166534;
  --doc-soft: #dcfce7;
  --doc-total: #f0fdf4;
  border-top: 8px solid #166534;
}
.theme-forest .print-table th, .theme-forest .print-table td { border-color: #86efac; }
.theme-forest .bank-box { background: #f0fdf4; border-color: #bbf7d0; }

.theme-coral {
  --doc-accent: #9a3412;
  --doc-soft: #ffedd5;
  --doc-total: #fff7ed;
  border-top: 8px solid #ea580c;
}
.theme-coral .letterhead { border-bottom-width: 2px; }
.theme-coral .print-table th, .theme-coral .print-table td { border-color: #fdba74; }
.theme-coral .bank-box { background: #fff7ed; border-color: #fed7aa; }

.theme-midnight {
  --doc-accent: #e2e8f0;
  --doc-soft: #1e293b;
  --doc-total: #0f172a;
  background: #fff;
  border: 1px solid #0f172a;
}
.theme-midnight .letterhead {
  background: #0f172a;
  color: #e2e8f0;
  border-bottom: 0;
  margin: -28px -28px 18px;
  padding: 22px 28px 16px;
  border-radius: 8px 8px 0 0;
}
.theme-midnight .letterhead .logo,
.theme-midnight .letterhead .tag,
.theme-midnight .doc-head h1,
.theme-midnight .meta strong,
.theme-midnight .party-name { color: #0f172a; }
.theme-midnight .letterhead .logo,
.theme-midnight .letterhead .tag { color: #f8fafc; }
.theme-midnight .doc-head h1 { color: #0f172a; }
.theme-midnight .print-table th { background: #0f172a; color: #f8fafc; }
.theme-midnight .total-row { background: #e2e8f0; color: #0f172a; }
.theme-midnight .bank-box { background: #0f172a; color: #e2e8f0; border-color: #0f172a; }

.theme-slate {
  --doc-accent: #0f766e;
  --doc-soft: #ccfbf1;
  --doc-total: #f0fdfa;
  border-left: 8px solid #0f766e;
}
.theme-slate .letterhead { border-bottom: 2px solid #0f766e; }
.theme-slate .print-table th, .theme-slate .print-table td { border-color: #99f6e4; }
.theme-slate .bank-box { background: #f0fdfa; border-color: #99f6e4; }

.theme-noir {
  --doc-accent: #0a0a0a;
  --doc-soft: #fff;
  --doc-total: #0a0a0a;
  border: 1px solid #0a0a0a;
  padding: 34px;
}
.theme-noir .letterhead { border-bottom: 1px solid #0a0a0a; padding-bottom: 18px; }
.theme-noir .letterhead .logo {
  font-weight: 400;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: 18px;
}
.theme-noir .doc-head h1 {
  font-weight: 300;
  letter-spacing: .34em;
  font-size: 22px;
}
.theme-noir .party-label { letter-spacing: .22em; }
.theme-noir .print-table th {
  background: #fff;
  border-width: 0 0 1px;
  border-color: #0a0a0a;
  letter-spacing: .18em;
  font-weight: 600;
}
.theme-noir .print-table td { border-width: 0 0 1px; border-color: #e5e5e5; }
.theme-noir .total-row { background: #0a0a0a; color: #fff; }
.theme-noir .total-row td { border-color: #0a0a0a; }
.theme-noir .bank-box { background: #fff; border: 1px solid #0a0a0a; border-left-width: 1px; }

.theme-ledger {
  --doc-accent: #1e3a5f;
  --doc-soft: #eef2f7;
  --doc-total: #dde7f3;
  border-color: #c3d0e0;
}
.theme-ledger .letterhead { border-bottom: 2px double #1e3a5f; }
.theme-ledger .meta, .theme-ledger .amount, .theme-ledger .totals {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.theme-ledger .print-table { font-size: 12.5px; }
.theme-ledger .print-table th {
  border-width: 1px 0;
  border-color: #1e3a5f;
  letter-spacing: .1em;
}
.theme-ledger .print-table td { border-width: 0 0 1px; border-color: #d4dce8; }
.theme-ledger .print-table tbody tr:nth-child(even) td { background: #f7f9fc; }
.theme-ledger .total-row { border-top: 2px double #1e3a5f; }
.theme-ledger .bank-box { background: #f7f9fc; border-color: #c3d0e0; }

.theme-aurora {
  --doc-accent: #4c1d95;
  --doc-soft: #ede9fe;
  --doc-total: #f5f3ff;
  border: 0;
  box-shadow: 0 0 0 1px #e9d5ff;
}
.theme-aurora .letterhead {
  background: linear-gradient(110deg, #4338ca, #7c3aed 55%, #c026d3);
  margin: -28px -28px 22px;
  padding: 26px 28px 20px;
  border: 0;
  border-radius: 8px 8px 0 0;
}
.theme-aurora .letterhead .logo, .theme-aurora .letterhead .tag { color: #fff; }
.theme-aurora .letterhead .muted { color: rgba(255, 255, 255, .82); }
.theme-aurora .doc-head h1 { font-weight: 800; }
.theme-aurora .print-table th { border-color: #ddd6fe; }
.theme-aurora .print-table td { border-color: #ede9fe; }
.theme-aurora .bank-box { background: #f5f3ff; border-color: #ddd6fe; }

.theme-sandstone {
  --doc-accent: #7c5c34;
  --doc-soft: #f1e7d8;
  --doc-total: #faf5ec;
  font-family: "Iowan Old Style", Georgia, serif;
  background: #fffdf8;
  border-color: #e2d3bb;
}
.theme-sandstone .letterhead {
  border-bottom: 1px solid #c9b391;
  align-items: flex-start;
}
.theme-sandstone .letterhead .logo {
  font-family: inherit;
  font-weight: 600;
  font-size: 25px;
}
.theme-sandstone .doc-head h1 {
  font-family: inherit;
  font-weight: 400;
  font-style: italic;
  letter-spacing: .04em;
}
.theme-sandstone .print-table th {
  background: #f1e7d8;
  border-color: #dfcdb0;
  font-variant: small-caps;
  text-transform: none;
  letter-spacing: .06em;
  font-size: 12px;
}
.theme-sandstone .print-table td { border-color: #e6d9c2; }
.theme-sandstone .bank-box { background: #faf5ec; border-color: #dfcdb0; }

.theme-plum {
  --doc-accent: #6b1839;
  --doc-soft: #f6e6ec;
  --doc-total: #fdf4f7;
  border-color: #e4c3d1;
}
.theme-plum .letterhead {
  border-bottom: 3px solid #6b1839;
  position: relative;
}
.theme-plum .letterhead .tag { color: #9d2f5a; }
.theme-plum .doc-head h1 {
  border-left: 5px solid #9d2f5a;
  padding-left: 12px;
  letter-spacing: .08em;
}
.theme-plum .print-table th { border-color: #e4c3d1; letter-spacing: .1em; }
.theme-plum .print-table td { border-color: #f0dbe3; }
.theme-plum .bank-box { background: #fdf4f7; border-color: #e4c3d1; }

.theme-nordic {
  --doc-accent: #37506b;
  --doc-soft: #eff3f7;
  --doc-total: #f7fafc;
  border-color: #dde5ec;
  padding: 38px;
  line-height: 1.7;
}
.theme-nordic .letterhead {
  display: block;
  border-bottom: 1px solid #dde5ec;
  padding-bottom: 20px;
  margin-bottom: 26px;
}
.theme-nordic .letterhead .tag { display: block; margin-top: 10px; letter-spacing: .24em; }
.theme-nordic .letterhead .logo { font-weight: 600; letter-spacing: .02em; }
.theme-nordic .doc-head h1 { font-weight: 500; letter-spacing: .2em; font-size: 24px; }
.theme-nordic .party-label { letter-spacing: .18em; }
.theme-nordic .print-table th {
  background: transparent;
  border-width: 0 0 1px;
  border-color: #37506b;
  letter-spacing: .14em;
}
.theme-nordic .print-table td { border-width: 0 0 1px; border-color: #e8eef3; padding: 11px 10px; }
.theme-nordic .bank-box { background: #f7fafc; border-color: #dde5ec; }

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

@media print {
  .print-page {
    border: none !important;
    box-shadow: none !important;
    padding: 18mm 16mm;
    min-height: auto;
  }
}
