@page {
    size: 80mm auto;
    margin: 0;
}

html, body {
    margin: 0;
    padding: 0;
    width: 80mm;
}

.thermal-invoice {
    width: 80mm;          /* actual printable width */
    margin-left: 0;      /* NO CENTERING */
    padding-left: 2mm;   /* small inner padding */
    padding-right: 2mm;
    box-sizing: border-box;
    font-family: monospace;
}

.th-title {
    font-weight: bold;
    font-size: 12px;
    margin: 3px 0;
}

.th-items td:first-child {
    width: 45mm;              /* fixed width for item column */
    max-width: 45mm;
    word-wrap: break-word;
	font-size: 11px;
    font-weight: bold;
    white-space: normal;
}

.th-items td:nth-child(2) {  /* Qty */
    width: 8mm;
    text-align: right;
	font-size: 11px;
    font-weight: bold;
	padding-left:5px;
	padding-right:5px;
}

.th-items td:nth-child(3) {  /* Rate */
    width: 9mm;
    text-align: right;
	font-size: 11px;
    font-weight: bold;
	padding-left:5px;
	padding-right:5px;
}

.th-items td:nth-child(4) {  /* Amount */
    width: 10mm;
    text-align: right;
	font-size: 11px;
    font-weight: bold;
	padding-left:5px;
	padding-right:5px;
}


.th-items th:first-child { width: 45mm; }
.th-items th:nth-child(2) { width: 8mm; }
.th-items th:nth-child(3) { width: 9mm; }
.th-items th:nth-child(4) { width: 10mm; }


.th-center {
    text-align: center;
    width: 100%;
}
.th-left { text-align: left; }

.th-company {
    font-size: 17px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.th-small {
    font-size: 13px;
    font-weight: bold;
}

.th-logo {
    max-width: 40mm;
    max-height: 20mm;
    margin-bottom: 4px;
}

hr {
    border: none;
    border-top: 1px dashed #000;
    margin: 4px 0;
}


.th-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 4px;
}

.th-items th {
    border-bottom: 1px solid #000;
    padding: 2px 0;
    font-size: 10px;
}

.th-items td {
    padding: 2px 0;
    vertical-align: top;
}

.th-hsn {
    font-size: 8px;
    color: #333;
}

.th-sep {
    border-top: 1px dashed #000;
    margin: 6px 0;
}

.th-items, .th-totals {
    width: 100%;
    border-collapse: collapse;
}

.c-item { width: 45%; text-align: left; }
.c-qty  { width: 15%; text-align: right; }
.c-rate { width: 20%; text-align: right; }
.c-amt  { width: 20%; text-align: right; }

.th-desc {
    font-size: 8px;
    color: #444;
    line-height: 1.2;
}

.th-totals td {
    padding: 2px 0;
    font-size: 10px;
    font-weight: bold;
}

.th-grand td {
    border-top: 1px solid #000;
    font-size: 12px;
    font-weight: bold;
    font-weight: bold;
}

.th-totals td:last-child { text-align: right; }

#barcode{
    display: block;
    margin: 6px auto;
    max-width: 45mm;
    text-align: center;
}

.th-barcode svg { width: 100%; height: 40px; }

#upiQR {
    display: block;
    margin: 6px auto;
    max-width: 72mm;
    text-align: center;
}

#upiQR canvas {
    margin: 0 auto;
}
#upiQR img {
    display: block;
    margin: 0 auto;
    width: 85px !important;
    height: 85px !important;
}


@media print {
    html, body {
        height: auto !important;
        overflow: hidden !important;
    }

    .thermal-invoice {
        page-break-after: avoid;
        page-break-before: avoid;
        page-break-inside: avoid;
    }
}

@media print {

    body * {
        visibility: hidden !important;
    }

    #thermalPreview, #thermalPreview * {
        visibility: visible !important;
    }

    #thermalPreview {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        margin: 0;
        padding: 0;
    }

    .modal-overlay,
    .modal-box,
    .modal-header,
    .modal-footer,
    .modal-toggle {
        display: none !important;
    }

    @page {
        size: 80mm auto;
        margin: 0;
    }
}
