* { box-sizing: border-box; }
body { margin: 0; color: #172a25; background: #edf2ef; font: 1rem/1.55 system-ui, sans-serif; }
main { max-width: 68rem; margin: auto; padding: 1rem; }
.controls, article { background: white; padding: 1.4rem; margin-bottom: 1.5rem; border: 1px solid #65786f; border-radius: .4rem; }
h1, h2, h3 { line-height: 1.25; } h3 { font-size: 1rem; margin-bottom: .2rem; } p { margin-top: .4rem; white-space: pre-wrap; }
label { display: block; margin: .8rem 0; } input:not([type=checkbox]), textarea { display: block; width: 100%; padding: .6rem; font: inherit; border: 1px solid #586b62; }
button { padding: .7rem 1rem; margin: .5rem 0; font: inherit; cursor: pointer; } button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #a45109; outline-offset: 3px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; } th, td { border: 1px solid #586b62; padding: .5rem; text-align: left; overflow-wrap: anywhere; }
dt { font-weight: bold; } dd { margin: 0; } dl > div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #65786f; padding: .35rem 0; }
article { overflow-wrap: anywhere; } .print-block { display: none; }
/* Mentions de l’entreprise en pied du devis (avant les règles d’impression, qui l’emportent). */
.mentions { margin-top: 1.2rem; padding-top: .5rem; border-top: 1px solid #65786f; font-size: .85rem; }
.mentions p { margin: .1rem 0; }
.cgv { margin-top: 1.5rem; } .cgv p { font-size: .9rem; }
@page { size: A4; margin: 15mm; }
@media print {
  html, body { background: white; color: black; font-size: 10pt; }
  main { max-width: none; margin: 0; padding: 0; }
  .controls, .demo-home { display: none !important; }
  article { margin: 0; padding: 0; border: 0; border-radius: 0; color: black; background: white; }
  h1, h2, h3 { break-after: avoid; } tr, dl > div { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; } th, td { border-color: black; }
  p { orphans: 3; widows: 3; } table, article { overflow: visible; max-height: none; }
  body:not([data-ready="true"]) #document { display: none; }
  body:not([data-ready="true"]) .print-block { display: block; }
  /* Conditions générales en dernière page ; le rappel des mentions ne s’imprime jamais. */
  .cgv { break-before: page; page-break-before: always; } .cgv p { font-size: 8.5pt; }
  .rappel-mentions { display: none !important; }
}

/* Remise : détail sous le motif, montant négatif aligné à droite. */
.remise dt small { display: block; font-weight: 400; } .remise dd { white-space: nowrap; flex-shrink: 0; }

/* Devis conforme : faits en grille, textes légaux en petit, une page pour un devis ordinaire. */
dl.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.2rem; }
dl.facts > div { display: block; border-bottom: 1px solid #c2d2ca; padding: .2rem 0; }
dl.facts dt { font-size: .85rem; } dl.facts dd { margin: 0; }
.legal { font-size: .85rem; } .legal h3 { font-size: .9rem; margin: .4rem 0 0; } .legal p { margin: .1rem 0; }
@media print {
  article h1 { font-size: 15pt; margin: 0 0 .2rem; } article h2 { font-size: 11pt; margin: .5rem 0 .2rem; } article h3 { margin: .2rem 0 0; } article p { margin: .1rem 0; }
  dl.facts { gap: 0 .8rem; } dl.facts > div { padding: 0; } dl.facts dt, dl.facts dd { font-size: 8pt; } dl > div { padding: .05rem 0; }
  th, td { padding: .08rem .3rem; font-size: 8.5pt; }
  .legal, .legal p, .legal h3 { font-size: 7.5pt; } .mentions { margin-top: .4rem; font-size: 7.5pt; } .mentions p { margin: 0; }
  dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #document dt, #document dd, #document > p { font-size: 8.5pt; line-height: 1.3; }
  #document dl.facts dt, #document dl.facts dd { font-size: 8pt; }
  /* Une page pour un devis ordinaire (CGV à part) : « libellé : valeur » sur une ligne, textes légaux sur deux colonnes, mentions de l’entreprise à la suite. */
  #document dl.facts > div { display: flex; gap: .25rem; align-items: baseline; } #document dl.facts dt { flex: none; } #document dl.facts dt::after { content: ' :'; }
  .legal { column-count: 2; column-gap: 1rem; } .legal h3 { break-after: avoid; }
  .mentions p { display: inline; } .mentions p + p::before { content: ' · '; }
  article h2 { margin: .35rem 0 .1rem; } th, td { padding: 0 .3rem; font-size: 8pt; line-height: 1.35; } #document dl > div { padding: 0; }
  .legal, .legal p, .legal h3 { font-size: 7pt; line-height: 1.3; }
}

#document .logo-entreprise { display: block; max-width: 150px; max-height: 60px; margin-bottom: 8px; }

@media screen {
  .mentions, .cgv p, dl.facts dt, .legal { font-size: var(--t-meta); }
  .legal h3 { font-size: var(--t-corps); }
}
