/* Générateur de contrats : tokens de l'agence RJS uniquement. */
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("/polices/Poppins-Regular.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("/polices/Poppins-Medium.ttf") format("truetype"); }
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("/polices/Poppins-SemiBold.ttf") format("truetype"); }

:root {
  --papier: #FAF9F5;
  --surface: #FFFFFF;
  --texte: #171717;
  --texte-2: #3F3F3F;
  --discret: #6B7280;
  --filet: #E5E7EB;
  --menthe: #3CEBD2;
  --nuit: #111827;
  --menthe-pale: color-mix(in srgb, var(--menthe) 32%, #FFFFFF);
  --menthe-tres-pale: color-mix(in srgb, var(--menthe) 14%, #FFFFFF);
  --police: "Poppins", Arial, sans-serif;
  --rayon: 6px;
  --gouttiere: 16px;
  --largeur-lecture: 880px;
  --largeur-max: 1120px;
  --hauteur-champ: 44px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--texte);
  font: 400 16px/1.55 var(--police);
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol, dl, dd, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.icone { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lien-evitement {
  position: absolute; left: var(--gouttiere); top: -100px; z-index: 20;
  background: var(--nuit); color: #FFFFFF; padding: 10px 16px; border-radius: var(--rayon);
}
.lien-evitement:focus { top: 8px; }

/* Anneau de focus : trait bleu nuit lisible, halo menthe. */
:focus-visible {
  outline: 2px solid var(--nuit);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--menthe);
}
main:focus, h1:focus, h2:focus, h3:focus { outline: none; box-shadow: none; }

/* ---------- mise en page ---------- */
.conteneur { width: 100%; max-width: var(--largeur-max); margin: 0 auto; padding: 0 var(--gouttiere); }
.lecture { max-width: var(--largeur-lecture); }
main { padding: 32px 0 72px; min-height: 60vh; }

.entete { background: var(--surface); border-bottom: 1px solid var(--filet); }
.entete-contenu { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 12px; padding-bottom: 12px; }
.marque { font-weight: 600; font-size: 18px; text-decoration: none; letter-spacing: 0.01em; }
.entete-nav { display: flex; gap: 8px; }
.entete-nav a { text-decoration: none; padding: 8px 12px; border-radius: var(--rayon); color: var(--texte-2); font-weight: 500; }
.entete-nav a:hover { background: var(--papier); }
.entete-nav a[aria-current="page"] { color: var(--texte); box-shadow: inset 0 -3px 0 var(--menthe); border-radius: 0; }

h1.page-titre { font-size: 32px; line-height: 1.2; font-weight: 600; margin-bottom: 8px; }
h2.etape-h { font-size: 26px; line-height: 1.25; font-weight: 600; margin-bottom: 8px; }
h3.groupe-titre { font-size: 19px; line-height: 1.3; font-weight: 600; }
h4.sous-titre { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--texte-2); margin-bottom: 6px; }
.intro { color: var(--texte-2); max-width: 70ch; margin-bottom: 16px; }
.discret { color: var(--discret); font-size: 14px; }

/* ---------- boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--hauteur-champ); padding: 8px 18px;
  background: var(--nuit); color: #FFFFFF; border: 1px solid var(--nuit); border-radius: var(--rayon);
  font-weight: 500; font-size: 15px; line-height: 1.3; text-decoration: none; cursor: pointer; text-align: center;
}
.bouton:hover { background: #000000; border-color: #000000; }
.bouton:disabled { opacity: 0.5; cursor: not-allowed; }
.bouton--secondaire { background: var(--surface); color: var(--texte); border-color: var(--nuit); }
.bouton--secondaire:hover { background: var(--menthe-tres-pale); border-color: var(--nuit); }
.bouton--lien { background: transparent; color: var(--texte); border-color: transparent; padding-left: 8px; padding-right: 8px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--menthe); text-decoration-thickness: 2px; }
.bouton--lien:hover { background: var(--menthe-tres-pale); border-color: transparent; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }

/* ---------- pastilles ---------- */
.pastille {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; line-height: 1.5; font-weight: 500; border: 1px solid var(--filet); background: var(--surface); color: var(--texte); white-space: nowrap;
}
.pastille--manquant { background: var(--menthe-pale); border-color: var(--menthe); color: var(--texte); }
.pastille--pret { background: var(--menthe); border-color: var(--menthe); color: var(--texte); }
.pastille--brouillon { background: var(--surface); border-color: var(--discret); }
.pastille--echec { background: var(--nuit); border-color: var(--nuit); color: #FFFFFF; }
.pastille--petite { padding: 0 8px; font-size: 12px; }
.etiquette { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--texte-2); }

/* ---------- cartes ---------- */
.carte { background: var(--surface); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 20px; }
.carte-ligne { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.carte-titre { font-size: 18px; line-height: 1.3; font-weight: 600; }
.carte-resume, .carte-client, .carte-reference, .carte-meta { color: var(--texte-2); }
.carte-meta { font-size: 14px; color: var(--discret); }

/* ---------- accueil ---------- */
.accueil-entete { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.accueil-entete .intro { margin-bottom: 0; }
.outils { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; margin-bottom: 12px; }
.champ--recherche { flex: 1 1 260px; max-width: 420px; }
.compteur { color: var(--discret); font-size: 14px; margin-bottom: 12px; }
.liste-dossiers { display: grid; gap: 12px; max-width: var(--largeur-lecture); }
.carte-dossier { display: grid; gap: 10px; }
.carte--archive { background: var(--papier); }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { font-size: 13px; padding: 1px 10px; border: 1px solid var(--filet); border-radius: 999px; color: var(--texte-2); background: var(--papier); }
.vide { padding: 32px 0; color: var(--texte-2); }

/* ---------- formulaire ---------- */
.dossier { max-width: var(--largeur-max); }
.dossier-entete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.etat-enregistrement { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--texte-2); }
.etat-enregistrement[data-etat="ok"] .icone { background: var(--menthe); color: var(--nuit); border-radius: 50%; padding: 2px; width: 1.4em; height: 1.4em; }
.etat-enregistrement[data-etat="erreur"], .etat-enregistrement[data-etat="conflit"] { font-weight: 600; color: var(--texte); }
.champ--titre { max-width: var(--largeur-lecture); margin-bottom: 20px; }
input.titre-dossier { font-size: 20px; font-weight: 600; }

.fil { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 32px; }
.etape {
  position: relative; width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--filet); border-radius: var(--rayon); padding: 10px 12px; min-height: var(--hauteur-champ);
  font-size: 14px; line-height: 1.3; font-weight: 500;
}
.etape:hover { border-color: var(--nuit); }
.etape-numero {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--discret); font-size: 13px; font-weight: 600;
}
.etape--courante { background: var(--nuit); border-color: var(--nuit); color: #FFFFFF; }
.etape--courante .etape-numero { background: var(--menthe); border-color: var(--menthe); color: var(--nuit); }
.etape-compte { margin-left: auto; }

#zone-etape { max-width: var(--largeur-lecture); }
#zone-etape:has(.apercu:not([hidden])) { max-width: none; }
#zone-etape:has(.apercu:not([hidden])) > :not(.apercu):not(.cartes-verification) { max-width: var(--largeur-lecture); }
.groupe { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--filet); }
.groupe > .groupe-titre { margin-bottom: 8px; }
.groupe .intro { margin-bottom: 12px; }

