:root {
  --orange: #e8670c;
  --red: #d6192f;
  --ink: #1c1c28;
  --muted: #6b6b78;
  --line: #dcdce2;
  --cream: #fdf1e6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Quicksand", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #e9e9ee;
  line-height: 1.4;
  padding: 24px 0;
}
a { color: inherit; text-decoration: none; }

/* Actions écran uniquement. Elles ne font jamais partie de la feuille A4. */
.dv-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 210mm;
  max-width: calc(100% - 24px);
  margin: -12px auto 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px;
  background: rgba(255,255,255,.96);
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.dv-toolbar button {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 4px;
  font: 700 13px/1 "Quicksand", sans-serif;
  cursor: pointer;
}
.dv-toolbar__button { border: 1px solid var(--orange); background: var(--orange); color: #fff; }
.dv-toolbar__button.is-dex-export { border-color: #006634; background: #006634; color: #fff; }
.dv-toolbar__link { border: 1px solid #ccc; background: #fff; color: #333; }

/* Une feuille = une vraie page A4 (210 x 297 mm).
   Le contenu fourni est dessiné sur 920 x 1301,2 px puis réduit x 0,86272
   afin de conserver exactement sa géométrie sur l'A4. */
.sheet {
  width: 210mm;
  height: 297mm;
  margin: 0 auto 24px;
  background: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.page {
  width: 920px;
  height: 1301.2px;
  padding: 44px 56px 28px;
  transform: scale(0.86272);
  transform-origin: 0 0;
  overflow: hidden;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.page.p1,
.page.p2 {
  display: flex;
  flex-direction: column;
}

/* ===== PAGE 1 ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--red);
}
.topbar img.logo { width: 222px; height: auto; display: block; margin-top: -4px; }
.ref { text-align: right; font-size: 14px; color: var(--muted); margin-top: 8px; }
.ref strong { display: block; color: var(--ink); letter-spacing: 1.5px; margin-bottom: 4px; font-weight: 700; }

.title { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 26px; gap: 16px; }
.title h1 { font-size: 44px; font-weight: 700; line-height: 1.1; }
.price { font-size: 44px; font-weight: 800; color: var(--orange); white-space: nowrap; line-height: 1.1; }
.price small { font-size: 21px; }
.subtitle { margin-top: 8px; font-size: 18px; color: #333; }
.tags { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 24px; font-size: 15px; font-weight: 700; }

.photo { margin-top: 18px; border-radius: 8px; overflow: hidden; line-height: 0; }
.photo img { width: 100%; height: auto; display: block; }

h2 { color: var(--orange); font-size: 26px; font-weight: 700; margin: 30px 0 14px; }

.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 28px; }
.spec { border-top: 1px solid var(--line); padding: 10px 0 8px; }
.spec dt { font-size: 14px; color: var(--muted); }
.spec dd { font-size: 16px; font-weight: 700; }

.footer-line {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}

/* ===== PAGE 2 ===== */
.mini-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--red);
}
.mini-head img { width: 125px; height: auto; display: block; }
.mini-head .center {
  flex: 1;
  margin-left: 18px;
  font-size: 18px;
  color: #333;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-head .center b { font-weight: 700; color: var(--ink); }
.mini-head .right { font-size: 14px; color: var(--muted); white-space: nowrap; }
.mini-head .right b { color: var(--ink); }

/* Options et équipements utilisent exactement la même typographie. */
.options-text,
.equip li {
  font-family: "Quicksand", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 13px;
  color: var(--ink);
}
.options-text { min-height: 22px; }

.equip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 12px; }
.equip ul { list-style: none; }
.equip li { padding-left: 8px; text-indent: -8px; margin-bottom: 0; break-inside: avoid; }
.equip li::before { content: "· "; }
.page.p2 h2 { margin: 20px 0 10px; }
.page.p2 .mini-head + h2 { margin-top: 18px; }

/* Les densités conservent la grille et l'A4, elles réduisent seulement le texte
   si un véhicule contient beaucoup plus d'équipements que l'exemple. */
.dv-density-compact .options-text,
.dv-density-compact .equip li { font-size: 12px; line-height: 12px; }
.dv-density-tight .options-text,
.dv-density-tight .equip li { font-size: 11px; line-height: 11px; }
.dv-density-tight .page.p2 h2 { margin-top: 16px; margin-bottom: 7px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 22px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 22px 16px; }
.page.p2 .card h2 { margin: 0 0 8px; font-size: 24px; }
.card h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }
.card p { color: #444; font-size: 15px; line-height: 1.3; }
.card .tel { display: block; margin-top: 8px; font-weight: 700; font-size: 16px; }

.comments { border: 1px solid var(--line); border-radius: 10px; padding: 16px 16px 8px; }
.comments div { border-bottom: 1px dotted #999; height: 30px; }
.comments div:last-child { border-bottom: 0; }

.spacer { flex: 1; min-height: 0; }

.dealers {
  background: var(--cream);
  border-top: 3px solid var(--orange);
  padding: 22px 24px 14px;
  border-radius: 0 0 12px 12px;
  margin: 0 -24px;
}
.dealers h3 { font-size: 18px; margin-bottom: 14px; font-weight: 700; }
.dealer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.dealer b { display: block; font-size: 16px; font-weight: 700; }
.dealer .tel { display: block; color: var(--orange); font-weight: 700; margin: 4px 0; font-size: 15px; }
.dealer span { font-size: 14px; color: #444; }
.brands { margin-top: 18px; font-size: 14px; color: #333; }
.brands b { color: var(--ink); }
.bottom {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #ead9c8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #555;
}
.bottom .slogan { color: var(--orange); font-size: 22px; font-weight: 800; }

.dv-error {
  max-width: 640px;
  margin: 80px auto;
  padding: 30px;
  background: #fff;
  border-radius: 6px;
}

/* ===== Petits écrans : mise en page fluide (hors A4) ===== */
@media screen and (max-width: 840px) {
  body { padding: 0; background: #fff; }
  .dv-toolbar { position: relative; width: auto; max-width: none; margin: 0; border-radius: 0; }
  .sheet { width: auto; height: auto; overflow: visible; box-shadow: none; margin-bottom: 0; }
  .page { width: auto; height: auto; transform: none; overflow: visible; padding: 24px 18px; }
  .title h1, .price { font-size: 32px; }
  .specs { grid-template-columns: repeat(2, 1fr); }
  .equip { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .dealer-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-head { flex-wrap: wrap; gap: 8px; }
  .dealers { margin: 0; }
  .footer-line, .bottom { flex-direction: column; gap: 6px; }
  .footer-line { margin-top: 30px; }
}

/* ===== Impression : 2 pages A4 exactes, sans marges ===== */
@page { size: A4 portrait; margin: 0; }
@media print {
  html, body { background: #fff; padding: 0; margin: 0; }
  .dv-toolbar { display: none !important; }
  .sheet {
    margin: 0;
    box-shadow: none;
    height: 296.6mm;
    break-after: page;
    page-break-after: always;
  }
  .sheet:last-of-type {
    break-after: auto;
    page-break-after: auto;
  }
}
