/* Page d'envoi groupé — feuille unique.
   Aucune police distante : la pile système suffit et ne fuite vers personne.
   Couleurs neutres : la seule couleur est celle du bouton Envoyer (--action), pour qu'on ne
   puisse pas se tromper de geste ; elle se remplace par celle de l'association.
   La politique de sécurité interdit les style= dans les vues : tout passe par des classes. */

:root {
  --fond:          #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #eef0f3;
  --texte:         #1f2328;
  --texte-doux:    #59636e;
  --bordure:       #e1e4e8;
  --bordure-nette: #8c959f;
  --fort:          #1f2328;
  --sur-fort:      #ffffff;
  --action:        #1f5fae;
  --sur-action:    #ffffff;
  --danger:        #b42318;
  --succes:        #176b31;
  --ombre:         0 1px 2px rgb(31 35 40 / 6%), 0 4px 12px rgb(31 35 40 / 4%);
  --rayon:         10px;
  --touche:        44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond:          #111315;
    --surface:       #181b1f;
    --surface-2:     #22262b;
    --texte:         #e6e8eb;
    --texte-doux:    #9aa4af;
    --bordure:       #2b3036;
    --bordure-nette: #6e7781;
    --fort:          #e6e8eb;
    --sur-fort:      #111315;
    --action:        #7fb0f0;
    --sur-action:    #0b1a2c;
    --danger:        #ff8f80;
    --succes:        #7ee2a0;
    --ombre:         0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 24%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

/* Un `display` posé en CSS écrase le `display:none` de l'attribut `hidden` :
   sans cette ligne, un élément caché mais typé en CSS resterait visible. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 48px;
}

a { color: var(--texte); text-underline-offset: 2px; }
.icone { flex: none; display: inline-block; vertical-align: -0.2em; }

/* ------------------------------------------------------------------ ossature */

.enveloppe { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.barre-haute {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
  padding-top: env(safe-area-inset-top);
}
.barre-haute .dedans {
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 56px;
}
.titre-page {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 640;
  margin: 0;
  /* Base « auto » : avec flex: 1 (base nulle), le titre et les onglets tiennent « en théorie » sur une
     ligne quand le bouton de déconnexion est absent (démo ouverte), et le titre s'écrit sur les onglets. */
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
}
.titre-page .icone { color: var(--texte-doux); }

.navigation { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.navigation::-webkit-scrollbar { display: none; }
.onglet {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 560;
  color: var(--texte-doux);
  border-bottom: 2px solid transparent;
  padding: 10px 10px 8px;
  white-space: nowrap;
  text-decoration: none;
  min-height: var(--touche);
}
.onglet:hover { color: var(--texte); }
.onglet[aria-current="page"] { color: var(--texte); border-bottom-color: var(--texte); }

@media (max-width: 560px) {
  .navigation { order: 3; flex-basis: 100%; margin: 0 -10px; }
}
/* Sous 360 px (petits téléphones), les trois onglets ne tiennent qu'ainsi : sinon « Réglages » est coupé
   au bord, et personne ne pense à faire défiler la barre. */
@media (max-width: 360px) {
  .onglet { font-size: 14px; padding: 10px 6px 8px; }
}
/* ------------------------------------------------- bande de présentation (démo) */

/* Elle coiffe la page d'envoi : autre forme (deux boutons accolés) et autre fond que les onglets
   soulignés du produit, pour qu'on ne prenne pas « Devis » pour une fonction de la page. */
.presentation { background: var(--fort); color: var(--sur-fort); } /* couleurs d'AMK PRO : charte-amkpro.css */
.presentation-dedans {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.presentation-marque { font-weight: 650; font-size: 15px; letter-spacing: .02em; }
.segments {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sur-fort) 16%, transparent);
}
.segment {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 560;
  color: var(--sur-fort);
  text-decoration: none;
}
.segment:hover { background: color-mix(in srgb, var(--sur-fort) 12%, transparent); }
.segment[aria-current="page"] { background: var(--sur-fort); color: var(--fort); }
.segment:focus-visible { outline-color: var(--sur-fort); }

/* -------------------------------------------------------------------- boutons */

.bouton, .bouton-plat, .bouton-icone {
  font: inherit;
  font-weight: 560;
  border-radius: var(--rayon);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  min-height: var(--touche);
  padding: 0 16px;
  transition: background-color .12s ease, border-color .12s ease;
}
.bouton { background: var(--fort); color: var(--sur-fort); }
.bouton:hover { background: color-mix(in srgb, var(--fort) 86%, var(--fond)); }
.bouton.bouton-envoi { background: var(--action); color: var(--sur-action); }
.bouton.bouton-envoi:hover { background: color-mix(in srgb, var(--action) 88%, black); }
.bouton-petit { min-height: 38px; padding: 0 12px; font-size: 15px; }
.bouton-plat { background: var(--surface); color: var(--texte); border-color: var(--bordure-nette); }
.bouton-plat:hover { background: var(--surface-2); }
.bouton-icone { background: transparent; color: var(--texte); min-width: var(--touche); padding: 0 10px; }
.bouton-icone:hover { background: var(--surface-2); }
.bouton[disabled], .bouton-plat[disabled], .bouton-icone[disabled] { opacity: .5; cursor: default; }

:where(button, a, input, select, textarea, summary, label):focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 2px;
}

/* ----------------------------------------------------------------- champs */

.champ {
  font: inherit;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure-nette);
  border-radius: var(--rayon);
  padding: 10px 13px;
  width: 100%;
  min-height: var(--touche);
}
select.champ { padding-right: 32px; }
.champ:focus { outline: 2px solid var(--action); outline-offset: -1px; border-color: transparent; }
.champ:disabled { color: var(--texte-doux); background: var(--surface-2); }
.champ[aria-invalid="true"] { border-color: var(--danger); }

