/* ==========================================================================
   LAKSHMI SALES - Pixel-Perfect Tax Invoice & Estimate Print Engine
   A4 True Sheet Architecture with Responsive Mobile Wrapper & Isolated Print
   ========================================================================== */

/* Outer scrollable canvas for screen view */
.invoice-preview-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
  background: rgba(15, 23, 42, 0.6);
  padding: 16px;
  border-radius: var(--radius-md);
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

[data-theme="light"] .invoice-preview-wrapper {
  background: rgba(226, 232, 240, 0.8);
}

/* Master A4 Sheet Container */
.invoice-sheet,
.memo-sheet-invoice {
  background: #ffffff !important;
  color: #000000 !important;
  width: 100%;
  max-width: 800px;
  min-width: 740px; /* Maintains strict A4 structure without squishing on mobile */
  margin: 0 auto;
  padding: 20px 22px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.memo-sheet-page {
  width: 100%;
  box-sizing: border-box;
}

/* Purchase Order, Cash Memo & Closing Balances Full-Page Auto-Scaling Layout */
.po-sheet-page,
.memo-full-page,
.balances-page-sheet {
  min-height: 260mm;
  display: flex;
  flex-direction: column;
}

.po-box-grid,
.memo-box-grid {
  border: 1.5px solid #000000 !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  width: 100% !important;
  min-height: 260mm;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1 1 auto;
}

.memo-sheet-page + .memo-sheet-page,
.statement-sheet-page + .statement-sheet-page,
.balances-page-sheet + .balances-page-sheet {
  margin-top: 24px;
}

.multi-page-running-header {
  border-bottom: 1.5px solid #000000;
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  background: #fafafa;
}

.invoice-title {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  color: #000000;
}

/* Master Outline Grid */
.invoice-box-grid {
  border: 1.5px solid #000000 !important;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
}

/* Master Outline Grid for Statement, Closing Balances, and General Ledger */
.statement-box-grid,
.balances-box-grid,
.combined-ledger-box-grid,
.gl-box-grid {
  border: 2px solid #000000 !important;
  display: flex;
  flex-direction: column;
  width: 100% !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  padding: 18px 20px;
}

@media screen and (max-width: 640px) {
  .statement-box-grid,
  .balances-box-grid,
  .combined-ledger-box-grid,
  .gl-box-grid {
    padding: 10px 8px !important;
    border-width: 1.5px !important;
  }
}

/* Top Section: Seller Profile & Meta */
.invoice-row-top {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  border-bottom: 1.5px solid #000000 !important;
  width: 100%;
  box-sizing: border-box;
}

.invoice-col-seller {
  padding: 8px 10px;
  border-right: 1.5px solid #000000 !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10.5px;
  box-sizing: border-box;
}

.seller-name {
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: #000000;
  margin-bottom: 2px;
}

.invoice-col-meta {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid #000000 !important;
  flex: 1;
  box-sizing: border-box;
}

.meta-row:last-child {
  border-bottom: none !important;
}

.meta-row.full-width {
  display: block;
}

.meta-cell {
  padding: 5px 8px;
  border-right: 1px solid #000000 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

.meta-cell:last-child,
.meta-cell.full-width {
  border-right: none !important;
}

.meta-label {
  font-size: 9px;
  color: #333333;
  font-weight: 600;
  display: block;
}

.meta-val {
  font-size: 11px;
  font-weight: 700;
  color: #000000;
}

/* Buyer & Consignee Section */
.invoice-row-buyer {
  padding: 0 !important;
  border-bottom: 1.5px solid #000000 !important;
  display: flex;
  flex-direction: row;
  width: 100%;
  box-sizing: border-box;
}

.invoice-col-buyer {
  flex: 1;
  padding: 8px 10px;
  border-right: 1.5px solid #000000 !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10.5px;
  box-sizing: border-box;
}

.invoice-col-buyer:last-child {
  border-right: none !important;
}

.buyer-title {
  font-size: 9px;
  color: #444444;
  font-weight: 600;
}

.buyer-name {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: #000000;
  margin-bottom: 1px;
}

/* Table of Goods & Services */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  table-layout: fixed;
  box-sizing: border-box;
  margin: 0;
}

.invoice-table th {
  border-bottom: 1.5px solid #000000 !important;
  border-right: 1px solid #000000 !important;
  padding: 6px 4px;
  font-size: 9.5px;
  font-weight: 800;
  text-align: center;
  background: #f8f9fa !important;
  color: #000000 !important;
  box-sizing: border-box;
  line-height: 1.2;
}

.invoice-table th:last-child {
  border-right: none !important;
}

.invoice-table td {
  border-right: 1px solid #000000 !important;
  padding: 6px 5px;
  font-size: 10.5px;
  vertical-align: top;
  box-sizing: border-box;
  color: #000000 !important;
}

.invoice-table td:last-child {
  border-right: none !important;
}

.invoice-table .item-row {
  min-height: auto;
}

.memo-table .item-row,
.po-table .item-row {
  min-height: auto !important;
  height: auto !important;
}

/* Format 2: Continuous Column Grid Spacer & Table Fit */
.po-table,
.memo-table {
  height: 100% !important;
  border-collapse: collapse !important;
}

.grid-spacer-row {
  height: 100% !important;
}

.grid-spacer-row td {
  padding: 0 !important;
  height: 100% !important;
  border-top: none !important;
  border-bottom: none !important;
  background: transparent !important;
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-bold { font-weight: 800 !important; }

.item-desc-title {
  font-weight: 800;
  text-transform: uppercase;
  color: #000000;
}

.item-desc-sub {
  font-size: 9.5px;
  color: #333333;
  margin-top: 2px;
  font-weight: 600;
}

/* Totals Row */
.invoice-total-row {
  border-top: 1.5px solid #000000 !important;
  border-bottom: 1px solid #000000 !important;
  font-weight: 800;
  background: #fdfdfd !important;
}

.invoice-total-row td {
  padding: 5px 6px;
  font-size: 11px;
}

/* Amount in Words Box */
.invoice-words-box {
  padding: 6px 10px;
  border-top: 1.5px solid #000000 !important;
  border-bottom: 1.5px solid #000000 !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fafafa !important;
  box-sizing: border-box;
}

.words-label {
  font-size: 9px;
  color: #333333;
}

.words-text {
  font-size: 10.5px;
  font-weight: 800;
  color: #000000;
}

/* Footer Information Grid */
.invoice-footer-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  border-bottom: 1px solid #000000 !important;
  box-sizing: border-box;
  width: 100%;
}

.footer-left {
  padding: 8px 10px;
  border-right: 1.5px solid #000000 !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  box-sizing: border-box;
}

.footer-right {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  min-height: 105px;
  font-size: 10px;
  box-sizing: border-box;
}

.bank-details-box {
  font-size: 9.5px;
  line-height: 1.45;
  text-align: left;
}

.declaration-box {
  font-size: 8.5px;
  color: #222222;
  line-height: 1.3;
}

.signatory-box {
  font-size: 10px;
  font-weight: 800;
  text-align: right;
}

.bottom-note {
  text-align: center;
  font-size: 9px;
  padding: 4px 8px;
  color: #444444;
  background: #fcfcfc;
  box-sizing: border-box;
}

/* Mobile Scroll Indicator Banner (Hidden by Default) */
.mobile-scroll-hint {
  display: none !important;
}

/* Memo Live & Static Preview Toolbar Styling */
.memo-preview-modal-container {
  width: 100%;
}

.memo-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-glass);
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  flex-wrap: wrap;
  gap: 0.75rem;
  box-sizing: border-box;
}

