/* ==========================================================================
   ACSIST — Feuille de style principale
   Charte extraite de https://acsist.fr/ (Avenir / #2E3244 / #7E14FF)

   IMPORTANT (logique commerciale) :
   Aucune couleur ni aucun nom d'entreprise n'est codé en dur dans les
   composants. Tout passe par les variables CSS ci-dessous, qui sont
   surchargées au runtime par js/branding.js depuis la table `parametres`.
   Pour un nouveau client : changer les valeurs en base, pas le CSS.
   ========================================================================== */

:root {
  /* --- Identité (surchargée par la table `parametres`) --- */
  --marque-primaire:      #2E3244;   /* bleu nuit ACSIST */
  --marque-primaire-clair:#3A3F55;
  --marque-primaire-fonce:#232635;
  --marque-accent:        #7E14FF;   /* violet ACSIST */
  --marque-accent-clair:  #CBA0FF;
  --marque-accent-sombre: #6510CC;

  /* Voiles dérivés de l'accent (recalculés par js/branding.js) */
  --halo-focus:     rgba(126, 20, 255, .18);
  --accent-voile:   rgba(126, 20, 255, .12);
  --accent-voile-l: rgba(126, 20, 255, .16);
  --accent-lueur-1: rgba(126, 20, 255, .20);
  --accent-lueur-2: rgba(126, 20, 255, .10);

  /* --- Surfaces (thème sombre) --- */
  --fond:            #1B1E29;
  --surface:         #232735;
  --surface-2:       #2E3244;
  --surface-3:       #383D52;
  --surface-survol:  #3E4460;

  /* --- Texte --- */
  --texte:           #F2F3F7;
  --texte-doux:      #A8AEC2;
  --texte-faible:    #6F758C;

  /* --- Bordures --- */
  --bordure:         #363B4F;
  --bordure-forte:   #474D66;

  /* --- Sémantique --- */
  --succes:          #2ECC8F;
  --succes-fond:     rgba(46, 204, 143, .12);
  --alerte:          #F5A623;
  --alerte-fond:     rgba(245, 166, 35, .12);
  --erreur:          #FF5C6C;
  --erreur-fond:     rgba(255, 92, 108, .12);
  --info:            #4FA8FF;

  /* --- Palette graphiques (dérivée de l'accent, lisible sur fond sombre) --- */
  --graph-1: #7E14FF;
  --graph-2: #4FA8FF;
  --graph-3: #2ECC8F;
  --graph-4: #F5A623;
  --graph-5: #FF5C6C;
  --graph-6: #CBA0FF;

  /* --- Typographie --- */
  --police: 'Avenir Next', 'Avenir', 'Nunito Sans', 'Segoe UI', -apple-system,
            BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;

  /* --- Géométrie --- */
  --rayon-s:  6px;
  --rayon:    10px;
  --rayon-l:  16px;
  --ombre:    0 4px 16px rgba(0, 0, 0, .28);
  --ombre-l:  0 12px 40px rgba(0, 0, 0, .45);

  /* Hauteur de la barre de navigation, y compris la zone sûre iPhone */
  --h-nav: calc(62px + env(safe-area-inset-bottom, 0px));
  --h-topbar: 58px;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--police);
  background: var(--fond);
  color: var(--texte);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 .6em; }

a { color: var(--marque-accent-clair); text-decoration: none; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bordure-forte); border-radius: 4px; }

/* Utilitaires */
.cache { display: none !important; }
.muet { color: var(--texte-doux); }
.faible { color: var(--texte-faible); }
.petit { font-size: .82rem; }
.centre { text-align: center; }
.gras { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Écran de connexion
   ========================================================================== */

#ecran-login {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 620px at 50% -10%, var(--accent-lueur-1), transparent 62%),
    radial-gradient(760px 520px at 90% 110%, var(--accent-lueur-2), transparent 60%),
    var(--fond);
}

.carte-login {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-l);
  box-shadow: var(--ombre-l);
  padding: 38px 30px 30px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
  color: var(--texte);
}

.login-logo svg,
.login-logo img { width: 96px; height: auto; display: block; }

.login-nom-entreprise {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: .16em;
  margin: 10px 0 2px;
}

