<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Devis {{NUMERO}} | {{EMETTEUR_NOM}}</title>
<!--
  MODÈLE DE DEVIS (A4, à imprimer en PDF)
  Fichier autonome : styles intégrés, polices du système, aucune ressource externe, aucun script.

  Remplissage (détail dans references/remplir-le-modele.md) :
  - Remplace chaque {{REPERE}} par sa valeur. Une information inconnue devient
    <span class="a-completer">[SIRET]</span>, surlignée à l'écran comme à l'impression.
  - Les blocs encadrés par les commentaires OPTION et FIN OPTION se suppriment s'ils ne servent pas.
  - Le bloc encadré par les commentaires LIGNE et FIN LIGNE se répète pour chaque ligne du devis.
  - Le bloc LIGNE DE TVA des totaux se répète pour chaque taux de TVA.
  - Couleur d'accent : --accent, et --accent-doux (la même couleur très claire : 8 % de la couleur, 92 % de blanc).
  - Logo : une image intégrée en data URI (data:image/png;base64,...) dans la balise img de l'option logo.
  - Montants : 2 450,00 €, avec une espace fine insécable pour les milliers et une espace insécable avant €.
-->
<style>
:root {
  --accent: #2F4E7A;
  --accent-doux: #EEF1F5;
  --encre: #17191C;
  --gris: #59616B;
  --gris-clair: #8A929C;
  --filet: #E1E4E8;
  --fond: #F5F6F8;
  --repere: #FFF0B3;
  --repere-texte: #674B00;
}
@page {
  size: A4; margin: 13mm 15mm 14mm;
  @bottom-right { content: "Devis {{NUMERO}} · page " counter(page) " / " counter(pages); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 6.8pt; color: #8A929C; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 9pt; line-height: 1.4; color: var(--encre); background: #fff;
}
.feuille { display: flex; flex-direction: column; min-height: 268mm; }
@media screen {
  body { background: #E8EAED; padding: 8mm 0; }
  .feuille { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 13mm 15mm 14mm; background: #fff; box-shadow: 0 0.6mm 3mm rgba(0, 0, 0, .10); }
}

/* Bandeau des éléments à compléter : à supprimer quand tout est rempli */
.bandeau-a-completer { background: var(--repere); color: var(--repere-texte); border-radius: 1.6mm; padding: 1.6mm 3.4mm; font-size: 7.8pt; margin-bottom: 4.5mm; }
.a-completer { background: var(--repere); color: var(--repere-texte); border-radius: 0.8mm; padding: 0 0.9mm; font-weight: 500; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* En-tête */
.entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; padding-bottom: 5mm; border-bottom: 1px solid var(--filet); }
.marque .logo { display: block; max-height: 14mm; max-width: 50mm; margin-bottom: 2mm; }
.marque-nom { font-size: 14.5pt; font-weight: 700; letter-spacing: -0.01em; color: var(--accent); line-height: 1.15; }
.marque-activite { font-size: 8.4pt; color: var(--gris); margin-top: 0.8mm; }
.titre-doc { text-align: right; }
.titre-doc h1 { font-size: 22pt; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.meta { display: flex; justify-content: flex-end; gap: 6.5mm; margin-top: 3.4mm; }
.meta dt { font-size: 6.6pt; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gris-clair); }
.meta dd { font-size: 9.2pt; font-weight: 600; margin-top: 0.4mm; white-space: nowrap; }

/* Émetteur et client */
.parties { display: flex; gap: 5mm; margin-top: 5mm; }
.partie { flex: 1; background: var(--fond); border-radius: 2.2mm; padding: 3.4mm 4.6mm 3.6mm; }
.partie.client { background: var(--accent-doux); }
.etiquette { display: block; font-size: 6.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.11em; color: var(--accent); margin-bottom: 1.3mm; }
.partie .nom { font-size: 10.2pt; font-weight: 650; }
.partie p + p { margin-top: 0.8mm; }
.partie .secondaire { color: var(--gris); font-size: 8.2pt; }

/* Objet */
.objet { margin-top: 5.5mm; display: flex; align-items: baseline; gap: 3.5mm; }
.objet .etiquette { margin: 0; flex: none; }
.objet p { font-size: 10pt; font-weight: 550; }

/* Lignes */
table.lignes { width: 100%; border-collapse: collapse; margin-top: 3.8mm; }
table.lignes thead { display: table-header-group; }
table.lignes th { font-size: 6.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--gris-clair); text-align: left; padding: 0 2.2mm 1.8mm; border-bottom: 1.4px solid var(--accent); white-space: nowrap; }
table.lignes td { padding: 2.2mm 2.2mm 2.3mm; border-bottom: 1px solid var(--filet); vertical-align: top; line-height: 1.35; }
table.lignes tr { break-inside: avoid; }
table.lignes .n { width: 7mm; padding-left: 0; color: var(--gris-clair); font-variant-numeric: tabular-nums; }
table.lignes .q, table.lignes .u, table.lignes .pu, table.lignes .tx, table.lignes .mt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lignes .u { text-align: left; }
table.lignes td.u { color: var(--gris); }
table.lignes .mt { padding-right: 0; font-weight: 650; }
table.lignes th.mt { font-weight: 700; }
.designation { font-weight: 600; }
.detail { color: var(--gris); font-size: 8pt; margin-top: 0.3mm; }

/* Conditions et totaux */
.bas { display: flex; justify-content: space-between; align-items: flex-start; gap: 9mm; margin-top: 5mm; break-inside: avoid; }
.conditions { flex: 1; font-size: 8.2pt; }
.conditions dl > div { display: flex; gap: 3mm; padding: 1.05mm 0; border-bottom: 1px solid var(--filet); }
.conditions dl > div:last-child { border-bottom: 0; }
.conditions dt { width: 31mm; flex: none; color: var(--gris); }
.conditions dd { font-weight: 500; }
table.totaux { width: 79mm; flex: none; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.totaux th { text-align: left; font-weight: 500; color: var(--gris); padding: 1.1mm 0; white-space: nowrap; vertical-align: top; }
table.totaux td { text-align: right; padding: 1.1mm 0; white-space: nowrap; font-weight: 600; vertical-align: top; }
table.totaux .base { display: block; font-size: 7pt; font-weight: 400; color: var(--gris-clair); white-space: normal; }
table.totaux tr.fort td { padding: 0; }
.total-fort { display: flex; justify-content: space-between; align-items: baseline; gap: 4mm; background: var(--accent); color: #fff; border-radius: 1.8mm; padding: 2.4mm 3.4mm; font-size: 11pt; font-weight: 700; }
table.totaux tr.espace td, table.totaux tr.espace th { padding: 0; height: 1.6mm; }
table.totaux tr.acompte th, table.totaux tr.acompte td { padding: 1.8mm 3.4mm 0; font-size: 8.2pt; }
table.totaux tr.acompte td { font-weight: 600; color: var(--encre); }

/* Bon pour accord */
.accord { display: flex; justify-content: space-between; align-items: flex-start; gap: 9mm; margin-top: 5mm; break-inside: avoid; }
.accord .note { flex: 1; font-size: 8pt; color: var(--gris); padding-top: 3.2mm; }
.accord .cadre { width: 79mm; flex: none; border: 1px solid var(--filet); border-radius: 2.2mm; padding: 3.2mm 4mm; min-height: 27mm; }
.accord .cadre p { font-size: 7.8pt; color: var(--gris); }
.accord .cadre p + p { margin-top: 1.2mm; }

/* Pied de page : mentions légales */
.pied { margin-top: auto; padding-top: 5mm; }
.pied .mentions { border-top: 1px solid var(--filet); padding-top: 2.6mm; font-size: 6.9pt; line-height: 1.5; color: var(--gris-clair); text-align: center; }
</style>
</head>
<body>
<main class="feuille">

  <!-- OPTION bandeau : à garder tant qu'un élément reste à compléter -->
  <div class="bandeau-a-completer"><strong>Document incomplet</strong>&nbsp;: {{NOMBRE_A_COMPLETER}} éléments surlignés à compléter avant envoi.</div>
  <!-- FIN OPTION -->

  <header class="entete">
    <div class="marque">
      <!-- OPTION logo : à supprimer sans logo -->
      <img class="logo" src="{{LOGO_DATA_URI}}" alt="Logo {{EMETTEUR_NOM}}">
      <!-- FIN OPTION -->
      <div class="marque-nom">{{EMETTEUR_NOM}}</div>
      <div class="marque-activite">{{EMETTEUR_ACTIVITE}}</div>
    </div>
    <div class="titre-doc">
      <h1>Devis</h1>
      <dl class="meta">
        <div><dt>Numéro</dt><dd>{{NUMERO}}</dd></div>
        <div><dt>Date</dt><dd>{{DATE}}</dd></div>
        <div><dt>Valable jusqu’au</dt><dd>{{DATE_VALIDITE}}</dd></div>
      </dl>
    </div>
  </header>

  <section class="parties">
    <div class="partie">
      <span class="etiquette">Émetteur</span>
      <p class="nom">{{EMETTEUR_NOM}}</p>
      <p>{{EMETTEUR_ADRESSE}}</p>
      <p class="secondaire">{{EMETTEUR_CONTACT}}</p>
    </div>
    <div class="partie client">
      <span class="etiquette">Client</span>
      <p class="nom">{{CLIENT_NOM}}</p>
      <!-- OPTION interlocuteur -->
      <p class="secondaire">À l’attention de {{CLIENT_INTERLOCUTEUR}}</p>
      <!-- FIN OPTION -->
      <p>{{CLIENT_ADRESSE}}</p>
      <!-- OPTION client professionnel -->
      <p class="secondaire">SIREN {{CLIENT_SIREN}}</p>
      <!-- FIN OPTION -->
    </div>
  </section>

  <section class="objet">
    <span class="etiquette">Objet</span>
    <p>{{OBJET}}</p>
  </section>

  <table class="lignes">
    <thead>
      <tr>
        <th class="n">N°</th>
        <th>Désignation</th>
        <th class="q">Qté</th>
        <th class="u">Unité</th>
        <th class="pu">Prix unit. HT</th>
        <th class="tx">TVA</th>
        <th class="mt">Total HT</th>
      </tr>
    </thead>
    <tbody>
      <!-- LIGNE : à répéter pour chaque ligne -->
      <tr>
        <td class="n">{{LIGNE_NUMERO}}</td>
        <td><div class="designation">{{LIGNE_DESIGNATION}}</div><div class="detail">{{LIGNE_DETAIL}}</div></td>
        <td class="q">{{LIGNE_QUANTITE}}</td>
        <td class="u">{{LIGNE_UNITE}}</td>
        <td class="pu">{{LIGNE_PRIX_UNITAIRE_HT}}</td>
        <td class="tx">{{LIGNE_TAUX_TVA}}</td>
        <td class="mt">{{LIGNE_TOTAL_HT}}</td>
      </tr>
      <!-- FIN LIGNE -->
    </tbody>
  </table>

  <section class="bas">
    <div class="conditions">
      <span class="etiquette">Conditions</span>
      <dl>
        <div><dt>Validité de l’offre</dt><dd>{{VALIDITE}}</dd></div>
        <div><dt>Réalisation</dt><dd>{{DELAI_REALISATION}}</dd></div>
        <div><dt>Paiement</dt><dd>{{CONDITIONS_PAIEMENT}}</dd></div>
        <!-- OPTION franchise en base de TVA -->
        <div><dt>Franchise en base</dt><dd>{{MENTION_FRANCHISE}}</dd></div>
        <!-- FIN OPTION -->
        <!-- OPTION devis gratuit ou payant (obligatoire pour certains travaux et dépannages) -->
        <div><dt>Devis</dt><dd>{{DEVIS_GRATUIT_OU_PAYANT}}</dd></div>
        <!-- FIN OPTION -->
      </dl>
    </div>
    <table class="totaux">
      <tr><th>Total HT</th><td>{{TOTAL_HT}}</td></tr>
      <!-- OPTION remise globale : la ligne du dessus devient « Sous-total HT » -->
      <tr><th>Remise {{REMISE_LIBELLE}}</th><td>{{REMISE_MONTANT}}</td></tr>
      <tr><th>Total HT après remise</th><td>{{TOTAL_HT_NET}}</td></tr>
      <!-- FIN OPTION -->
      <!-- LIGNE DE TVA : une par taux -->
      <tr><th>TVA {{TVA_TAUX}}<span class="base">sur {{TVA_BASE}}</span></th><td>{{TVA_MONTANT}}</td></tr>
      <!-- FIN LIGNE DE TVA -->
      <tr class="espace"><th></th><td></td></tr>
      <tr class="fort"><td colspan="2"><div class="total-fort"><span>Total TTC</span><span>{{TOTAL_TTC}}</span></div></td></tr>
      <!-- OPTION acompte -->
      <tr class="acompte"><th>{{ACOMPTE_LIBELLE}}</th><td>{{ACOMPTE_MONTANT}}</td></tr>
      <!-- FIN OPTION -->
    </table>
  </section>

  <section class="accord">
    <p class="note">{{NOTE_ACCORD}}</p>
    <div class="cadre">
      <span class="etiquette">Bon pour accord</span>
      <p>Date, nom et signature du client, précédés de la mention manuscrite «&nbsp;Bon pour accord&nbsp;».</p>
    </div>
  </section>

  <footer class="pied">
    <p class="mentions">{{MENTIONS_LEGALES}}</p>
  </footer>

</main>
</body>
</html>
