/* =====================================================================
   iris — feuille de style (vanilla CSS, pas de framework)
   Thème « maquette v2 » validé : sans-serif système, cartes arrondies
   (14 px) à ombres douces, fond gris clair, accent unique vert profond,
   chiffres tabulaires. Une page par parcours, pas d'onglets.
   ===================================================================== */

:root {
  --fond:       #f4f6f8;
  --carte:      #ffffff;
  --encre:      #16211c;
  --gris:       #67736d;
  --vert:       #0e6b4f;
  --vert-fonce: #0a523d;
  --vert-pale:  #e7f2ee;
  --filet:      #e3e8e6;
  --ambre:      #b07811;
  --ambre-pale: #faf3e3;
  --rouge:      #b4432f;
  --rouge-pale: #fbeae6;
  --ombre: 0 1px 3px rgba(22, 33, 28, .07), 0 6px 20px rgba(22, 33, 28, .05);
  --rayon: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--vert); outline-offset: 2px; }

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

h1 { font-size: 20px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 14px; }
h2 { font-size: 16px; font-weight: 800; margin: 18px 0 8px; }

/* --------------------------------------------------------------------
   Barre appli
   -------------------------------------------------------------------- */
.appbar {
  background: var(--carte);
  border-bottom: 1px solid var(--filet);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.02em;
  color: var(--vert);
  text-decoration: none;
}
.logo span { color: var(--encre); }

.form-dossier { display: flex; gap: 8px; flex: 1; min-width: 200px; }

select.dossier {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--carte);
  max-width: 100%;
  flex: 1;
  min-width: 180px;
  font-weight: 600;
}

.appbar-droite {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  color: var(--gris);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}
.nav-link:hover { background: var(--vert-pale); color: var(--vert); }
.nav-link.actif { background: var(--vert-pale); color: var(--vert); }
.nav-link.deconnexion { color: var(--rouge); }
.nav-link.deconnexion:hover { background: var(--rouge-pale); color: var(--rouge); }

/* Bouton neutre habillé en lien (ex. Déconnexion : formulaire POST + CSRF). */
button.btn-lien {
  background: none;
  border: none;
  margin: 0;
  cursor: pointer;
  line-height: inherit;
}

/* --------------------------------------------------------------------
   Contenu
   -------------------------------------------------------------------- */
.contenu {
  max-width: 820px;
  margin: 0 auto;
  padding: 18px 14px 48px;
}
/* Page principale : la barre « Facturer » fixe réserve sa place en bas. */
body.page-tableau .contenu { padding-bottom: 140px; }

.entete-page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.entete-page h1 { margin: 0; }

.carte {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.carte-etroite { max-width: 30rem; }

.aide { color: var(--gris); font-size: 12.5px; margin: .4rem 0 .9rem; }

code.mdp-temporaire {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 1.05rem;
  background: #fff;
  border: 1px solid var(--filet);
  border-radius: 8px;
  padding: .15rem .45rem;
  user-select: all;
}

/* --------------------------------------------------------------------
   Messages
   -------------------------------------------------------------------- */
.msg {
  border-radius: 10px;
  padding: .7rem .95rem;
  margin-bottom: 14px;
  font-size: 14px;
}
.msg ul { margin: 0; padding-left: 1.2rem; }
.msg.ok            { background: var(--vert-pale);  color: var(--vert-fonce); }
.msg.erreur        { background: var(--rouge-pale); color: var(--rouge); }
.msg.avertissement { background: var(--ambre-pale); color: var(--ambre); }

/* --------------------------------------------------------------------
   Formulaires
   -------------------------------------------------------------------- */
.champ { margin-bottom: .9rem; }

.champ label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gris);
  margin-bottom: .25rem;
}

.champ input,
.champ select,
.champ textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--encre);
  background: #fff;
  border: 1px solid var(--filet);
  border-radius: 10px;
}
.champ textarea { min-height: 5.5em; resize: vertical; }
.champ select:disabled { background: var(--fond); color: var(--gris); }

.champ label.case {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--encre);
  cursor: pointer;
}
.champ label.case input { width: 17px; height: 17px; accent-color: var(--vert); }

.grille-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

