  :root { --navy: #2f3368; --brun: #80340d; --line: #c9cbdb; --soft: #f1f2f8; --txt: #222; --ans: #1c3a8c; --fond: #e6e7ef; }
  * { box-sizing: border-box; }
  body { margin: 0; background: var(--fond); color: var(--txt); font: 14px/1.35 Calibri, Carlito, "Segoe UI", Arial, sans-serif; }
  .barre { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--navy); color: #fff; }
  .barre b { font-size: 16px; }
  .barre .eleve { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .barre .eleve strong { color: #ffd23f; }
  .barre button { border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
  .barre .eleve button { padding: 4px 10px; }
  .imprimer { background: #ffd23f; color: #222; }
  .vider { background: #fff; color: var(--navy); }
  .page { max-width: 1000px; margin: 16px auto; padding: 28px 30px; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
  .entete { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 14px; align-items: stretch; }
  .entete > * { min-width: 0; }
  .entete .client { order: 2; } .entete .cartouche { order: 3; }
  .client { display: flex; flex-direction: column; gap: 3px; }
  .client input { padding: 2px 5px; }
  .mentions .lg { color: #666; font-size: 11px; }
  #num[readonly] { border-color: transparent; background: var(--soft); }
  .societe { display: flex; gap: 14px; align-items: flex-start; }
  .societe img { width: 78px; height: auto; flex: none; }
  .societe strong { display: block; color: var(--navy); font-size: 18px; letter-spacing: .5px; }
  .societe em { display: block; color: var(--brun); font-size: 13px; margin-bottom: 4px; }
  .mentions { font-size: 12px; color: #444; line-height: 1.3; }
  .cartouche { border: 1px solid var(--navy); border-radius: 6px; overflow: hidden; }
  .cartouche h1 { margin: 0; padding: 8px 12px; background: var(--navy); color: #fff; font-size: 18px; letter-spacing: 1px; text-align: center; }
  .cartouche .in { padding: 8px 12px; }
  .champ { display: grid; grid-template-columns: 96px 1fr; gap: 6px; align-items: center; margin: 3px 0; }
  .champ label { font-size: 12px; color: #555; }
  .client { border: 1px solid var(--line); border-left: 4px solid var(--brun); border-radius: 4px; padding: 8px 12px; }
  .client .tit { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--brun); font-weight: 700; margin-bottom: 4px; }
  input, select { font: inherit; color: var(--ans); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; width: 100%; background: #fff; }
  input.num { text-align: right; }
  input.fort { font-weight: 700; }
  table { width: 100%; border-collapse: collapse; margin-top: 16px; }
  th, td { border: 1px solid var(--line); padding: 3px 6px; vertical-align: middle; }
  thead th { background: var(--navy); color: #fff; font-size: 12px; font-weight: 600; }
  td.sec { background: var(--soft); font-weight: 700; color: var(--brun); letter-spacing: .5px; }
  td.calc { text-align: right; white-space: nowrap; }
  td.lib { text-align: right; }
  tr.st td { font-weight: 700; background: #fafafd; }
  .w-ref { width: 92px; } .w-q { width: 64px; } .w-pu { width: 90px; } .w-r { width: 62px; } .w-m { width: 110px; }
  .bas { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: start; }
  .totaux td:first-child { font-weight: 600; }
  .totaux tr.ttc td { background: var(--navy); color: #fff; font-weight: 700; font-size: 15px; border-color: var(--navy); }
  .totaux tr.net td { font-weight: 700; }
  .regl thead th:first-child { text-align: left; }
  .validite { margin: 10px 0 0; font-size: 13px; }
  .validite input { width: 50px; display: inline-block; }
  .signature { margin-top: 10px; border: 1px solid var(--line); border-radius: 4px; min-height: 92px; padding: 8px; font-size: 12px; color: #555; }
  .aide { font-size: 12px; color: #555; margin-top: 12px; }
  .pied, .pv, .score { display: none; }
  .mailf { max-width: 680px; padding: 0; overflow: hidden; text-align: left; }
  .mhead { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--navy); color: #fff; }
  .mhead span { font-size: 12px; color: #ffd23f; }
  .mrow { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 8px; padding: 6px 16px; border-bottom: 1px solid #e3e5ee; }
  .mrow label { margin: 0; font-size: 12px; color: #555; }
  .mrow input { border: 0; padding: 4px 0; }
  .mrow input:focus { outline: none; }
  .pj { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 14px; font-size: 12px; background: var(--soft); width: fit-content; }
  .pj::before { content: "PDF"; font-size: 10px; font-weight: 700; color: #fff; background: #c62828; border-radius: 3px; padding: 1px 4px; }
  .mailf textarea { display: block; width: calc(100% - 32px); margin: 10px 16px 0; min-height: 220px; font: inherit; color: var(--ans); border: 1px solid var(--line); border-radius: 6px; padding: 8px; resize: vertical; }
  .mailf .err { padding: 0 16px; }
  .mbtn { display: flex; justify-content: flex-end; gap: 10px; padding: 0 16px 16px; }
  .mbtn button { width: auto; margin-top: 8px; padding: 9px 18px; }
  .mbtn button.vider { background: #fff; color: var(--navy); border: 1px solid var(--line); }
  .barre .envoye { background: #d6f5df; color: #145c2c; }
  .cprint { display: none; }
  .tva-choix { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
  .tva-choix label { cursor: pointer; }
  .tva-choix input { position: absolute; opacity: 0; width: 1px; height: 1px; }
  .tva-choix span { display: block; padding: 3px 8px; font-size: 12px; font-weight: 600; color: var(--navy); background: #fff; border-left: 1px solid var(--line); white-space: nowrap; }
  .tva-choix label:first-child span { border-left: 0; }
  .tva-choix input:checked + span { background: var(--navy); color: #fff; }
  .tva-choix input:focus-visible + span { outline: 2px solid var(--brun); outline-offset: -2px; }
  .totaux td.calc:nth-child(2) { width: 150px; text-align: center; }
  .totaux td:first-child { white-space: nowrap; }
  .oblig { font-weight: 400; text-transform: none; letter-spacing: 0; color: #777; }
  input.manque { border-color: #b00020; background: #fff3f4; }
  .alerte { margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; background: #fff3f4; color: #8a0018; border: 1px solid #f0b8c0; font-weight: 600; }
  .geo { font-size: 12px; opacity: .85; }
  .redac { color: var(--ans); }
  /* Fenêtre de connexion */
  .ident { display: none; position: fixed; inset: 0; z-index: 20; background: rgba(28,32,60,.78); align-items: center; justify-content: center; padding: 16px; }
  .ident.on { display: flex; }
  .boite { background: #fff; border-radius: 10px; padding: 22px 24px; width: 100%; max-width: 560px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
  .boite h2 { margin: 0; color: #2f3368; font-size: 20px; text-align: center; }
  .boite .sous { margin-top: 2px; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #80340d; text-align: center; }
  .boite p { margin: 8px 0 12px; font-size: 13px; color: #555; text-align: center; }
  .boite label { display: block; font-size: 12px; color: #555; margin-top: 8px; }
  .noms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .choix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
  .choix label { margin: 0; cursor: pointer; }
  .choix input { position: absolute; opacity: 0; width: 1px; height: 1px; }
  .carte { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; padding: 10px 8px; border: 2px solid #d8dae6; border-radius: 8px; text-align: center; transition: border-color .15s, box-shadow .15s; }
  .carte img { height: 54px; width: auto; max-width: 100%; object-fit: contain; }
  .carte b { color: #222; font-size: 14px; }
  .carte span { font-size: 11px; color: #666; line-height: 1.25; }
  .choix input:checked + .carte { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
  .choix input:focus-visible + .carte { outline: 2px solid #2f3368; outline-offset: 2px; }
  .boite button { margin-top: 16px; width: 100%; border: 0; border-radius: 6px; padding: 10px; font: inherit; font-weight: 700; cursor: pointer; background: #ffd23f; color: #222; }
  .boite .err { color: #b00020; font-size: 12px; min-height: 16px; margin-top: 6px; text-align: center; }
  /* Confirmation intégrée (pas de boîte de dialogue du navigateur) */
  .conf { display: none; align-items: center; gap: 6px; }
  .conf.on { display: inline-flex; }
  footer { max-width: 1000px; margin: 0 auto 20px; font-size: 11px; color: #666; text-align: center; }
  @media (max-width: 760px) { .entete, .bas { grid-template-columns: 1fr; } .entete .client { order: 3; } .entete .cartouche { order: 2; } .page { padding: 12px; margin: 8px; } table { font-size: 12px; } .choix { grid-template-columns: 1fr; } .carte { flex-direction: row; text-align: left; } .carte img { height: 40px; } }
  @media print {
    @page { size: A4; margin: 12mm 12mm 14mm; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body { background: #fff; font-size: 10.5px; line-height: 1.25; }
    .barre, .aide, footer, .ident, .alerte, .tva-choix, .oblig { display: none !important; }
    .redac { color: #000; }
    .page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
    .page input, .page select { display: none !important; }
    .pv { display: inline; }
    td .pv { display: block; }
    .client .pv { display: block; font-weight: 600; }
    .client .pv:empty { display: none; }
    .cartouche .champ .pv { font-weight: 600; }
    tr.vide { display: none; }
    table { margin-top: 8px; }
    .client { padding: 4px 8px; gap: 1px; }
    .societe img { width: 60px; }
    .societe img { width: 80px; }
    .cartouche h1 { padding: 5px 10px; font-size: 15px; }
    .champ { margin: 2px 0; }
    th, td { padding: 1px 5px; }
    .signature { min-height: 80px; }
    table, .bas, .signature { break-inside: avoid; }
    .ok, .pv.ok, td.ok, b.ok { color: #157a3a !important; font-weight: 700; }
    .totaux tr.ttc td.ok { color: #b9f3c9 !important; }
    .bas { grid-template-columns: 1fr 300px; }
    .totaux td.calc:nth-child(2) { width: 60px; }
    .totaux td:first-child { white-space: nowrap; }
    .score i { color: #157a3a; font-style: normal; }
    .score { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; padding: 6px 10px; border: 2px solid var(--navy); border-radius: 6px; font-size: 11px; }
    .score b { font-size: 16px; color: var(--navy); }
    .cprint:not([hidden]) { display: block; break-before: page; }
    .cprint h2 { margin: 0 0 8px; font-size: 15px; color: var(--navy); }
    .ctab { margin-top: 0; }
    .ctab th { width: 110px; text-align: left; background: var(--soft); color: var(--navy); font-size: 11px; }
    .ctxt { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; white-space: pre-wrap; font-size: 11.5px; line-height: 1.45; min-height: 200px; }
    .pied { display: block; margin-top: 14px; padding-top: 6px; border-top: 2px solid var(--navy); font-size: 10px; color: #555; text-align: center; }
  }
