/* ============================================================
   VIP Doors – Authentic Tally UI A5 Estimate Bill Print Styles
   Calibrated for A5 Paper (148mm × 210mm Portrait)
   Strict Grid Borders, Zero Bottom Cutoff & Indian Currency Words
   ============================================================ */

#a5PrintContainer {
  display: none !important;
}

@media print {
  body.print-mode-a5 > *:not(#a5PrintContainer) {
    display: none !important;
  }

  body.print-mode-a5 #a5PrintContainer {
    display: block !important;
    position: static !important;
    width: 100%;
    background: #ffffff !important;
    color: #000000 !important;
    font-family: 'Plus Jakarta Sans', Arial, Helvetica, sans-serif !important;
    font-size: 7.5pt !important;
    line-height: 1.2 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .a5-estimate-sheet {
    width: 100% !important;
    box-shadow: none !important;
    border: 1.5px solid #000000 !important;
    box-decoration-break: clone !important;
    -webkit-box-decoration-break: clone !important;
    page-break-after: always;
    break-after: page;
  }

  .a5-estimate-sheet:last-child {
    page-break-after: avoid;
    break-after: avoid;
  }

  table {
    page-break-inside: auto;
    break-inside: auto;
  }

  tr, th, td {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

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

  tfoot, .tally-table-totals {
    display: table-row-group !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .tally-section-header {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .tally-bottom-grid {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
}

/* ============================================================
   A5 ESTIMATE SHEET CONTAINER & TALLY FORMAT
   ============================================================ */

.a5-estimate-sheet {
  width: 148mm;
  min-height: 205mm;
  margin: 0 auto 16px auto;
  background: #ffffff;
  color: #000000;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', Arial, sans-serif;
  font-size: 7.5pt;
  line-height: 1.2;
  border: 1.5px solid #000000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

/* Top Title: ESTIMATE */
.tally-top-title {
  text-align: center;
  font-size: 10.5pt;
  font-weight: 900;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  padding: 3px 0;
  border-bottom: 1.5px solid #000000;
  margin: 0;
  background-color: #f8fafc;
}

/* Tally Header: Party details & Estimate Meta */
.tally-meta-table {
  width: 100%;
  border-collapse: collapse;
  border-bottom: 1.5px solid #000000;
}

.tally-meta-table td {
  padding: 3px 6px;
  vertical-align: top;
  border-right: 1.5px solid #000000;
  font-size: 7.2pt;
  line-height: 1.25;
}

.tally-meta-table td:last-child {
  border-right: none;
}

.tally-label {
  font-size: 6.5pt;
  font-weight: 700;
  color: #4b5563;
  text-transform: uppercase;
}

.tally-val {
  font-weight: 800;
  color: #000000;
}

.tally-val-mono {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  color: #000000;
}

/* Section Header (Doors / WPC Frames) */
.tally-section-header {
  background-color: #e5e7eb;
  color: #000000;
  font-weight: 800;
  font-size: 6.8pt;
  text-transform: uppercase;
  padding: 2.5px 6px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #000000;
  border-top: 1px solid #000000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Data Table with complete vertical & horizontal rules */
.tally-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 7.2pt;
  table-layout: fixed;
}

.tally-data-table th {
  background-color: #f3f4f6;
  color: #000000;
  font-weight: 800;
  border: 1px solid #000000;
  padding: 2px 3.5px;
  text-align: left;
  font-size: 6.8pt;
  text-transform: uppercase;
  line-height: 1.15;
  overflow: hidden;
  white-space: nowrap;
}

.tally-data-table td {
  border: 1px solid #000000;
  padding: 2px 3.5px;
  vertical-align: middle;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tally-data-table th.center,
.tally-data-table td.center {
  text-align: center !important;
}

.tally-data-table th.right,
.tally-data-table td.right {
  text-align: right !important;
}

.tally-item-title {
  font-weight: 800;
  font-size: 7.2pt;
  color: #000000;
}

.tally-item-subtext {
  font-size: 6.3pt;
  color: #4b5563;
  margin-top: 0.5px;
}

/* Totals Row */
.tally-data-table tr.tally-table-total-row td {
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  background-color: #f9fafb;
  font-weight: 800;
  padding: 2px 3.5px;
  font-size: 7.2pt;
}

/* Bottom Grid: Words on Left, Totals on Right */
.tally-bottom-grid {
  display: flex;
  border-top: 1.5px solid #000000;
  width: 100%;
}

.tally-words-box {
  flex: 1;
  padding: 4px 6px;
  border-right: 1.5px solid #000000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 6.8pt;
}

.tally-words-title {
  font-size: 6.2pt;
  font-weight: 700;
  text-transform: uppercase;
  color: #4b5563;
  margin-bottom: 2px;
}

.tally-words-text {
  font-weight: 800;
  color: #000000;
  line-height: 1.2;
  text-transform: capitalize;
  font-size: 7.2pt;
}

.tally-eoe {
  font-size: 6.5pt;
  font-weight: 700;
  color: #6b7280;
  margin-top: 4px;
}

/* Right Totals Table */
.tally-totals-table {
  width: 65mm;
  border-collapse: collapse;
  font-size: 7.2pt;
}

.tally-totals-table td {
  padding: 2px 5px;
  border-bottom: 1px solid #d1d5db;
  line-height: 1.15;
}

.tally-totals-table tr.tally-total-row td {
  border-top: 1.5px solid #000000;
  border-bottom: 1.5px solid #000000;
  font-weight: 900;
  background-color: #f3f4f6;
  font-size: 7.8pt;
  padding: 2.5px 5px;
}

.tally-totals-table tr.tally-balance-row td {
  border-top: 1.5px solid #000000;
  border-bottom: 1.8px solid #000000;
  font-weight: 900;
  font-size: 8.5pt;
  background-color: #fef3c7;
  color: #92400e;
  padding: 3px 5px;
}