.login-baseline {
  text-align: center;
  color: var(--texte-doux);
  font-size: .82rem;
  margin-bottom: 26px;
}

.champ { margin-bottom: 15px; }

.champ label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--texte-doux);
  margin-bottom: 6px;
}

.champ input,
.champ select,
.champ textarea {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  color: var(--texte);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.champ input::placeholder,
.champ textarea::placeholder { color: var(--texte-faible); }

.champ input:focus,
.champ select:focus,
.champ textarea:focus {
  border-color: var(--marque-accent);
  box-shadow: 0 0 0 3px var(--halo-focus);
}

.champ select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23A8AEC2' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

.champ .aide { font-size: .74rem; color: var(--texte-faible); margin-top: 5px; }

.identifiants-demo {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--bordure);
  text-align: center;
  font-size: .72rem;
  line-height: 1.7;
  color: var(--texte-faible);
}

.identifiants-demo code {
  color: var(--texte-doux);
  font-family: inherit;
}

/* ==========================================================================
   Boutons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: var(--rayon-s);
  background: var(--surface-3);
  color: var(--texte);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, transform .08s, opacity .15s;
  user-select: none;
}

.btn:hover { background: var(--surface-survol); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primaire {
  background: var(--marque-accent);
  color: #fff;
}
.btn-primaire:hover { background: var(--marque-accent-sombre); }

.btn-fantome {
  background: transparent;
  border-color: var(--bordure-forte);
  color: var(--texte-doux);
}
.btn-fantome:hover { background: var(--surface-2); color: var(--texte); }

.btn-danger { background: transparent; border-color: var(--erreur); color: var(--erreur); }
.btn-danger:hover { background: var(--erreur-fond); }

.btn-bloc { width: 100%; }
.btn-petit { padding: 7px 12px; font-size: .8rem; }
.btn-icone {
  padding: 7px;
  width: 32px; height: 32px;
  border-radius: var(--rayon-s);
  background: transparent;
  color: var(--texte-doux);
}
.btn-icone:hover { background: var(--surface-3); color: var(--texte); }

/* ==========================================================================
   Messages
   ========================================================================== */

.message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--rayon-s);
  font-size: .85rem;
  margin-bottom: 14px;
  border: 1px solid transparent;
  animation: apparait .22s ease;
}

.message-erreur  { background: var(--erreur-fond);  border-color: rgba(255,92,108,.35);  color: #FFB3BB; }
.message-succes  { background: var(--succes-fond);  border-color: rgba(46,204,143,.35);  color: #93E7C6; }
.message-info    { background: rgba(79,168,255,.10); border-color: rgba(79,168,255,.30); color: #A9D3FF; }
.message-alerte  { background: var(--alerte-fond);  border-color: rgba(245,166,35,.35);  color: #F7CE8C; }

@keyframes apparait {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Structure de l'application
   ========================================================================== */

#ecran-app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--h-topbar) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  padding-right: 16px;
  background: var(--marque-primaire);
  border-bottom: 1px solid var(--bordure);
}

.topbar-logo {
  display: flex;
  align-items: center;
  color: var(--texte);
  flex-shrink: 0;
}
.topbar-logo svg,
.topbar-logo img { height: 26px; width: auto; display: block; }

.topbar-titre {
  font-weight: 700;
  letter-spacing: .12em;
  font-size: .95rem;
  flex-shrink: 0;
}

.topbar-espaceur { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar-user-nom {
  text-align: right;
  line-height: 1.15;
  min-width: 0;
  overflow: hidden;
}
.topbar-user-nom strong { display: block; font-size: .84rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.topbar-user-nom span   { display: block; font-size: .68rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .06em; }

/* --- Cloche de notifications --- */

.btn-cloche {
  position: relative;
  width: 36px; height: 36px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  border-radius: var(--rayon-s);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--texte-doux);
  transition: background .15s;
}
.btn-cloche:hover { background: var(--surface-3); }

.pastille {
  position: absolute;
  top: 2px; right: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--erreur);
  color: #fff;
  font-size: .64rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.panneau-notifications {
  position: absolute;
  top: calc(100% - 6px);
  right: 12px;
  z-index: 60;
  width: min(360px, calc(100vw - 24px));
  max-height: min(440px, 70vh);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
  box-shadow: var(--ombre-l);
}

.notif-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.notif-entete h4 { margin: 0; font-size: .88rem; }

.notif {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--bordure);
  font-size: .84rem;
}
.notif:last-child { border-bottom: none; }
.notif.non-lue { background: var(--accent-voile); }

.notif-icone { font-size: 1rem; line-height: 1.2; flex-shrink: 0; }
.notif-corps { flex: 1; min-width: 0; }
.notif-titre { font-weight: 600; margin-bottom: 2px; }
.notif-texte { color: var(--texte-doux); font-size: .8rem; }
.notif-date { color: var(--texte-faible); font-size: .72rem; margin-top: 3px; }

.avatar {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--marque-accent);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
}

/* --- Contenu --- */

.contenu {
  flex: 1;
  padding: 18px 16px calc(var(--h-nav) + 22px);
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.vue { animation: apparait .2s ease; }

.entete-vue {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.entete-vue p { color: var(--texte-doux); font-size: .85rem; margin: 3px 0 0; }

/* --- Barre de navigation basse --- */

.nav-basse {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  height: var(--h-nav);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--marque-primaire);
  border-top: 1px solid var(--bordure);
  backdrop-filter: blur(8px);
}

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--texte-faible);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 0 2px;
  transition: color .15s;
  position: relative;
}

.nav-btn .nav-icone { font-size: 1.18rem; line-height: 1; }
.nav-btn .nav-label { font-size: .63rem; font-weight: 600; letter-spacing: .02em; }

.nav-btn.actif { color: var(--marque-accent-clair); }
.nav-btn.actif::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 26px; height: 2px;
  background: var(--marque-accent);
  border-radius: 0 0 2px 2px;
}

/* ==========================================================================
   Cartes et panneaux
   ========================================================================== */

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  margin-bottom: 14px;
}

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