.champ { margin-top: 20px; padding: 0; border: 0; min-width: 0; }
.champ--manquant { box-shadow: -4px 0 0 0 var(--menthe); padding-left: 12px; margin-left: -16px; margin-right: 0; padding-right: 0; }
.champ--cible { background: var(--menthe-pale); outline: 2px solid var(--menthe); outline-offset: 6px; border-radius: var(--rayon); }
.champ-tete { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 6px; padding: 0; }
.champ-libelle { font-weight: 500; }
.champ-aide { color: var(--discret); font-size: 14px; margin-top: 6px; max-width: 70ch; }
.champ-erreur { margin-top: 6px; padding: 6px 10px; background: var(--menthe-pale); border-left: 4px solid var(--nuit); font-weight: 500; font-size: 14px; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], textarea {
  width: 100%; min-height: var(--hauteur-champ); padding: 9px 12px; background: var(--surface);
  border: 1px solid var(--discret); border-radius: var(--rayon); font-size: 16px; line-height: 1.4;
}
textarea { resize: vertical; min-height: 110px; }
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="search"]:focus, textarea:focus { border-color: var(--nuit); }
input[aria-invalid="true"] { border-width: 2px; border-color: var(--nuit); }

.options { display: flex; flex-wrap: wrap; gap: 8px; }
.option { display: inline-flex; align-items: center; gap: 10px; min-height: var(--hauteur-champ); padding: 6px 14px 6px 12px; background: var(--surface); border: 1px solid var(--discret); border-radius: var(--rayon); cursor: pointer; }
.option:hover { background: var(--menthe-tres-pale); }
.option input { width: 18px; height: 18px; margin: 0; accent-color: var(--nuit); flex: none; }
.option:has(input:checked) { border-color: var(--nuit); background: var(--menthe-pale); }
.option:has(input:focus-visible) { outline: 2px solid var(--nuit); outline-offset: 2px; box-shadow: 0 0 0 5px var(--menthe); }
.option input:focus-visible { outline: none; box-shadow: none; }

