* {
    box-sizing: border-box;
}

:root {
    --blue: #0753bf;
    --blue2: #2f78df;
    --green: #0b6e37;
}

body {
    margin: 0;
    background: #eef1f5;
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
}

.app {
    max-width: 1180px;
    margin: 28px auto;
    padding: 0 16px;
}

/* BOUTONS */
.btn,
.smallbtn {
    display: inline-block;
    border: 0;
    border-radius: 7px;
    padding: 11px 16px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
}

.btn.secondary {
    background: #444;
}

.btn.add {
    background: #16823c;
}

.btn.save {
    font-weight: 700;
}

.smallbtn {
    padding: 8px 11px;
    font-size: 13px;
}

.smallbtn.edit {
    background: #555;
}

.smallbtn.jp,
.jpbig {
    background: #0a6f35;
}

/* LOGO : largeur fixée à 3 cm */
.brand-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 10px;
}

.site-logo,
.form-logo,
.history-logo,
.password-logo,
.pdf-logo {
    width: 4cm !important;
    height: auto !important;
    max-width: 4cm !important;
    max-height: none !important;
    object-fit: contain;
}

.password-logo {
    display: block;
    margin: 0 auto 15px;
}

.pdf-logo {
    display: block;
    object-position: left center;
    margin: 0 0 2mm 2mm;
}

/* EN-TÊTE FORMULAIRE */
.form-header {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
}

.form-title-wrap {
    text-align: center;
}

.form-title-wrap h1 {
    margin: 0 0 12px;
    color: #13224e;
}

.top-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* FORMULAIRE */
.invoice-form {
    background: #fff;
    border: 1px solid #c7c7c7;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    display: grid;
    grid-template-columns: 58% 42%;
}

.form-company {
    border-right: 1px solid #c7c7c7;
}

.blue-company {
    background: var(--blue);
    color: #fff;
    padding: 15px;
    min-height: 76px;
}

.blue-company .auto {
    margin-top: 22px;
    font-weight: 700;
}

.company-details {
    padding: 12px 14px;
    color: #12214f;
    line-height: 1.55;
    min-height: 100px;
}

.form-facture-box {
    padding: 18px 22px;
}

.form-facture-title {
    text-align: right;
    font-size: 32px;
    font-weight: 900;
    font-style: italic;
}

.date-block {
    margin-top: 42px;
    display: grid;
    grid-template-columns: 65px 1fr;
    gap: 8px;
    align-items: center;
}

.date-block label {
    font-weight: 700;
}

.date-block input {
    padding: 10px;
    font-size: 16px;
}

.date-block small {
    grid-column: 2;
    text-align: right;
}

.customer-line {
    grid-column: 1 / -1;
    margin: 24px 0 18px;
    border: 1px solid #888;
    padding: 9px 13px;
    width: 58%;
}

.entry-table {
    grid-column: 1 / -1;
    width: 100%;
    border-collapse: collapse;
}

.entry-table th {
    background: var(--blue);
    color: #fff;
    border: 1px solid #0f3e8c;
    padding: 11px 8px;
    text-align: center;
}

.entry-table td {
    border: 1px solid #d0d0d0;
    padding: 6px;
}

.entry-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid #d8d8d8;
    font-size: 15px;
}

.entry-table .rownum {
    width: 42px;
}

.entry-table .actioncol {
    width: 44px;
}

.row-index {
    text-align: center;
    font-weight: 700;
}

.unit,
.line-total {
    text-align: center;
    font-weight: 700;
}

.remove {
    border: 0;
    border-radius: 5px;
    background: #e83939;
    color: #fff;
    width: 30px;
    height: 30px;
    font-size: 20px;
    cursor: pointer;
}

.below-table {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 14px;
}

.totalbox {
    width: 320px;
    background: var(--blue);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    font-size: 20px;
}

.payment-form {
    grid-column: 1 / -1;
    margin-top: 22px;
    background: var(--blue);
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    font-size: 14px;
}

.legal {
    grid-column: 1 / -1;
    padding-top: 9px;
    font-size: 13px;
}

.info-box {
    margin-top: 15px;
    background: #eaf1ff;
    border: 1px solid #99b9ff;
    color: #1640a0;
    border-radius: 8px;
    padding: 15px 18px;
    font-size: 15px;
}

/* HISTORIQUE */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
    margin-bottom: 20px;
}

.history-header > div {
    text-align: right;
}