.carte-titre h3 { font-size: .95rem; }

.grille { display: grid; gap: 14px; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.ligne { display: flex; gap: 10px; flex-wrap: wrap; }
.ligne-fin { justify-content: flex-end; }

/* Champs côte à côte */
.champs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .champs-2 { grid-template-columns: 1fr; gap: 0; } }

/* ==========================================================================
   Étapes du formulaire RDV
   ========================================================================== */

.fil-etapes {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.fil-etape {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.fil-pastille {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .75rem;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--bordure-forte);
  color: var(--texte-faible);
  transition: all .2s;
}

.fil-libelle { font-size: .76rem; color: var(--texte-faible); font-weight: 600; }

.fil-etape.actif .fil-pastille { background: var(--marque-accent); border-color: var(--marque-accent); color: #fff; }
.fil-etape.actif .fil-libelle { color: var(--texte); }
.fil-etape.faite .fil-pastille { background: var(--succes-fond); border-color: var(--succes); color: var(--succes); }
.fil-etape.faite .fil-libelle { color: var(--texte-doux); }

.fil-trait { flex: 1; height: 1px; background: var(--bordure-forte); margin: 0 8px; min-width: 8px; }

@media (max-width: 560px) { .fil-libelle { display: none; } .fil-trait { margin: 0 4px; } }

/* ==========================================================================
   Autocomplétion d'adresse
   ========================================================================== */

.champ-auto { position: relative; }

.liste-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-s);
  box-shadow: var(--ombre);
  max-height: 260px;
  overflow-y: auto;
}

.suggestion {
  padding: 10px 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--bordure);
  font-size: .87rem;
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.survol { background: var(--surface-survol); }
.suggestion .sug-principal { display: block; }
.suggestion .sug-secondaire { display: block; font-size: .75rem; color: var(--texte-faible); }

/* ==========================================================================
   Sélection de type de RDV / chargé d'affaires (tuiles)
   ========================================================================== */

.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

.tuile {
  text-align: left;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  cursor: pointer;
  transition: all .15s;
  color: var(--texte);
}

.tuile:hover { border-color: var(--bordure-forte); background: var(--surface-3); }

.tuile.selection {
  border-color: var(--marque-accent);
  background: var(--accent-voile);
  box-shadow: 0 0 0 1px var(--marque-accent) inset;
}

.tuile-nom { font-weight: 600; font-size: .87rem; display: block; margin-bottom: 3px; }
.tuile-duree { font-size: .76rem; color: var(--texte-doux); }

