/* ==========================================================================
   3. A4 LIVE PREVIEW SHEET BASE STYLES
   ========================================================================== */
.sheet {
  width: var(--sheet-w);
  min-height: var(--sheet-h);
  height: auto;
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 4px;
  position: relative;
  box-sizing: border-box;
}

/* PDF Export Clean Mode */
.rendering-pdf {
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.rendering-pdf.sheet-wrap {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.rendering-pdf .sheet-page-divider,
.rendering-pdf .preview-label {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.rendering-pdf.page-2-container,
.rendering-pdf .page-2-container {
  margin: 0 !important;
  padding: 0 !important;
}

.rendering-pdf.sheet,
.rendering-pdf.sheet-page-card,
.rendering-pdf .sheet,
.rendering-pdf .sheet-page-card {
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  height: 1123px !important;
  min-height: 1123px !important;
  max-height: 1123px !important;
  overflow: hidden !important;
}

/* Seller Block Header */
.seller-block {
  display: flex;
  flex-direction: column;
}

.invoice-logo {
  max-height: 48px;
  max-width: 170px;
  object-fit: contain;
  margin-bottom: 8px;
  display: none;
  align-self: flex-start;
}

.invoice-logo.show {
  display: block;
}

.seller-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
}

.seller-detail {
  font-size: 11px;
  color: var(--muted);
  white-space: pre-line;
  margin-top: 4px;
}

/* Document Title Header */
.invoice-title {
  display: flex;
  flex-direction: column;
}

.invoice-title h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0 0 2px;
}

.invoice-subtitle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: none;
}

.invoice-subtitle.show {
  display: block;
}

.invoice-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.status {
  display: inline-block;
  align-self: flex-end;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
}

.status.paid {
  background: var(--greenbg);
  color: var(--green);
}

.status.unpaid {
  background: var(--amberbg);
  color: var(--amber);
}

/* Meta Information Section (Bill to & Dates) */
.meta {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin-top: 73px;
  margin-bottom: 20px;
}

.meta h3 {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.client-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.client-detail {
  font-size: 11px;
  color: var(--muted);
  white-space: pre-line;
  margin-top: 2px;
}

.date-grid {
  display: flex;
  gap: 24px;
}

.date-label {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);

}

.date-value {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
}

/* Quotation Specific Text Blocks */
.quotation-intro {
  font-size: 11px;
  color: #334155;
  line-height: 1.6;
  margin: 12px 0 16px;
  white-space: pre-line;
}

.quotation-closing {
  font-size: 11px;
  color: #334155;
  line-height: 1.6;
  margin: 16px 0 12px;
  white-space: pre-line;
}

/* Items Table */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.invoice-table th {
  text-align: left;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.invoice-table th.num,
.invoice-table td.num {
  text-align: right;
}

/* Keep numerical column headings and values aligned consistently in every template. */
.invoice-table th:not(:first-child) {
  text-align: center;
}

.invoice-table th:nth-child(3),
.invoice-table th:last-child {
  text-align: center !important;
}

/* Price and amount labels align with the right edge of their monetary values. */
.invoice-table #p-th-price,
.invoice-table #p-th-amount {
  text-align: right !important;
}

/* Fixed proportional columns keep each value on its intended visual guide. */
.invoice-table th:first-child {
  width: 35%;
}

.invoice-table th:nth-child(2) {
  width: 7%;
  text-align: center !important;
}

.invoice-table th:nth-child(3) {
  width: 18%;
  text-align: right !important;
}

.invoice-table th:nth-child(4) {
  width: 16%;
  text-align: right !important;
}

.invoice-table th:last-child {
  width: 24%;
  text-align: right !important;
}

.invoice-table td.num:not(:last-child) {
  text-align: center;
}

.invoice-table td.num:nth-child(3) {
  text-align: right !important;
}

.invoice-table td.num:nth-child(4):not(:last-child) {
  text-align: right !important;
}

.invoice-table td.num:last-child {
  text-align: right;
}