.notice {
    background: #dff4e4;
    border: 1px solid #7ab98a;
    padding: 12px;
    border-radius: 7px;
    margin-bottom: 15px;
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

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

.history-table th,
.history-table td {
    border: 1px solid #aaa;
    padding: 10px;
}

.history-table th {
    background: var(--blue);
    color: #fff;
}

.action-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* MOT DE PASSE */
.password-box {
    max-width: 430px;
    margin: 70px auto;
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 18px rgba(0,0,0,.15);
}

.password-box h1 {
    text-align: center;
}

.password-box label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.password-box input {
    width: 100%;
    padding: 11px;
    font-size: 16px;
}

.password-box .btn {
    width: 100%;
    margin-top: 15px;
}

.error {
    background: #ffdfe3;
    padding: 10px;
    margin: 10px 0;
    border-radius: 6px;
}

/* FACTURE A4 */
.invoice-shell {
    padding: 10px;
}

.toolbar {
    max-width: 210mm;
    margin: 0 auto 10px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.invoice-a4 {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background: #fff;
    padding: 5mm 6mm 4mm;
    box-shadow: 0 2px 18px rgba(0,0,0,.16);
    display: flex;
    flex-direction: column;
}

.invoice-header {
    display: grid;
    grid-template-columns: 62% 38%;
    min-height: 48mm;
}

.identity {
    padding-right: 2mm;
}

.blue-block {
    background: var(--blue);
    color: #fff;
    padding: 5mm 2mm 3mm;
    font-size: 4mm;
    min-height: 30mm;
}

.blue-block .auto {
    margin-top: 9mm;
    font-weight: 700;
}

.details {
    padding: 2mm 1mm;
    color: #154da4;
    font-size: 3.5mm;
    line-height: 1.45;
}

.facture-title {
    font-size: 8mm;
    font-weight: 900;
    font-style: italic;
    padding: 4mm 2mm;
}

.facture-date {
    font-size: 3.6mm;
    font-style: normal;
    margin-top: 16mm;
}

.client-bar {
    margin-top: 4mm;
    border-top: 7mm solid var(--blue2);
    border-bottom: .4mm solid #222;
    padding: 2mm 1mm;
    width: 62%;
    font-size: 3.7mm;
}

.pdf-table {
    margin-top: 5mm;
    width: 100%;
    border-collapse: collapse;
    font-size: 3.55mm;
    table-layout: fixed;
}

.pdf-table th {
    background: var(--blue);
    color: #fff;
    border: .35mm solid #0d3f91;
    text-align: center;
    height: 12.5mm;
}

.pdf-table th:nth-child(1) {
    width: 50%;
}

.pdf-table th:nth-child(2) {
    width: 12%;
}

.pdf-table th:nth-child(3) {
    width: 20%;
}

.pdf-table th:nth-child(4) {
    width: 18%;
}

.pdf-table td {
    border: .3mm solid #444;
    height: 7.4mm;
    padding: 1mm 1.5mm;
    color: #104aa1;
    font-weight: 600;
}

.pdf-total {
    margin-left: auto;
    width: 40%;
    background: var(--blue);
    color: #fff;
    display: flex;
    justify-content: space-between;
    padding: 3mm 4mm;
    font-size: 4.2mm;
    font-weight: 700;
}

.payment {
    margin-top: 5mm;
    background: var(--blue);
    color: #fff;
    padding: 4mm 2mm;
    display: flex;
    justify-content: space-between;
    gap: 10mm;
    font-size: 3.3mm;
}

.invoice-a4 footer {
    font-size: 3mm;
    margin-top: 2mm;
}

/* MOBILE */
@media (max-width: 850px) {
    .form-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .site-logo,
    .form-logo,
    .history-logo {
        margin: 0 auto;
    }

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

    .form-company {
        border-right: 0;
    }

    .customer-line {
        width: 100%;
    }

    .below-table,
    .payment-form,
    .history-header {
        flex-direction: column;
        align-items: stretch;
    }

    .totalbox {
        width: 100%;
    }

    .history-header > div {
        text-align: center;
    }

    .invoice-shell {
        padding: 0;
        overflow-x: auto;
    }
}

/* IMPRESSION / PDF */
@media print {
    html,
    body {
        width: 210mm;
        height: 297mm;
        margin: 0;
        background: #fff;
    }

    .no-print {
        display: none !important;
    }

    .invoice-shell {
        padding: 0;
    }

    .invoice-a4 {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        padding: 4mm 5mm 3mm;
        box-shadow: none;
    }

    /* Logo toujours 3 cm sur le PDF */
    .pdf-logo {
        width: 3cm !important;
        max-width: 3cm !important;
        height: auto !important;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }
}
