/* Devis MSP : feuille de style unique. Aucun style en ligne (CSP). */

:root {
  --fond: #f3f5f8;
  --surface: #ffffff;
  --surface-douce: #f8fafc;
  --texte: #1f2937;
  --texte-doux: #5b6472;
  --bordure: #e1e5ec;
  --bordure-forte: #c5ccd8;
  --accent: #1d4ed8;
  --accent-fonce: #1e3fa8;
  --accent-pale: #e8eefd;
  --succes: #166534;
  --succes-pale: #e6f4ea;
  --alerte: #92400e;
  --alerte-pale: #fff3dc;
  --danger: #b42318;
  --danger-pale: #fdecea;
  --rayon: 10px;
  --rayon-petit: 6px;
  --ombre: 0 1px 2px rgb(16 24 40 / 5%), 0 1px 4px rgb(16 24 40 / 6%);
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "DejaVu Sans", sans-serif;
  color: var(--texte);
  background: var(--fond);
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

h4 {
  font-size: 0.95rem;
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-fonce);
}

.invisible {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Bandeaux, en-tête, page ---------- */

.bandeau {
  margin: 0;
  padding: 0.35rem 2rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.bandeau-dev {
  background: #fde68a;
  color: #713f12;
}

.bandeau-demo {
  background: #dbeafe;
  color: #1e3a8a;
}

.entete {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.7rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}

.entete .marque {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.navigation {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}

.navigation a {
  color: var(--texte-doux);
  font-weight: 600;
  text-decoration: none;
}

.navigation a:hover {
  color: var(--accent);
}

.compte {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  color: var(--texte-doux);
  font-size: 0.925rem;
}

.contenu {
  max-width: 86rem;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
}

.titre-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.titre-page h1 {
  margin: 0;
}

.sous-titre {
  color: var(--texte-doux);
  margin-top: -0.5rem;
}

/* ---------- Cartes ---------- */

.carte,
.volet-client,
.nouveau-client,
.panneau-totaux,
.rubrique,
.option,
.ajouts {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.carte > .aide,
.colonnes > section > .aide {
  margin-bottom: 1rem;
}

.carte > :last-child,
.rubrique > :last-child {
  margin-bottom: 0;
}

.carte-titre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.carte-titre > * {
  margin: 0;
}

/* ---------- Boutons ---------- */

button,
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.45rem 1rem;
  font: inherit;
  font-size: 0.925rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-petit);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.bouton:hover {
  background: var(--surface-douce);
  border-color: #aab3c2;
  color: var(--texte);
}

button:focus-visible,
.bouton:focus-visible,
a:focus-visible {
  outline: 3px solid rgb(29 78 216 / 35%);
  outline-offset: 2px;
}

button.principal,
.bouton.principal {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

button.principal:hover,
.bouton.principal:hover {
  color: #fff;
  background: var(--accent-fonce);
  border-color: var(--accent-fonce);
}

button.discret {
  min-height: auto;
  padding: 0.3rem 0.55rem;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--texte-doux);
  background: transparent;
  border-color: transparent;
}

button.discret:hover {
  color: var(--danger);
  background: var(--danger-pale);
  border-color: transparent;
}

.actions,
.actions-devis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1.25rem 0 0;
}

/* ---------- Formulaires ---------- */

input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.65rem;
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-petit);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(29 78 216 / 18%);
}

input::placeholder,
textarea::placeholder {
  color: #9aa3b2;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

.champs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem 1.25rem;
}

.champ {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
}

.champ > label,
.champ > legend {
  font-weight: 600;
  font-size: 0.9rem;
}

.champ-large {
  grid-column: 1 / -1;
}

.champ-case {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  align-self: end;
  min-height: 2.4rem;
}

.champ-case > label {
  font-weight: 500;
}

.champ-case > .aide,
.champ-case > .errorlist {
  flex-basis: 100%;
}

fieldset.champ {
  border: 0;
  padding: 0;
}

fieldset.champ > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

fieldset.champ > div label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

.aide,
.note {
  color: var(--texte-doux);
  font-size: 0.85rem;
  margin: 0;
}

.errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
}

.errorlist.nonfield {
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
  background: var(--danger-pale);
  border-radius: var(--rayon-petit);
}