.memo-preview-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.memo-preview-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.memo-preview-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.memo-preview-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.memo-preview-row1,
.memo-preview-row2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.memo-orient-group {
  display: flex;
  background: var(--bg-glass-card);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
}

.memo-orient-group .btn {
  font-size: 0.8rem;
  padding: 5px 12px;
  font-weight: 700;
  white-space: nowrap;
}

.memo-close-btn {
  font-weight: 700;
  padding: 6px 14px;
  color: #f87171 !important;
  border: 1px solid rgba(248, 113, 113, 0.4) !important;
  background: rgba(239, 68, 68, 0.08) !important;
  white-space: nowrap;
}

.memo-close-btn:hover {
  background: rgba(239, 68, 68, 0.2) !important;
}

.memo-nup-select {
  width: 155px;
  font-size: 0.82rem;
  height: 36px;
  padding: 2px 8px;
  font-weight: 700;
}

.memo-print-btn {
  font-weight: 700;
  padding: 6px 16px;
  white-space: nowrap;
}

@media (max-width: 992px) {
  .invoice-preview-wrapper {
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}

@media screen and (max-width: 768px) {
  #liveMemoPreviewOverlay {
    padding: 0.5rem !important;
  }
  
  #liveMemoPreviewOverlay .modal-container {
    max-height: 98vh !important;
    border-radius: var(--radius-md) !important;
  }

  .memo-preview-toolbar {
    padding: 0.75rem 0.6rem !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.6rem !important;
  }

  .memo-preview-title {
    font-size: 0.95rem !important;
  }

  .memo-preview-sub {
    font-size: 0.75rem !important;
  }

  .memo-preview-controls {
    width: 100% !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  /* Row 1: Orientation Switcher + Close Preview */
  .memo-preview-row1 {
    width: 100% !important;
    display: flex !important;
    gap: 0.5rem !important;
    justify-content: space-between !important;
  }

  .memo-preview-row1 .memo-orient-group {
    flex: 1 1 auto !important;
    display: flex !important;
  }

  .memo-preview-row1 .memo-orient-group .btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 7px 6px !important;
    font-size: 0.78rem !important;
  }

  .memo-preview-row1 .memo-close-btn {
    flex: 0 0 auto !important;
    padding: 7px 12px !important;
    font-size: 0.8rem !important;
  }

  /* Row 2: N-Up Select + Print Now */
  .memo-preview-row2 {
    width: 100% !important;
    display: flex !important;
    gap: 0.5rem !important;
    justify-content: space-between !important;
  }

  .memo-preview-row2 .memo-nup-select {
    flex: 1 1 50% !important;
    width: auto !important;
    height: 38px !important;
    font-size: 0.82rem !important;
  }

  .memo-preview-row2 .memo-print-btn {
    flex: 1 1 50% !important;
    justify-content: center !important;
    height: 38px !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
  }

  .invoice-preview-wrapper {
    padding: 6px 2px;
    background: transparent;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block !important;
    width: 100% !important;
  }

  .invoice-sheet,
  .memo-sheet-invoice {
    min-width: 100% !important;
    max-width: 100% !important;
    padding: 10px 8px !important;
    font-size: 9.5px !important;
    line-height: 1.3 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
    background: #ffffff !important;
    border: none !important;
    border-radius: 4px !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
  }

  .invoice-title {
    font-size: 13px !important;
    padding: 4px 0 !important;
    margin-bottom: 6px !important;
  }

  .invoice-row-top {
    grid-template-columns: 1fr !important;
  }

  .invoice-col-seller {
    border-right: none !important;
    border-bottom: 1.5px solid #000000 !important;
    padding: 6px 8px !important;
  }

  .invoice-row-buyer {
    flex-direction: column !important;
  }

  .invoice-col-buyer {
    border-right: none !important;
    border-bottom: 1px solid #000000 !important;
    padding: 6px 8px !important;
  }

  .invoice-col-buyer:last-child {
    border-bottom: none !important;
  }

  .invoice-table th {
    padding: 4px 2px !important;
    font-size: 8px !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    line-height: 1.15 !important;
  }

  .invoice-table td {
    padding: 4px 2.5px !important;
    font-size: 8.5px !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  .invoice-table .item-row {
    min-height: auto !important;
  }

  .invoice-footer-grid {
    grid-template-columns: 1fr !important;
  }

  .footer-left {
    border-right: none !important;
    border-bottom: 1.5px solid #000000 !important;
    padding: 6px 8px !important;
  }

  .footer-right {
    padding: 6px 8px !important;
    min-height: 70px !important;
  }

  /* Mobile Cash Memo & Estimate Slip Responsive Preview */
  .memo-screen-viewport {
    padding: 6px 2px !important;
    background: transparent !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .memo-sheet-container {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    padding: 10px 8px !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
  }

  .memo-title-banner {
    font-size: 13px !important;
    font-weight: 900 !important;
    letter-spacing: 0.8px !important;
    padding: 5px 8px !important;
    border-bottom: 1.5px solid #000000 !important;
    background: #f8fafc !important;
  }

  .memo-subheader-bar {
    font-size: 10.5px !important;
    font-weight: 700 !important;
    padding: 3px 8px !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  .memo-header-grid {
    display: flex !important;
    flex-direction: column !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  .memo-client-box {
    border-right: none !important;
    border-bottom: 1.5px solid #000000 !important;
    padding: 6px 8px !important;
  }

  .memo-ms-line {
    gap: 6px !important;
  }

  .memo-ms-label {
    font-size: 11px !important;
    font-weight: 800 !important;
  }

  .memo-client-name {
    font-size: 12.5px !important;
    font-weight: 900 !important;
  }

  .memo-client-address {
    font-size: 10px !important;
    margin-top: 3px !important;
  }

  .memo-meta-box {
    padding: 5px 8px !important;
    gap: 2px !important;
  }

  .memo-meta-row {
    font-size: 10.5px !important;
  }

  .memo-meta-label {
    width: 65px !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
  }

  .memo-items-table {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  .memo-items-table th {
    padding: 4px 3px !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    border-right: 1px solid #000000 !important;
    border-bottom: 1.5px solid #000000 !important;
    white-space: nowrap !important;
    background: #f1f5f9 !important;
  }

  .memo-items-table td {
    padding: 4px 3px !important;
    font-size: 9.5px !important;
    border-right: 1px solid #000000 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    vertical-align: top !important;
  }

  .memo-items-table .th-sr,
  .memo-items-table .cell-sr {
    width: 22px !important;
    min-width: 22px !important;
    text-align: center !important;
    padding: 4px 1px !important;
  }

  .memo-items-table .th-particulars,
  .memo-items-table .cell-particulars {
    min-width: 90px !important;
    width: auto !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .memo-prod-title {
    font-size: 10px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
  }

  .memo-prod-desc {
    font-size: 8.5px !important;
    line-height: 1.2 !important;
  }

  .memo-items-table .th-sku, .memo-items-table .cell-sku,
  .memo-items-table .th-hsn, .memo-items-table .cell-hsn {
    width: auto !important;
    min-width: auto !important;
    font-size: 8.5px !important;
    text-align: center !important;
  }

  .memo-items-table .th-mrp, .memo-items-table .cell-mrp,
  .memo-items-table .th-qty, .memo-items-table .cell-qty,
  .memo-items-table .th-unit, .memo-items-table .cell-unit,
  .memo-items-table .th-rate, .memo-items-table .cell-rate,
  .memo-items-table .th-gst, .memo-items-table .cell-gst,
  .memo-items-table .th-tax, .memo-items-table .cell-tax,
  .memo-items-table .th-amount, .memo-items-table .cell-amount {
    width: auto !important;
    min-width: auto !important;
    white-space: nowrap !important;
  }

  .memo-empty-row {
    display: none !important;
  }

  .memo-footer-grid {
    display: flex !important;
    flex-direction: column !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  .memo-footer-left {
    border-right: none !important;
    border-bottom: 1.5px solid #000000 !important;
  }

  .memo-supervisor-row {
    padding: 4px 8px !important;
    font-size: 10px !important;
    border-bottom: 1px solid #000000 !important;
  }

  .memo-balance-subtable td {
    padding: 3px 8px !important;
    font-size: 10px !important;
  }

  .memo-footer-right {
    width: 100% !important;
  }

  .memo-calc-row {
    padding: 3px 8px !important;
    font-size: 10.5px !important;
  }

  .memo-final-grand-box {
    padding: 5px 8px !important;
    font-size: 12px !important;
    font-weight: 900 !important;
  }

  .memo-terms-bottom-bar {
    padding: 4px 8px !important;
    font-size: 9px !important;
    line-height: 1.3 !important;
  }
}

/* ==========================================================================
   PRINT ENGINE STYLES (Clean A4 Page Fit - Zero Clipping / Zero Missing Data)
   ========================================================================== */
#printArea {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0 !important; /* Zero margin suppresses browser headers/footers (URL & timestamp) */
  }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #app,
  .app-container,
  .sidebar,
  .top-header,
  .modal-backdrop,
  .toast-container,
  .no-print {
    display: none !important;
    visibility: hidden !important;
  }

  #printArea {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    position: static !important;
  }

  #printArea * {
    visibility: visible !important;
  }

  #printArea .invoice-sheet,
  #printArea .memo-sheet-invoice,
  #printArea .memo-sheet-container,
  #printArea .purchase-order-sheet,
  #printArea .financial-sheet,
  #printArea #printablePayslip,
  #printArea #printableFinancialReport,
  #printArea #printableTaxInvoice,
  #printArea #printableEstimate,
  #printArea #printableMemo,
  #printArea #printableCashMemo {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 auto !important;
    max-width: 100% !important;
    min-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    page-break-inside: auto !important;
    background: transparent !important;
    color: #000000 !important;
  }

  /* Account Statement, Closing Balances & General Ledger Print Styling with Solid Border */
  #printArea #printableStatement,
  #printArea .statement-sheet,
  #printArea #printableBalancesReport,
  #printArea .balances-report-sheet,
  #printArea #printableCombinedLedgerBook,
  #printArea #printableGlStatement {
    display: block !important;
    visibility: visible !important;
    background: transparent !important;
    color: #000000 !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: auto !important;
  }

  #printArea .statement-box-grid {
    display: block !important;
    visibility: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 16px 18px !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
  }

  #printArea .combined-ledger-box-grid,
  #printArea .gl-box-grid {
    display: block !important;
    visibility: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 16px 18px !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: auto !important;
    page-break-inside: auto !important;
  }

  #printArea .balances-box-grid {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    visibility: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 10px 14px !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: 100% !important;
    max-height: 260mm !important;
    min-height: 260mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
    overflow: hidden !important;
  }

  #printArea table {
    page-break-inside: auto !important;
  }

  #printArea thead {
    display: table-header-group !important;
  }

  #printArea tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Dedicated Payment Voucher & Receipt Print Styling Matching Image 3 */
  #printArea .voucher-preview-modal-wrapper {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
  }

  #printArea .payment-voucher-sheet,
  #printArea #printablePaymentReceipt {
    display: block !important;
    visibility: visible !important;
    background: transparent !important;
    color: #000000 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #printArea .payment-voucher-sheet *,
  #printArea #printablePaymentReceipt * {
    visibility: visible !important;
    color: #000000 !important;
  }

  #printArea .payment-voucher-box-grid {
    display: block !important;
    visibility: visible !important;
    border: 2px solid #000000 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 20px 24px !important;
    overflow: hidden !important;
  }

  #printArea .voucher-amount-box {
    border: 2px solid #000000 !important;
    padding: 10px 18px !important;
    display: inline-block !important;
    font-weight: 800 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  #printArea .voucher-computer-note {
    color: #333333 !important;
    margin-top: 12px !important;
    font-size: 11px !important;
    font-style: italic !important;
    text-align: center !important;
    display: block !important;
    width: 100% !important;
  }

  .memo-sheet-page,
  .memo-full-page,
  .po-sheet-page,
  .balances-page-sheet {
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    min-height: 297mm !important;
    padding: 10mm 12mm !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
    page-break-after: always !important;
    break-after: page !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #ffffff !important;
  }

  .statement-sheet-page {
    width: 210mm !important;
    max-width: 210mm !important;
    padding: 8mm 10mm !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    margin-bottom: 0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid-page !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-before: auto !important;
    break-before: auto !important;
    display: block !important;
    background: #ffffff !important;
  }

  .statement-sheet-page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .statement-sheet-page + .statement-sheet-page,
  .statement-page-break {
    page-break-before: auto !important;
    break-before: auto !important;
    margin-top: 0 !important;
    padding-top: 8mm !important;
  }

  .memo-sheet-page:last-child,
  .po-sheet-page:last-child,
  .balances-page-sheet:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .memo-sheet-page + .memo-sheet-page,
  .memo-page-break,
  .po-sheet-page + .po-sheet-page,
  .balances-page-sheet + .balances-page-sheet,
  .balances-page-break {
    page-break-before: always !important;
    break-before: page !important;
    margin-top: 0 !important;
    padding-top: 10mm !important;
  }

  .multi-page-running-header {
    border: 1.5px solid #000000 !important;
    border-bottom: 1px solid #000000 !important;
    background: #f8fafc !important;
    padding: 5px 10px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 10.5px !important;
    font-weight: 800 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #printArea .invoice-box-grid {
    border: 1.5px solid #000000 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    background: #ffffff !important;
  }

  #printArea .memo-box-grid {
    border: 1.5px solid #000000 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 254mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    overflow: hidden !important;
  }

  #printArea .po-box-grid {
    border: 1.5px solid #000000 !important;
    box-sizing: border-box !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 254mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    overflow: hidden !important;
  }

  #printArea .grid-spacer-row {
    height: 100% !important;
  }

  #printArea .grid-spacer-row td {
    padding: 0 !important;
    height: 100% !important;
    border-top: none !important;
    border-bottom: none !important;
    background: transparent !important;
  }

  #printArea table {
    border-collapse: collapse !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  #printArea thead {
    display: table-header-group !important;
  }

  #printArea tr {
    page-break-inside: avoid !important;
  }

  #printArea th,
  #printArea td {
    color: #000000 !important;
    border-color: #000000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ==========================================================================
   CASH MEMO / ESTIMATE REFERENCE FORMAT & N-UP MULTI-PRINT ENGINE
   ========================================================================== */

