    .al-left {
        text-align: left !important;
    }

    .al-right {
        text-align: right !important;
    }

    .al-center {
        text-align: center !important;
    }

    /* safe for numbers */
    .num {
        text-align: right !important;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    .txt {
        text-align: left !important;
    }

    /* Optional: table headings center */
    .th-center thead th {
        text-align: center !important;
    }

    /* ===== COMMON STYLES ===== */
    .invoice-page-container {
        background: #f5f7fa;
        min-height: 100vh;
        padding: 20px;
    }

    .invoice-toolbar {
        background: #fff;
        border-radius: 10px;
        padding: 16px 24px;
        margin-bottom: 20px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 16px;
    }

    .toolbar-left {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .back-btn {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        border: 1px solid #e0e0e0;
        background: #fff;
        color: #666;
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        transition: all 0.2s;
    }

        .back-btn:hover {
            background: #f5f5f5;
            color: #333;
            border-color: #ccc;
        }

    .invoice-title-block h4 {
        margin: 0;
        font-size: 18px;
        font-weight: 600;
        color: #1a1a2e;
    }

    .invoice-meta-info {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: 4px;
    }

    .status-badge {
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
    }

    .status-paid {
        background: #d4edda;
        color: #155724;
    }

    .status-unpaid {
        background: #f8d7da;
        color: #721c24;
    }

    .status-partial {
        background: #fff3cd;
        color: #856404;
    }

    .status-draft {
        background: #e2e3e5;
        color: #383d41;
    }

    .toolbar-right {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .template-selector {
        display: flex;
        align-items: center;
        gap: 8px;
        background: #f8f9fa;
        padding: 6px 12px;
        border-radius: 8px;
        border: 1px solid #e0e0e0;
    }

        .template-selector label {
            font-size: 13px;
            color: #666;
            margin: 0;
        }

        .template-selector select {
            border: none;
            background: transparent;
            font-size: 13px;
            font-weight: 500;
            color: #333;
            cursor: pointer;
            padding: 4px 8px;
        }

            .template-selector select:focus {
                outline: none;
            }

    .action-btn {
        padding: 10px 18px;
        border-radius: 8px;
        font-size: 13px;
        font-weight: 500;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s;
        text-decoration: none;
    }

    .btn-outline {
        background: #fff;
        border: 1px solid #ddd;
        color: #555;
    }

        .btn-outline:hover {
            background: #f5f5f5;
            border-color: #ccc;
            color: #333;
        }

    .btn-danger-outline {
        background: #fff;
        border: 1px solid #dc3545;
        color: #dc3545;
    }

        .btn-danger-outline:hover {
            background: #dc3545;
            color: #fff;
        }

    .btn-warning {
        background: #ffc107;
        color: #000;
    }

        .btn-warning:hover {
            background: #e0a800;
        }

    .btn-success {
        background: #28a745;
        color: #fff;
    }

        .btn-success:hover {
            background: #218838;
        }

    .btn-primary {
        background: #007bff;
        color: #fff;
    }

        .btn-primary:hover {
            background: #0069d9;
        }

    /* Invoice Preview Container */
    .invoice-preview-container {
        display: flex;
        justify-content: center;
        padding: 20px;
    }

    .invoice-paper {
        background: #fff;
        width: 100%;
        max-width: 800px;
        min-height: auto;
        padding: 0;
        box-sizing: border-box;
        box-shadow: 0 4px 20px rgba(0,0,0,0.1);
        border-radius: 4px;
        overflow: hidden;
    }

    /* ===== TEMPLATE 1: DEFAULT STYLE ===== */
    .template-default {
        padding: 40px;
        font-family: 'Segoe UI', Arial, sans-serif;
    }

    .default-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 30px;
        padding-bottom: 20px;
        border-bottom: 2px solid #333;
    }

    .default-logo img {
        width: 120px;
        height: 120px;
        max-width: 120px;
        max-height: 120px;
        object-fit: contain;
    }

    .default-company-info {
        text-align: right;
    }

        .default-company-info h2 {
            margin: 0 0 8px 0;
            font-size: 20px;
            font-weight: 700;
            color: #333;
        }

        .default-company-info p {
            margin: 0;
            font-size: 12px;
            color: #666;
            line-height: 1.6;
        }

    .default-title {
        text-align: center;
        margin: 30px 0;
    }

        .default-title h1 {
            margin: 0;
            font-size: 24px;
            font-weight: 700;
            letter-spacing: 3px;
            color: #333;
        }

    .default-details-section {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;
    }

    .default-bill-to h4 {
        margin: 0 0 10px 0;
        font-size: 14px;
        font-weight: 700;
        color: #333;
    }

    .default-bill-to p {
        margin: 0;
        font-size: 13px;
        color: #555;
        line-height: 1.7;
    }

    .default-invoice-meta {
        text-align: right;
    }

        .default-invoice-meta table {
            margin-left: auto;
        }

        .default-invoice-meta td {
            padding: 4px 0;
            font-size: 13px;
        }

            .default-invoice-meta td:first-child {
                color: #666;
                padding-right: 20px;
            }

            .default-invoice-meta td:last-child {
                font-weight: 600;
                color: #333;
            }

    .default-items-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 30px;
    }

        .default-items-table th {
            background: #f8f9fa;
            padding: 12px 15px;
            font-size: 12px;
            font-weight: 600;
            color: #333;
            border-bottom: 2px solid #333;
        }

        .default-items-table td {
            padding: 12px 15px;
            font-size: 13px;
            color: #444;
            border-bottom: 1px solid #eee;
            vertical-align: top;
        }

        /* DEFAULT TABLE ALIGNMENT (ERP) */
        .default-items-table th,
        .default-items-table td {
            text-align: left;
        }

            .default-items-table th:nth-child(1),
            .default-items-table td:nth-child(1) {
                text-align: center;
            }
            /* S.No */

            .default-items-table th:nth-child(3),
            .default-items-table th:nth-child(4),
            .default-items-table th:nth-child(5),
            .default-items-table th:nth-child(6),
            .default-items-table th:nth-child(7),
            .default-items-table td:nth-child(3),
            .default-items-table td:nth-child(4),
            .default-items-table td:nth-child(5),
            .default-items-table td:nth-child(6),
            .default-items-table td:nth-child(7) {
                text-align: right;
            }
    /* numeric cols */

    .default-totals {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 30px;
    }

        .default-totals table {
            width: 280px;
        }

        .default-totals td {
            padding: 8px 0;
            font-size: 13px;
        }

            .default-totals td:first-child {
                text-align: left !important;
                color: #666;
                padding-right: 20px;
            }

            .default-totals td:last-child {
                text-align: right !important;
                font-weight: 500;
            }

        .default-totals tr.grand-total {
            border-top: 2px solid #333;
        }

            .default-totals tr.grand-total td {
                font-weight: 700;
                font-size: 15px;
                padding-top: 12px;
            }

    .default-amount-words {
        background: #f8f9fa;
        padding: 12px 15px;
        border-radius: 4px;
        margin-bottom: 30px;
        font-size: 13px;
    }

    .default-notes {
        margin-bottom: 20px;
    }

        .default-notes h5 {
            margin: 0 0 8px 0;
            font-size: 13px;
            font-weight: 600;
        }

        .default-notes p {
            margin: 0;
            font-size: 12px;
            color: #666;
            line-height: 1.6;
        }

    .default-footer {
        display: flex;
        justify-content: space-between;
        margin-top: 50px;
        padding-top: 20px;
        border-top: 1px solid #eee;
    }

    .default-footer-left p {
        margin: 0;
        font-size: 12px;
        font-weight: 600;
    }

    .default-footer-right {
        text-align: center;
    }

        .default-footer-right .signature-line {
            width: 150px;
            border-bottom: 1px solid #333;
            margin-bottom: 8px;
        }

        .default-footer-right p {
            margin: 0;
            font-size: 12px;
            color: #666;
        }

    /* ===== TEMPLATE 2: ZOHO STYLE ===== */
    .template-zoho .zoho-header {
        background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
        padding: 30px 40px;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .template-zoho .zoho-logo {
        background: #fff;
        width: 80px;
        height: 80px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }

        .template-zoho .zoho-logo img {
            width: 120px;
            height: 120px;
            max-width: 120px;
            max-height: 120px;
            object-fit: contain;
        }

    .template-zoho .zoho-company-info {
        text-align: right;
        color: #fff;
    }

        .template-zoho .zoho-company-info h2 {
            margin: 0 0 8px 0;
            font-size: 22px;
            font-weight: 700;
        }

        .template-zoho .zoho-company-info p {
            margin: 0;
            font-size: 13px;
            opacity: 0.9;
            line-height: 1.6;
        }

    .template-zoho .zoho-title-bar {
        background: #fff;
        text-align: center;
        padding: 20px;
        border-bottom: 3px solid #2ecc71;
    }

        .template-zoho .zoho-title-bar h1 {
            margin: 0;
            font-size: 28px;
            font-weight: 300;
            color: #333;
            letter-spacing: 2px;
        }

    .template-zoho .zoho-body {
        padding: 30px 40px;
    }

    .template-zoho .zoho-details-row {
        display: flex;
        justify-content: space-between;
        margin-bottom: 30px;
    }

    .template-zoho .zoho-bill-to {
        flex: 1;
    }

    .template-zoho .zoho-ship-to {
        flex: 1;
        padding-left: 30px;
    }

    .template-zoho .zoho-invoice-number {
        text-align: right;
    }

    .template-zoho .zoho-bill-to h4,
    .template-zoho .zoho-ship-to h4 {
        margin: 0 0 12px 0;
        font-size: 12px;
        font-weight: 600;
        color: #999;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .template-zoho .zoho-bill-to .customer-name {
        font-size: 16px;
        font-weight: 600;
        color: #333;
        margin-bottom: 6px;
    }

    .template-zoho .zoho-bill-to p {
        margin: 0;
        font-size: 13px;
        color: #666;
        line-height: 1.7;
    }

    .template-zoho .zoho-invoice-number span {
        font-size: 12px;
        color: #999;
    }

    .template-zoho .zoho-invoice-number h3 {
        margin: 4px 0 0 0;
        font-size: 20px;
        font-weight: 700;
        color: #333;
    }

    .template-zoho .zoho-meta-table {
        background: #2ecc71;
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 25px;
    }

        .template-zoho .zoho-meta-table table {
            width: 100%;
        }

        .template-zoho .zoho-meta-table th {
            background: #2ecc71;
            color: #fff;
            padding: 12px 20px;
            font-size: 13px;
            font-weight: 500;
            text-align: center;
        }

        .template-zoho .zoho-meta-table td {
            background: #fff;
            padding: 12px 20px;
            font-size: 13px;
            color: #333;
            text-align: left;
        }

    .template-zoho .zoho-items-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 25px;
    }

        .template-zoho .zoho-items-table th {
            background: #2ecc71;
            color: #fff;
            padding: 14px 15px;
            font-size: 13px;
            font-weight: 500;
        }

        .template-zoho .zoho-items-table td {
            padding: 16px 15px;
            font-size: 13px;
            color: #444;
            border-bottom: 1px solid #eee;
            vertical-align: top;
        }

        .template-zoho .zoho-items-table .item-name {
            font-weight: 600;
            color: #333;
        }

        .template-zoho .zoho-items-table .item-desc {
            font-size: 12px;
            color: #888;
            margin-top: 4px;
        }

        /* ZOHO TABLE ALIGNMENT (ERP) */
        .template-zoho .zoho-items-table th,
        .template-zoho .zoho-items-table td {
            text-align: left;
        }

            .template-zoho .zoho-items-table th:nth-child(1),
            .template-zoho .zoho-items-table td:nth-child(1) {
                text-align: center;
            }
            /* # */

            .template-zoho .zoho-items-table th:nth-child(3),
            .template-zoho .zoho-items-table th:nth-child(4),
            .template-zoho .zoho-items-table th:nth-child(5),
            .template-zoho .zoho-items-table td:nth-child(3),
            .template-zoho .zoho-items-table td:nth-child(4),
            .template-zoho .zoho-items-table td:nth-child(5) {
                text-align: right;
            }
    /* Qty/Rate/Amount */

    .template-zoho .zoho-totals-section {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
    }

    .template-zoho .zoho-notes {
        flex: 1;
        padding-right: 40px;
    }

        .template-zoho .zoho-notes p {
            margin: 0;
            font-size: 13px;
            color: #666;
        }

    .template-zoho .zoho-totals {
        width: 280px;
    }

        .template-zoho .zoho-totals table {
            width: 100%;
        }

        .template-zoho .zoho-totals td {
            padding: 10px 0;
            font-size: 13px;
        }

            .template-zoho .zoho-totals td:first-child {
                text-align: left !important;
                color: #666;
                padding-right: 15px;
            }

            .template-zoho .zoho-totals td:last-child {
                text-align: right !important;
                font-weight: 500;
                width: 120px;
            }

        .template-zoho .zoho-totals tr.total-row {
            background: #f8f9fa;
        }

            .template-zoho .zoho-totals tr.total-row td {
                font-weight: 700;
                font-size: 15px;
                padding: 12px 0;
            }

    .template-zoho .zoho-terms {
        margin-top: 40px;
        padding-top: 20px;
        border-top: 1px solid #eee;
    }

        .template-zoho .zoho-terms h5 {
            margin: 0 0 10px 0;
            font-size: 13px;
            font-weight: 600;
            color: #333;
        }

        .template-zoho .zoho-terms p {
            margin: 0;
            font-size: 12px;
            color: #666;
            line-height: 1.7;
        }

    /* ===== TEMPLATE 3: TALLY STYLE ===== */
    .template-tally {
        padding: 30px;
        font-family: 'Times New Roman', serif;
    }

        .template-tally .tally-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 20px;
        }

        .template-tally .tally-logo {
            width: 100px;
            height: 100px;
            border: 1px solid #333;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            color: #666;
        }

            .template-tally .tally-logo img {
                width: 120px;
                height: 120px;
                max-width: 120px;
                max-height: 120px;
                object-fit: contain;
            }

        .template-tally .tally-company-info {
            text-align: right;
            flex: 1;
            padding-left: 20px;
        }

            .template-tally .tally-company-info h2 {
                margin: 0 0 8px 0;
                font-size: 18px;
                font-weight: 700;
                color: #333;
            }

            .template-tally .tally-company-info p {
                margin: 0;
                font-size: 12px;
                color: #555;
                line-height: 1.5;
            }

        .template-tally .tally-title {
            text-align: center;
            margin: 25px 0;
            padding: 10px 0;
            border-top: 1px solid #333;
            border-bottom: 1px solid #333;
        }

            .template-tally .tally-title h1 {
                margin: 0;
                font-size: 18px;
                font-weight: 700;
                color: #0066cc;
                letter-spacing: 1px;
            }

        .template-tally .tally-details-section {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }

        .template-tally .tally-bill-to {
            flex: 1;
        }

            .template-tally .tally-bill-to h4 {
                margin: 0 0 8px 0;
                font-size: 14px;
                font-weight: 700;
                color: #333;
            }

            .template-tally .tally-bill-to .customer-name {
                font-weight: 700;
                color: #333;
                margin-bottom: 4px;
            }

            .template-tally .tally-bill-to p {
                margin: 0;
                font-size: 12px;
                color: #555;
                line-height: 1.5;
            }

        .template-tally .tally-invoice-meta {
            width: 280px;
        }

            .template-tally .tally-invoice-meta table {
                width: 100%;
                border-collapse: collapse;
            }

            .template-tally .tally-invoice-meta td {
                padding: 6px 8px;
                font-size: 12px;
                border-bottom: 1px dotted #ccc;
            }

                .template-tally .tally-invoice-meta td:first-child {
                    color: #666;
                    width: 120px;
                    text-align: left;
                }

                .template-tally .tally-invoice-meta td:last-child {
                    font-weight: 600;
                    color: #333;
                    text-align: left;
                }

        .template-tally .tally-items-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
            border: 1px solid #333;
        }

            .template-tally .tally-items-table th {
                background: #f5f5f5;
                padding: 10px 8px;
                font-size: 11px;
                font-weight: 700;
                color: #333;
                border: 1px solid #333;
            }

            .template-tally .tally-items-table td {
                padding: 8px;
                font-size: 12px;
                color: #333;
                border: 1px solid #ccc;
                vertical-align: top;
            }

            /* TALLY TABLE ALIGNMENT (ERP) */
            .template-tally .tally-items-table th,
            .template-tally .tally-items-table td {
                text-align: left;
            }

                .template-tally .tally-items-table th:nth-child(1),
                .template-tally .tally-items-table td:nth-child(1) {
                    text-align: center;
                }
                /* S.No */

                .template-tally .tally-items-table th:nth-child(3),
                .template-tally .tally-items-table th:nth-child(4),
                .template-tally .tally-items-table th:nth-child(5),
                .template-tally .tally-items-table td:nth-child(3),
                .template-tally .tally-items-table td:nth-child(4),
                .template-tally .tally-items-table td:nth-child(5) {
                    text-align: right;
                }

                .template-tally .tally-items-table th:nth-child(6),
                .template-tally .tally-items-table td:nth-child(6),
                .template-tally .tally-items-table th:nth-child(7),
                .template-tally .tally-items-table td:nth-child(7) {
                    text-align: right;
                }

        .template-tally .tally-totals-row {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-bottom: 20px;
        }

        .template-tally .tally-amount-words {
            flex: 1;
            padding-right: 30px;
        }

            .template-tally .tally-amount-words span {
                font-size: 12px;
                color: #333;
            }

            .template-tally .tally-amount-words strong {
                display: block;
                margin-top: 4px;
            }

        .template-tally .tally-totals {
            width: 250px;
        }

            .template-tally .tally-totals table {
                width: 100%;
                border-collapse: collapse;
            }

            .template-tally .tally-totals td {
                padding: 6px 8px;
                font-size: 12px;
                border-bottom: 1px dotted #ccc;
            }

                .template-tally .tally-totals td:first-child {
                    text-align: left !important;
                    color: #666;
                }

                .template-tally .tally-totals td:last-child {
                    text-align: right !important;
                    font-weight: 500;
                    width: 90px;
                }

            .template-tally .tally-totals tr.net-amount {
                border-top: 2px solid #333;
                border-bottom: 2px solid #333;
            }

                .template-tally .tally-totals tr.net-amount td {
                    font-weight: 700;
                    font-size: 13px;
                    padding: 10px 8px;
                }

        .template-tally .tally-notes {
            margin-bottom: 20px;
            padding: 10px;
            background: #f9f9f9;
            border-left: 3px solid #0066cc;
        }

            .template-tally .tally-notes h5 {
                margin: 0 0 6px 0;
                font-size: 12px;
                font-weight: 600;
                color: #333;
            }

            .template-tally .tally-notes p {
                margin: 0;
                font-size: 11px;
                color: #666;
                line-height: 1.5;
            }

        .template-tally .tally-footer {
            display: flex;
            justify-content: space-between;
            margin-top: 40px;
            padding-top: 15px;
            border-top: 1px solid #ccc;
        }

        .template-tally .tally-footer-left p {
            margin: 0;
            font-size: 12px;
            color: #0066cc;
            font-weight: 600;
        }

        .template-tally .tally-footer-right {
            text-align: right;
        }

            .template-tally .tally-footer-right p {
                margin: 0;
                font-size: 12px;
                font-weight: 600;
                color: #333;
            }

    /* ===== THERMAL INVOICE ===== */
    .thermal-invoice {
        max-width: 320px;
        margin: 0 auto;
        background: #fff;
        font-family: 'Courier New', monospace;
        font-size: 12px;
        padding: 15px;
    }

    .thermal-header {
        text-align: center;
        border-bottom: 2px dashed #333;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    .thermal-logo img {
        width: 120px;
        height: 120px;
        max-width: 120px;
        max-height: 120px;
        object-fit: contain;
        margin-bottom: 8px;
    }

    .thermal-company-name {
        font-size: 14px;
        font-weight: bold;
        margin: 0;
    }

    .thermal-address {
        font-size: 10px;
        color: #555;
        margin-top: 4px;
    }

    .thermal-title {
        text-align: center;
        font-size: 14px;
        font-weight: bold;
        padding: 8px;
        border: 1px solid #333;
        margin-bottom: 10px;
    }

    .thermal-details {
        border: 1px solid #ddd;
        margin-bottom: 10px;
    }

    .thermal-detail-row {
        display: flex;
        justify-content: space-between;
        padding: 5px 8px;
        border-bottom: 1px dotted #ddd;
        font-size: 11px;
    }

        .thermal-detail-row:last-child {
            border-bottom: none;
        }

    .thermal-items-header {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr 1fr;
        font-weight: bold;
        font-size: 10px;
        padding: 5px 0;
        border-top: 1px solid #333;
        border-bottom: 1px solid #333;
    }

    .thermal-items-header.with-item-tax {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    }

    .thermal-item-row {
        padding: 6px 0;
        border-bottom: 1px dotted #ccc;
    }

    .thermal-item-name {
        font-weight: 500;
        margin-bottom: 3px;
    }

    .thermal-item-details {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr 1fr;
        font-size: 11px;
        color: #555;
    }

    .thermal-item-details.with-item-tax {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    }

    .thermal-totals {
        border: 1px solid #333;
        margin: 10px 0;
    }

    .thermal-total-row {
        display: flex;
        justify-content: space-between;
        padding: 5px 8px;
        font-size: 11px;
        border-bottom: 1px dotted #ddd;
    }

        .thermal-total-row:last-child {
            border-bottom: none;
        }

        .thermal-total-row.grand {
            font-weight: bold;
            font-size: 12px;
            background: #f5f5f5;
        }

    .thermal-footer {
        text-align: center;
        border: 1px solid #333;
        padding: 10px;
        font-weight: bold;
        margin-top: 10px;
    }

    .thermal-terms {
        text-align: center;
        font-size: 9px;
        color: #666;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px dashed #ccc;
    }

    /* THERMAL ALIGNMENT (ERP strict) */
    .thermal-items-header span:nth-child(2),
    .thermal-items-header span:nth-child(3),
    .thermal-items-header span:nth-child(4),
    .thermal-items-header span:nth-child(5) {
        text-align: right !important;
    }

    .thermal-item-details span:nth-child(2),
    .thermal-item-details span:nth-child(3),
    .thermal-item-details span:nth-child(4),
    .thermal-item-details span:nth-child(5) {
        text-align: right !important;
    }

    /* ===== TAX INVOICE TEMPLATE ===== */
    .template-taxinvoice {
        padding: 0;
        background: #fff;
        color: #000;
    }

    .tax-top-header {
        display: grid;
        grid-template-columns: 150px 1fr 250px;
        padding: 25px 30px;
        border: 2px solid #000;
        border-bottom: none;
        gap: 20px;
        align-items: start;
    }

    .tax-logo-section {
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .tax-logo-section img {
            width: 120px;
            height: 120px;
            max-width: 120px;
            max-height: 120px;
            object-fit: contain;
        }

    .tax-company-details {
        padding-top: 5px;
    }

        .tax-company-details h2 {
            margin: 0 0 8px 0;
            font-size: 16px;
            font-weight: 700;
            color: #000;
        }

        .tax-company-details p {
            margin: 0;
            font-size: 11px;
            line-height: 1.6;
            color: #000;
        }

    .tax-title-section {
        text-align: right;
        padding-top: 10px;
    }

        .tax-title-section h1 {
            margin: 0;
            font-size: 32px;
            font-weight: 700;
            letter-spacing: 4px;
            color: #000;
        }

    .tax-details-grid {
        display: grid;
        grid-template-columns: 130px 1fr;
        padding: 0px 26px;
        border-left: 2px solid #000;
        border-right: 2px solid #000;
        border-bottom: 2px solid #000;
        gap: 3px 0;
    }

    .tax-detail-label {
        font-size: 12px;
        color: #000;
    }

    .tax-detail-value {
        font-size: 12px;
        font-weight: 600;
        color: #000;
    }

    .tax-billto-section {
        padding: 15px 30px;
        background: #f5f5f5;
        border-left: 2px solid #000;
        border-right: 2px solid #000;
        border-bottom: 2px solid #000;
    }

        .tax-billto-section h4 {
            margin: 0 0 10px 0;
            font-size: 12px;
            font-weight: 700;
            color: #000;
        }

        .tax-billto-section h3 {
            margin: 0 0 5px 0;
            font-size: 14px;
            font-weight: 700;
            color: #000;
        }

        .tax-billto-section p {
            margin: 0;
            font-size: 11px;
            line-height: 1.5;
            color: #000;
        }

    .tax-table-wrapper {
        border-left: 2px solid #000;
        border-right: 2px solid #000;
    }

    .tax-table {
        width: 100%;
        border-collapse: collapse;
    }

        .tax-table thead {
            background: #e8e8e8;
        }

        .tax-table th {
            padding: 12px 10px;
            font-size: 11px;
            font-weight: 700;
            color: #000;
            border-top: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
        }

        .tax-table td {
            padding: 10px 10px;
            font-size: 11px;
            color: #000;
            border-bottom: 1px solid #e0e0e0;
            vertical-align: top;
        }

    .tax-item-qty-unit {
        font-size: 10px;
        color: #666;
    }

    /* TAX TABLE ALIGNMENT (ERP) */
    .tax-table th,
    .tax-table td {
        text-align: left;
    }

        .tax-table th:nth-child(1),
        .tax-table td:nth-child(1) {
            text-align: center;
        }
        /* # */

        /* Qty, Rate, Amount, Vat%, Vat Amt, Amount */
        .tax-table th:nth-child(3),
        .tax-table th:nth-child(4),
        .tax-table th:nth-child(5),
        .tax-table th:nth-child(6),
        .tax-table th:nth-child(7),
        .tax-table th:nth-child(8),
        .tax-table td:nth-child(3),
        .tax-table td:nth-child(4),
        .tax-table td:nth-child(5),
        .tax-table td:nth-child(6),
        .tax-table td:nth-child(7),
        .tax-table td:nth-child(8) {
            text-align: right;
        }

    .tax-bottom-section {
        display: grid;
        grid-template-columns: 1fr 400px;
        border-left: 2px solid #000;
        border-right: 2px solid #000;
        border-bottom: 2px solid #000;
        min-height: 168px;
    }

    .tax-notes-area {
        padding: 14px 23px;
        border-right: 1px solid #ccc;
    }

        .tax-notes-area h5 {
            margin: 0 0 10px 0;
            font-size: 12px;
            font-weight: 700;
            color: #000;
        }

        .tax-notes-area p {
            margin: 0 0 20px 0;
            font-size: 11px;
            line-height: 1.6;
            color: #000;
        }

    .tax-bank-details {
        font-size: 11px;
        line-height: 1.7;
        color: #000;
    }

    .tax-totals-area {
        display: flex;
        flex-direction: column;
    }

    .tax-totals-table {
        width: 100%;
        border-collapse: collapse;
    }

        .tax-totals-table td {
            border-bottom: 1px solid #e6e6e6;
        }

            .tax-totals-table td:first-child {
                text-align: left !important;
            }

            .tax-totals-table td:last-child {
                text-align: right !important;
                white-space: nowrap;
                font-variant-numeric: tabular-nums;
            }

    .tax-signature-wrapper {
        padding: 26px 27px 4px 30px;
        border-left: 2px solid #000;
        border-right: 2px solid #000;
        display: flex;
        justify-content: flex-end;
    }

    .tax-signature-container {
        text-align: center;
        width: 180px;
    }

    .tax-stamp-image {
        width: 110px;
        height: 110px;
        margin: 0 auto 15px auto;
    }

        .tax-stamp-image img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

    .tax-signature-line-custom {
        border-top: 1px solid #000;
        margin: 15px 0 8px 0;
    }

    .tax-signature-text {
        font-size: 11px;
        color: #000;
        font-weight: 500;
    }

    .tax-terms-wrapper {
        padding: 20px 30px 25px 30px;
        border-left: 2px solid #000;
        border-right: 2px solid #000;
        border-bottom: 2px solid #000;
    }

        .tax-terms-wrapper h4 {
            margin: 0 0 10px 0;
            font-size: 12px;
            font-weight: 700;
            color: #000;
        }

        .tax-terms-wrapper p {
            margin: 0 0 6px 0;
            font-size: 10px;
            line-height: 1.6;
            color: #000;
        }

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

    #printable-form, #printable-form * {
        visibility: visible;
    }

    #printable-form .inv-page-footer,
    #printable-form .inv-page-footer *,
    #printable-form .erp-print-document-footer,
    #printable-form .erp-print-document-footer * {
        visibility: visible !important;
    }

    #erp-print-fixed-footer-host,
    #erp-print-fixed-footer-host * {
        visibility: visible !important;
    }

    #erp-print-fixed-footer-host > .inv-page-footer,
    #erp-print-fixed-footer-host > .erp-print-document-footer,
    #erp-print-fixed-footer-host > .erp-print-footer-clone {
        display: block !important;
        visibility: visible !important;
        position: fixed !important;
        bottom: 12mm !important;
        left: 12mm !important;
        right: 12mm !important;
        width: auto !important;
        z-index: 2147483647 !important;
        background: #fff !important;
        border-top: 1px solid #cbd5e1 !important;
    }

        body {
            margin: 0;
            padding: 0;
        }

        .invoice-paper {
            position: relative;
            width: 100%;
            max-width: 100%;
            min-height: auto;
            padding: 0;
            box-shadow: none;
            margin: 0 auto;
            border-radius: 0;
            box-sizing: border-box;
            background: #fff !important;
        }

        .invoice-toolbar,
        .invoice-page-container > *:not(.invoice-preview-container) {
            display: none !important;
        }

        .invoice-preview-container {
            padding: 0;
            display: block;
        }

        .template-taxinvoice,
        .template-default,
        .template-zoho,
        .template-tally,
        .template-erp-a4,
        .template-invox,
        .thermal-invoice {
            width: 100%;
            box-sizing: border-box;
            -webkit-print-color-adjust: exact;
            print-color-adjust: exact;
            color-adjust: exact;
            color: #000 !important;
        }

        * {
            box-shadow: none !important;
        }

        .thermal-invoice {
            max-width: 320px;
            margin: 0 auto;
        }
    }

    @media (max-width: 768px) {
        .invoice-toolbar {
            flex-direction: column;
            align-items: stretch;
        }

        .toolbar-right {
            justify-content: center;
        }

        .default-details-section,
        .zoho-details-row,
        .tally-details-section {
            flex-direction: column;
            gap: 20px;
        }

        .tax-top-header {
            grid-template-columns: 1fr;
        }

        .tax-title-section {
            text-align: left;
        }

        .tax-bottom-section {
            grid-template-columns: 1fr;
        }
    }

