.billing-app {
    min-height: 100vh;
    background: #f4f7fa
}

.billing-main {
    margin-left: 245px;
    padding: 2.35rem clamp(1.25rem, 4vw, 4.5rem)
}

.billing-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1.35rem
}

.billing-header h1 {
    margin: .25rem 0;
    font-family: 'Playfair Display', serif;
    font-size: 2.25rem;
    letter-spacing: -.045em
}

.billing-header p {
    margin: 0;
    color: var(--muted)
}

.billing-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap
}

.billing-notice {
    display: flex;
    gap: .6rem;
    align-items: flex-start;
    margin-bottom: 1.4rem;
    padding: .85rem 1rem;
    border: 1px solid #cee1f5;
    border-radius: 9px;
    background: #eef7ff;
    color: #37668e;
    font-size: .86rem
}

.billing-notice i {
    color: var(--blue);
    font-size: 1rem
}

.invoice-stage {
    overflow: auto;
    padding: 2rem;
    border: 1px solid #e1e7ed;
    border-radius: 14px;
    background: #edf1f5
}

.invoice-sheet {
    width: min(100%, 920px);
    min-width: 740px;
    margin: auto;
    padding: 26px 28px 35px;
    border: 1px solid #b8c0c7;
    background: #fff;
    color: #111;
    font-family: Georgia, 'Times New Roman', serif;
    box-shadow: 0 12px 28px #17385a14
}

.invoice-branding {
    padding-bottom: 8px;
    border-bottom: 1px solid #111;
    text-align: center
}

.invoice-branding h2 {
    margin: 0 0 5px;
    font-size: 2.35rem;
    letter-spacing: .04em
}

.invoice-branding p {
    margin: 1px;
    font-size: .78rem
}

.invoice-branding span {
    font-size: .85rem
}

.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 122px;
    padding: 21px 4px 0;
    font-family: 'DM Sans', sans-serif;
    font-size: .82rem
}

.invoice-meta p {
    margin-top: 24px;
    font-weight: 600
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DM Sans', sans-serif;
    font-size: .77rem;
    text-align: center
}

.invoice-table th,
.invoice-table td {
    padding: 4px 5px;
    border: 1px solid #222;
    line-height: 1.2
}

.invoice-table th {
    font-size: .74rem
}

.invoice-table .charge-row td {
    border-top: 0;
    border-bottom: 0;
    padding: 2px 5px
}

.invoice-table .blank-row td {
    height: 36px
}

.invoice-table tfoot td {
    text-align: right
}

.invoice-table tfoot td:last-child {
    text-align: center
}

.amount-words {
    margin: 0;
    padding: 6px 8px;
    border: 1px solid #222;
    border-top: 0;
    font-family: 'DM Sans', sans-serif;
    font-size: .78rem
}

.invoice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 8px 0;
    font-family: 'DM Sans', sans-serif
}

.bank-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 7px;
    border: 1px solid #222;
    font-size: .74rem
}

.signature {
    display: flex;
    min-width: 240px;
    min-height: 95px;
    flex-direction: column;
    text-align: center;
    font-size: .84rem
}

.signature span {
    margin-top: auto
}

.theme-options {
    display: grid;
    gap: .65rem
}

.theme-option {
    display: grid;
    grid-template-columns: 42px 1fr;
    column-gap: .75rem;
    align-items: center;
    padding: .7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    text-align: left
}

.theme-option small {
    grid-column: 2;
    color: var(--muted)
}

.theme-option.selected {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px #2877d71a
}

.theme-swatch {
    grid-row: span 2;
    width: 38px;
    height: 38px;
    border: 1px solid #c7cfd7;
    border-radius: 6px
}

.theme-swatch.classic {
    background: linear-gradient(#fff 33%, #222 33% 39%, #fff 39%)
}

.theme-swatch.navy {
    background: linear-gradient(#112a46 33%, #fff 33% 80%, #2877d7 80%)
}

.theme-swatch.green {
    background: linear-gradient(#137a57 33%, #fff 33% 80%, #75c7a9 80%)
}

@media(max-width:850px) {
    .billing-main {
        margin-left: 0;
        padding: 1.15rem 0.85rem 2rem;
        width: 100%;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1020;
        width: 100%;
        min-height: auto;
    }

    .billing-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.85rem;
        margin-bottom: 1.2rem;
    }

    .billing-header h1 {
        font-size: clamp(1.4rem, 5.5vw, 1.85rem);
    }

    .billing-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .billing-actions .btn {
        flex: 1 1 calc(50% - 0.5rem);
        min-height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .billing-notice {
        padding: 0.75rem 0.85rem;
        font-size: 0.82rem;
    }

    .invoice-stage {
        padding: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
    }

    .invoice-sheet {
        margin: 0 auto;
        min-width: 680px;
    }
}

@media(max-width:480px) {
    .billing-actions .btn {
        flex: 1 1 100%;
        min-height: 44px;
    }

    .invoice-stage {
        padding: 0.5rem;
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm 12mm;
    }

    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .sidebar,
    .billing-sidebar,
    .billing-header,
    .billing-notice,
    .billing-actions,
    .template-toolbar,
    .toast-portal-container,
    .modal,
    #pageAlert,
    .btn {
        display: none !important;
    }

    .billing-main,
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .invoice-stage {
        padding: 0 !important;
        border: 0 !important;
        background: #fff !important;
        overflow: visible !important;
    }

    .invoice-sheet {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-shadow: none !important;
        border: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .table-responsive {
        overflow: visible !important;
        border: none !important;
    }

    .invoice-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8.5pt !important;
        page-break-inside: auto;
    }

    .invoice-table tr {
        page-break-inside: avoid;
    }

    .invoice-table th,
    .invoice-table td {
        border: 1px solid #1e293b !important;
        padding: 4px 6px !important;
    }

    .invoice-table th {
        background-color: #f1f5f9 !important;
        color: #0f172a !important;
        font-weight: 700 !important;
        text-align: center !important;
    }

    .invoice-footer {
        page-break-inside: avoid;
    }
}