.invoice-table td {
  padding: 5.5px 8px;
  font-size: 11.5px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

.invoice-table td .desc {
  white-space: pre-line;
  color: var(--accent);
}

.empty-table {
  text-align: center;
  color: var(--muted);
  padding: 24px 0 !important;
  font-style: italic;
}

/* Summary Area */
.summary-area {
  display: flex;
  justify-content: flex-end;
}

.summary {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}

.sum-row.total {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  border-top: 2px solid var(--accent);
  padding-top: 6px;
  margin-top: 4px;
}

.words {
  font-size: 10px;
  font-style: italic;
  color: var(--muted);
  text-align: right;
  margin-top: 2px;
}

/* Bank Account Inline Details & Notes */
.notes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notes h3 {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.notes p {
  font-size: 11px;
  color: var(--muted);
  white-space: pre-line;
}

/* Separate payment instructions and contractual notes into distinct blocks. */
.main-notes {
  align-items: flex-start;
  gap: 30px;
  max-width: 310px;
}

.main-notes .payment-info-block,
.main-notes .terms-condition-block {
  width: 100%;
}

.main-notes .notes-subheading {
  margin: 0 0 8px;
  color: #172033;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.main-notes .bank-inline-wrap {
  margin: 0;
}

.main-notes .bank-inline-content {
  display: block;
}

.main-notes .account-num::before {
  content: ' - ';
  font-family: inherit;
  font-weight: 400;
  color: var(--muted);
}

.main-notes .bank-primary-row {
  display: block;
}

.main-notes #p-bank-extra-wrap-notes::before {
  content: '\A';
  white-space: pre;
}

.bank-inline-wrap {
  display: none;
  font-size: 11px;
  color: #334155;
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 8px;
}

.bank-inline-wrap.show {
  display: block;
}

.bank-inline-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.account-num {
  font-family: monospace;
  font-weight: 700;
  color: #0f172a;
}

/* Signature Block */
.signature-wrap {
  display: flex;
  justify-content: flex-end;
  align-self: end !important;
  margin-top: auto !important;
  padding-top: 4px;
  break-inside: avoid !important;
  page-break-inside: avoid !important;
}

.signature-wrap.force-page-break {
  break-before: page !important;
  page-break-before: always !important;
  margin-top: 40px !important;
}

.signature-block {
  text-align: center;
  width: 200px;
}

.signature-date {
  font-size: 10px;
  color: #6b7280;
  margin-bottom: 2px;
}

.signature-label {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 2px;
}

.signature-image-container {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 1px 0;
}

.signature-img {
  width: 100%;
  height: 100%;
  max-width: 170px;
  max-height: 44px;
  object-fit: contain;
  object-position: center;
  display: none;
}

.signature-img.show {
  display: block;
}

.signer-name {
  font-size: 12px;
  font-weight: 700;
  color: #172033;
  text-decoration: underline;
  margin-top: 4px;
}

.signer-title {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
}

/* General Footer (for Modern Slate & Minimal Classic) */
.footer,
.page-footer-copy {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 10px;
  color: #64748b;
  box-sizing: border-box;
}

.footer-top-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.footer-questions-title {
  font-weight: 800;
  font-size: 11px;
  color: #1e293b;
}

.footer-questions-text {
  display: flex;
  flex-direction: column;
  font-size: 10px;
  color: #64748b;
  line-height: 1.4;
}

.footer-questions-text strong {
  color: #334155;
  font-weight: 600;
}

.footer-bottom-row {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-address {
  color: #94a3b8;
  font-size: 9.5px;
}

.footer-contact-pills {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  color: #64748b;
}

/* ==========================================================================
   A4 VISUAL PAGE BREAK INDICATOR (FOR LIVE PREVIEW)
   ========================================================================== */
.page-break-indicator {
  position: absolute;
  left: -20px;
  right: -20px;
  height: 0;
  pointer-events: none;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-break-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px dashed #3b82f6;
  opacity: 0.75;
}

.page-break-badge {
  position: relative;
  background: #0f172a;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  border: 1px solid #334155;
  text-transform: uppercase;
}

.page-count-badge {
  display: inline-flex;
  align-items: center;
  background: #e2e8f0;
  color: #334155;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   MULTI-PAGE SEPARATE A4 SHEET CARDS STYLES
   ========================================================================== */
.page-2-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.sheet-page-card {
  width: var(--sheet-w);
  min-height: var(--sheet-h);
  height: var(--sheet-h);
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 2px;
  position: relative;
  box-sizing: border-box;
}

.sheet-page-divider {
  width: var(--sheet-w);
  height: 48px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
}

.running-header {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
  margin-bottom: 24px;
}

.rh-seller {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #0f172a;
  text-transform: uppercase;
}

.rh-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.04em;
}

.page-2-content-slot {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  height: 100%;
  min-height: 860px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media print {
  .page-break-indicator,
  .sheet-page-divider {
    display: none !important;
  }
}