/* ============================================================
   KUI WAKA HIRE CARS - INVOICE SYSTEM STYLES
   MOBILE RESPONSIVE + FIXED DESKTOP PDF LAYOUT
   ============================================================ */

/* ---------- GLOBAL ---------- */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background: #f0ebe6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* ============================================================
   LOGIN OVERLAY
   ============================================================ */

#loginOverlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.35s ease;
}

#loginOverlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    background: #ffffff;
    max-width: 400px;
    width: 94%;
    padding: 2.2rem 1.8rem 2rem;
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    border-top: 6px solid #C41E3A;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0.2rem;
}

.login-logo {
    max-height: 60px;
    width: auto;
    object-fit: contain;
}

.login-brand span {
    font-weight: 700;
    font-size: 1.7rem;
    color: #1A1A2E;
}

.login-sub {
    font-size: 0.7rem;
    color: #C41E3A;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: -4px;
}

.login-card h2 {
    font-weight: 600;
    color: #1A1A2E;
    font-size: 1.4rem;
    margin-top: 0.6rem;
}

.login-desc {
    color: #6b6b7a;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.login-card .input-group {
    margin-bottom: 1rem;
    text-align: left;
}

.login-card label {
    font-weight: 600;
    font-size: 0.75rem;
    color: #1A1A2E;
    display: block;
    margin-bottom: 0.2rem;
}

.login-card label i {
    color: #C41E3A;
    width: 20px;
}

.login-card input {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid #e0dad4;
    border-radius: 12px;
    font-size: 0.95rem;
    background: #f9f6f2;
    transition: 0.2s;
}

.login-card input:focus {
    outline: none;
    border-color: #C41E3A;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.08);
}

.login-btn {
    width: 100%;
    padding: 0.8rem;
    background: #C41E3A;
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(196, 30, 58, 0.25);
    transition: 0.2s;
    margin-top: 0.3rem;
}

.login-btn:hover {
    background: #a01830;
    transform: translateY(-2px);
}

.login-error {
    color: #C41E3A;
    font-size: 0.75rem;
    margin-top: 0.6rem;
    min-height: 1.2rem;
}

/* ============================================================
   APP CONTAINER
   ============================================================ */

.app-container {
    display: none;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.app-container.active {
    display: block;
}

/* ============================================================
   HEADER
   ============================================================ */

.app-header {
    background: #1A1A2E;
    padding: 0.8rem 1.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #C41E3A;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.header-logo {
    max-height: 50px;
    width: auto;
    object-fit: contain;
}

.header-left h1 {
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.header-left p {
    color: #C41E3A;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: -2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.header-user {
    color: #e0dad4;
    font-size: 0.85rem;
}

.header-user i {
    color: #C41E3A;
    margin-right: 0.3rem;
}

.btn-logout {
    background: transparent;
    border: 2px solid #C41E3A;
    color: #C41E3A;
    padding: 0.3rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    transition: 0.2s;
}

.btn-logout:hover {
    background: #C41E3A;
    color: white;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */

.main-content {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 1.2rem;
    padding: 1.5rem;
    background: #f8f5f2;
    min-height: calc(100vh - 90px);
}

/* ============================================================
   FORM SECTION
   ============================================================ */

.form-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    height: fit-content;
}

.form-header {
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e5e0da;
}

.form-header h2 {
    font-size: 1.2rem;
    color: #1A1A2E;
}

.form-header h2 i {
    color: #C41E3A;
    margin-right: 0.4rem;
}

.form-group {
    margin-bottom: 0.7rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1A1A2E;
    margin-bottom: 0.15rem;
}

.form-group label i {
    color: #C41E3A;
    margin-right: 0.3rem;
    width: 16px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: #f9f6f2;
    border: 2px solid #e5e0da;
    border-radius: 10px;
    font-size: 0.85rem;
    transition: 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #C41E3A;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.06);
    background: #ffffff;
}

.form-group input[readonly] {
    background: #f0ece6;
    cursor: default;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}

.section-label {
    margin-top: 1rem;
    font-size: 0.95rem;
    color: #C41E3A;
    border-bottom: 2px solid #C41E3A;
    padding-bottom: 0.2rem;
    margin-bottom: 0.6rem;
}

.btn-block {
    width: 100%;
    margin-top: 0.8rem;
}

/* ============================================================
   INVOICE SECTION
   ============================================================ */

.invoice-section {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.invoice-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid #e5e0da;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.invoice-preview-header h2 {
    font-size: 1.2rem;
    color: #1A1A2E;
}

.invoice-preview-header h2 i {
    color: #C41E3A;
    margin-right: 0.4rem;
}

.action-buttons {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ============================================================
   PDF CONTAINER
   IMPORTANT:
   Screen can be responsive.
   PDF generation always uses fixed desktop width.
   ============================================================ */

#pdfContainer {
    width: 100%;
    max-width: 780px;
    margin: 0 auto;
    padding: 15px;
    background: white;
    box-sizing: border-box;
}

#invoiceContent {
    width: 100%;
    max-width: 100%;
    background: white;
    border-radius: 12px;
    padding: 1.2rem;
    font-family: 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #e5e0da;
    box-sizing: border-box;
}

/* ============================================================
   INVOICE HEADER
   ============================================================ */

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    border-bottom: 2px dashed #e5e0da;
    padding-bottom: 0.8rem;
    margin-bottom: 0.8rem;
    gap: 0.5rem;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.invoice-logo {
    max-height: 65px;
    width: auto;
    object-fit: contain;
}

.brand-text h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #1A1A2E;
}