.liste-objets { display: grid; gap: 12px; }
.ligne-objet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px 12px; align-items: end; padding: 12px; background: var(--surface); border: 1px solid var(--filet); border-radius: var(--rayon); }
.cellule { display: grid; gap: 4px; min-width: 0; }
.cellule-titre { font-size: 13px; color: var(--texte-2); font-weight: 500; }
.bouton--ajout, .liste-objets > .bouton { justify-self: start; }

/* ---------- étape contrats ---------- */
.cartes-contrats { display: grid; gap: 12px; }
.carte-contrat { position: relative; display: flex; gap: 14px; align-items: flex-start; cursor: pointer; border-width: 1px; }
.carte-contrat:hover { border-color: var(--nuit); }
.carte-contrat input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.carte-coche { flex: none; width: 28px; height: 28px; margin-top: 2px; border: 1px solid var(--discret); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); color: transparent; }
.carte-corps { display: grid; gap: 4px; }
.carte--choisie { border-color: var(--nuit); box-shadow: inset 4px 0 0 0 var(--menthe); background: var(--menthe-tres-pale); }
.carte--choisie .carte-coche { background: var(--menthe); border-color: var(--nuit); color: var(--nuit); }
.carte-contrat:has(input:focus-visible) { outline: 2px solid var(--nuit); outline-offset: 2px; box-shadow: 0 0 0 5px var(--menthe); }
.carte--choisie:has(input:focus-visible) { box-shadow: inset 4px 0 0 0 var(--menthe), 0 0 0 5px var(--menthe); }

.avertissement { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin: 0 0 16px; background: var(--menthe-pale); border-left: 4px solid var(--nuit); color: var(--texte); font-weight: 500; }
.avertissement--neutre { background: var(--surface); border: 1px solid var(--filet); border-left: 4px solid var(--nuit); font-weight: 400; }
.avertissement .icone { margin-top: 3px; }
.succes { display: flex; gap: 10px; align-items: center; padding: 12px 14px; margin: 16px 0; background: var(--menthe); color: var(--texte); font-weight: 500; border-radius: var(--rayon); }
.alerte { display: flex; gap: 12px; align-items: flex-start; padding: 16px; margin: 0 0 24px; background: var(--menthe-pale); border: 1px solid var(--menthe); border-left: 4px solid var(--nuit); border-radius: var(--rayon); max-width: var(--largeur-lecture); }
.alerte .icone { margin-top: 4px; }
.alerte-corps { display: grid; gap: 8px; }
.alerte-titre { font-weight: 600; }
.alerte--ok { background: var(--surface); }

/* ---------- vérification, aperçu ---------- */
.cartes-verification { display: grid; gap: 16px; max-width: var(--largeur-lecture); }
.carte-verification { display: grid; gap: 12px; }
.liste { display: grid; gap: 6px; padding-left: 0; }
.liste li { padding-left: 18px; position: relative; }
.liste li::before { content: ""; position: absolute; left: 2px; top: 0.7em; width: 6px; height: 6px; background: var(--nuit); border-radius: 50%; }
.liste .bouton--lien { min-height: 32px; padding: 2px 6px; text-align: left; }
.apercu { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--filet); }
.apercu .carte-ligne { margin-bottom: 12px; }
.apercu-pdf { width: 100%; height: 80vh; min-height: 520px; border: 1px solid var(--filet); border-radius: var(--rayon); background: var(--surface); }

.chargement { display: flex; align-items: center; gap: 12px; padding: 16px 0; color: var(--texte-2); }
.rond { width: 20px; height: 20px; border: 3px solid var(--filet); border-top-color: var(--nuit); border-radius: 50%; animation: tourner 0.9s linear infinite; flex: none; }
@keyframes tourner { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rond { animation-duration: 3s; } }

/* ---------- génération ---------- */
.liste-resultats { display: grid; gap: 12px; margin: 12px 0 16px; }
.resultat { display: grid; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--filet); border-radius: var(--rayon); justify-items: start; }
.resultat .carte-ligne { width: 100%; }
.resultat--echec { border-color: var(--nuit); border-left-width: 4px; }
.resultat-detail { color: var(--texte-2); overflow-wrap: anywhere; }
.bloc-generation { margin-top: 24px; }
.historique { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--filet); }
#zone-resultat { margin-top: 16px; }