/* ==========================================================================
   Créneaux proposés
   ========================================================================== */

.creneau {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 10px;
  text-align: left;
  width: 100%;
  color: var(--texte);
}

.creneau:hover { border-color: var(--bordure-forte); background: var(--surface-2); }

.creneau.selection {
  border-color: var(--marque-accent);
  background: var(--accent-voile);
  box-shadow: 0 0 0 1px var(--marque-accent) inset;
}

.creneau-rang {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  font-weight: 700;
  font-size: .8rem;
  color: var(--texte-doux);
}

.creneau.selection .creneau-rang,
.creneau:first-child .creneau-rang { background: var(--marque-accent); color: #fff; }

.creneau-info { flex: 1; min-width: 0; }
.creneau-date { font-weight: 600; font-size: .9rem; }
.creneau-date::first-letter { text-transform: uppercase; }

/* Qui interviendrait : en comparaison multi-agendas, c'est une information
   de premier plan, pas un détail. */
.creneau-qui {
  display: block;
  font-size: .8rem;
  color: var(--marque-accent-clair);
  font-weight: 600;
  margin-top: 2px;
}
.creneau-qui .badge { margin-left: 5px; vertical-align: 1px; }
.creneau-detail { font-size: .78rem; color: var(--texte-doux); margin-top: 2px; }

.creneau-score { text-align: right; flex-shrink: 0; }
.creneau-score-val { font-weight: 700; font-size: 1rem; color: var(--marque-accent-clair); }
.creneau-score-lbl { font-size: .64rem; color: var(--texte-faible); text-transform: uppercase; letter-spacing: .06em; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--surface-3);
  color: var(--texte-doux);
}

.badge-succes { background: var(--succes-fond); color: var(--succes); }
.badge-accent { background: var(--accent-voile-l); color: var(--marque-accent-clair); }
.badge-alerte { background: var(--alerte-fond); color: var(--alerte); }
.badge-erreur { background: var(--erreur-fond); color: var(--erreur); }

/* ==========================================================================
   Récapitulatif / aperçu Outlook
   ========================================================================== */

.recap-ligne {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--bordure);
  font-size: .87rem;
}
.recap-ligne:last-child { border-bottom: none; }
.recap-cle { color: var(--texte-doux); flex-shrink: 0; }
.recap-val { text-align: right; font-weight: 600; }

.apercu-outlook {
  background: var(--surface-2);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-s);
  overflow: hidden;
}

.apercu-outlook-entete {
  background: var(--marque-primaire-fonce);
  padding: 9px 13px;
  font-size: .72rem;
  color: var(--texte-doux);
  border-bottom: 1px solid var(--bordure-forte);
  display: flex;
  align-items: center;
  gap: 7px;
}

.apercu-outlook-corps {
  padding: 13px;
  font-size: .82rem;
  white-space: pre-wrap;
  line-height: 1.65;
  color: var(--texte-doux);
  max-height: 260px;
  overflow-y: auto;
}

/* Écran de confirmation */
.confirmation { text-align: center; padding: 26px 12px; }
.confirmation-icone {
  width: 66px; height: 66px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--succes-fond);
  color: var(--succes);
  font-size: 1.9rem;
  animation: pop .35s cubic-bezier(.3, 1.4, .5, 1);
}

@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ==========================================================================
   Agenda
   ========================================================================== */

.jour-agenda { margin-bottom: 18px; }

.jour-entete {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding-bottom: 7px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: calc(var(--h-topbar) + env(safe-area-inset-top, 0px));
  background: var(--fond);
  z-index: 10;
}

/* Capitalisation de la première lettre seulement : en français, « lundi 10
   août » ne porte pas de majuscule au mois. `capitalize` les mettrait toutes. */
.jour-date { font-weight: 700; font-size: .92rem; }
.jour-date::first-letter { text-transform: uppercase; }
.jour-compte { font-size: .74rem; color: var(--texte-faible); }
.jour-entete.aujourdhui .jour-date { color: var(--marque-accent-clair); }

.rdv-item {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-left: 3px solid var(--marque-accent);
  border-radius: var(--rayon-s);
  margin-bottom: 8px;
  transition: background .15s;
  overflow: hidden;
}
.rdv-item:hover { background: var(--surface-2); }