.brand-text span {
    display: block;
    font-size: 0.6rem;
    font-weight: 500;
    color: #C41E3A;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.invoice-title {
    text-align: right;
}

.invoice-title h2 {
    font-size: 1.2rem;
    font-weight: 300;
    color: #C41E3A;
    letter-spacing: 1px;
}

.invoice-title p {
    font-size: 0.75rem;
    color: #6b6b7a;
    margin-top: 0.1rem;
}

/* ============================================================
   INVOICE DETAILS
   ============================================================ */

.invoice-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem 1rem;
    background: #f9f6f2;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    margin-bottom: 0.8rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item .label {
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #8a8a9a;
}

.detail-item .value {
    font-size: 0.75rem;
    font-weight: 500;
    color: #1A1A2E;
    margin-top: 1px;
    word-break: break-word;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

/* ============================================================
   INVOICE TABLE
   ============================================================ */

.invoice-table-wrap {
    overflow-x: auto;
    margin: 0.6rem 0;
    border-radius: 10px;
    border: 1px solid #ece7e1;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    min-width: 280px;
}

th {
    background: #f1ede8;
    color: #1A1A2E;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 2px solid #C41E3A;
}

td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #eae5df;
    color: #2d2d3f;
}

tr:last-child td {
    border-bottom: none;
}

.text-right {
    text-align: right;
}

.highlight {
    font-weight: 600;
    color: #C41E3A;
}

.total-row td {
    font-weight: 700;
    font-size: 0.9rem;
    background: #f9f6f2;
    border-top: 2px solid #C41E3A;
}

.total-row .highlight {
    font-size: 1rem;
}

/* ============================================================
   CUSTOMER AGREEMENT
   ONLY ONE CUSTOMER NAME UNDERLINE
   ============================================================ */

.agreement-section {
    margin-top: 0.8rem;
    padding: 0.8rem;
    background: #f9f6f2;
    border-radius: 8px;
    border: 2px solid #C41E3A;
}

.agreement-section .agreement-title {
    font-weight: 700;
    color: #1A1A2E;
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
}

.agreement-section .agreement-text {
    font-size: 0.85rem;
    color: #1A1A2E;
    line-height: 1.6;
    margin-bottom: 0.6rem;
}

.agreement-section .agreement-text .bold {
    font-weight: 700;
    font-size: 0.9rem;
}

/*
   CUSTOMER NAME LINE
   There is only ONE underline.
   No extra border or duplicate line.
*/

.agreement-section .agreement-text .highlight-red {
    display: inline-block;
    min-width: 200px;
    height: 1.25em;
    vertical-align: baseline;
    margin: 0 3px;
    padding: 0 3px 1px;
    border: none;
    border-bottom: 2px solid #C41E3A;
    background: transparent;
    color: #C41E3A;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.1;
    box-shadow: none;
    outline: none;
}

/* Prevent any duplicate underline from pseudo-elements */

.agreement-section .agreement-text .highlight-red::before,
.agreement-section .agreement-text .highlight-red::after {
    content: none !important;
    display: none !important;
}

/* Agreement input fields */

.agreement-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.agreement-row .agreement-field label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #1A1A2E;
    display: block;
    margin-bottom: 0.15rem;
}

.agreement-row .agreement-field input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 2px solid #e5e0da;
    border-radius: 8px;
    font-size: 0.85rem;
    background: white;
}