/* Screen Preview Container */
.memo-screen-viewport {
  background: #262626;
  padding: 24px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

/* Individual Cash Memo Sheet */
.memo-sheet-container {
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  color: #000000;
  font-family: 'Inter', Arial, sans-serif;
  border: 2px solid #000000;
  box-sizing: border-box;
  margin: 0 auto;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  line-height: 1.3;
}

/* Title Banner */
.memo-title-banner {
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 2px solid #000000;
  background: #f8fafc;
}

/* Sub-Header Bar (Debit Memo / Original) */
.memo-subheader-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 2px solid #000000;
}

/* Header Grid */
.memo-header-grid {
  display: flex;
  border-bottom: 2px solid #000000;
}

.memo-client-box {
  flex: 1.3;
  padding: 8px 10px;
  border-right: 2px solid #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.memo-ms-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.memo-ms-label {
  font-weight: 800;
  font-size: 13px;
}

.memo-client-name {
  font-weight: 900;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.memo-client-address {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  margin-top: 10px;
  color: #1e293b;
}

.memo-meta-box {
  flex: 0.9;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.memo-meta-row {
  display: flex;
  align-items: center;
  font-size: 12.5px;
}

.memo-meta-label {
  width: 75px;
  font-weight: 700;
}

.memo-meta-colon {
  width: 14px;
  font-weight: 800;
}

.memo-meta-val {
  font-weight: 600;
}

/* Items Table */
.memo-items-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  border-bottom: 2px solid #000000;
}

.memo-items-table th {
  background: #f1f5f9;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 6px;
  border-right: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  text-align: left;
}

.memo-items-table th:last-child {
  border-right: none;
}

.memo-items-table td {
  padding: 4px 6px;
  border-right: 1.5px solid #000000;
  font-size: 12px;
  vertical-align: top;
}

.memo-items-table td:last-child {
  border-right: none;
}

.memo-items-table .th-sr,
.memo-items-table .cell-sr {
  width: 38px;
  text-align: center;
}

.memo-items-table .th-particulars,
.memo-items-table .cell-particulars {
  text-align: left;
  font-weight: 600;
}

.memo-items-table .th-particulars,
.memo-items-table .cell-particulars {
  text-align: left;
  min-width: 140px;
  word-break: break-word;
}

.memo-prod-title {
  font-size: 12px;
  font-weight: 800;
  color: #000000;
  line-height: 1.25;
  text-transform: uppercase;
}

.memo-prod-desc {
  font-size: 9.5px;
  color: #334155;
  font-weight: 500;
  margin-top: 1.5px;
  line-height: 1.2;
}

.memo-items-table .th-sku,
.memo-items-table .cell-sku {
  width: 70px;
  text-align: center;
  font-size: 10px;
}

.memo-items-table .th-hsn,
.memo-items-table .cell-hsn {
  width: 60px;
  text-align: center;
  font-size: 10px;
}

.memo-items-table .th-mrp,
.memo-items-table .cell-mrp {
  width: 65px;
  text-align: right;
}

.memo-items-table .th-qty,
.memo-items-table .cell-qty {
  width: 55px;
  text-align: right;
  font-weight: 600;
}

.memo-items-table .th-unit,
.memo-items-table .cell-unit {
  width: 50px;
  text-align: center;
}

.memo-items-table .th-rate,
.memo-items-table .cell-rate {
  width: 75px;
  text-align: right;
  font-weight: 600;
}

.memo-items-table .th-gst,
.memo-items-table .cell-gst {
  width: 55px;
  text-align: center;
}

.memo-items-table .th-tax,
.memo-items-table .cell-tax {
  width: 70px;
  text-align: right;
}

.memo-items-table .th-amount,
.memo-items-table .cell-amount {
  width: 90px;
  text-align: right;
  font-weight: 700;
}

.memo-empty-row td {
  height: 20px;
}

/* Footer Section */
.memo-footer-grid {
  display: flex;
  border-bottom: 2px solid #000000;
}

.memo-footer-left {
  flex: 1.1;
  border-right: 2px solid #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.memo-supervisor-row {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1.5px solid #000000;
  display: flex;
  align-items: center;
}

.memo-balance-subtable {
  width: 100%;
  border-collapse: collapse;
}

.memo-balance-subtable td {
  padding: 4px 10px;
  font-size: 11.5px;
  border-bottom: 1px solid #000000;
}

.memo-balance-subtable td:first-child {
  border-right: 1.5px solid #000000;
}

.memo-balance-subtable tr:last-child td {
  border-bottom: none;
}

.memo-balance-subtable .balance-grand-row td {
  font-size: 13px;
  font-weight: 800;
}

.memo-footer-right {
  flex: 0.9;
  display: flex;
  flex-direction: column;
}

.memo-calc-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
}