.etiquette {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--texte-doux);
  margin-bottom: 6px;
}

.rangee { display: flex; gap: 8px; flex-wrap: wrap; }
.rangee .champ { flex: 1 1 220px; width: auto; }

/* Masqué à l'œil mais présent pour le clavier et les lecteurs d'écran : un champ de
   fichier en display:none ne s'ouvre plus par son étiquette sur certains Safari. */
.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.visuellement-cache:focus-visible + label { outline: 2px solid var(--action); outline-offset: 2px; }

/* ------------------------------------------------------------- pièces jointes */



.liste { list-style: none; margin: 0; padding: 0; }
.liste-pieces:not(:empty) { margin-bottom: 12px; }
.piece {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bordure);
}
.piece:last-child { border-bottom: 0; }
.piece .icone { color: var(--texte-doux); }
.piece-texte { flex: 1; min-width: 0; }
.piece-nom { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece-detail { display: block; font-size: 13px; color: var(--texte-doux); }
.piece-erreur .piece-detail { color: var(--danger); }
.piece progress { margin-top: 4px; }

/* ------------------------------------------------------------------- cartes */

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  margin: 16px 0;
  box-shadow: var(--ombre);
}
.carte h2 { font-size: 17px; margin: 0 0 12px; }
.pile { display: flex; flex-direction: column; gap: 16px; }
.entre { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.separateur { border: 0; height: 1px; background: var(--bordure); margin: 4px 0; width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .bouton, .actions .bouton-plat { flex: 1 1 auto; }

.pastille {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--texte-doux);
}
.pastille-termine { color: var(--succes); }
.pastille-bloque, .pastille-a_verifier { color: var(--danger); }

/* Pas de display:flex sur summary : il effacerait le triangle qui signale que ça se déplie. */
details summary { cursor: pointer; font-weight: 560; padding: 10px 0; }

/* ----------------------------------------------------------------- messages */

.message {
  border: 1px solid var(--bordure-nette);
  background: var(--surface);
  border-radius: var(--rayon);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 15px;
  margin: 14px 0;
}
.message .icone { margin-top: 2px; }
.message-erreur { color: var(--danger); border-color: currentColor; }
.message-succes .icone { color: var(--succes); }
.annonce:empty { display: none; }

/* -------------------------------------------------------------- progression */

progress.progression {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 10px;
  border: 0;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--texte);
}
progress.progression::-webkit-progress-bar { background: var(--surface-2); border-radius: 4px; }
progress.progression::-webkit-progress-value { background: var(--texte); border-radius: 4px; }
progress.progression::-moz-progress-bar { background: var(--texte); border-radius: 4px; }
.piece progress.progression { height: 4px; }

/* ---------------------------------------------------------------- dialogue */