.champ-en-erreur input,
.champ-en-erreur select,
.champ-en-erreur textarea {
  border-color: var(--danger);
}

fieldset {
  margin: 0 0 1.25rem;
  padding: 1rem 1.25rem 1.1rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}

legend {
  padding: 0 0.35rem;
  font-weight: 700;
}

.recherche {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
}

.recherche label {
  font-weight: 600;
  font-size: 0.9rem;
}

.recherche input[type="search"] {
  width: 20rem;
  max-width: 100%;
}

.recherche select {
  width: auto;
  min-width: 11rem;
}

form.en-ligne {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

form.en-ligne select {
  width: auto;
}

/* ---------- Tableaux ---------- */

.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

.tableau th {
  padding: 0.55rem 0.75rem;
  white-space: nowrap;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--texte-doux);
  background: var(--surface-douce);
  border-bottom: 1px solid var(--bordure);
}

.tableau td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--bordure);
  vertical-align: middle;
}

.tableau td:first-child {
  white-space: nowrap;
}

.tableau tbody tr:last-child td {
  border-bottom: 0;
}

.tableau tbody tr:hover td {
  background: #fafbfd;
}

.carte > .tableau {
  margin: -0.25rem 0 0;
}

.nombre {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tableau th.nombre {
  text-align: right;
}

/* ---------- Fiches (listes de définitions) ---------- */

.fiche {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: 0.45rem 1.5rem;
  margin: 0;
}

.fiche dt {
  color: var(--texte-doux);
  font-weight: 600;
  font-size: 0.9rem;
}

.fiche dd {
  margin: 0;
}

/* ---------- Badges et étiquettes ---------- */

.badge {
  display: inline-block;
  white-space: nowrap;
  padding: 0.1rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: middle;
  color: var(--texte-doux);
  background: #edf0f4;
  border-radius: 999px;
}

.badge-emise,
.badge-conseil,
.badge-retenue {
  color: var(--accent-fonce);
  background: var(--accent-pale);
}

.badge-acceptee,
.badge-en_production {
  color: var(--succes);
  background: var(--succes-pale);
}

.badge-refusee {
  color: var(--danger);
  background: var(--danger-pale);
}

.badge-prevu,
.badge-en_cours,
.badge-expiree {
  color: var(--alerte);
  background: var(--alerte-pale);
}

.ligne .marque {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--alerte);
  background: var(--alerte-pale);
  border-radius: 999px;
}

.a-fournir {
  font-weight: 700;
  color: var(--danger);
}

/* ---------- Messages et avertissements ---------- */