.memo-final-grand-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-size: 13.5px;
  font-weight: 900;
  background: #f8fafc;
  border-top: 2px solid #000000;
  border-bottom: 3px double #000000;
}

/* Bottom Disclaimer Bar */
.memo-terms-bottom-bar {
  padding: 4px 10px;
  font-size: 10.5px;
  color: #334155;
  font-style: italic;
  background: #ffffff;
}

/* Responsive On-Screen Preview Container */
.memo-screen-viewport {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  display: flex;
  justify-content: center;
  box-sizing: border-box;
}

.memo-screen-viewport.landscape-mode {
  overflow-x: auto;
}

.memo-screen-viewport.landscape-mode .memo-sheet-container {
  width: 100%;
  max-width: 950px;
}

.memo-preview-grid-2up-landscape {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 1100px;
}

.memo-preview-grid-2up-portrait {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 780px;
}

.memo-preview-grid-3up {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 780px;
}

.memo-preview-grid-4up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 950px;
}

/* ==========================================================================
   N-UP MULTI-COPY PRINT RULES (@media print & multi-page grid)
   ========================================================================== */

/* ==========================================================================
   N-UP MULTI-COPY PRINT RULES (@media print & multi-page grid)
   ========================================================================== */

@media print {
  /* 1-Up Full Page */
  .memo-print-page.n-up-1 {
    width: 100% !important;
    height: 100vh !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .memo-print-page.n-up-1 .memo-sheet-container {
    max-width: 100% !important;
    width: 100% !important;
    border: 2px solid #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
  }

  /* 2-Up Portrait (50/50 Equal Half Page Split with Center Positioning) */
  .memo-print-page.n-up-2.portrait-mode {
    display: grid !important;
    grid-template-rows: 1fr 1fr !important;
    height: 284mm !important;
    max-height: 284mm !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  .memo-print-page.n-up-2.portrait-mode .memo-slot {
    height: 142mm !important;
    max-height: 142mm !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    box-sizing: border-box !important;
    padding-bottom: 8mm !important;
    page-break-inside: avoid !important;
  }
  .memo-print-page.n-up-2.portrait-mode .memo-slot:first-child {
    border-bottom: 1px dashed #cbd5e1 !important;
    margin-bottom: 3mm !important;
    padding-bottom: 5mm !important;
  }
  .memo-print-page.n-up-2.portrait-mode .memo-sheet-container {
    max-width: 100% !important;
    width: 100% !important;
    border: 1.5px solid #000000 !important;
    box-shadow: none !important;
    font-size: 10.5px !important;
    margin-bottom: 0 !important;
  }
  .memo-print-page.n-up-2.portrait-mode .memo-title-banner { font-size: 13.5px !important; padding: 2.5px 6px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-subheader-bar { font-size: 10px !important; padding: 2px 6px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-client-name { font-size: 12.5px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-items-table th, 
  .memo-print-page.n-up-2.portrait-mode .memo-items-table td { padding: 2px 4px !important; font-size: 10px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-empty-row td { height: 12px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-footer-grid { font-size: 10px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-balance-subtable td { padding: 2.5px 6px !important; font-size: 10.5px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-calc-row { padding: 2.5px 6px !important; font-size: 10.5px !important; }
  .memo-print-page.n-up-2.portrait-mode .memo-final-grand-box { padding: 4px 6px !important; font-size: 12px !important; }

  /* 2-Up Landscape (Side-by-Side 2 Halves on A4 Landscape) */
  .memo-print-page.n-up-2.landscape-mode {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8mm !important;
    height: 100vh !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .memo-print-page.n-up-2.landscape-mode .memo-slot {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
  }
  .memo-print-page.n-up-2.landscape-mode .memo-sheet-container {
    max-width: 100% !important;
    width: 100% !important;
    border: 1.5px solid #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    font-size: 10px !important;
  }
  .memo-print-page.n-up-2.landscape-mode .memo-title-banner { font-size: 12.5px !important; padding: 2.5px 5px !important; }
  .memo-print-page.n-up-2.landscape-mode .memo-subheader-bar { font-size: 9.5px !important; padding: 2px 5px !important; }
  .memo-print-page.n-up-2.landscape-mode .memo-items-table th, 
  .memo-print-page.n-up-2.landscape-mode .memo-items-table td { padding: 2px 3px !important; font-size: 9.5px !important; }
  .memo-print-page.n-up-2.landscape-mode .memo-empty-row td { height: 11px !important; }

  /* 3-Up (1/3rd A4 Sheet each) */
  .memo-print-page.n-up-3 {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    justify-content: space-between !important;
    gap: 4mm !important;
    box-sizing: border-box !important;
  }
  .memo-print-page.n-up-3 .memo-slot {
    height: 33% !important;
  }
  .memo-print-page.n-up-3 .memo-sheet-container {
    max-width: 100% !important;
    width: 100% !important;
    border: 1.2px solid #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    font-size: 9.5px !important;
  }
  .memo-print-page.n-up-3 .memo-title-banner { font-size: 12px !important; padding: 2px 4px !important; }
  .memo-print-page.n-up-3 .memo-items-table th, 
  .memo-print-page.n-up-3 .memo-items-table td { padding: 1.5px 3px !important; font-size: 9.5px !important; }

  /* 4-Up (2x2 Quarter Grid on single A4) */
  .memo-print-page.n-up-4 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: 1fr 1fr !important;
    gap: 5mm !important;
    height: 100vh !important;
    box-sizing: border-box !important;
  }
  .memo-print-page.n-up-4 .memo-sheet-container {
    max-width: 100% !important;
    width: 100% !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    page-break-inside: avoid !important;
    font-size: 9px !important;
  }
  .memo-print-page.n-up-4 .memo-title-banner { font-size: 11px !important; padding: 2px 4px !important; }
  .memo-print-page.n-up-4 .memo-items-table th, 
  .memo-print-page.n-up-4 .memo-items-table td { padding: 1.5px 3px !important; font-size: 8.5px !important; }
  .memo-print-page.n-up-4 .memo-client-name { font-size: 11px !important; }
}
