/* Éditeur de facture en direct — mise en page calquée sur la facture PDF */
.modal.fx-modal { align-items: flex-start; }
.fx-modal .modal-content.fx-fenetre { max-width: 1180px; width: 96%; padding: 0; overflow: visible; margin: 20px auto; }

.fx-barre {
    position: sticky; top: 0; z-index: 5;
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 20px; background: #f4f6f8; border-bottom: 1px solid #e3e6ea;
}
.fx-etat { font-size: 13px; color: #5b6573; }
.fx-boutons { display: flex; gap: 8px; flex-wrap: wrap; }
.fx-boutons button { padding: 8px 14px; font-size: 14px; }

#fxCorps { padding: 28px 32px 32px; }

.fx-doc { font-family: Helvetica, Arial, sans-serif; color: #1f2a37; font-size: 13px; line-height: 1.45; }
.fx-muted { color: #9aa3ad; }

.fx-haut { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.fx-logo { width: 190px; min-height: 150px; background: #ececec; display: flex; align-items: center; justify-content: center; padding: 14px; }
.fx-logo svg, .fx-logo img { max-width: 100%; max-height: 120px; }
.fx-titre { width: 48%; }
.fx-titre h2 { font-size: 21px; font-weight: 700; margin: 4px 0 8px; color: #1f2a37; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fx-dates div { margin: 2px 0; }

.fx-parties { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.fx-emetteur, .fx-destinataire { width: 48%; }
.fx-emetteur strong { font-weight: 400; }
.fx-client { margin-bottom: 6px; font-weight: 700; }

.fx-objet { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
input.fx-objet { width: 100%; }

.fx-defile { overflow-x: auto; }
.fx-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.fx-table th { background: #dfe1e3; font-weight: 700; padding: 9px 7px; text-align: left; font-size: 13px; vertical-align: middle; }
.fx-table td { padding: 7px; border-bottom: 1px solid #e3e6ea; vertical-align: top; }
.fx-table tbody td + td { border-left: 1px solid #e3e6ea; }
.fx-table tfoot td { border-bottom: none; padding-top: 10px; }
.fx-desig { min-width: 260px; }
.fx-fige .fx-desig { width: 40%; }
.fx-r { text-align: right; }
.fx-c { text-align: center; }
.fx-w-ref { width: 60px; } .fx-w-qte { width: 112px; } .fx-w-pu { width: 92px; } .fx-w-tva { width: 64px; } .fx-w-act { width: 112px; }
/* Largeurs minimales : le tableau défile plutôt que d'écraser les montants */
.fx-defile .fx-table { min-width: 940px; table-layout: fixed; }
.fx-defile .fx-table th:nth-child(1) { width: auto; }
.fx-defile .fx-table th:nth-child(2) { width: 58px; }
.fx-defile .fx-table th:nth-child(3) { width: 118px; }
.fx-defile .fx-table th:nth-child(4) { width: 92px; }
.fx-defile .fx-table th:nth-child(5) { width: 84px; }
.fx-defile .fx-table th:nth-child(6) { width: 62px; }
.fx-defile .fx-table th:nth-child(7) { width: 84px; }
.fx-defile .fx-table th:nth-child(8) { width: 92px; }
.fx-defile .fx-table th:nth-child(9) { width: 104px; }
.fx-table td .fx-in { min-width: 0; margin: 0; }

/* Cases modifiables : discrètes, comme du texte, encadrées au survol */
.fx-in {
    font: inherit; color: inherit; background: transparent;
    border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; width: 100%;
}
.fx-in:hover { border-color: #cfd5db; background: #fff; }
.fx-in:focus { outline: none; border-color: #2BA7E6; background: #fff; box-shadow: 0 0 0 3px rgba(43,167,230,.15); }
input.fx-in[type="number"] { -moz-appearance: textfield; }
input.fx-in[type="number"]::-webkit-inner-spin-button, input.fx-in[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.fx-num { width: 140px; font-size: 21px; font-weight: 700; }
.fx-dates input { width: 150px; display: inline-block; }
.fx-titre-ligne { font-weight: 700; resize: none; overflow: hidden; min-height: 28px; margin-bottom: 4px !important; }
.fx-details { resize: none; overflow: hidden; min-height: 28px; color: #374151; }
.fx-table td input.fx-in, .fx-table td textarea.fx-in { background: #fafbfc; border-color: #eef0f2; }
.fx-table td input.fx-in:focus, .fx-table td textarea.fx-in:focus { background: #fff; border-color: #2BA7E6; }

.fx-qte { white-space: nowrap; }
.fx-qte input { width: 54px !important; display: inline-block; text-align: center; }
.fx-pas {
    width: 24px; height: 28px; border: 1px solid #d5dae0; background: #fff; border-radius: 4px;
    font-size: 15px; line-height: 1; cursor: pointer; color: #1f2a37; vertical-align: top;
}
.fx-pas:hover { background: #eaf6fd; border-color: #2BA7E6; }

.fx-actions-ligne { white-space: nowrap; text-align: center; }
.fx-actions-ligne button {
    border: none; background: transparent; cursor: pointer; font-size: 14px; padding: 4px 5px; color: #6b7280; border-radius: 4px;
}
.fx-actions-ligne button:hover { background: #eef0f2; color: #1f2a37; }
.fx-actions-ligne .fx-suppr:hover { background: #fdecea; color: #c62828; }

.fx-ajouts { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.fx-ajouts select { padding: 7px 10px; border: 1px solid #d5dae0; border-radius: 4px; font-size: 13px; max-width: 100%; background: #fff; }

.fx-bas { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 18px; flex-wrap: wrap-reverse; }
.fx-apayer { font-size: 13px; }
.fx-apayer strong { font-size: 18px; }
.fx-apayer span { font-weight: 700; }
.fx-recap { border-collapse: collapse; }
.fx-recap th { text-align: right; padding: 4px 18px 4px 0; font-weight: 700; }
.fx-recap td { text-align: right; padding: 4px 0; min-width: 110px; }

.fx-reglages { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 14px; background: #f4f6f8; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.fx-reglages label { display: flex; align-items: center; gap: 6px; }
.fx-reglages input[type="number"] { width: 64px; background: #fff; border-color: #d5dae0; }
.fx-reglages input[type="date"], .fx-reglages select { width: auto; background: #fff; border-color: #d5dae0; }
.fx-notes-saisie { border-color: #e3e6ea; }

.fx-notes { margin-top: 14px; white-space: normal; }
.fx-mentions { margin-top: 26px; font-size: 10px; color: #6b7280; }
.fx-pied { display: flex; justify-content: space-between; margin-top: 18px; font-size: 10px; color: #6b7280; border-top: 1px solid #e3e6ea; padding-top: 6px; }

/* Zone hors écran qui sert à fabriquer le PDF */
#fxImpression { position: absolute; left: -10000px; top: 0; width: 760px; background: #fff; }
#fxImpression .fx-doc { padding: 4px; }
#fxImpression .fx-table tr { page-break-inside: avoid; }

#fxBulle {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
    background: #1f2a37; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
    transition: all .25s; z-index: 3000; pointer-events: none;
}
#fxBulle.visible { opacity: 1; transform: translate(-50%, 0); }

.fx-reglage-logo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.fx-apercu-logo { width: 140px; height: 70px; background: #ececec; display: flex; align-items: center; justify-content: center; padding: 8px; }
.fx-apercu-logo svg, .fx-apercu-logo img { max-width: 100%; max-height: 100%; }

@media (max-width: 760px) {
    #fxCorps { padding: 16px; }
    .fx-haut, .fx-parties { flex-direction: column; }
    .fx-titre, .fx-emetteur, .fx-destinataire { width: 100%; }
    .fx-logo { width: 150px; min-height: 100px; }
    .fx-barre { padding: 10px 16px; }
}

/* Case quantité : − [nombre] + sur une seule ligne */
.fx-table td.fx-qte { padding: 7px 4px; }
.fx-table td.fx-qte > * { vertical-align: middle; }
.fx-table .fx-pas { padding: 0 !important; margin: 0 !important; width: 26px !important; min-width: 0 !important; height: 28px; font-weight: 600; box-shadow: none; }
.fx-table td.fx-qte input.fx-in { width: 50px !important; padding: 4px 2px; margin: 0 2px; }

/* Version PDF : plus compacte, pour tenir sur une page comme l'original */
.fx-fige { font-size: 11px; line-height: 1.4; }
.fx-fige .fx-haut { margin-bottom: 18px; }
.fx-fige .fx-logo { width: 160px; min-height: 120px; }
.fx-fige .fx-titre h2 { font-size: 18px; }
.fx-fige .fx-parties { margin-bottom: 20px; }
.fx-fige .fx-objet { font-size: 12.5px; margin-bottom: 8px; }
.fx-fige .fx-table th { font-size: 11px; padding: 6px 5px; }
.fx-fige .fx-table td { padding: 5px; }
.fx-fige .fx-apayer strong { font-size: 15px; }
.fx-fige .fx-mentions { margin-top: 16px; font-size: 9px; }
.fx-fige .fx-pied { font-size: 9px; }

/* ===== Saisie façon tableur ===== */
.fx-numero { width: 34px; text-align: center; color: #9aa3ad; font-size: 12px; }
.fx-defile .fx-saisie { min-width: 980px; }
.fx-defile .fx-saisie th:nth-child(1) { width: 34px; }
.fx-defile .fx-saisie th:nth-child(2) { width: auto; }
.fx-defile .fx-saisie th:nth-child(3) { width: 58px; }
.fx-defile .fx-saisie th:nth-child(4) { width: 118px; }
.fx-defile .fx-saisie th:nth-child(5) { width: 92px; }
.fx-defile .fx-saisie th:nth-child(6) { width: 84px; }
.fx-defile .fx-saisie th:nth-child(7) { width: 62px; }
.fx-defile .fx-saisie th:nth-child(8) { width: 84px; }
.fx-defile .fx-saisie th:nth-child(9) { width: 92px; }
.fx-defile .fx-saisie th:nth-child(10) { width: 104px; }
.fx-saisie tbody tr:focus-within { background: #f2f9fe; }
.fx-saisie tr.fx-ligne-vide .fx-calc, .fx-saisie tr.fx-ligne-vide .fx-actions-ligne { visibility: hidden; }
.fx-saisie tr.fx-ligne-vide .fx-details { display: none; }
.fx-saisie tr.fx-ligne-vide .fx-titre-ligne { font-weight: 400; }
.fx-aide-saisie { font-size: 12px; color: #8a94a0; margin: -10px 0 14px; }
.fx-numero-futur { font-size: 12px; color: #6b7280; margin: -4px 0 8px; }
.fx-brouillon-etiquette { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
    background: #fff3cd; color: #8a6d00; padding: 3px 8px; border-radius: 4px; vertical-align: middle; }
.fx-origine { margin: -14px 0 14px; font-weight: 700; }

.fx-suggestions { position: absolute; z-index: 20; background: #fff; border: 1px solid #cfd5db; border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.14); max-height: 320px; overflow-y: auto; }
.fx-sugg { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.fx-sugg small { display: block; color: #6b7280; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
.fx-sugg b { white-space: nowrap; color: #1f2a37; }
.fx-sugg.actif, .fx-sugg:hover { background: #eaf6fd; }

/* ===== Lecture d'un document émis ===== */
.fx-lecture { border: 1px solid #e3e6ea; border-radius: 6px; padding: 28px; background: #fff; }
.fx-etat-doc { padding: 10px 14px; border-radius: 6px; background: #fff7e0; color: #7a5b00; margin-bottom: 12px; font-size: 14px; }
.fx-etat-paye { background: #e7f6ec; color: #1b7f3b; }
.fx-etat-retard { background: #fdecea; color: #a12020; }
.fx-etat-annule { background: #eef0f2; color: #4b5563; }
.fx-verrou { margin-top: 12px; font-size: 13px; color: #6b7280; }
.fx-paye { color: #1b7f3b; }

.fx-mail { border: 1px solid #cfe6f5; background: #f4fafe; border-radius: 6px; padding: 14px; margin-bottom: 14px; display: grid; gap: 8px; }
.fx-mail-haut { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.fx-mail label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.fx-mail input, .fx-mail textarea, .fx-mail select { flex: 1; padding: 7px 9px; border: 1px solid #d5dae0; border-radius: 4px; font: inherit; font-size: 13px; }
.fx-mail-actions { display: flex; gap: 8px; }

/* ===== Connexion ===== */
body.mf-verrou > *:not(.mf-ecran) { display: none !important; }
.mf-ecran { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #eef0f3; padding: 16px; }
.mf-boite { background: #fff; padding: 32px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.08); width: 100%; max-width: 400px; }
.mf-boite h1 { font-size: 22px; margin-bottom: 18px; color: #1f2a37; }
.mf-boite label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 12px; color: #374151; }
.mf-boite input { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid #d5dae0; border-radius: 6px; font-size: 15px; }
.mf-boite button { width: 100%; padding: 11px; font-size: 15px; }
.mf-aide { font-size: 13px; color: #6b7280; margin-bottom: 16px; }
.mf-erreur { color: #b42318; font-size: 13px; min-height: 18px; }
.mf-compte { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #cfd8e3; }
.mf-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-lien { background: none; border: none; color: #cfd8e3; text-decoration: underline; cursor: pointer; font-size: 13px; }
.mf-etat { padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,.12); white-space: nowrap; }
.mf-etat[data-etat="erreur"], .mf-etat[data-etat="conflit"] { background: #b42318; color: #fff; }
.mf-bandeau { background: #eaf6fd; border: 1px solid #b9def5; color: #1f4f6e; padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }

/* ===== Liste des factures ===== */
.lf-entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.lf-entete h2 { margin: 0; }
.lf-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lf-indicateurs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.lf-indicateurs button { text-align: left; background: #f6f7f9; border: 1px solid #e6e8eb; border-radius: 8px; padding: 12px 14px; cursor: pointer; }
.lf-indicateurs button:hover { border-color: #b9c2cc; }
.lf-indicateurs span { display: block; font-size: 12px; color: #6b7280; }
.lf-indicateurs strong { display: block; font-size: 19px; color: #1f2a37; margin: 2px 0; }
.lf-indicateurs small { font-size: 12px; color: #8a94a0; }
.lf-indicateurs .lf-alerte strong { color: #b42318; }
.lf-filtres { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.lf-filtres input[type="search"] { flex: 1 1 280px; padding: 9px 12px; border: 1px solid #d5dae0; border-radius: 6px; font-size: 14px; }
.lf-filtres select, .lf-filtres input[type="date"] { padding: 8px 10px; border: 1px solid #d5dae0; border-radius: 6px; font-size: 13px; background: #fff; }
.lf-coche { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.lf-defile { overflow-x: auto; border: 1px solid #e6e8eb; border-radius: 6px; }
.lf-tableau { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 900px; }
.lf-tableau th { background: #f3f4f6; text-align: left; padding: 9px 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: #4b5563; white-space: nowrap; }
.lf-tableau th[data-tri] { cursor: pointer; user-select: none; }
.lf-tableau th[data-tri]::after { content: attr(data-sens); margin-left: 4px; font-size: 10px; }
.lf-tableau th.lf-trie { color: #1f2a37; }
.lf-tableau td { padding: 8px 10px; border-top: 1px solid #eef0f2; white-space: nowrap; }
.lf-tableau tbody tr { cursor: pointer; }
.lf-tableau tbody tr:hover { background: #f5f9fc; }
.lf-tableau tfoot td { background: #f9fafb; font-weight: 600; border-top: 2px solid #e6e8eb; }
.lf-r { text-align: right; }
.lf-case { width: 32px; }
.lf-num { font-weight: 600; }
.lf-objet { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.lf-gris { color: #9aa3ad; }
.lf-vide { text-align: center; color: #9aa3ad; padding: 30px !important; }
.lf-barre td:not(:last-child) { text-decoration: line-through; color: #9aa3ad; }
.lf-statut { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.lf-statut::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.lf-brouillon { color: #8a94a0; } .lf-apayer { color: #b7791f; } .lf-retard { color: #b42318; font-weight: 600; }
.lf-payee { color: #1b7f3b; } .lf-annulee { color: #6b7280; } .lf-avoir { color: #6d28d9; }
.lf-comptable { max-width: 640px; }
.lf-periode-export { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.lf-periode-export input, .lf-comptes input { padding: 7px 9px; border: 1px solid #d5dae0; border-radius: 4px; margin-left: 6px; }
.lf-resume { font-size: 14px; color: #374151; margin-bottom: 12px; }
.lf-exports { display: grid; gap: 10px; margin-bottom: 14px; }
.lf-export { display: block; padding: 12px 14px; border: 1px solid #e3e6ea; border-radius: 8px; text-decoration: none; color: #1f2a37; }
.lf-export:hover { border-color: #2BA7E6; background: #f4fafe; }
.lf-export span { display: block; font-size: 12.5px; color: #6b7280; margin-top: 3px; }
.lf-comptes { font-size: 13px; }
.lf-comptes label { display: block; margin: 8px 0; }
.lf-comptes summary { cursor: pointer; color: #4b5563; }

@media (max-width: 760px) {
    .lf-indicateurs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mf-email { display: none; }
}