.rdv-principal {
  display: flex;
  gap: 12px;
  padding: 11px 13px;
}

.rdv-heure {
  flex-shrink: 0;
  width: 52px;
  font-weight: 700;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.rdv-heure small { display: block; font-weight: 400; font-size: .7rem; color: var(--texte-faible); }

.rdv-corps { flex: 1; min-width: 0; }
.rdv-titre { font-weight: 600; font-size: .88rem; }
.rdv-meta { font-size: .76rem; color: var(--texte-doux); margin-top: 2px; }
.rdv-meta span + span::before { content: '·'; margin: 0 6px; color: var(--texte-faible); }

/* --- Barre d'actions d'un rendez-vous ---
   Y aller, appeler, envoyer un SMS : les trois gestes du terrain. Disposées
   en bande pleine largeur plutôt qu'en colonne serrée, pour que chaque cible
   dépasse 44 px de haut — la taille utilisable au pouce, dans une voiture,
   avec le téléphone sur un support. */

.rdv-actions {
  display: flex;
  border-top: 1px solid var(--bordure);
}

.action-rdv {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 6px;
  background: var(--surface-2);
  color: var(--texte-doux);
  text-decoration: none;
  font-size: .78rem;
  font-weight: 600;
  border-right: 1px solid var(--bordure);
  transition: background .15s, color .15s;
}

.action-rdv:last-child { border-right: none; }

.action-rdv:hover {
  background: var(--accent-voile);
  color: var(--marque-accent-clair);
}
.action-rdv:active { background: var(--surface-survol); }

.action-icone { font-size: 1rem; line-height: 1; }

/* Pointe vers le haut-droite, comme un cap sur une carte. */
.action-icone.fleche { transform: rotate(-45deg); color: var(--marque-accent-clair); }

/* Écran étroit : on garde les icônes, les libellés passent en dessous. */
@media (max-width: 380px) {
  .action-rdv { flex-direction: column; gap: 2px; font-size: .66rem; }
}

/* ==========================================================================
   Listes / tableaux
   ========================================================================== */

.liste-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  margin-bottom: 8px;
}

.liste-item-corps { flex: 1; min-width: 0; }
.liste-item-titre { font-weight: 600; font-size: .88rem; }
.liste-item-meta { font-size: .76rem; color: var(--texte-doux); margin-top: 2px; }

.vide {
  text-align: center;
  padding: 38px 18px;
  color: var(--texte-faible);
  font-size: .87rem;
}
.vide-icone { font-size: 2rem; display: block; margin-bottom: 10px; opacity: .55; }

/* Barre de filtres */
.filtres {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filtres .champ { margin-bottom: 0; flex: 1; min-width: 140px; }

/* ==========================================================================
   Statistiques
   ========================================================================== */

.kpi {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 14px;
}
.kpi-val { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-lbl { font-size: .72rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.kpi-delta { font-size: .74rem; margin-top: 5px; }
.kpi-delta.up { color: var(--succes); }
.kpi-delta.down { color: var(--erreur); }

.graphique { width: 100%; overflow-x: auto; }
.graphique svg { display: block; max-width: 100%; height: auto; }

.legende { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.legende-item { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--texte-doux); }
.legende-puce { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Barres horizontales (charge de travail) */
.barre-ligne { margin-bottom: 12px; }
.barre-entete { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: 5px; }
.barre-piste { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.barre-remplie { height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.4, 0, .2, 1); }

/* ==========================================================================
   Modale
   ========================================================================== */

.voile {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 18, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: apparait .16s ease;
}

.modale {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-l);
  box-shadow: var(--ombre-l);
  padding: 20px;
}

.modale-titre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* Notification flottante */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--h-nav) + 14px);
  transform: translateX(-50%);
  z-index: 200;
  padding: 11px 18px;
  border-radius: var(--rayon);
  background: var(--surface-3);
  border: 1px solid var(--bordure-forte);
  box-shadow: var(--ombre-l);
  font-size: .85rem;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  animation: monte .25s cubic-bezier(.3, 1.3, .5, 1);
}

.toast.succes { border-color: var(--succes); color: var(--succes); }
.toast.erreur { border-color: var(--erreur); color: var(--erreur); }

