/* =====================================================================
   NR FORMATION — Feuille de style du DOCUMENT (devis / facture).
   Chargée par l'app (aperçu live dans l'éditeur) ET par la fenêtre
   d'impression : un seul fichier => l'aperçu est fidèle au PDF.
   Volontairement sans variables de thème : une feuille est toujours blanche.
   ===================================================================== */

.de-paper {
  --pad: 44px;
  --dp-brand: #3B5BFF;
  --dp-brand-dark: #2E49D6;
  --dp-brand-soft: #EEF2FF;
  --dp-line: #E4E8F0;
  --dp-ink: #1E2430;
  --dp-soft: #5B6478;

  background: #fff;
  color: var(--dp-ink);
  width: 100%;
  max-width: 720px;
  min-height: 900px;
  padding: 38px var(--pad) 44px;
  border-radius: 6px;
  box-shadow: 0 6px 30px rgba(20, 26, 40, .14);
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Bandeau de couleur en tête de feuille */
.dp-band {
  height: 5px;
  background: linear-gradient(90deg, var(--dp-brand), #8AA0FF);
  margin: -38px calc(var(--pad) * -1) 30px;
  border-radius: 6px 6px 0 0;
}

/* ---- En-tête : émetteur à gauche, document à droite ---- */
.dp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; }
.dp-issuer { max-width: 58%; }
.dp-logo { height: 46px; width: auto; max-width: 240px; display: block; margin-bottom: 12px; }
.dp-id { font-size: 11px; line-height: 1.6; color: var(--dp-soft); }
.dp-id strong { color: var(--dp-ink); font-size: 12.5px; }

.dp-right { text-align: right; flex-shrink: 0; }
.dp-type {
  font-size: 26px; font-weight: 800; letter-spacing: .01em;
  color: var(--dp-brand); line-height: 1.1; text-transform: uppercase;
}
.dp-num { font-size: 14px; font-weight: 700; margin-top: 2px; }
.dp-dates { margin: 12px 0 0; font-size: 11.5px; }
.dp-dates > div { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; }
.dp-dates dt { color: var(--dp-soft); }
.dp-dates dd { margin: 0; font-weight: 600; min-width: 88px; text-align: right; }

/* ---- Destinataire ---- */
.dp-client {
  margin: 28px 0 0 auto; width: 270px;
  border: 1px solid var(--dp-line); border-left: 3px solid var(--dp-brand);
  border-radius: 8px; padding: 12px 14px; font-size: 12.5px; line-height: 1.55;
}
.dp-client span {
  display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dp-brand); font-weight: 800; margin-bottom: 4px;
}

/* ---- Tableau des lignes ---- */
.dp-tbl { width: 100%; border-collapse: collapse; margin-top: 30px; }
.dp-tbl th {
  background: var(--dp-brand-soft); color: var(--dp-brand-dark);
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 800;
  padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--dp-line);
}
.dp-tbl th:first-child { border-radius: 5px 0 0 0; }
.dp-tbl th:last-child { border-radius: 0 5px 0 0; }
.dp-tbl td { padding: 10px; border-bottom: 1px solid var(--dp-line); text-align: left; }
.dp-tbl tbody tr:nth-child(even) td { background: #FAFBFE; }
.dp-tbl .r { text-align: right; white-space: nowrap; }
/* Colonnes chiffrées à largeur fixe : la désignation prend le reste */
.dp-tbl th:nth-child(2), .dp-tbl td:nth-child(2) { width: 50px; }
.dp-tbl th:nth-child(3), .dp-tbl td:nth-child(3) { width: 84px; }
.dp-tbl th:nth-child(4), .dp-tbl td:nth-child(4) { width: 56px; }
.dp-tbl th:nth-child(5), .dp-tbl td:nth-child(5) { width: 98px; }
.dp-des { font-weight: 600; }
.dp-empty { color: #A8AEBC; text-align: center; font-style: italic; }

/* ---- Pied : note à gauche, totaux à droite ---- */
.dp-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 26px; margin-top: 20px; }

.dp-notes {
  flex: 1; max-width: 56%; font-size: 12px; color: var(--dp-soft);
  background: #FAFBFE; border-left: 3px solid var(--dp-line);
  border-radius: 0 6px 6px 0; padding: 10px 13px; white-space: pre-line;
}
.dp-notes span {
  display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 800; color: var(--dp-ink); margin-bottom: 4px;
}

.dp-tot { width: 280px; flex-shrink: 0; font-size: 12.5px; }
.dp-tot > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 12px; }
.dp-tot span { color: var(--dp-soft); }
.dp-tot b { font-weight: 700; }
.dp-tot .g {
  background: var(--dp-brand); color: #fff; border-radius: 6px;
  padding: 10px 12px; margin-top: 6px; font-size: 15px; font-weight: 800;
}
.dp-tot .g span { color: rgba(255, 255, 255, .88); font-weight: 700; }
.dp-tot .dp-paid { margin-top: 6px; color: #2E7D52; }
.dp-tot .dp-paid b, .dp-tot .dp-paid span { color: #2E7D52; }
.dp-tot .dp-due { border-top: 1px solid var(--dp-line); margin-top: 2px; padding-top: 8px; font-size: 14px; }
.dp-tot .dp-due b { color: var(--dp-brand-dark); font-weight: 800; }

/* ---- Mentions légales ---- */
.dp-legal {
  margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--dp-line);
  font-size: 9.5px; color: #8A90A0; line-height: 1.55;
}
.dp-legal p { margin: 3px 0; }

/* ---- Écrans étroits ----
   `screen` est indispensable : une page A4 fait ~794 px de large, donc sans
   lui cette règle s'appliquerait aussi à l'impression et casserait le PDF. */
@media screen and (max-width: 1000px) {
  .de-paper { --pad: 22px; min-height: 0; padding: 26px var(--pad) 30px; }
  .dp-band { margin: -26px calc(var(--pad) * -1) 22px; }
  .dp-head { flex-direction: column; }
  .dp-issuer { max-width: none; }
  .dp-right { text-align: left; }
  .dp-dates > div { justify-content: flex-start; }
  .dp-dates dd { text-align: left; }
  .dp-client { width: auto; margin-left: 0; }
  .dp-foot { flex-direction: column; }
  .dp-notes { max-width: none; }
  .dp-tot { width: 100%; }
}

/* ---- Impression / PDF ---- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { margin: 0; background: #fff; }
  .de-paper {
    --pad: 0px;
    max-width: none; min-height: 0; padding: 0;
    box-shadow: none; border-radius: 0; font-size: 11.5px;
  }
  .dp-band { margin: 0 0 22px; border-radius: 0; }
  /* Pas de coupure au milieu d'une ligne, d'un bloc de totaux ou des mentions */
  .dp-tbl thead { display: table-header-group; }
  .dp-tbl tr, .dp-tot, .dp-notes, .dp-legal { break-inside: avoid; page-break-inside: avoid; }
  .dp-tbl tbody tr:nth-child(even) td { background: #FAFBFE !important; }
  .dp-tbl th, .dp-tot .g { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