/* --------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------- */
.btn {
  display: inline-block;
  border: 0;
  background: var(--vert-pale);
  color: var(--vert);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #d9eae3; }

.btn-principal { background: var(--vert); color: #fff; font-weight: 700; padding: 10px 18px; }
.btn-principal:hover { background: var(--vert-fonce); }

.btn-danger { background: var(--rouge-pale); color: var(--rouge); }
.btn-danger:hover { background: #f6dcd6; }

.btn-petit { padding: 5px 10px; font-size: 13px; }

.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:disabled:hover { background: var(--vert-pale); }
.btn-principal:disabled:hover { background: var(--vert); }

/* Actions par ligne de tableau (✎ / 🗑) : boutons discrets. */
.btn-icone {
  display: inline-block;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 5px 6px;
  border-radius: 8px;
  color: var(--gris);
  text-decoration: none;
}
.btn-icone:hover { background: var(--vert-pale); color: var(--vert); }
.btn-icone.danger:hover { background: var(--rouge-pale); color: var(--rouge); }

.form-en-ligne { display: inline-block; margin: 0; }

/* --------------------------------------------------------------------
   Tableaux (admin + blocs de la page principale)
   -------------------------------------------------------------------- */
.defile { overflow-x: auto; }

table.tableau,
.bloc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.bloc table { min-width: 560px; }

table.tableau th,
.bloc th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gris);
  text-align: left;
  padding: 8px 14px;
  border-bottom: 1px solid var(--filet);
  white-space: nowrap;
}
table.tableau td,
.bloc td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--filet);
  vertical-align: middle;
}
table.tableau tbody tr:last-child td,
.bloc tbody tr:last-child td { border-bottom: 0; }

td.d, th.d { text-align: right; }

.ligne-inactive td { color: var(--gris); }
.col-actions { white-space: nowrap; }
.col-actions .btn { margin: .1rem .15rem .1rem 0; }
.actions-ligne { white-space: nowrap; }

/* --------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 9px;
  border-radius: 999px;
  vertical-align: middle;
}
.badge-admin   { background: var(--vert-pale);  color: var(--vert); }
.badge-inactif { background: var(--rouge-pale); color: var(--rouge); }
.badge-attente { background: var(--ambre-pale); color: var(--ambre); }

/* --------------------------------------------------------------------
   Page principale — résumé (KPI)
   -------------------------------------------------------------------- */