@keyframes monte {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Chargement */
.chargement {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  color: var(--texte-doux);
  font-size: .85rem;
}

.spinner {
  width: 17px; height: 17px;
  border: 2px solid var(--bordure-forte);
  border-top-color: var(--marque-accent);
  border-radius: 50%;
  animation: tourne .7s linear infinite;
}

@keyframes tourne { to { transform: rotate(360deg); } }

/* ==========================================================================
   Bandeau mode démonstration
   ========================================================================== */

.bandeau-demo {
  background: var(--alerte-fond);
  border-bottom: 1px solid rgba(245, 166, 35, .3);
  color: var(--alerte);
  font-size: .72rem;
  text-align: center;
  padding: 5px 12px;
  letter-spacing: .02em;
}

/* ==========================================================================
   Écrans larges : la nav bascule sur le côté
   ========================================================================== */

@media (min-width: 900px) {
  :root { --h-nav: 0px; }

  #ecran-app { flex-direction: column; }

  .nav-basse {
    position: static;
    height: auto;
    padding: 0;
    border-top: none;
    border-bottom: 1px solid var(--bordure);
    background: var(--marque-primaire-fonce);
    justify-content: center;
    gap: 4px;
  }

  .nav-btn {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 8px;
    padding: 13px 20px;
  }

  .nav-btn .nav-icone { font-size: 1rem; }
  .nav-btn .nav-label { font-size: .82rem; }

  .nav-btn.actif::before { top: auto; bottom: 0; width: 100%; border-radius: 2px 2px 0 0; }

  .contenu { padding: 24px 24px 40px; }

  .jour-entete { top: 0; }
}

/* ---- Pointage sur site ---- */
.action-rdv.pointage { color: var(--marque-accent-clair); font-weight: 700; }
.rdv-meta.pointage-encours { color: var(--info); font-weight: 600; }
.rdv-meta.pointage-ok      { color: var(--succes); }
.rdv-meta.pointage-avance  { color: var(--succes); }
.rdv-meta.pointage-depasse { color: var(--alerte); }

/* ---- Tableaux de statistiques ---- */
.tableau-stats { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tableau-stats th, .tableau-stats td { padding: 8px 10px; border-bottom: 1px solid var(--bordure); text-align: right; white-space: nowrap; }
.tableau-stats th:first-child, .tableau-stats td:first-child { text-align: left; white-space: normal; }
.tableau-stats th { color: var(--texte-faible); font-weight: 600; font-size: .8rem; }
.tableau-stats .depasse { color: var(--alerte); font-weight: 700; }
.tableau-stats .avance  { color: var(--succes); font-weight: 700; }
.defile-x { overflow-x: auto; }
.jauge { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 80px; }
.jauge > span { display: block; height: 100%; background: var(--marque-accent); }

/* ==========================================================================
   Double authentification
   ========================================================================== */

.carte-login-2fa { max-width: 440px; }

.titre-2fa { font-size: 1.15rem; margin-bottom: 6px; outline: none; }
.carte-login-2fa .petit { margin-bottom: 14px; }

/* Cible tactile : 44 px minimum partout où l'on tape d'une main. */
.btn-tactile { min-height: 44px; }
.btn-icone-tactile { width: 44px; height: 44px; }

/* Champ de code : lisible à bout de bras, chiffres espacés. */
.champ .champ-code {
  min-height: 56px;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: .38em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  /* le dernier chiffre reste centré malgré l'espacement final */
  padding-left: calc(13px + .38em);
}
.champ .champ-code-secours { font-size: 1.25rem; letter-spacing: .18em; padding-left: calc(13px + .18em); }

/* Case à cocher : toute la ligne est la cible. */
.case {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin: 2px 0 12px;
  font-size: .9rem;
  color: var(--texte);
  cursor: pointer;
}
.case input { width: 22px; height: 22px; flex-shrink: 0; margin: 0; accent-color: var(--marque-accent); }

/* Liens-boutons sous le champ : secours, retour. */
.liens-2fa {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
}
.lien {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--marque-accent-clair);
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lien:hover { color: var(--texte); }

/* Enrôlement : trois étapes numérotées. */
.etapes-2fa { list-style: none; margin: 14px 0 6px; padding: 0; counter-reset: etape; }
.etapes-2fa > li {
  position: relative;
  padding: 0 0 18px 44px;
  counter-increment: etape;
}
.etapes-2fa > li::before {
  content: counter(etape);
  position: absolute;
  left: 0; top: -2px;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-voile-l);
  color: var(--marque-accent-clair);
  font-weight: 700;
  font-size: .85rem;
}
.etapes-2fa > li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 14px; top: 32px; bottom: 6px;
  width: 2px;
  background: var(--bordure);
}
.etapes-2fa h3 { font-size: .95rem; margin-bottom: 4px; }
.etapes-2fa .btn-bloc { margin: 8px 0 6px; text-decoration: none; }