.navigation-etapes { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--filet); max-width: var(--largeur-lecture); }
.navigation-etapes #bouton-suivant { margin-left: auto; }

/* ---------- revue des modèles ---------- */
.modifications { display: grid; gap: 16px; margin-top: 12px; }
.modification { display: grid; gap: 14px; }
.modification-id { font-weight: 600; font-size: 14px; letter-spacing: 0.04em; }
.avant-apres { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.texte-avant, .texte-apres { padding: 12px 14px; border: 1px solid var(--filet); border-radius: var(--rayon); background: var(--papier); }
.texte-apres { background: var(--menthe-tres-pale); border-color: var(--menthe); }
.extrait { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.meta { display: grid; gap: 6px; font-size: 14px; }
.meta div { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.meta dt { color: var(--discret); font-weight: 500; }
.meta dd { color: var(--texte-2); }

/* ---------- connexion ---------- */
.entete-compte { display: flex; align-items: center; gap: 8px 12px; min-width: 0; }
.entete-compte-nom { font-weight: 500; color: var(--texte-2); overflow-wrap: anywhere; }
.entete-compte .bouton { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.carte-connexion { max-width: 440px; margin: 24px auto 0; display: grid; gap: 4px; }
.carte-connexion h1.page-titre { margin-bottom: 12px; }
.carte-connexion .intro { margin-bottom: 4px; }
.formulaire-connexion { display: grid; gap: 0; }
.formulaire-actions { margin-top: 20px; }
.formulaire-actions .bouton { flex: 1 1 auto; }
.connexion-oubli { margin-top: 16px; }
/* Code reçu par e-mail : gros chiffres espacés, faciles à relire. */
.champ-code { font-size: 24px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.connexion-etapes .formulaire-connexion > .discret { margin-top: 12px; }
input[readonly] { background: var(--papier); color: var(--texte-2); }
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 52px; }
.champ-mdp-oeil {
  position: absolute; top: 0; right: 0; width: var(--hauteur-champ); height: var(--hauteur-champ);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  background: transparent; border: 0; border-radius: var(--rayon); color: var(--texte-2); cursor: pointer;
}
.champ-mdp-oeil:hover { background: var(--menthe-tres-pale); color: var(--texte); }
.champ-mdp-oeil .icone { width: 22px; height: 22px; }
.criteres { display: grid; gap: 6px; margin-top: 10px; }
.critere { display: flex; align-items: center; gap: 10px; color: var(--texte-2); font-size: 14px; }
.critere-coche { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--discret); display: inline-flex; align-items: center; justify-content: center; color: transparent; }
.critere-coche .icone { width: 14px; height: 14px; }
.critere--ok { color: var(--texte); }
.critere--ok .critere-coche { background: var(--menthe); border-color: var(--menthe); color: var(--nuit); }

/* ---------- dialogue ---------- */
dialog { border: 1px solid var(--nuit); border-radius: var(--rayon); padding: 0; max-width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--texte); }
dialog::backdrop { background: color-mix(in srgb, var(--nuit) 55%, transparent); }
.dialogue-corps { display: grid; gap: 14px; padding: 24px; }
.dialogue-titre { font-size: 20px; font-weight: 600; }

/* ---------- petits écrans ---------- */
@media (max-width: 720px) {
  main { padding-top: 20px; }
  .entete-nav { order: 2; }
  .entete-compte { order: 3; flex: 1 0 100%; justify-content: space-between; }
  .carte-connexion { margin-top: 8px; padding: 16px; }
  h1.page-titre { font-size: 26px; }
  h2.etape-h { font-size: 22px; }
  .fil { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ligne-objet { grid-template-columns: 1fr; }
  .ligne-objet .bouton--lien { justify-self: start; }
  .avant-apres { grid-template-columns: 1fr; }
  .meta div { grid-template-columns: 1fr; gap: 0; }
  .navigation-etapes .bouton, .actions > .bouton { flex: 1 1 auto; }
  .champ--manquant { margin-left: 0; padding-left: 10px; }
  .apercu-pdf { height: 70vh; min-height: 420px; }
}
.ligne-objet:not(:first-of-type) .cellule-titre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 720px) {
  .ligne-objet:not(:first-of-type) .cellule-titre { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
}
