@page {
    size: A4;
    margin: 10mm;
}

body {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #000;
}

.tally-invoice {
    border: 2px solid #000;
    padding: 3px;
    box-sizing: border-box;
}

/* HEADER */
.ti-header {
    width: 100%;
    border: 1px solid #000;
    border-collapse: collapse;
}

.ti-header td {
    border: 1px solid #000;
    vertical-align: top;
    padding: 6px;
}

.ti-head-left {
    width: 65%;
}

.ti-head-right {
    width: 35%;
    text-align: center;
}

.ti-head-brand {
    display: flex;
    align-items: center;
}

.ti-head-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
    margin-right: 6px;
}

.ti-head-company {
    font-size: 18px;
    font-weight: bold;
}

.ti-tax-title {
    font-size: 16px;
    font-weight: bold;
}

.ti-head-address {
    font-size: 11px;
    line-height: 1.3;
}

.ti-original {
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 3px;
}

.ti-head-meta {
    font-size: 11px;
}

.ti-logo {
    border-right: 1px solid #000;
    padding: 6px;
    vertical-align: top;
}

.ti-logo-img {
    width: 65px;
    max-height: 65px;
    object-fit: contain;
}

.ti-company {
    padding: 6px;
    vertical-align: top;
}

.ti-company-name {
    font-size: 18px;
    font-weight: bold;
}

.ti-company-line {
    font-size: 11px;
    line-height: 1.3;
}

.ti-invbox {
    border-left: 1px solid #000;
    padding: 6px;
    vertical-align: top;
}

.ti-inv-title {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.ti-original {
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
}

.ti-meta table td {
    font-size: 11px;
}

/* PARTY */
.ti-party {
    border: 1px solid #000;
    border-top: none;
}

.ti-party-box {
    padding: 6px;
    border-right: 1px solid #000;
    vertical-align: top;
}

.ti-party-box:last-child {
    border-right: none;
}




/* ITEM GRID – TALLY STYLE */
.ti-items {
    border-collapse: collapse;
    width: 100%;
    font-size: 10.5px;
}

.ti-items th, .ti-items td {
    border: 1px solid #000;
    padding: 3px 0px;
}

.ti-items th {
    background: #f2f2f2;
    text-align: center;
    font-weight: bold;
}
.item-sub-desc {
    font-size: 9.5px;
    color: #333;
    margin-top: 2px;
}

/* Column widths (Tally proportion) */
.w-sr   { width: 4%;  }
.w-item { width: 32%; }
.w-hsn  { width: 8%;  }
.w-unit { width: 6%;  }
.w-mrp  { width: 8%;  }
.w-qty  { width: 6%;  }
.w-rate { width: 10%; }
.w-gst  { width: 6%;  }
.w-disc { width: 8%;  }
.w-amt  { width: 12%; }

/* Alignment helpers */
.r { text-align: right; }
.c { text-align: center; }

/* TOTALS */
/* BOTTOM SECTION */
.ti-bottom {
    margin-top: 6px;
}

/* HSN SUMMARY */
.ti-hsn {
    border-collapse: collapse;
    width: 100%;
    font-size: 10px;
}

.ti-hsn th, .ti-hsn td {
    border: 1px solid #000;
    padding: 3px 4px;
}

.ti-hsn th {
    background: #f2f2f2;
    text-align: center;
}

/* TOTALS BOX (RIGHT, TALLY STYLE) */
.ti-totals {
    border-collapse: collapse;
    width: 100%;
    font-size: 11px;
}

.ti-totals td {
    border: 1px solid #000;
    padding: 4px 6px;
}

.ti-grand-row td {
    font-weight: bold;
    font-size: 12px;
}

.ti-grand-total td {
    font-weight: bold;
    font-size: 12px;
}

/* AMOUNT IN WORDS */
.ti-words {
    border: 1px solid #000;
    padding: 4px;
    margin-top: 4px;
    font-size: 11px;
}

/* BANK + QR */
.ti-bank-wrap {
    border: 1px solid #000;
    margin-top: 5px;
}

.ti-bank-box, .ti-qr-box {
    padding: 6px;
    border-right: 1px solid #000;
    vertical-align: top;
}

/* QR CENTER ALIGNMENT */
#upiQR {
    max-width: 110px;
    max-height: 110px;
}

/* QR CENTER ALIGNMENT */
.ti-qr-box {
    text-align: center;
    vertical-align: middle;
}

.ti-qr-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ti-qr-text {
    font-size: 10px;
    margin-top: 4px;
    font-weight: bold;
}

.ti-qr-amount {
    font-size: 11px;
    margin-top: 2px;
}

/* TERMS */
.ti-terms-wrap {
    border: 1px solid #000;
    border-top: none;
}

.ti-terms-box {
    padding: 6px;
    font-size: 10px;
}

/* DECLARATION & SIGN */
.ti-decl-wrap {
    border: 1px solid #000;
    border-top: none;
}

.ti-decl-box, .ti-sign-box {
    padding: 8px;
    vertical-align: top;
}

.ti-decl-box,
.ti-terms-box,
.ti-bank-box {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

.ti-decl-wrap td,
.ti-terms-wrap td,
.ti-bank-wrap td {
    max-width: 100%;
    box-sizing: border-box;
}

.ti-sign-box {
    text-align: right;
}

/* ALIGN HELPERS */
.r { text-align: right; }
.c { text-align: center; }

/* PRINT ONLY INVOICE */
@media print {
    body * {
        visibility: hidden;
    }

    #invoicePreview, #invoicePreview * {
        visibility: visible;
    }

    #invoicePreview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .invoice-toolbar,
    .sidebar,
    .header,
    .topbar {
        display: none !important;
    }
}
@media print {
    .tally-invoice {
        page-break-after: avoid;
        page-break-before: avoid;
    }

    table, tr, td {
        page-break-inside: avoid;
    }
}

.ti-header,
.ti-party,
.ti-items,
.ti-bottom,
.ti-bank-wrap,
.ti-terms-wrap,
.ti-decl-wrap {
    width: 100%;
    table-layout: fixed;
}