.resume { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

.kpi {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 14px 18px;
  flex: 1;
  min-width: 140px;
}
.kpi .l { font-size: 12px; color: var(--gris); }
.kpi .v { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi.principal { background: var(--vert); color: #fff; }
.kpi.principal .l { color: #cde6dd; }

.meta-dossier {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--gris);
  margin: -4px 2px 14px;
}
.meta-dossier a { font-weight: 600; }

/* --------------------------------------------------------------------
   Page principale — saisie rapide d'une diligence
   -------------------------------------------------------------------- */
.ajout {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.ajout .titre { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.ajout form { display: flex; gap: 8px; flex-wrap: wrap; }
.ajout input {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.ajout .date { width: 135px; }
.ajout .lib  { flex: 1; min-width: 170px; }
.ajout .min  { width: 88px; }
.ajout .taux { width: 110px; }

.astuce { flex-basis: 100%; font-size: 12px; color: var(--gris); margin-top: 4px; }
.astuce b { color: var(--encre); }

/* « utiliser un autre taux » : bouton habillé en lien, révélé par app.js. */
button.lien-taux {
  background: none;
  border: 0;
  padding: 0;
  color: var(--vert);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

/* --------------------------------------------------------------------
   Page principale — bloc « À facturer » + historique replié
   -------------------------------------------------------------------- */
.bloc {
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 6px 0 0;
  margin-bottom: 14px;
  overflow: hidden;
}
.bloc .entete {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px 6px;
  flex-wrap: wrap;
}
.bloc .entete h2 { margin: 0; font-size: 15px; font-weight: 800; }
.bloc .entete .sous { font-size: 12px; color: var(--gris); }
.bloc .vide { padding: 4px 16px 16px; color: var(--gris); font-size: 14px; }

/* Lien de téléchargement — placeholder désactivé jusqu'au module 5. */
.telecharger {
  margin-left: auto;
  font-size: 13px;
  color: var(--vert);
  text-decoration: none;
  font-weight: 600;
}
.telecharger.desactive { color: var(--gris); opacity: .6; cursor: not-allowed; }

.taux-diff {
  display: inline-block;
  font-size: 11px;
  background: var(--rouge-pale);
  color: var(--rouge);
  border-radius: 99px;
  padding: 1px 8px;
  margin-left: 6px;
  white-space: nowrap;
}

tr.total td {
  font-weight: 800;
  background: var(--vert-pale);
  border-top: 2px solid var(--vert);
}

input.coche { width: 17px; height: 17px; accent-color: var(--vert); }

.historique { padding: 0 16px 14px; }
.historique summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--gris);
  padding: 10px 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.historique summary::-webkit-details-marker { display: none; }
.historique summary::before { content: "▸"; transition: transform .15s; }
.historique[open] summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) {
  .historique summary::before { transition: none; }
}
.historique table { opacity: .65; min-width: 520px; }

.chip-fact {
  font-size: 11px;
  background: var(--vert-pale);
  color: var(--vert);
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* --------------------------------------------------------------------
   Page principale — barre « Facturer » fixe
   -------------------------------------------------------------------- */
.barre {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--encre);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.barre .info { font-size: 14px; }
.barre .info b { font-size: 16px; }
.barre .btn { background: #fff; color: var(--encre); margin-left: auto; font-weight: 700; }
.barre .btn:disabled { opacity: .55; }
.barre .btn:disabled:hover { background: #fff; }

/* --------------------------------------------------------------------
   Module 4 — panneau d'émission (bottom-sheet par-dessus la page unique)
   Invisible sans JS : le repli est la page /factures/preparer.
   -------------------------------------------------------------------- */
.voile {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 28, .45);
  z-index: 29;
  display: none;
}
.panneau {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: none;
  background: var(--carte);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
  padding: 18px 18px 22px;
  max-width: 560px;
  margin: 0 auto;
  max-height: 86vh;
  overflow-y: auto;
}
body.ouvert .voile,
body.ouvert .panneau { display: block; }
body.ouvert { overflow: hidden; }

.panneau h3 { margin: 0 0 4px; font-size: 17px; }
.panneau .sous { font-size: 12.5px; color: var(--gris); margin-bottom: 12px; }
.panneau .champ textarea { min-height: 4em; }

.fermer {
  position: absolute;
  right: 14px;
  top: 12px;
  border: 0;
  background: none;
  font-size: 20px;
  color: var(--gris);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.fermer:hover { background: var(--rouge-pale); color: var(--rouge); }

/* Lignes de montants (partagées panneau / page de repli) */
.ligne {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
}
.ligne input {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 8px 10px;
  width: 130px;
  text-align: right;
  background: #fff;
}
.ligne.remise { color: var(--rouge); }
.ligne.total {
  font-weight: 800;
  font-size: 17px;
  border-top: 2px solid var(--vert);
  margin-top: 6px;
  padding-top: 12px;
}
.ligne .aide { display: block; font-size: 11.5px; color: var(--gris); font-weight: 400; margin: 0; }

.lettres {
  font-size: 13px;
  font-style: italic;
  color: var(--gris);
  background: var(--vert-pale);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0 14px;
}

/* Débours : lignes ajoutables/supprimables (boutons ✕ créés par app.js) */
.deb-ligne { display: flex; gap: 8px; margin: 6px 0; align-items: center; }
.deb-ligne input {
  border: 1px solid var(--filet);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
.deb-ligne .l { flex: 1; min-width: 100px; text-align: left; }
.deb-ligne .mnt { width: 130px; text-align: right; }
.deb-suppr {
  border: 0;
  background: none;
  color: var(--gris);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 6px 7px;
  border-radius: 8px;
}
.deb-suppr:hover { background: var(--rouge-pale); color: var(--rouge); }
.ajout-deb {
  border: 0;
  background: none;
  color: var(--vert);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.actions .btn { flex: 1; text-align: center; min-width: 130px; }

.note-num { font-size: 11.5px; color: var(--gris); margin-top: 10px; }

/* Le bouton de la barre redevient un vrai submit (formulaire sélection) */
.barre form { margin-left: auto; }
.barre form .btn { margin-left: 0; }

/* --------------------------------------------------------------------
   Module 4 — liste des factures du dossier (statuts, paiement)
   -------------------------------------------------------------------- */
.chip-statut {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
}
.st-emise   { background: var(--ambre-pale); color: var(--ambre); }
.st-payee   { background: var(--vert-pale);  color: var(--vert); }
.st-annulee { background: var(--rouge-pale); color: var(--rouge); }
.sous-statut { display: block; font-size: 11.5px; color: var(--gris); margin-top: 2px; }

.form-payer { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.form-payer input[type="date"],
.form-payer select {
  border: 1px solid var(--filet);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 13px;
  background: #fff;
}

/* Page de repli /factures/preparer : mêmes champs, pleine page */
.carte-facture { max-width: 560px; }
.carte-facture .defile { margin-bottom: 12px; }

/* --------------------------------------------------------------------
   Page de connexion
   -------------------------------------------------------------------- */
.page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-carte {
  width: 100%;
  max-width: 24rem;
  background: var(--carte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1.75rem 1.75rem 1.5rem;
}

.auth-titre {
  margin: 0;
  text-align: center;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--vert);
}

.auth-sous-titre {
  margin: .2rem 0 1.4rem;
  text-align: center;
  color: var(--gris);
  font-size: .92rem;
}

.auth-carte .btn { width: 100%; margin-top: .4rem; }

/* --------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------- */
@media (max-width: 640px) {
  .contenu { padding: 14px 10px 40px; }
  body.page-tableau .contenu { padding-bottom: 150px; }
  .carte { padding: 14px 12px; }
  table.tableau { display: block; overflow-x: auto; }
  .appbar { padding: 10px 12px; }
  .grille-2 { grid-template-columns: 1fr; }
}