.agreement-row .agreement-field input:focus {
    outline: none;
    border-color: #C41E3A;
}

.agreement-row .agreement-field input[readonly] {
    background: #f0ece6;
    cursor: default;
}

/* ============================================================
   SIGNATURES
   ============================================================ */

.signature-grid {
    margin-top: 0.8rem;
    padding: 0.8rem 0.8rem 0.3rem;
    background: #f9f6f2;
    border-radius: 8px;
    border-top: 2px solid #C41E3A;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.sig-left {
    grid-column: 1 / 2;
}

.sig-right {
    grid-column: 2 / 3;
}

.sig-full {
    grid-column: 1 / -1;
}

.sig-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1A1A2E;
}

.sig-line {
    border-bottom: 2px solid #1A1A2E;
    height: 35px;
    margin-top: 0.2rem;
}

.sig-underscore {
    font-size: 0.65rem;
    color: #6b6b7a;
    margin-top: 0.1rem;
}

/* ============================================================
   TERMS
   ============================================================ */

.terms {
    margin-top: 0.8rem;
    padding: 0.5rem 0.8rem;
    background: #f9f6f2;
    border-radius: 8px;
    border-left: 4px solid #C41E3A;
    font-size: 0.7rem;
    color: #1A1A2E;
    text-align: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    background: #f0ece6;
    color: #1A1A2E;
}

.btn-primary {
    background: #C41E3A;
    color: white;
    box-shadow: 0 4px 14px rgba(196, 30, 58, 0.2);
}

.btn-primary:hover {
    background: #a01830;
    transform: translateY(-2px);
}

.btn-outline {
    border: 2px solid #C41E3A;
    background: transparent;
    color: #C41E3A;
}

.btn-outline:hover {
    background: #C41E3A;
    color: white;
}

/* ============================================================
   FOOTER
   ============================================================ */

.app-footer {
    background: #1A1A2E;
    padding: 0.8rem 2rem;
    border-top: 3px solid #C41E3A;
    text-align: center;
}

.footer-content p {
    color: #e0dad4;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

/* ============================================================
   TABLET RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {

    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .form-section {
        margin-right: 0;
    }

    .invoice-section {
        margin-left: 0;
    }
}

/* ============================================================
   MOBILE RESPONSIVE SCREEN VIEW
   THESE RULES DO NOT AFFECT PDF GENERATION MODE
   ============================================================ */

@media (max-width: 768px) {

    .app-header {
        padding: 0.6rem 1rem;
        flex-direction: column;
        gap: 0.4rem;
    }

    .header-left {
        width: 100%;
        justify-content: center;
    }

    .header-left h1 {
        font-size: 0.95rem;
    }

    .header-right {
        width: 100%;
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .invoice-details {
        grid-template-columns: 1fr 1fr;
        gap: 0.3rem 0.8rem;
    }

    .invoice-preview-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .action-buttons {
        justify-content: center;
    }

    .invoice-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .invoice-title {
        text-align: left;
        width: 100%;
    }

    .agreement-row {
        grid-template-columns: 1fr;
    }

    .signature-grid {
        grid-template-columns: 1fr;
    }

    .sig-left,
    .sig-right,
    .sig-full {
        grid-column: 1 / -1;
    }

    .app-footer {
        padding: 0.6rem 1rem;
    }

    .footer-content p {
        font-size: 0.65rem;
    }

    .invoice-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
    }

    #pdfContainer {
        width: min(94vw, 560px);
        max-width: 560px;
        margin: 0 auto;
        padding: 8px;
        box-sizing: border-box;
    }

    #invoiceContent {
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 8px;
        box-sizing: border-box;
    }

    .agreement-section .agreement-title {
        font-size: 0.8rem;
    }

    .agreement-section .agreement-text {
        font-size: 0.75rem;
        line-height: 1.5;
    }

    .agreement-section .agreement-text .bold,
    .agreement-section .agreement-text .highlight-red {
        font-size: 0.8rem;
    }

    .agreement-section .agreement-text .highlight-red {
        min-width: 160px;
    }
}

/* ============================================================
   SMALL MOBILE
   ============================================================ */

