/* Invoice document — preview, print, PDF */

.invoice-doc {
  font-family: var(--inv-font, system-ui, sans-serif);
  color: #1a1a1a;
  background: #fff;
  font-size: 11pt;
  line-height: 1.45;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  border-radius: 2px;
}

.inv-page {
  padding: 12mm 14mm;
  box-sizing: border-box;
}

.preview-container .inv-page {
  min-height: 277mm;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.inv-header-left {
  flex: 1;
  min-width: 0;
}

.inv-logo {
  max-height: 56px;
  max-width: 180px;
  object-fit: contain;
  margin-bottom: 12px;
  display: block;
}

.inv-party-details {
  font-size: 10pt;
  color: #444;
  line-height: 1.5;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.inv-party-first {
  font-weight: 700;
}

.inv-sender-name {
  font-weight: 700;
  font-size: 13pt;
  margin-bottom: 4px;
}

.inv-sender-addr,
.inv-sender-contact {
  font-size: 10pt;
  color: #444;
}

.inv-sender-contact {
  margin-top: 6px;
}

.inv-title {
  margin: 0 0 12px;
  font-size: 22pt;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--inv-accent, #2563eb);
  text-align: right;
}

.inv-meta {
  margin-left: auto;
  border-collapse: collapse;
  font-size: 10pt;
}

.inv-header-balance-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.inv-header-balance {
  flex: 1;
  min-width: 0;
}

.inv-meta--balance td {
  font-size: 13pt;
}

.inv-header-balance-value {
  font-weight: 700;
  color: var(--inv-accent, #2563eb);
  font-variant-numeric: tabular-nums;
}

.inv-meta th {
  text-align: right;
  padding: 3px 10px 3px 0;
  font-weight: 500;
  color: #666;
  white-space: nowrap;
  min-height: 1.4em;
}

.inv-meta td {
  text-align: right;
  padding: 3px 0;
  font-weight: 600;
  min-height: 1.4em;
}

.inv-field-slot {
  display: block;
  min-height: 4.5em;
}

.inv-party-details.inv-field-slot {
  min-height: 6em;
}

.inv-heading-slot {
  min-height: 1.2em;
  margin: 0 0 8px;
}

.inv-footer .inv-field-slot {
  min-height: 1.4em;
}

.inv-sum-row {
  min-height: 1.6em;
}

.inv-parties {
  margin-bottom: 20px;
}

.inv-bill-to h2 {
  margin: 0 0 8px;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  font-weight: 600;
}

.inv-client-name {
  font-weight: 700;
  font-size: 12pt;
}

.inv-client-co,
.inv-client-addr,
.inv-client-contact {
  font-size: 10pt;
  color: #444;
}

.inv-items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 10pt;
}

.inv-items thead {
  background: var(--inv-accent, #2563eb);
  color: #fff;
}

.inv-items th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-items td {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

.inv-items .col-qty,
.inv-items .col-price,
.inv-items .col-tax,
.inv-items .col-disc,
.inv-items .col-total {
  width: 72px;
  text-align: right;
  white-space: nowrap;
}

.desc-text {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.inv-summary-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.inv-summary {
  min-width: 240px;
  max-width: 300px;
}

.inv-sum-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 10pt;
  border-bottom: 1px solid #f0f0f0;
}

.inv-sum-row span:last-child {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.inv-sum-bold {
  font-weight: 700;
  font-size: 11pt;
  border-top: 2px solid #333;
  border-bottom: none;
  margin-top: 4px;
  padding-top: 8px;
}

.inv-sum-accent {
  font-weight: 700;
  color: var(--inv-accent, #2563eb);
  border-bottom: none;
  font-size: 12pt;
}

.inv-additional {
  margin-top: 20px;
  font-size: 9.5pt;
  color: #444;
}

.inv-add-block {
  margin-bottom: 14px;
  page-break-inside: avoid;
}

.inv-add-block h3 {
  margin: 0 0 4px;
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
}

.inv-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 9pt;
  color: #888;
  text-align: center;
}

/* Template: Modern (default) */
.tpl-modern .inv-header {
  border-bottom: 3px solid var(--inv-accent, #2563eb);
  padding-bottom: 16px;
}

/* Template: Minimal */
.tpl-minimal .inv-items thead {
  background: transparent;
  color: #333;
  border-bottom: 2px solid #333;
}

.tpl-minimal .inv-items th {
  color: #333;
  padding-left: 0;
}

.tpl-minimal .inv-title {
  color: #111;
  font-weight: 300;
  letter-spacing: 0.12em;
}

.tpl-minimal .inv-items td {
  border-bottom-color: #eee;
  padding-left: 0;
}

/* Template: Professional */
.tpl-professional {
  border: 1px solid #ddd;
}

.tpl-professional .inv-page {
  padding: 10mm 12mm;
}

.tpl-professional .inv-header {
  background: #f8f9fb;
  margin: -10mm -12mm 20px;
  padding: 10mm 12mm 16px;
}

.tpl-professional .inv-items thead {
  background: #2d3748;
}

.tpl-professional .inv-bill-to {
  background: #f8f9fb;
  padding: 12px 14px;
  border-left: 4px solid var(--inv-accent, #2563eb);
}

/* Template: Classic */
.tpl-classic .inv-items {
  border: 1px solid #999;
}

.tpl-classic .inv-items th,
.tpl-classic .inv-items td {
  border: 1px solid #ccc;
}

.tpl-classic .inv-items thead {
  background: #f5f5f5;
  color: #222;
}

.tpl-classic .inv-items th {
  color: #222;
}

.tpl-classic .inv-title {
  color: #222;
  font-family: Georgia, serif;
}

/* Print */
#print-root {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }

  #print-root,
  #print-root * {
    visibility: visible;
  }

  #print-root {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  #print-root .invoice-doc {
    box-shadow: none;
    border-radius: 0;
  }

  #print-root .inv-page {
    min-height: auto;
    page-break-after: always;
  }

  #print-root .inv-row {
    page-break-inside: avoid;
  }

  @page {
    size: A4;
    margin: 10mm;
  }
}

/* PDF export wrapper */
.pdf-export-wrapper {
  position: fixed;
  left: 0;
  top: 0;
  background: #fff;
  z-index: 2147483647;
  overflow: visible;
  pointer-events: none;
}

.pdf-export-wrapper .invoice-doc {
  box-shadow: none;
  overflow: visible;
}

.pdf-export-wrapper .inv-page {
  min-height: auto !important;
  height: auto !important;
  overflow: visible;
}

.pdf-export-wrapper .inv-header-left {
  min-width: auto !important;
  overflow: visible !important;
}

.pdf-export-wrapper .inv-header-right {
  min-width: auto !important;
  overflow: visible !important;
}

.pdf-export-wrapper .inv-title,
.pdf-export-wrapper .inv-items th,
.pdf-export-wrapper .inv-bill-to h2 {
  letter-spacing: normal !important;
  overflow: visible !important;
}

.pdf-export-wrapper .inv-items th {
  white-space: normal !important;
  width: auto !important;
  min-width: 0 !important;
  text-transform: none !important;
}

.pdf-export-wrapper .inv-items td.col-qty,
.pdf-export-wrapper .inv-items td.col-price,
.pdf-export-wrapper .inv-items td.col-tax,
.pdf-export-wrapper .inv-items td.col-disc,
.pdf-export-wrapper .inv-items td.col-total {
  width: auto !important;
  min-width: 48px !important;
}

.pdf-export-wrapper .tpl-professional .inv-header {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.pdf-export-wrapper .tpl-professional {
  border: none !important;
}

.pdf-staging {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 718px;
  pointer-events: none;
  overflow: visible;
}

.pdf-staging .inv-page {
  min-height: auto;
}

.pdf-staging .invoice-doc {
  box-shadow: none;
}