.qr-details { margin: 10px 0 12px; }
.qr-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--marque-accent-clair);
  font-weight: 600;
  font-size: .85rem;
}
.qr-2fa {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;     /* un QR code exige un fond clair, quel que soit le thème */
  border-radius: var(--rayon);
  width: max-content;
  max-width: 100%;
}
.qr-2fa img { display: block; max-width: 100%; height: auto; }

.cle-2fa-ligne { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.cle-2fa-ligne code {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .95rem;
  letter-spacing: .06em;
  word-break: break-all;
  user-select: all;
}

/* Codes de secours */
.codes-secours {
  list-style: none;
  margin: 14px 0;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon);
}
.codes-secours code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .06em;
  user-select: all;
}
.ligne-2fa { margin-bottom: 8px; }
.ligne-2fa .btn { flex: 1; }
@media (max-width: 360px) { .codes-secours { grid-template-columns: 1fr; } }

/* Encart « Sécurité du compte » */
.faits-2fa { margin: 12px 0; padding-left: 20px; font-size: .88rem; color: var(--texte-doux); }
.faits-2fa li { margin-bottom: 4px; }
.texte-alerte { color: var(--alerte); }
.actions-2fa { display: flex; flex-direction: column; gap: 8px; }

/* Barre du haut : le profil est un bouton (accès à « Sécurité du compte »). */
.topbar-compte {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 44px;
  padding: 0 4px;
  border: none;
  border-radius: var(--rayon-s);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.topbar-compte:hover { background: var(--surface-3); }
.topbar-compte .topbar-user-nom { display: block; }

/* Paramètres et liste des comptes */
.sous-titre-params {
  margin: 18px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--bordure);
  font-size: .9rem;
}
.aide-bloc { margin: -6px 0 14px; }
.liste-item-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.liste-item-actions .btn { min-height: 44px; }

/* Texte caché à l'écran (copie de secours dans le presse-papiers) */
.hors-ecran { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* Focus clavier visible sur les éléments de cet écran */
.lien:focus-visible, .case input:focus-visible, .topbar-compte:focus-visible,
.qr-details summary:focus-visible {
  outline: 2px solid var(--marque-accent-clair);
  outline-offset: 2px;
}

/* ==========================================================================
   Fiche mission
   ========================================================================== */

/* Bouton de l'agenda : l'icône, le libellé, puis les pastilles de contenu. */
.action-mission { flex-wrap: wrap; row-gap: 2px; }
.pastilles-mission { display: inline-flex; gap: 4px; }
.pastille-m {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-voile-l);
  color: var(--marque-accent-clair);
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

/* Rappel dans le modal de transfert */
.rappel-mission {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--accent-lueur-1);
  border-radius: var(--rayon-s);
  background: var(--accent-voile);
}
.rappel-mission-titre { margin: 0; font-weight: 600; font-size: .88rem; }
.rappel-mission-detail { margin: 4px 0 0; font-size: .82rem; color: var(--texte-doux); }
.rappel-mission-detail:empty { display: none; }

/* Fenêtre : plein écran sur téléphone, fenêtre centrée au-delà. */
.voile-mission { padding: 0; align-items: stretch; }
.modale-mission {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
}
.mission-haut {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--bordure);
  background: var(--surface);
}
.mission-haut h3 { outline: none; }
.mission-corps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 700px) {
  .voile-mission { padding: 20px; align-items: center; }
  .modale-mission {
    max-width: 640px;
    height: auto;
    max-height: 92vh;
    border: 1px solid var(--bordure-forte);
    border-radius: var(--rayon-l);
  }
}

