@page { size: 80mm auto; margin: 4mm; }
@media print {
  html,body{background:#fff!important;margin:0!important;padding:0!important;}
  body{-webkit-print-color-adjust: exact;print-color-adjust: exact;}
  .no-print{display:none!important;}
  .page.receipt{width:auto!important;margin:0!important;}
}

*{box-sizing:border-box;}
html,body{overflow-x:hidden;}
body{font-family:"Cairo",sans-serif;font-size:11px;line-height:1.45;color:#111827;background:#fff;margin:0;}
.page.receipt{width:80mm;max-width:80mm;margin:0 auto;padding:0;background:#fff;overflow:hidden;}
.print-body{width:100%;}

.receipt-header{padding:0 0 6px 0;border-bottom:1px dashed #cbd5e1;margin-bottom:8px;text-align:center;}
.receipt-header-top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;margin-bottom:6px;}
.receipt-meta{flex:1;min-width:0;text-align:right;}
.receipt-meta-row{display:flex;justify-content:space-between;gap:6px;font-size:10px;color:#374151;margin-bottom:2px;}
.receipt-meta-row strong{font-size:10px;font-weight:800;color:#111827;}
.receipt-logo{width:26px;height:26px;border-radius:50%;overflow:hidden;border:1px solid #d9dde6;background:#fff;flex:0 0 26px;}
.receipt-logo img{display:block;width:100%;height:100%;object-fit:contain;}
.receipt-company-name{font-size:13px;font-weight:800;line-height:1.25;margin-bottom:2px;}
.receipt-company-sub,.receipt-company-contact{font-size:9px;color:#6b7280;line-height:1.35;word-break:break-word;}
.receipt-doc-title{font-size:15px;font-weight:800;line-height:1.25;margin-top:6px;}
.receipt-doc-subtitle{font-size:9px;color:#6b7280;letter-spacing:.4px;}

.receipt-headline{font-size:15px;font-weight:800;text-align:center;margin:6px 0 2px;}
.receipt-subtitle{font-size:9px;color:#6b7280;text-align:center;margin-bottom:6px;}
.receipt-meta-grid{display:grid;grid-template-columns:1fr;gap:4px;margin-bottom:8px;}
.receipt-meta-grid.two-col{grid-template-columns:1fr 1fr;}
.receipt-meta-grid > div{border:1px solid #e5e7eb;border-radius:8px;padding:5px 6px;min-width:0;}
.receipt-meta-grid span{display:block;font-size:9px;color:#6b7280;line-height:1.2;margin-bottom:2px;}
.receipt-meta-grid strong{display:block;font-size:10px;font-weight:800;line-height:1.3;word-break:break-word;}

.receipt-table{width:100%;border-collapse:collapse;table-layout:fixed;margin-bottom:8px;}
.receipt-table th,.receipt-table td{padding:5px 3px;border-bottom:1px solid #eef2f7;vertical-align:top;word-wrap:break-word;}
.receipt-table th{font-size:9px;font-weight:800;color:#111827;border-top:1px solid #e5e7eb;background:#f8fafc;}
.receipt-table td{font-size:10px;}
.receipt-table th:nth-child(1), .receipt-table td:nth-child(1){width:10%;text-align:center;}
.receipt-table th:nth-child(2), .receipt-table td:nth-child(2){width:46%;}
.receipt-table th:nth-child(3), .receipt-table td:nth-child(3){width:18%;text-align:center;}
.receipt-table th:nth-child(4), .receipt-table td:nth-child(4){width:26%;text-align:left;}
.receipt-line-meta{font-size:9px;color:#6b7280;margin-top:2px;line-height:1.3;word-break:break-word;}

.receipt-summary{margin-top:6px;border-top:1px dashed #cbd5e1;padding-top:6px;}
.receipt-summary > div{display:flex;justify-content:space-between;gap:8px;padding:2px 0;font-size:10px;}
.receipt-summary > div span{color:#374151;}
.receipt-summary > div strong{font-weight:800;color:#111827;text-align:left;}
.receipt-summary .grand{margin-top:4px;padding-top:4px;border-top:1px solid #e5e7eb;font-size:12px;font-weight:800;}

.receipt-note-box{border:1px solid #e5e7eb;border-radius:8px;padding:6px;margin-top:8px;font-size:10px;line-height:1.5;}
.receipt-note-title{font-size:9px;color:#6b7280;margin-bottom:3px;font-weight:700;}

.print-footer.receipt-footer{margin-top:8px;border-top:1px dashed #cbd5e1;padding-top:6px;text-align:center;}
.receipt-footer-company{margin-bottom:6px;}
.receipt-footer-name{font-size:11px;font-weight:800;line-height:1.3;margin-bottom:2px;}
.receipt-footer-line{font-size:9px;color:#6b7280;line-height:1.35;word-break:break-word;}
.receipt-footer-bottom{display:flex;flex-direction:column;gap:2px;color:#6b7280;font-size:8.5px;line-height:1.35;}

.box{border:1px solid #e5e7eb;border-radius:10px;padding:6px;margin-bottom:6px;}
.grid2{display:grid;grid-template-columns:1fr;gap:6px;}
.field-title{font-size:10px;color:#6b7280;margin-bottom:2px;}
.field-value{font-size:12px;font-weight:700;}
.table{width:100%;border-collapse:collapse;table-layout:fixed;}
.table th{font-size:10px;padding:4px 2px;border-bottom:1px solid #e5e7eb;}
.table td{font-size:10px;padding:4px 2px;border-bottom:1px solid #eef2f7;word-wrap:break-word;}
.summary{margin-top:6px;border-top:1px dashed #cbd5e1;padding-top:6px;}
.summary table{width:100%;border-collapse:collapse;}
.summary td{padding:3px 0;}
.summary .val{text-align:left;font-weight:700;}
.summary .total{font-size:12px;font-weight:800;border-top:1px solid #e5e7eb;padding-top:6px;}
.pieces{margin-top:6px;font-size:10px;color:#374151;font-weight:700;}


/* generic receipt table alignment helpers */
.table th, .table td{text-align:right;vertical-align:top;}
.table th:nth-child(1), .table td:nth-child(1){width:10%;text-align:center;}
.table th:nth-child(3), .table td:nth-child(3){text-align:center;}
.table th:nth-child(4), .table td:nth-child(4),
.table th:nth-child(5), .table td:nth-child(5){text-align:left;}


/* final stabilization for 80mm printing */
@media print {
  @page { size: 80mm auto; margin: 2mm; }
  html,body{width:80mm!important;max-width:80mm!important;overflow:visible!important;}
  .page.receipt{width:76mm!important;max-width:76mm!important;margin:0 auto!important;overflow:visible!important;}
  .receipt-table thead{display:table-header-group;}
  .receipt-table tr,.table tr,.receipt-note-box,.box,.summary,.receipt-summary{break-inside:avoid;page-break-inside:avoid;}
}
.receipt-meta-grid strong,.field-value,.summary .val,.receipt-summary strong,.receipt-footer-bottom,.receipt-meta-row strong{
  font-variant-numeric:tabular-nums;
  unicode-bidi:plaintext;
}
.receipt-table td,.receipt-table th,.table td,.table th{font-variant-numeric:tabular-nums;}

/* Phase print stabilization: 80mm readability and duplicate-summary cleanup */
.receipt-meta-grid,.receipt-summary,.receipt-note-box,.box{break-inside:avoid;page-break-inside:avoid;}
.receipt-summary + .receipt-summary{margin-top:4px;}
.receipt-summary .grand strong,.summary .total .val{font-size:12.5px;}
.receipt-table th,.receipt-table td,.table th,.table td{line-height:1.35;}
.receipt-table td:last-child,.receipt-table th:last-child,.table td:last-child,.table th:last-child{direction:ltr;unicode-bidi:plaintext;font-variant-numeric:tabular-nums;text-align:left;}
.receipt-meta-grid strong,.field-value{overflow-wrap:anywhere;}
@media print{
  .receipt-header{margin-bottom:6px;padding-bottom:5px;}
  .receipt-meta-grid{gap:3px;margin-bottom:6px;}
  .receipt-meta-grid > div{padding:4px 5px;border-radius:7px;}
  .receipt-table th,.receipt-table td,.table th,.table td{padding-top:4px;padding-bottom:4px;}
}


/* Phase receipt refresh: darker and clearer invoice receipts */
body{font-size:12px;line-height:1.55;color:#0f172a;font-weight:600;}
.page.receipt{padding:0 1mm;}
.receipt-header{padding:0 0 8px 0;border-bottom:1px dashed #94a3b8;margin-bottom:10px;text-align:center;}
.receipt-header-top{display:block;margin:0;}
.receipt-logo{width:38px;height:38px;margin:0 auto 6px auto;border:1px solid #cbd5e1;background:#fff;}
.receipt-company-name{font-size:17px;font-weight:900;line-height:1.2;margin-bottom:3px;color:#0f172a;}
.receipt-company-sub,.receipt-company-contact{font-size:10px;color:#475569;line-height:1.45;word-break:break-word;}
.receipt-doc-title{font-size:19px;font-weight:900;line-height:1.2;margin-top:7px;color:#0f172a;}
.receipt-doc-subtitle{display:none;}
.receipt-head-chips{display:flex;flex-wrap:wrap;gap:5px;justify-content:center;margin-top:7px;}
.receipt-head-chip{min-width:0;border:1px solid #cbd5e1;border-radius:999px;padding:3px 8px;background:#f8fafc;display:flex;align-items:center;gap:6px;}
.receipt-head-chip span{font-size:9px;color:#475569;font-weight:700;}
.receipt-head-chip strong{font-size:10.5px;font-weight:900;color:#0f172a;}
.receipt-meta-grid{display:grid;grid-template-columns:1fr 1fr;gap:5px;margin-bottom:9px;}
.receipt-meta-grid.two-col{grid-template-columns:1fr 1fr;}
.receipt-meta-grid > div,.box{border:1px solid #cbd5e1;border-radius:9px;padding:6px 7px;background:#fff;}
.receipt-meta-grid span,.field-title{display:block;font-size:9.5px;color:#475569;line-height:1.2;margin-bottom:3px;font-weight:700;}
.receipt-meta-grid strong,.field-value{display:block;font-size:11.5px;font-weight:900;line-height:1.35;color:#0f172a;word-break:break-word;}
.receipt-table,.table{width:100%;border-collapse:collapse;table-layout:fixed;margin-bottom:9px;}
.receipt-table th,.table th{padding:6px 4px;border-bottom:1px solid #cbd5e1;border-top:1px solid #0f2942;background:#0f2942;color:#fff;font-size:9.5px;font-weight:900;}
.receipt-table td,.table td{padding:6px 4px;border-bottom:1px solid #e2e8f0;vertical-align:top;word-wrap:break-word;font-size:10.5px;color:#0f172a;font-weight:700;}
.receipt-table th:nth-child(1), .receipt-table td:nth-child(1),.table th:nth-child(1), .table td:nth-child(1){width:10%;text-align:center;}
.receipt-table th:nth-child(2), .receipt-table td:nth-child(2),.table th:nth-child(2), .table td:nth-child(2){width:46%;text-align:right;}
.receipt-table th:nth-child(3), .receipt-table td:nth-child(3),.table th:nth-child(3), .table td:nth-child(3){width:18%;text-align:center;}
.receipt-table th:nth-child(4), .receipt-table td:nth-child(4),.table th:nth-child(4), .table td:nth-child(4){width:26%;text-align:left;}
.receipt-line-meta{font-size:9.2px;color:#475569;margin-top:3px;line-height:1.35;word-break:break-word;font-weight:700;}
.receipt-summary,.summary{margin-top:7px;border-top:1px dashed #94a3b8;padding-top:7px;}
.receipt-summary > div,.summary td{font-size:10.5px;color:#0f172a;}
.receipt-summary > div{display:flex;justify-content:space-between;gap:8px;padding:3px 0;}
.receipt-summary > div span{color:#334155;font-weight:700;}
.receipt-summary > div strong,.summary .val{font-weight:900;color:#0f172a;text-align:left;}
.receipt-summary .grand,.summary .total{margin-top:5px;padding-top:5px;border-top:1px solid #cbd5e1;font-size:13px;font-weight:900;}
.receipt-summary .grand strong,.summary .total .val{font-size:13px;font-weight:900;}
.receipt-note-box{border:1px solid #cbd5e1;border-radius:9px;padding:7px;margin-top:8px;font-size:10.5px;line-height:1.55;color:#0f172a;font-weight:700;}
.receipt-note-title{font-size:9.5px;color:#475569;margin-bottom:4px;font-weight:800;}
.print-footer.receipt-footer{margin-top:10px;border-top:1px dashed #cbd5e1;padding-top:6px;text-align:center;}
.receipt-footer-company{display:none;}
.receipt-footer-bottom{display:flex;flex-direction:column;gap:2px;color:#475569;font-size:9px;line-height:1.35;font-weight:700;}
@media print {
  @page { size: 80mm auto; margin: 3mm 2.5mm; }
  body{font-size:11.5px;}
  .page.receipt{width:75mm!important;max-width:75mm!important;margin:0 auto!important;}
}