dialog {
  border: 1px solid var(--bordure);
  border-radius: 14px;
  background: var(--surface);
  color: var(--texte);
  padding: 0;
  box-shadow: 0 12px 40px rgb(0 0 0 / 22%);
  width: min(540px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(17 19 21 / 45%); }
.dialogue-corps { padding: 18px; }
.dialogue-titre { font-size: 18px; font-weight: 640; margin: 0 0 12px; }
.dialogue-pied { display: flex; gap: 8px; margin-top: 18px; }
.dialogue-pied .bouton-plat { flex: 1; }
.dialogue-pied .bouton { flex: 2; }

.recap { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.recap dt { color: var(--texte-doux); }
.recap dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Sur téléphone le dialogue monte du bas ; sur grand écran il reste une petite boîte centrée. */
@media (max-width: 560px) {
  dialog.feuille {
    width: 100vw;
    max-width: none;
    margin: 0;
    position: fixed;
    bottom: 0;
    top: auto;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ------------------------------------------------------- connexion, public */

.centre { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.boite-connexion { width: min(400px, 100%); }
.marque { display: flex; align-items: center; gap: 10px; font-weight: 640; font-size: 19px; margin: 0 0 20px; }
.marque .icone { color: var(--texte-doux); }
.titre-public { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 0 0 12px; }
.titre-public .icone { color: var(--succes); }

.vide { text-align: center; padding: 56px 24px; color: var(--texte-doux); }
.vide .icone { display: block; margin: 0 auto 14px; color: var(--bordure-nette); }
.vide h2 { color: var(--texte); font-size: 18px; margin: 0 0 6px; }
.vide p { margin: 0 auto; max-width: 36ch; }

/* ------------------------------------------------------------ écran courriel */

.titre-ecran { font-size: 22px; font-weight: 650; margin: 20px 0 0; }
.tete-ecran {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.tete-ecran .titre-ecran { margin: 0; }

/* Toute la carte reçoit les fichiers qu'on y fait glisser, comme une fenêtre de courriel. */
.courriel { padding: 0; overflow: hidden; }
.courriel.survol { outline: 2px dashed var(--bordure-nette); outline-offset: -6px; background: var(--surface-2); }

.courriel-ligne {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--bordure);
  padding: 0 16px;
}
.courriel-ligne label { color: var(--texte-doux); font-size: 15px; }
.courriel-ligne:focus-within { box-shadow: inset 0 -2px 0 var(--action); }
.champ-nu { border: 0; border-radius: 0; background: transparent; padding-left: 0; min-height: 52px; }
.champ-nu:focus { outline: none; }

.barre-texte { display: flex; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--bordure); }
.bouton-outil {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touche);
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--texte-doux);
  cursor: pointer;
}
.bouton-outil:hover { background: var(--surface-2); color: var(--texte); }
.bouton-outil.ql-active { background: var(--surface-2); color: var(--texte); box-shadow: inset 0 0 0 1px var(--bordure-nette); }
.bouton-outil:disabled { opacity: .4; cursor: default; }

/* Quill (quill-2.0.3.core.css) fixe 13 px et une police Helvetica : on reprend celles de la page. */
.editeur.ql-container {
  font-family: inherit;
  font-size: 16px; /* sous 16 px, Safari iOS agrandit la page à chaque saisie */
  height: auto;
}
.editeur .ql-editor { min-height: 240px; padding: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.editeur .ql-editor.ql-blank::before { color: var(--texte-doux); font-style: normal; left: 16px; right: 16px; }
.editeur .ql-editor li { margin: 2px 0; }

.signature-apercu { padding: 0 16px 16px; }
.signature-texte { margin: 0 0 6px; color: var(--texte-doux); font-size: 15px; }

.courriel-pieces { border-top: 1px solid var(--bordure); padding: 12px 16px; }
.rangee-pieces { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }

.courriel-pied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--bordure);
  padding: 12px 16px;
}
.courriel-pied-outils { display: flex; gap: 8px; flex-wrap: wrap; }
.courriel-pied .bouton-envoi { min-width: 160px; }

.champ-texte { min-height: 112px; resize: vertical; line-height: 1.5; }
.lien-action { font-weight: 560; }

@media (max-width: 560px) {
  .courriel-ligne { grid-template-columns: 56px 1fr; padding: 0 12px; }
  /* Aperçu et essai d'abord, Envoyer en dernier : l'ordre dans lequel on doit s'en servir. */
  .courriel-pied { flex-direction: column; align-items: stretch; }
  .courriel-pied-outils > * { flex: 1 1 0; }
  .courriel-pied .bouton-envoi { width: 100%; }
}

/* ------------------------------------------------------------------- aperçu */

dialog.fenetre-apercu { width: min(760px, calc(100vw - 32px)); max-height: calc(100svh - 32px); }
.fenetre-apercu[open] { display: flex; flex-direction: column; }
.apercu-tete { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 2px 18px; }
.apercu-entete { padding: 8px 18px 14px; border-bottom: 1px solid var(--bordure); }
/* Fond blanc même en mode sombre : c'est ainsi que la plupart des messageries afficheront le courriel. */
.apercu-cadre { display: block; width: 100%; flex: 1; min-height: 52svh; border: 0; background: #ffffff; }
@media (max-width: 560px) {
  /* La largeur de grand écran (plus haut) l'emporterait sinon : la feuille doit couvrir tout le téléphone. */
  dialog.fenetre-apercu.feuille { width: 100vw; height: 94svh; max-height: none; }
}

/* --------------------------------------------------------------- historique */

/* Une ligne par envoi, comme le dossier « Envoyés » d'une messagerie : toute la ligne s'ouvre. */
.boite-envois { padding: 0; overflow: hidden; }
.boite-envois li + li { border-top: 1px solid var(--bordure); }
.envoi-ligne {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 12px 12px 16px;
  color: var(--texte);
  text-decoration: none;
}
.envoi-ligne:hover { background: var(--surface-2); }
.envoi-ligne:focus-visible { outline-offset: -2px; }
.envoi-ligne > .icone { color: var(--bordure-nette); }
.envoi-ligne-texte { flex: 1; min-width: 0; }
.envoi-ligne-haut, .envoi-ligne-bas { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.envoi-ligne-bas { margin-top: 2px; font-size: 15px; color: var(--texte-doux); }
/* L'objet passe à la ligne plutôt que d'être coupé : sur téléphone, « Les documents de la sem… »
   ne se distinguerait plus des autres envois. */
.envoi-objet, .envoi-a { min-width: 0; overflow-wrap: anywhere; }
.envoi-objet { font-weight: 600; }
.envoi-date { flex: none; font-size: 14px; color: var(--texte-doux); }
.envoi-pj { flex: none; display: inline-flex; align-items: center; gap: 2px; }
.envoi-ligne .pastille { display: inline-block; margin-top: 6px; }

.retour { margin: 12px 0 0; }
.retour a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--touche);
  margin-left: -6px;
  padding-right: 8px;
  color: var(--texte-doux);
  font-weight: 560;
  text-decoration: none;
}
.retour a:hover { color: var(--texte); }
.titre-ecran.titre-envoi { margin-top: 0; overflow-wrap: anywhere; }

.fiche-envoi { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 0; font-size: 15px; }
.fiche-envoi > div { display: contents; }
.fiche-envoi dt { color: var(--texte-doux); }
.fiche-envoi dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.fiche-envoi li + li { margin-top: 2px; }

.actions-envoi { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 0; }
/* Fond blanc même en mode sombre, comme l'aperçu. La hauteur suit le courriel (app.js) ; sans script, on défile dedans. */
.cadre-courriel {
  display: block;
  width: 100%;
  height: 60svh;
  margin: 18px 0 0;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: #ffffff;
}

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

.document { padding: 24px; }
.document h3 { font-size: 17px; margin: 26px 0 8px; }
.devis-entete { display: flex; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; font-size: 15px; }
.devis-destinataire { text-align: right; }
.document .devis-titre { font-size: 20px; margin: 28px 0 4px; } /* .carte h2 l'emporterait sinon */
.devis-liste { margin: 0; padding-left: 20px; }
.devis-liste li { margin: 0 0 6px; }
.devis-total { font-size: 18px; font-weight: 650; background: var(--surface-2); border-radius: var(--rayon); padding: 12px 14px; margin: 22px 0 8px; }

.tableau { width: 100%; border-collapse: collapse; font-size: 15px; margin: 4px 0 10px; }
.tableau th, .tableau td { text-align: left; vertical-align: top; padding: 9px 10px 9px 0; border-bottom: 1px solid var(--bordure); }
.tableau thead th { font-size: 14px; color: var(--texte-doux); font-weight: 600; }
.tableau tfoot td { border-bottom: 0; text-align: right; padding-right: 0; }
.tableau .nombre { text-align: right; white-space: nowrap; padding-right: 0; padding-left: 12px; }

@media (max-width: 560px) {
  .document { padding: 16px; }
  .devis-destinataire { text-align: left; }
}

/* À l'impression, le devis seul : ni barre ni bouton. */
@media print {
  .presentation, .barre-haute, [data-imprimer] { display: none !important; }
  body { background: #ffffff; color: #000000; padding: 0; }
  .enveloppe { max-width: none; padding: 0; }
  .carte { border: 0; box-shadow: none; margin: 0; }
  .devis-total { background: none; border: 1px solid #999999; }
  a { color: inherit; text-decoration: none; }
  .tableau tr, .devis-total { break-inside: avoid; }
  .document h3 { break-after: avoid; }
}

/* --------------------------------------------------------- classes d'appoint */

.discret      { font-size: 14px; color: var(--texte-doux); }
.petit-texte  { font-size: 14px; }
.rupture-mots { overflow-wrap: anywhere; }
.sans-marge   { margin: 0; }
.forme-enligne{ display: contents; }
.mt-serre     { margin: 6px 0 0; }
.mt-petit     { margin-top: 10px; }
.mt-moyen     { margin-top: 16px; }
.mb-moyen     { margin-bottom: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