.mission-site { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; }
.mission-resume { margin-bottom: 20px; }

.mission-section { margin-bottom: 26px; }
.mission-section-titre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 44px;
}
.mission-section-titre h4 { font-size: 1rem; outline: none; }
.mission-compte { color: var(--texte-faible); font-weight: 400; }
.mission-vide { margin: 0 0 8px; }

/* 16 px : en dessous, iOS zoome la page à la prise de focus. */
.modale-mission .champ input,
.modale-mission .champ textarea { font-size: 16px; min-height: 44px; }
.modale-mission .champ textarea { resize: vertical; line-height: 1.45; }
.mission-modif { margin: -4px 0 12px; }

/* Ajout d'un devis */
.mission-ajout {
  margin-bottom: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}
.mission-ajout .champ { margin-bottom: 12px; }
.mission-ajout form + .lien { margin-top: 6px; }
.mission-ajout #m-manuel { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--bordure); }

.liste-candidats { list-style: none; margin: 8px 0 4px; padding: 0; display: grid; gap: 8px; }
.candidat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--bordure-forte);
  border-radius: var(--rayon-s);
  color: var(--texte);
  cursor: pointer;
}
.candidat:hover { background: var(--surface-survol); }
.candidat:focus-visible { outline: 2px solid var(--marque-accent-clair); outline-offset: 2px; }
.candidat-num { font-weight: 700; }
.candidat-objet { flex-basis: 100%; font-size: .82rem; color: var(--texte-doux); order: 3; }

/* Carte de devis */
.carte-devis {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}
.devis-entete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.devis-num { font-weight: 700; font-size: .98rem; outline: none; overflow-wrap: anywhere; }
.devis-objet { margin: 6px 0 0; font-size: .88rem; overflow-wrap: anywhere; }
.devis-montants { margin: 6px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.devis-source { margin: 8px 0 0; }
.devis-pdf-reserve { margin: 4px 0 0; }

.badge-info { background: rgba(79, 168, 255, .14); color: var(--info); }
.badge-statut { text-transform: none; letter-spacing: 0; font-size: .76rem; white-space: nowrap; }

.devis-lignes { margin-top: 8px; }
.devis-lignes summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  color: var(--marque-accent-clair);
  font-weight: 600;
  font-size: .85rem;
}
.devis-lignes summary:focus-visible { outline: 2px solid var(--marque-accent-clair); outline-offset: 2px; }
.devis-lignes ul { list-style: none; margin: 0; padding: 0; }
.devis-lignes li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--bordure);
  font-size: .86rem;
}
.ligne-desc { min-width: 0; overflow-wrap: anywhere; }
.ligne-qte { flex-shrink: 0; color: var(--texte-doux); font-variant-numeric: tabular-nums; }

.devis-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.devis-actions .btn { flex: 1 1 130px; text-decoration: none; }
.btn.arme { background: var(--erreur); border-color: var(--erreur); color: #fff; }

/* Pièces jointes */
.liste-pieces { list-style: none; margin: 0 0 12px; padding: 0; }
.piece {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-s);
}
.piece-corps { min-width: 0; }
.piece-nom { display: block; font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; outline: none; }
.piece-meta { display: block; margin-top: 2px; font-size: .76rem; color: var(--texte-doux); }
.piece-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.piece-actions .btn { flex: 1 1 120px; text-decoration: none; }
.mission-section > .petit { margin-top: 8px; }

/* ---- Impression des codes de secours : noir sur blanc, rien d'autre ---- */
#zone-impression { display: none; }

@media print {
  body.impression { background: #fff; color: #000; height: auto; }
  body.impression > *:not(#zone-impression) { display: none !important; }
  body.impression #zone-impression {
    display: block;
    padding: 24mm 20mm;
    color: #000;
    background: #fff;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 12pt;
    line-height: 1.5;
  }
  #zone-impression h1 { font-size: 18pt; margin: 0 0 8mm; }
  #zone-impression ol { margin: 8mm 0; padding-left: 10mm; }
  #zone-impression li {
    font-family: 'Courier New', Courier, monospace;
    font-size: 15pt;
    letter-spacing: .08em;
    margin-bottom: 4mm;
  }
  #zone-impression .date { font-size: 10pt; color: #444; }
}