@media print {
    body.invoice-details-print,
    body.invoice-details-print html {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: #fff !important;
    }

    body.invoice-details-print .page-wrapper,
    body.invoice-details-print .content,
    body.invoice-details-print .invoice-page-container,
    body.invoice-details-print .invoice-preview-container,
    body.invoice-details-print #printable-form,
    body.invoice-details-print .invoice-paper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        min-height: auto !important;
        height: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    body.invoice-details-print .template-default,
    body.invoice-details-print .template-zoho,
    body.invoice-details-print .template-tally,
    body.invoice-details-print .template-taxinvoice,
    body.invoice-details-print .template-erp-a4,
    body.invoice-details-print .template-invox {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    body.invoice-details-print .default-header {
        margin-bottom: 16px !important;
        padding-bottom: 12px !important;
    }

    body.invoice-details-print .default-logo img,
    body.invoice-details-print .zoho-logo img,
    body.invoice-details-print .tally-logo img,
    body.invoice-details-print .tax-logo-section img {
        width: 72px !important;
        height: 72px !important;
        max-width: 72px !important;
        max-height: 72px !important;
    }

    body.invoice-details-print .default-items-table,
    body.invoice-details-print .zoho-items-table,
    body.invoice-details-print .tally-items-table,
    body.invoice-details-print .tax-table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
    }

    body.invoice-details-print .default-items-table th,
    body.invoice-details-print .default-items-table td,
    body.invoice-details-print .zoho-items-table th,
    body.invoice-details-print .zoho-items-table td,
    body.invoice-details-print .tally-items-table th,
    body.invoice-details-print .tally-items-table td,
    body.invoice-details-print .tax-table th,
    body.invoice-details-print .tax-table td {
        padding: 6px 5px !important;
        font-size: 12px !important;
        line-height: 1.35 !important;
        word-wrap: break-word !important;
        overflow-wrap: anywhere !important;
    }

    body.invoice-details-print .default-company-info h2 {
        font-size: 18px !important;
    }

    body.invoice-details-print .default-company-info p,
    body.invoice-details-print .default-bill-to p,
    body.invoice-details-print .default-invoice-meta td {
        font-size: 12px !important;
    }

    body.invoice-details-print .default-title h1 {
        font-size: 22px !important;
        letter-spacing: 1px !important;
    }

    body.invoice-details-print .zoho-totals-section {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }

    body.invoice-details-print .zoho-totals {
        width: 260px !important;
        max-width: 42% !important;
        flex-shrink: 0 !important;
    }

    body.invoice-details-print .zoho-totals tr.total-row td,
    body.invoice-details-print .default-totals tr.grand-total td {
        font-size: 14px !important;
        font-weight: 700 !important;
    }

    body.invoice-details-print .default-totals {
        width: 260px !important;
        max-width: 45% !important;
    }

    body.invoice-details-print .default-totals table {
        width: 100% !important;
        max-width: 100% !important;
    }

    body.invoice-details-print .default-totals td {
        padding: 5px 0 !important;
        font-size: 12px !important;
    }

    body.invoice-details-print .default-amount-words,
    body.invoice-details-print .default-notes p {
        font-size: 12px !important;
    }

    body.invoice-details-print .sidebar,
    body.invoice-details-print .header,
    body.invoice-details-print #sidebar,
    body.invoice-details-print .invoice-toolbar,
    body.invoice-details-print .navbar,
    body.invoice-details-print .sidebar-contact,
    body.invoice-details-print .sidebar-themesettings,
    body.invoice-details-print .sidebar-themeoverlay,
    body.invoice-details-print .modal,
    body.invoice-details-print .toast,
    body.invoice-details-print .offcanvas,
    body.invoice-details-print .mobile_btn,
    body.invoice-details-print .no-print {
        display: none !important;
    }

    body.invoice-details-print .main-wrapper,
    body.invoice-details-print .page-wrapper,
    body.invoice-details-print .invoice-page-container,
    body.invoice-details-print .invoice-preview-container {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        min-height: auto !important;
        width: 100% !important;
        overflow: visible !important;
    }

    body.invoice-details-print #printable-form {
        page-break-before: auto !important;
        page-break-after: auto !important;
    }

    body.invoice-details-print .template-erp-a4,
    body.invoice-details-print .template-invox {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        display: block !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.invoice-details-print .template-erp-a4 .erp-a4-body,
    body.invoice-details-print .template-invox .invox-body,
    body.invoice-details-print .template-invox .invox-main {
        display: block !important;
        flex: none !important;
        min-height: auto !important;
        height: auto !important;
    }

    body.invoice-details-print .erp-a4-header {
        border-bottom-color: #1e293b !important;
    }

    body.invoice-details-print .erp-a4-items-table thead th {
        background: #1e293b !important;
        color: #fff !important;
    }

    body.invoice-details-print .erp-a4-totals {
        display: flex !important;
        justify-content: flex-end !important;
        width: 100% !important;
    }

    body.invoice-details-print .erp-a4-totals table {
        width: 240px !important;
        max-width: 100% !important;
    }

    body.invoice-details-print .erp-a4-totals td:last-child,
    body.invoice-details-print .erp-a4-value.erp-a4-balance-highlight,
    body.invoice-details-print .invox-balance-amount {
        white-space: nowrap !important;
        unicode-bidi: isolate;
    }

    body.invoice-details-print .erp-a4-totals tr.erp-a4-grand td {
        background: #f1f5f9 !important;
    }

    body.invoice-details-print .erp-a4-words {
        background: #f8fafc !important;
    }

    body.invoice-details-print .erp-a4-items-table,
    body.invoice-details-print .invox-table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        page-break-inside: auto;
    }

    body.invoice-details-print .erp-a4-items-table thead,
    body.invoice-details-print .invox-table thead {
        display: table-header-group;
    }

    body.invoice-details-print .invox-table thead th {
        background: #3482b4 !important;
        color: #fff !important;
    }

    body.invoice-details-print .invox-table tfoot tr.invox-grand td.invox-grand-bar {
        background: #eaf2f8 !important;
    }

    body.invoice-details-print .erp-a4-items-table tbody tr,
    body.invoice-details-print .erp-a4-items-table tbody td,
    body.invoice-details-print .invox-table tbody tr,
    body.invoice-details-print .invox-table tbody td {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    body.invoice-details-print .erp-a4-totals,
    body.invoice-details-print .erp-a4-words,
    body.invoice-details-print .invox-totals-wrap,
    body.invoice-details-print .invox-bottom-wrap,
    body.invoice-details-print .invox-words,
    body.invoice-details-print .invox-section,
    body.invoice-details-print .invox-footer {
        page-break-inside: auto;
    }

    body.invoice-details-print .erp-a4-footer,
    body.invoice-details-print .erp-a4-notes,
    body.invoice-details-print .erp-a4-terms {
        page-break-inside: auto;
    }

    body.invoice-details-print .accounting-print-pages {
        width: 100%;
    }

    body.invoice-details-print .a4-accounting-sheet {
        position: relative;
        width: 100%;
        max-width: 210mm;
        margin: 0 auto;
        padding: 0;
        box-sizing: border-box;
        page-break-after: always;
        break-after: page;
        min-height: auto;
    }

    body.invoice-details-print .a4-accounting-sheet:last-child {
        page-break-after: auto;
        break-after: auto;
    }
}