.messages {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.message,
.reprise,
.bandeau-avertissement,
.indicateur {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-radius: var(--rayon-petit);
  border-left: 4px solid var(--accent);
  background: var(--accent-pale);
}

.messages .message {
  margin: 0;
}

.message-success {
  border-left-color: var(--succes);
  background: var(--succes-pale);
}

.message-warning,
.bandeau-avertissement {
  border-left-color: #d97706;
  background: var(--alerte-pale);
}

.message-error {
  border-left-color: var(--danger);
  background: var(--danger-pale);
}

.alertes {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem 0.7rem 2rem;
  color: var(--danger);
  background: var(--danger-pale);
  border-radius: var(--rayon-petit);
}

.avertissement {
  margin: 0.4rem 0 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  color: var(--alerte);
  background: var(--alerte-pale);
  border-radius: var(--rayon-petit);
}

/* ---------- Nouveau devis ---------- */

.nouveau-client > summary {
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
}

.nouveau-client[open] > summary {
  margin-bottom: 1.25rem;
}

.nouveau-client fieldset {
  margin-top: 1.25rem;
}

/* ---------- Besoin et offre ---------- */

.volet-client p {
  margin: 0 0 0.2rem;
}

.volet-client-nom {
  font-weight: 700;
  font-size: 1.05rem;
}

.colonnes {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.colonnes > section {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1.25rem 1.5rem;
}

.colonnes > section + section {
  position: sticky;
  top: 1rem;
}

.colonnes > section > .champ,
.colonnes > section > .champs {
  margin-bottom: 1rem;
}

.modele,
.choix {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.6rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
}

.modele:has(input:checked),
.choix:has(input:checked) {
  border-color: var(--accent);
  background: #f7f9ff;
}

.modele > label,
.choix > label {
  font-weight: 600;
  cursor: pointer;
}

.modele > .note,
.modele > .avertissement,
.choix > .note {
  grid-column: 2;
}

.modele .avertissement {
  display: none;
}

.modele input:checked ~ .avertissement {
  display: block;
}

.pourquoi {
  margin-top: 0.6rem;
  font-size: 0.875rem;
  color: var(--texte-doux);
}

.pourquoi summary {
  cursor: pointer;
  font-weight: 600;
}

/* ---------- Écran « Devis » ---------- */

.devis-corps {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28.5rem;
  gap: 1.5rem;
  align-items: start;
}

.panneau-totaux {
  position: sticky;
  top: 1rem;
}

.panneau-totaux .tableau th,
.panneau-totaux .tableau td {
  padding: 0.45rem 0.3rem;
  white-space: nowrap;
}

.panneau-totaux .tableau td,
.panneau-totaux .tableau tbody th {
  font-size: 0.85rem;
}

.panneau-totaux .tableau tbody th {
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--texte);
  background: none;
}

.panneau-totaux h3 {
  margin-top: 1.25rem;
  font-size: 0.9rem;
}

.panneau-totaux .fiche {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.panneau-totaux form {
  margin-top: 1rem;
}

.proposees {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.lignes {
  display: table;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

.ligne {
  display: table-row;
}

.ligne > .cellule {
  display: table-cell;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--bordure);
  vertical-align: middle;
}

.ligne.entete > .cellule {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--texte-doux);
  background: var(--surface-douce);
}

.ligne:last-child > .cellule {
  border-bottom: 0;
}

.cellule.nombre {
  text-align: right;
}

.actions-ligne {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.saisie {
  width: 6.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sous-total {
  margin: 0.6rem 0 0;
  text-align: right;
  font-weight: 700;
}

.bloc + .bloc {
  margin-top: 1.5rem;
}

.ajouts form {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) auto;
  gap: 0.5rem 0.75rem;
  align-items: end;
  padding: 0.85rem 0;
  border-top: 1px solid var(--bordure);
}

.ajouts form:first-of-type {
  border-top: 0;
  padding-top: 0.25rem;
}

.ajouts form.remise {
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.5fr) minmax(0, 0.8fr) auto;
}

.ajouts .champ > label {
  font-size: 0.85rem;
}

.option-entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.option-entete h4 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
}

.option-retiree {
  opacity: 0.65;
}

.option-proposee {
  border-style: dashed;
}

details.besoin > summary {
  font-weight: 700;
  cursor: pointer;
}

details.besoin[open] > summary {
  margin-bottom: 1rem;
}

/* ---------- Connexion et « À compléter » ---------- */

.connexion {
  max-width: 30rem;
  margin: 3rem auto;
}

.choix-compte {
  display: grid;
  gap: 0.6rem;
}

.rubrique h2 {
  font-size: 1rem;
}

.rubrique ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* ---------- Écrans moyens et petits ---------- */

@media (width <= 1150px) {
  .devis-corps {
    grid-template-columns: minmax(0, 1fr);
  }

  .panneau-totaux {
    position: static;
    order: -1;
  }
}

@media (width <= 900px) {
  .colonnes {
    grid-template-columns: minmax(0, 1fr);
  }

  .colonnes > section + section {
    position: static;
  }

  .ajouts form,
  .ajouts form.remise {
    grid-template-columns: minmax(0, 1fr);
  }

  .contenu {
    padding: 1.25rem 1rem 2rem;
  }

  .entete {
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    padding: 0.7rem 1rem;
  }
}

/* Statuts d'un devis, dans la liste */
.badge-emis {
  color: var(--accent-fonce);
  background: var(--accent-pale);
}

.badge-accepte {
  color: var(--succes);
  background: var(--succes-pale);
}

.badge-refuse {
  color: var(--danger);
  background: var(--danger-pale);
}

.badge-expire {
  color: var(--alerte);
  background: var(--alerte-pale);
}