@media (max-width: 480px) {

    body {
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .app-container {
        border-radius: 16px;
    }

    .app-header {
        padding: 0.5rem 0.8rem;
    }

    .main-content {
        padding: 0.6rem;
    }

    .form-section {
        padding: 0.8rem;
    }

    .invoice-section {
        padding: 0.6rem;
    }

    #pdfContainer {
        width: 94vw;
        max-width: 420px;
        padding: 4px;
    }

    #invoiceContent {
        padding: 5px;
    }

    .invoice-details {
        grid-template-columns: 1fr;
    }

    .brand-box {
        flex-wrap: wrap;
    }

    .invoice-logo {
        max-height: 50px;
    }

    .brand-text h1 {
        font-size: 1.1rem;
    }

    .login-card {
        padding: 1.5rem 1.2rem;
        margin: 0 0.5rem;
    }

    .app-footer {
        padding: 0.4rem 0.6rem;
    }

    .footer-content p {
        font-size: 0.6rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.7rem;
    }

    .invoice-title h2 {
        font-size: 1rem;
    }

    table {
        font-size: 0.7rem;
    }

    th,
    td {
        padding: 0.3rem 0.4rem;
    }

    .agreement-section .agreement-title {
        font-size: 0.7rem;
    }

    .agreement-section .agreement-text {
        font-size: 0.65rem;
        line-height: 1.4;
    }

    .agreement-section .agreement-text .bold,
    .agreement-section .agreement-text .highlight-red {
        font-size: 0.7rem;
    }

    .agreement-section .agreement-text .highlight-red {
        min-width: 130px;
    }
}

/* ============================================================
   VERY SMALL SCREENS
   ============================================================ */

@media (max-width: 360px) {

    #pdfContainer {
        width: 92vw;
        max-width: 330px;
    }

    #invoiceContent {
        padding: 3px;
    }
}

/* ============================================================
   PDF GENERATION MODE
   IMPORTANT:
   THIS OVERRIDES ALL MOBILE STYLES.
   THE PDF ALWAYS USES DESKTOP LAYOUT.
   ============================================================ */

body.pdf-generation-mode {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    width: 100% !important;
    min-width: 780px !important;
    overflow: visible !important;
}

body.pdf-generation-mode .app-container {
    width: 100% !important;
    max-width: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

body.pdf-generation-mode #pdfContainer {
    display: block !important;
    width: 780px !important;
    min-width: 780px !important;
    max-width: 780px !important;
    padding: 0 !important;
    margin: 0 auto !important;
    background: white !important;
}

body.pdf-generation-mode #invoiceContent {
    display: block !important;
    width: 780px !important;
    min-width: 780px !important;
    max-width: 780px !important;
    padding: 12px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: white !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    font-size: 10pt !important;
}

/* ---------- PDF HEADER ---------- */

body.pdf-generation-mode #invoiceContent .invoice-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding-bottom: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

body.pdf-generation-mode #invoiceContent .brand-box {
    display: flex !important;
    flex-wrap: nowrap !important;
}

body.pdf-generation-mode #invoiceContent .brand-text h1 {
    font-size: 18pt !important;
}

body.pdf-generation-mode #invoiceContent .brand-text span {
    font-size: 9pt !important;
}

body.pdf-generation-mode #invoiceContent .invoice-title {
    text-align: right !important;
    width: auto !important;
}

body.pdf-generation-mode #invoiceContent .invoice-title h2 {
    font-size: 16pt !important;
}

body.pdf-generation-mode #invoiceContent .invoice-title p {
    font-size: 10pt !important;
}

/* ---------- PDF DETAILS ---------- */

body.pdf-generation-mode #invoiceContent .invoice-details {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 0.4rem 1rem !important;
    padding: 0.4rem 0.6rem !important;
    margin-bottom: 0.5rem !important;
}

body.pdf-generation-mode #invoiceContent .detail-item .label {
    font-size: 8pt !important;
}

body.pdf-generation-mode #invoiceContent .detail-item .value {
    font-size: 10pt !important;
}

/* ---------- PDF TABLE ---------- */

body.pdf-generation-mode #invoiceContent .invoice-table-wrap {
    overflow: visible !important;
}

body.pdf-generation-mode #invoiceContent table {
    width: 100% !important;
    min-width: 0 !important;
    font-size: 10pt !important;
}

body.pdf-generation-mode #invoiceContent th {
    font-size: 10pt !important;
    padding: 0.4rem 0.5rem !important;
}

body.pdf-generation-mode #invoiceContent td {
    font-size: 10pt !important;
    padding: 0.4rem 0.5rem !important;
}

body.pdf-generation-mode #invoiceContent .total-row td {
    font-size: 11pt !important;
}

