body.invoice-body {
    background-color: #f4f4f4; /* Light gray background for the page, not the invoice itself */
    font-family: 'Arial', sans-serif; /* A common, clean font */
    color: #333;
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.invoice-container {
    max-width: 800px; /* Approx A4 width, adjust as needed */
    margin: 20px auto;
    background-color: #fff;
    padding: 30px; /* More padding inside the invoice */
    border: 1px solid #ddd;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
}

/* Typography */
.invoice-container h1, .invoice-container h2, .invoice-container h3, .invoice-container h4, .invoice-container h5 {
    margin-top: 0;
    color: #222; /* Darker headings */
}

.text-red {
    color: #D8000C; /* Example red color */
}

.text-blue {
    color: #0072CE; /* PureHD Blue */
}

.bold {
    font-weight: bold;
}

/* Header section */
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #0072CE; /* PureHD Blue */
}

.invoice-header .company-logo img {
    max-height: 60px; /* Adjust as needed */
    margin-bottom: 10px;
}

.invoice-header .company-details p,
.invoice-header .invoice-info p {
    margin-bottom: 2px;
    font-size: 0.9em;
}
.invoice-header .company-details strong,
.invoice-header .invoice-info strong {
    display: inline-block;
    min-width: 90px; /* For alignment */
}

.invoice-header .invoice-info {
    text-align: right;
}
.invoice-header .invoice-info h2 {
    color: #0072CE; /* PureHD Blue */
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: bold;
}

/* Use h1 for INVOICE text as per new HTML */
.invoice-header .invoice-info h1 {
    color: #0072CE; /* PureHD Blue */
    margin-bottom: 10px;
    font-size: 2.2em; /* Slightly larger for INVOICE */
    font-weight: bold;
    text-align: right;
}

.invoice-header .invoice-info table td {
    padding: 1px 0px 1px 5px; /* Reduced padding */
    font-size: 0.9em;
}
.invoice-header .invoice-info table td.label {
    font-weight: bold;
    min-width: 110px; /* Adjust for alignment */
    text-align: left;
}

/* New section for Bill To / Ship To / Amount Due Flex layout */
.bill-ship-amount-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.addresses-contact-sales {
    flex: 3; /* Takes more space */
    padding-right: 20px;
}

.amount-due-box {
    flex: 1; /* Takes less space */
    border: 2px solid #D8000C; /* Red border as per image */
    padding: 10px;
    text-align: center;
    background-color: #fff; /* White background */
    min-height: 80px; /* Ensure some height */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.amount-due-title {
    font-size: 0.8em !important; /* Override section-title if needed */
    color: #D8000C !important; /* Red text */
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 5px;
    border-bottom: none !important; /* Remove inherited border */
    padding-bottom: 0 !important;
}

.amount-due-value {
    font-size: 1.8em; /* Large font for the amount */
    font-weight: bold;
    color: #D8000C; /* Red text */
}

/* Original addresses styling, ensure it works within the new flex parent */
.addresses {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px; /* Reduced margin */
    padding-bottom: 0; /* Remove bottom padding/border here as it's on parent */
    border-bottom: none;
}
.addresses > div {
    width: 48%;
}
.addresses h5 {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.addresses p {
    margin-bottom: 2px;
    font-size: 0.9em;
}

/* Items table */
.invoice-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}
.invoice-items-table th, .invoice-items-table td {
    border: 1px solid #ddd;
    padding: 10px;
    font-size: 0.9em;
    text-align: left;
}
.invoice-items-table th {
    background-color: #e9ecef; /* Darker shade for header */
    color: #212529; /* Dark text for header */
    font-weight: bold;
}
.invoice-items-table thead { /* Added for better header separation */
    border-top: 1px solid #dee2e6;
    border-bottom: 2px solid #dee2e6;
}
.invoice-items-table tbody tr:nth-child(odd) td { /* Zebra-striping for odd rows */
    background-color: #f9f9f9;
}
.invoice-items-table .text-right {
    text-align: right;
}
.invoice-items-table .text-center {
    text-align: center;
}

/* Totals and Terms Section */
.totals-and-terms {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align items to the top */
    margin-top: 10px; /* Reduced top margin */
    margin-bottom: 20px;
}

.payment-terms-box {
    font-size: 0.9em;
    color: #333;
    /* Takes available space on the left */
}
.payment-terms-box .label {
    font-weight: bold;
}

.invoice-totals-summary {
    /* Was .invoice-totals, renamed for clarity */
    /* display: flex; was here, not needed for this sub-part */
    /* justify-content: flex-end; was here, not needed for this sub-part */
}

.invoice-totals-summary table {
    width: 300px; /* Adjust as needed */
    border-collapse: collapse;
}
.invoice-totals-summary td {
    padding: 5px 10px; /* Adjusted padding */
    font-size: 0.9em;
}
.invoice-totals-summary tr td.label { /* Changed from :first-child for specificity */
    text-align: right;
    font-weight: bold;
    color: #555;
    padding-right: 10px;
}
.invoice-totals-summary tr td:last-child:not(.label) { /* Ensure data cell is right aligned */
    text-align: right;
}

.invoice-totals-summary tr.grand-total td {
    font-weight: bold;
    font-size: 1.2em; /* Slightly larger total */
    color: #333; /* Black for total as per image */
    border-top: 2px solid #333;
    padding-top: 8px;
    padding-bottom: 8px;
}

.invoice-totals-summary .payments-applied-header {
    font-size: 0.8em;
    text-align: right;
    padding-top: 10px;
    padding-bottom: 0;
}

.invoice-totals-summary tr.balance-due-row td {
    font-weight: bold;
    font-size: 0.9em;
}

/* Payment and Notes Section */
.payment-notes-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-size: 0.85em;
}

