/* FactureCM — générateur de factures Cameroun (LeFisk).
   Socle repris de bulletin-paie.css : formulaire + zone A4 + modèles + filigranes. */
  body{background:#F4F2EA;color:#16261C;font-family:'IBM Plex Sans',sans-serif}
  input,select,textarea{font-size:13px!important}
  .fld{width:100%;border:1px solid #DDD8C8;background:#fff;border-radius:6px;padding:6px 8px;outline:none}
  .fld:focus{border-color:#1F6E43;box-shadow:0 0 0 2px rgba(31,110,67,.15)}
  textarea.fld{min-height:52px;resize:vertical;line-height:1.35}
  .lbl{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;color:#5B6B5E;display:block;margin-bottom:3px}
  .chip{display:inline-flex;align-items:center;gap:4px;font-size:12px;border:1px solid #DDD8C8;background:#fff;border-radius:999px;padding:3px 10px;cursor:pointer;user-select:none}
  .chip:hover{border-color:#1F6E43;color:#1F6E43}
  details.sec{border:1px solid #DDD8C8;border-radius:10px;background:#fff;overflow:hidden}
  details.sec>summary{cursor:pointer;list-style:none;padding:10px 14px;font-family:'Space Grotesk';font-weight:600;font-size:14px;display:flex;align-items:center;gap:8px;background:#FBFAF5}
  details.sec>summary::-webkit-details-marker{display:none}
  details.sec[open]>summary{border-bottom:1px solid #EDE9DC}
  details.sec>summary .num{width:22px;height:22px;border-radius:6px;background:#1F6E43;color:#fff;font-size:11px;display:flex;align-items:center;justify-content:center;font-family:'IBM Plex Mono'}
  .cbx{accent-color:#1F6E43;width:15px;height:15px;cursor:pointer}
  .btn{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:600;border-radius:8px;padding:8px 14px;cursor:pointer;transition:.15s}
  .btn-p{background:#1F6E43;color:#fff}.btn-p:hover{background:#174F31}
  .btn-o{border:1px solid #16261C;color:#16261C;background:#fff}.btn-o:hover{background:#16261C;color:#fff}
  .btn-g{border:1px solid #DDD8C8;background:#fff}.btn-g:hover{border-color:#1F6E43;color:#1F6E43}
  /* Lignes d'articles */
  .lrow{display:grid;grid-template-columns:90px 1fr 62px 92px 52px 30px;gap:5px;align-items:center}
  .lrow input{border:1px solid #E2DED0;border-radius:5px;padding:5px 6px;width:100%;outline:none}
  .lrow input:focus{border-color:#1F6E43}
  .lrow .del{color:#B42318;cursor:pointer;text-align:center;font-size:15px}
  /* ---------- Zone facture A4 ---------- */
  #pageWrap{display:flex;justify-content:center}
  #page{width:210mm;min-height:297mm;background:#fff;box-shadow:0 8px 40px rgba(22,38,28,.18);transform-origin:top center;overflow:hidden}
  .bp{width:100%;height:100%;padding:12mm 12mm;font-size:calc(9.4pt*var(--fs,1));font-family:var(--fbody,'IBM Plex Sans',sans-serif);line-height:1.34;color:#111;position:relative;box-sizing:border-box}
  .bp table{width:100%;border-collapse:collapse}
  .bp .num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
  .bp .muted{color:#555}
  .bp h1,.bp h2,.bp h3{margin:0}
  /* Bloc « arrêtée à la somme de » commun */
  .bp .enlettres{font-style:italic}
  /* ===== MODÈLE MODERNE (propre, accent couleur) ===== */
  .tpl-moderne .top{display:flex;justify-content:space-between;align-items:flex-start;gap:10mm}
  .tpl-moderne .ttl{font-family:'Space Grotesk';font-weight:700;font-size:26pt;letter-spacing:.02em;color:var(--c1);line-height:1}
  .tpl-moderne .parties{display:grid;grid-template-columns:1fr 1fr;gap:6mm;margin-top:8mm}
  .tpl-moderne .card{border:1px solid #E7E3D6;border-radius:9px;padding:5px 11px}
  .tpl-moderne .card .cap{font-size:7.6pt;text-transform:uppercase;letter-spacing:.08em;color:var(--c1);font-weight:700;margin-bottom:2px}
  .tpl-moderne table.items{margin-top:7mm}
  .tpl-moderne table.items thead th{background:var(--c1bg,var(--c1));color:#fff;font-weight:600;font-size:8.4pt;text-transform:uppercase;letter-spacing:.03em;padding:5px 9px;text-align:left}
  .tpl-moderne table.items tbody td{padding:5px 9px;border-bottom:.6px solid #ECE8DB}
  .tpl-moderne table.items tbody tr:nth-child(even){background:#FAF9F3}
  .tpl-moderne .totbox{margin-top:6mm;margin-left:auto;width:74mm}
  .tpl-moderne .totbox .r{display:flex;justify-content:space-between;padding:3px 4px}
  .tpl-moderne .totbox .net{background:var(--c1bg,var(--c1));color:#fff;font-weight:700;border-radius:7px;padding:7px 10px;font-size:12pt;margin-top:4px}
  /* ===== MODÈLE TVA (ORCA) ===== */
  .tpl-tva{font-size:calc(9pt*var(--fs,1))}
  .tpl-tva .htitle{font-weight:700;font-size:15pt;letter-spacing:.02em}
  .tpl-tva table.items{border:1px solid #222;margin-top:5mm}
  .tpl-tva table.items th{border:.7px solid #222;background:#F0F0F0;font-weight:700;padding:3px 6px;font-size:8.4pt;text-align:center}
  .tpl-tva table.items td{border:.6px solid #555;padding:2.4px 6px}
  .tpl-tva .rec{border:.8px solid #444;padding:3px 8px}
  .tpl-tva .stamp{border:2.4px solid var(--c1);color:var(--c1);transform:rotate(-8deg);padding:2px 12px;font-weight:800;font-size:15pt;display:inline-block;letter-spacing:.06em;font-family:Arial}
  /* ===== MODÈLE SOUCHE (SOGER, carnet coloré) ===== */
  .tpl-souche{font-family:var(--fbody)}
  .tpl-souche .pill{display:inline-block;background:var(--c1bg,var(--c1));color:#fff;font-weight:800;letter-spacing:.06em;font-size:17pt;padding:2px 16px;border-radius:7px;font-family:'Space Grotesk',Arial}
  .tpl-souche table.items{border:1.4px solid var(--c1);margin-top:3mm}
  .tpl-souche table.items th{background:var(--c1bg,var(--c1));color:#fff;border:.7px solid var(--c1);padding:3px 6px;font-weight:700}
  .tpl-souche table.items td{border:.7px solid var(--c1);padding:3.4px 6px;height:7mm}
  .tpl-souche .totbox{border:1.6px solid var(--c1);display:inline-block;padding:3px 12px;font-weight:800;color:var(--c1);font-size:13pt}
  .tpl-souche .stamp{border:2.4px solid #1D4ED8;color:#1D4ED8;transform:rotate(-11deg);padding:2px 10px;font-weight:800;font-size:12pt;display:inline-block;font-family:Arial;opacity:.85}
  /* ===== MODÈLE BILL (China Mall, bilingue) ===== */
  .tpl-bill{font-family:var(--fbody)}
  .tpl-bill .brand{font-family:'Space Grotesk',Arial;font-weight:800;font-size:22pt;color:var(--c1);letter-spacing:.02em;line-height:1}
  .tpl-bill table.items{border:1.4px solid #111;margin-top:3mm}
  .tpl-bill table.items th{border:1px solid #111;padding:3px 6px;font-weight:700;background:#fff}
  .tpl-bill table.items td{border:.8px solid #111;padding:3.2px 6px;height:6.5mm}
  .tpl-bill .sumline{display:flex;justify-content:flex-end;gap:0}
  .tpl-bill .sumline .k{border:1px solid #111;padding:2px 10px;font-weight:800;background:#F3F3F3}
  .tpl-bill .sumline .v{border:1px solid #111;border-left:0;padding:2px 12px;font-weight:700;min-width:34mm;text-align:right}
  /* ===== MODÈLE MATRICIELLE (PLAZA, dot-matrix anglais) ===== */
  .tpl-matri{font-family:'Courier New',Cousine,monospace;font-size:calc(9pt*var(--fs,1))}
  .tpl-matri .center{text-align:center}
  .tpl-matri table.items{border:1px solid #333;margin-top:4mm}
  .tpl-matri table.items th{border:1px solid #333;padding:3px 6px;font-weight:700}
  .tpl-matri table.items td{border-left:1px solid #333;border-right:1px solid #333;padding:2px 6px}
  .tpl-matri .rule{border-top:1px solid #333}
  .tpl-matri .stampb{color:#1D4ED8;font-weight:700;transform:rotate(-6deg);display:inline-block;font-size:13pt;opacity:.8}
  /* ===== MODÈLE REÇU (Fact 4/5, compact) ===== */
  .tpl-recu{font-family:var(--fbody)}
  .tpl-recu .bx{border:2px solid #111;border-radius:4px}
  .tpl-recu table.items th{background:#D9D9D9;border:1px solid #111;padding:3px 6px;font-weight:700}
  .tpl-recu table.items td{border:1px solid #111;padding:3.4px 6px;height:7mm}
  .tpl-recu .net{border:1.6px solid #111;display:inline-block;padding:2px 12px;font-weight:800;font-size:13pt}
  .tpl-recu .dot{border-bottom:1px dotted #333}
  /* ===== MODÈLE PROFORMA (administratif — inspiré mercuriale, sans sceau État) ===== */
  .tpl-proforma{font-family:var(--fbody)}
  .tpl-proforma .dotline{flex:1;border-bottom:1px dotted #333;min-height:4mm}
  .tpl-proforma table.items{border:1px solid #333;margin-top:3mm}
  .tpl-proforma table.items th{border:1px solid #333;background:#F2F2F2;padding:3px 6px;font-weight:700;font-size:8.4pt;text-align:center}
  .tpl-proforma table.items td{border:1px solid #333;padding:3px 6px;vertical-align:top}
  .tpl-proforma table.items td.desg{white-space:pre-line}
  .tpl-proforma table.tot td{border:1px solid #333;padding:3px 8px}
  .tpl-proforma table.tot .nap td{background:var(--c1bg,var(--c1));color:#fff;font-weight:700}

  /* ===== ProformaMP (outil séparé /outils/facture-proforma-marche-public) —
     ces 5 modèles n'avaient aucune règle de bordure dédiée : les tableaux
     s'affichaient sans aucun quadrillage. Noms de classe préfixés tpl-mp-
     pour "moderne" spécifiquement, car tpl-moderne existe déjà ci-dessus
     pour FactureCM — même nom aurait fait hériter accidentellement le style
     de l'autre outil (constaté en audit). ===== */
  .tpl-officiel table.items{border:1px solid #333;margin-top:3mm}
  .tpl-officiel table.items th{border:1px solid #333;background:#F2F2F2;padding:3px 6px;font-weight:700;font-size:8.4pt;text-align:center}
  .tpl-officiel table.items td{border:1px solid #333;padding:3px 6px;vertical-align:top}
  .tpl-officiel table.tot td{border:1px solid #333;padding:3px 8px}
  .tpl-officiel table.tot .nap td{background:var(--c1bg,var(--c1));color:#fff;font-weight:700}
  .tpl-officiel .dotline{flex:1;border-bottom:1px dotted #333;min-height:4mm}

  .tpl-simple table.items{margin-top:3mm}
  .tpl-simple table.items th{border-bottom:2px solid var(--c1);padding:4px 6px;font-weight:700;font-size:8.4pt;text-align:left}
  .tpl-simple table.items td{border-bottom:.6px solid #ddd;padding:4px 6px}
  .tpl-simple table.tot td{padding:2.5px 6px}
  .tpl-simple table.tot .nap td{border-top:1.4px solid var(--c1);font-weight:700;padding-top:4px}

  .tpl-prestations table.items{margin-top:2mm}
  .tpl-prestations table.items thead th{background:#F1F5F9;color:#334155;font-weight:700;font-size:8pt;text-transform:uppercase;letter-spacing:.02em;padding:4px 7px;text-align:left}
  .tpl-prestations table.items tbody td{padding:4.5px 7px;border-bottom:.6px solid #E2E8F0}
  .tpl-prestations table.items tbody tr:nth-child(even){background:#FAFBFC}
  .tpl-prestations table.tot td{padding:2.5px 6px}
  .tpl-prestations table.tot .nap td{border-top:1.4px solid var(--c1);font-weight:700;padding-top:4px}

  .tpl-mp-moderne table.items{margin-top:2mm}
  .tpl-mp-moderne table.items thead th{background:var(--c1);color:#fff;font-weight:600;font-size:8.4pt;text-transform:uppercase;letter-spacing:.03em;padding:5px 9px;text-align:left}
  .tpl-mp-moderne table.items tbody td{padding:5px 9px;border-bottom:.6px solid #ECE8DB}
  .tpl-mp-moderne table.items tbody tr:nth-child(even){background:#F5F8F7}

  .tpl-brut table.items{margin-top:2mm}
  .tpl-brut table.items th{border-bottom:1.4px solid #374151;padding:3px 6px;font-weight:700;font-size:8.2pt;text-align:left}
  .tpl-brut table.items td{border-bottom:.5px solid #ddd;padding:3px 6px}
  .tpl-brut table.tot .nap td{border-top:1px solid #374151;font-weight:700}

  /* QR optionnel avec logo au centre (voir qrBlock() dans proforma-mp/templates.js) */
  .mp-qr-wrap{position:relative;width:20mm;height:20mm}
  .mp-qr-wrap img.mp-qr-logo{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
    max-width:6mm;max-height:6mm;background:#fff;padding:1px;border-radius:2px}

  /* Documents multi-pages : jamais une ligne coupée entre deux feuilles A4
     (html2pdf.js "css" pagebreak mode + impression navigateur). */
  .bp table.items tr, .bp table.tot tr{page-break-inside:avoid}
  /* Une référence de facture (doc_num) ou une référence mercuriale trop
     longue ne doit jamais déborder de la page ni casser la ligne pointillée
     à côté d'elle — quelques valeurs réelles posaient problème sans ceci. */
  .bp .dotline{overflow-wrap:anywhere;word-break:break-word}
  .tpl-officiel table.items td, .tpl-brut table.items td, .tpl-simple table.items td{overflow-wrap:anywhere}
  /* ---------- Filigranes (repris de watermark) ---------- */
  .wm-custom{position:absolute;inset:0;z-index:6;pointer-events:none}
  .wm-lefisk{position:absolute;inset:-25%;z-index:7;pointer-events:none;overflow:hidden;
    transform:rotate(-27deg);display:flex;flex-direction:column;justify-content:space-around;opacity:.11}
  .wm-lefisk>div{white-space:nowrap;font-family:'Space Grotesk',sans-serif;font-weight:800;
    font-size:15pt;letter-spacing:.12em;color:#1F6E43;text-align:center}
  @media print{
    body *{visibility:hidden} #page,#page *{visibility:visible}
    #page{position:absolute;left:0;top:0;transform:none!important;box-shadow:none;width:210mm}
    @page{size:A4;margin:0}
  }