body.pdf-generation-mode #invoiceContent .total-row .highlight {
    font-size: 12pt !important;
}

/* ============================================================
   PDF CUSTOMER AGREEMENT
   DESKTOP SIZE + ONLY ONE CUSTOMER NAME LINE
   ============================================================ */

body.pdf-generation-mode #invoiceContent .agreement-section {
    padding: 0.6rem !important;
    margin-top: 0.5rem !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

body.pdf-generation-mode #invoiceContent .agreement-section .agreement-title {
    font-size: 11pt !important;
    margin-bottom: 0.3rem !important;
}

body.pdf-generation-mode #invoiceContent .agreement-section .agreement-text {
    font-size: 10pt !important;
    line-height: 1.5 !important;
    margin-bottom: 0.4rem !important;
}

body.pdf-generation-mode #invoiceContent .agreement-section .agreement-text .bold {
    font-size: 10pt !important;
}

/*
   ONE CUSTOMER NAME LINE ONLY
*/

body.pdf-generation-mode
#invoiceContent
.agreement-section
.agreement-text
.highlight-red {
    display: inline-block !important;
    min-width: 200px !important;
    height: 1.2em !important;
    padding: 0 4px 1px 4px !important;
    margin: 0 2px !important;

    border: none !important;
    border-bottom: 2px solid #C41E3A !important;

    background: transparent !important;
    color: #C41E3A !important;
    font-weight: 700 !important;
    font-size: 10pt !important;
    line-height: 1.1 !important;

    box-shadow: none !important;
    outline: none !important;
}

body.pdf-generation-mode
#invoiceContent
.agreement-section
.agreement-text
.highlight-red::before,

body.pdf-generation-mode
#invoiceContent
.agreement-section
.agreement-text
.highlight-red::after {
    content: none !important;
    display: none !important;
    border: none !important;
}

/* ---------- PDF AGREEMENT FIELDS ---------- */

body.pdf-generation-mode #invoiceContent .agreement-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.8rem !important;
}

body.pdf-generation-mode #invoiceContent .agreement-row .agreement-field label {
    font-size: 8pt !important;
}

body.pdf-generation-mode #invoiceContent .agreement-row .agreement-field input {
    font-size: 10pt !important;
    padding: 0.3rem 0.4rem !important;
}

/* ---------- PDF SIGNATURE ---------- */

body.pdf-generation-mode #invoiceContent .signature-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    padding: 0.5rem 0.5rem 0.2rem !important;
    margin-top: 0.5rem !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

body.pdf-generation-mode #invoiceContent .sig-left {
    grid-column: 1 / 2 !important;
}

body.pdf-generation-mode #invoiceContent .sig-right {
    grid-column: 2 / 3 !important;
}

body.pdf-generation-mode #invoiceContent .sig-full {
    grid-column: 1 / -1 !important;
}

body.pdf-generation-mode #invoiceContent .sig-label {
    font-size: 9pt !important;
}

body.pdf-generation-mode #invoiceContent .sig-line {
    height: 30px !important;
}

body.pdf-generation-mode #invoiceContent .sig-underscore {
    font-size: 8pt !important;
}

/* ---------- PDF TERMS ---------- */

body.pdf-generation-mode #invoiceContent .terms {
    font-size: 8pt !important;
    padding: 0.4rem 0.5rem !important;
    margin-top: 0.5rem !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

/* ============================================================
   PRINT / PDF
   ============================================================ */

@media print {

    body {
        display: block !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .app-header,
    .form-section,
    .invoice-preview-header,
    .action-buttons,
    .app-footer {
        display: none !important;
    }

    .app-container {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: white !important;
    }

    .main-content {
        display: block !important;
        padding: 0 !important;
        background: white !important;
        min-height: auto !important;
    }

    .invoice-section {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }

    #pdfContainer {
        width: 780px !important;
        max-width: 780px !important;
        padding: 0 !important;
        margin: 0 auto !important;
    }

    #invoiceContent {
        width: 780px !important;
        max-width: 780px !important;
        padding: 12px !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    .invoice-details {
        grid-template-columns: 1fr 1fr 1fr !important;
        background: #f9f6f2 !important;
        padding: 0.4rem 0.6rem !important;
    }

    .invoice-logo {
        max-height: 55px !important;
    }

    .invoice-table-wrap {
        overflow: visible !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .agreement-section,
    .signature-grid,
    .terms {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}