/* Added for visual separation of payment notes sub-sections */
.payment-notes-section .notice-box,
.payment-notes-section .payment-info-box,
.payment-notes-section .lockbox-info {
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}
/* Remove bottom margin from the last child to avoid double spacing if followed by another element */
.payment-notes-section .notice-box:last-child,
.payment-notes-section .payment-info-box:last-child,
.payment-notes-section .lockbox-info:last-child {
    margin-bottom: 0;
}

.payment-notes-section .notice-box {
    border: 1px solid #D8000C; /* Red border for notice */
    padding: 15px;
    margin-bottom: 20px;
    background-color: #FFD2D2; /* Light red background */
}

.payment-notes-section .payment-info-box {
    border: 1px solid #0072CE; /* Blue border for payment info */
    padding: 15px;
    margin-bottom: 20px;
}

.payment-notes-section h5 {
    font-size: 1em;
    color: #333;
    margin-bottom: 8px;
}

.payment-status-stamp {
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    color: #D8000C; /* Red for due/past due */
    margin-top: 15px; /* Adjusted margin */
    margin-bottom: 15px;
}

.payment-notes-section .new-address-notice {
    text-align:center; 
    border: 1px solid #888; /* Grey border */
    background-color: #f8f8f8; /* Lighter grey background */
    padding: 10px;
    margin-bottom: 15px;
}
.payment-notes-section .new-address-notice h5{
    margin-bottom: 5px;
    font-size: 0.9em;
}
.payment-notes-section .new-address-notice p {
    margin: 2px 0;
    font-size: 0.9em;
}
.payment-notes-section .update-available-note {
    margin-top:8px; 
    font-size:0.85em;
}

.payment-notes-section .ach-cc-info {
    border: 2px solid #D8000C; /* Red border */
    padding: 10px;
    margin-bottom: 15px;
    font-size: 0.85em;
}
.payment-notes-section .ach-cc-info p {
    margin: 5px 0;
}

.payment-notes-section .lockbox-info {
    padding-top: 0; /* Removed extra padding if border was removed */
    border-top: none;
    font-size: 0.85em;
}
.payment-notes-section .lockbox-info p {
    margin-bottom: 2px;
}

.print-actions {
    text-align: center; 
    margin-top: 20px;
}
.print-actions button, .print-actions a {
    padding: 10px 20px; 
    font-size: 1em; 
    cursor: pointer;
    margin-left: 10px;
    text-decoration: none;
    border: 1px solid #ccc; 
    border-radius: 4px;
}
.print-actions button {
    background-color: #0072CE;
    color: white;
    border-color: #0072CE;
}
.print-actions a {
    background-color: #eee;
    color: #333;
}

/* Invoice Header company logo and details alignment */
.company-logo-img {
    max-height: 50px; /* Adjust as needed */
    margin-bottom: 10px;
}

.invoice-header .company-details .label {
    display: inline-block;
    min-width: 60px; /* For alignment of Phone, Fax etc */
    font-weight: bold; 
}

.contact-salesperson-info {
    font-size: 0.9em;
    margin-top: -10px; /* Adjust to pull it up */
    margin-bottom: 20px; /* Spacing below it */
}
.contact-salesperson-info table td {
    padding: 1px 5px 1px 0; /* Minimal padding */
    vertical-align: top;
    font-size: 0.9em; /* Match other address text */
}
.contact-salesperson-info table td.label { /* Changed from :first-child for specificity */
    font-weight: bold;
    min-width: 90px; /* For alignment */
}

.invoice-items-table .ava-tax-note {
    /* Style for the AvaTax note */
    font-size: 0.8em;
    color: #6c757d;
    font-style: italic;
    font-weight: normal; /* Ensure it's not bold if parent is */
}

.section-title {
    font-size: 0.75em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
    border-bottom: 1px solid #eee;
    padding-bottom: 2px;
}

/* Styles for the new print-only QR code section */
.payment-qr-section {
    text-align: center; /* Center the QR code and text */
    margin-top: 15px;
    margin-bottom: 15px;
}
.qr-code-img {
    max-width: 150px; /* Adjust size as needed */
    height: auto;
    margin: 10px auto;
    display: block;
}
.full-payment-url {
    font-size: 0.9em;
    word-break: break-all; /* Ensure long URLs wrap */
}

/* Initially hide print-only elements */
.print-only {
    display: none;
}

/* Print-specific styles */
@media print {
    body.invoice-body {
        background-color: #fff;
        padding: 0;
        margin: 0;
        font-size: 10pt; /* Adjust for print if necessary */
    }
    .invoice-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
    }
    .no-print {
        display: none !important;
    }
    /* Show print-only elements when printing */
    .print-only {
        display: block !important;
    }
    .invoice-header, .addresses, .invoice-items-table, .invoice-totals, .payment-notes-section {
        page-break-inside: avoid;
    }
} 