/* Style commun des pages web de Svet : pensé d'abord pour le téléphone, mode sombre automatique */
:root {
  --fond: #f4f5f7;
  --carte: #ffffff;
  --texte: #1c1e21;
  --texte-doux: #65676b;
  --bord: #dcdfe4;
  --accent: #2f6fb3;
  --accent-texte: #ffffff;
  --danger: #c9302c;
  --bulle-agent: #e9ebee;
  --bulle-utilisateur: #2f6fb3;
  --ombre: 0 1px 3px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #17191c;
    --carte: #23262b;
    --texte: #e8eaed;
    --texte-doux: #a0a4ab;
    --bord: #3a3e45;
    --accent: #5b9be0;
    --accent-texte: #0d1117;
    --danger: #e5534b;
    --bulle-agent: #33373e;
    --bulle-utilisateur: #3d7cc4;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--accent); }
h1, h2 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }

/* Pages publiques (accueil, confidentialité, conditions) */
.page-publique { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.page-publique h2 { margin-top: 24px; }

/* Bandeau du haut */
.bandeau {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--carte);
  border-bottom: 1px solid var(--bord);
}
.bandeau .titre { font-weight: 700; font-size: 1.15rem; color: var(--texte); text-decoration: none; }
.bandeau .sous-titre { color: var(--texte-doux); font-size: 0.9rem; }
.bandeau .espace { flex: 1; }

.contenu { max-width: 760px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--ombre);
  min-width: 0;
}
.carte-entete { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.carte-entete h2 { margin: 0; }
.discret { color: var(--texte-doux); font-size: 0.88rem; }
.vide { color: var(--texte-doux); font-style: italic; }

/* Boutons et champs */
button, .bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--bord); border-radius: 8px;
  background: var(--carte); color: var(--texte);
  font: inherit; text-decoration: none; cursor: pointer;
}
button.principal, .bouton { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.lien { border: none; background: none; color: var(--accent); padding: 0 6px; min-height: 32px; }
button:disabled { opacity: 0.5; cursor: default; }

input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel],
input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--bord); border-radius: 8px;
  background: var(--fond); color: var(--texte);
  font: inherit;
}
textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.9rem; }
label { display: block; font-size: 0.88rem; color: var(--texte-doux); margin: 10px 0 4px; }
.ligne-saisie { display: flex; gap: 8px; }
.ligne-saisie input, .ligne-saisie select { flex: 1; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
label.case { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--texte); font-size: 0.95rem; }
label.case input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }

/* Connexion */
.connexion { max-width: 360px; margin: 12vh auto 0; padding: 0 16px; }
.connexion .carte { padding: 24px 20px; }
.message-erreur { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; }

/* Mémos */
.memo { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-top: 1px solid var(--bord); }
.memo:first-of-type { border-top: none; }
.memo input[type=checkbox] { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.memo .corps { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.memo .details { color: var(--texte-doux); font-size: 0.85rem; }
.memo.fait .corps { text-decoration: line-through; color: var(--texte-doux); }
.memo-edition { padding: 8px 0 4px; flex-basis: 100%; }
.memo .details.retard { color: var(--danger); font-weight: 600; }
.memo:not(.compacte) .details { display: block; }
.memo.compacte { padding: 6px 0; }
.memo.compacte .corps { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; cursor: pointer; }
.memo.compacte .texte-memo { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memo.compacte.en-edition .texte-memo { white-space: normal; }
.memo.compacte .details { flex: none; }
.lien-discret { color: var(--accent); font-size: 0.9rem; text-decoration: none; }
.groupe-memos { margin: 14px 0 2px; color: var(--texte-doux); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }
.groupe-memos:first-child { margin-top: 0; }
.memo.compte { flex-wrap: wrap; gap: 0 4px; }
.memo.compte .corps { flex-basis: 100%; }

/* Météo */
.meteo-principale { display: flex; align-items: center; gap: 14px; }
.meteo-icone { font-size: 2.6rem; line-height: 1; }
.meteo-temperatures { font-size: 1.4rem; font-weight: 600; }
.meteo-heures { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.meteo-heure { flex: none; min-width: 64px; text-align: center; padding: 6px 4px; border-radius: 8px; background: var(--fond); font-size: 0.85rem; }
.meteo-heure .icone { font-size: 1.3rem; }
.meteo-heure .petit { font-size: 0.75rem; color: var(--texte-doux); }
.meteo-heure.risque { outline: 2px solid var(--danger); outline-offset: -2px; }
.meteo-heure.risque .alerte { color: var(--danger); font-weight: 600; }
#meteo + .lien-discret { display: inline-block; margin-top: 10px; }
.meteo-jour-titre { margin: 10px 0 4px; font-weight: 600; font-size: 0.9rem; }
.meteo-periodes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.meteo-periodes .meteo-heure { min-width: 0; }
.meteo-heure.nouveau-jour { border-left: 3px solid var(--accent); }

/* Tuiles de liens */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tuile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 84px; padding: 10px;
  border: 1px solid var(--bord); border-radius: 12px;
  background: var(--carte); color: var(--texte); text-decoration: none; text-align: center;
  box-shadow: var(--ombre);
}
.tuile .icone { font-size: 1.6rem; }
.tuile.inactive { opacity: 0.5; }

/* Fil de discussion */
.fil { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; padding: 4px 0; }
.message { display: flex; align-items: flex-end; gap: 6px; }
.message.utilisateur { justify-content: flex-end; }
.bulle { max-width: 82%; padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.agent .bulle { background: var(--bulle-agent); border-bottom-left-radius: 4px; }
.message.utilisateur .bulle { background: var(--bulle-utilisateur); color: #fff; border-bottom-right-radius: 4px; }
.message .heure { color: var(--texte-doux); font-size: 0.75rem; flex: none; }
.separateur-date { text-align: center; color: var(--texte-doux); font-size: 0.8rem; margin: 8px 0 2px; }
.attente { color: var(--texte-doux); font-style: italic; font-size: 0.9rem; }
.fil-saisie { margin-top: 10px; }
.piece-choisie { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 0.9em; overflow-wrap: anywhere; }
.piece-choisie[hidden], .tuile[hidden] { display: none; }

/* Contacts */
.liste-contacts { list-style: none; margin: 0; padding: 0; }
.contact { border-top: 1px solid var(--bord); }
.contact:first-child { border-top: none; }
.contact-resume { display: flex; align-items: center; gap: 10px; padding: 10px 0; cursor: pointer; }
.contact-resume .nom { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.contact-resume .sous { display: block; font-weight: 400; color: var(--texte-doux); font-size: 0.85rem; }
.contact-resume a { flex: none; text-decoration: none; font-size: 1.2rem; padding: 4px 6px; }
.contact-fiche { padding: 0 0 14px; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 12px; }
.attribut { display: flex; gap: 6px; margin-bottom: 6px; }
.attribut input { flex: 1; min-width: 0; }

/* Documents */

.notification {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 8px;
  background: var(--texte); color: var(--fond);
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.notification.visible { opacity: 1; }

/* Page d'un mail */
.mail-texte { white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--bord); margin-top: 10px; padding-top: 10px; }
.bulle a { color: inherit; font-weight: 600; }

/* Mise en forme */
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; }
.vignette { border: 1px solid var(--bord); border-radius: 8px; padding: 6px; font-size: 0.85rem; text-align: center; }
.vignette[draggable] { cursor: grab; background: var(--carte); }
.vignette img { width: 100%; height: 80px; object-fit: cover; border-radius: 4px; display: block; }
.vignette .actions { justify-content: center; margin-top: 4px; gap: 2px; }
.icone-pdf { height: 80px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.8rem;
  background: var(--fond); border-radius: 4px; overflow: hidden; }
.icone-pdf span { font-size: 0.7rem; padding: 0 4px; overflow-wrap: anywhere; max-height: 2.6em; overflow: hidden; }
textarea.texte-document { min-height: 320px; }

.barre-projet { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.barre-projet select { width: auto; flex: 1 1 280px; max-width: 520px; }
/* Mise en forme sur ordinateur : vignettes | texte | aperçu ; sur petit écran, les uns sous les autres */
.mise-en-forme { display: grid; grid-template-columns: 200px 1fr 1fr; gap: 16px; align-items: start; }
.mise-en-forme .medias { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.mise-en-forme .medias .vignettes { grid-template-columns: repeat(2, 1fr); gap: 6px; }
.mise-en-forme .medias .vignette img, .mise-en-forme .medias .icone-pdf { height: 64px; }
.mise-en-forme .editeur { display: flex; flex-direction: column; }
.mise-en-forme .editeur textarea.texte-document { height: calc(100vh - 210px); min-height: 320px; resize: vertical; }
.mise-en-forme .apercu-carte { position: sticky; top: 12px; }
@media (max-width: 1000px) {
  .mise-en-forme { grid-template-columns: 1fr; }
  .mise-en-forme .medias, .mise-en-forme .apercu-carte { position: static; max-height: none; }
}

/* Aperçu : page blanche aux couleurs de la charte (documents.COULEURS_PAR_DEFAUT), même en mode sombre */
.apercu { background: #fff; color: #333; border: 1px solid var(--bord); border-radius: 4px; padding: 20px 24px;
  height: calc(100vh - 110px); min-height: 320px; overflow-y: auto; font-family: Georgia, serif; font-size: 0.85rem; line-height: 1.45; }
.apercu .vide { color: #666; }
.apercu [data-debut] { cursor: pointer; border-radius: 3px; }
.apercu [data-debut]:hover { outline: 1px dashed #C9A97A; }
.apercu .cible { box-shadow: 0 3px 0 0 #2f6fb3; }
.apercu .cible-cote { box-shadow: inset -4px 0 0 0 #2f6fb3; }
.apercu figure[draggable] { cursor: grab; }
.ap-titre { color: #5C4630; font-weight: bold; margin: 12px 0 6px; }
.ap-titre-1 { background: #D9C3A0; padding: 4px 8px; font-size: 1.05rem; }
.ap-titre-2 { color: #8B6F47; font-size: 0.98rem; }
.ap-titre-3 { font-size: 0.9rem; }
.ap-paragraphe { margin: 0 0 8px; text-align: justify; }
.ap-dore { color: #8B6F47; font-size: 0.8rem; }
.ap-puce { margin: 0 0 3px 18px; position: relative; }
.ap-puce::before { content: "•"; position: absolute; left: -12px; }
.ap-numero::before { content: attr(data-numero); left: -18px; }
.ap-encadre { background: #F6F0E7; border: 1px solid #C9A97A; padding: 8px 10px; margin: 8px 0; }
.ap-encadre > .ap-titre-1 { margin-top: 0; }
.ap-tableau { overflow-x: auto; margin: 8px 0; }
.ap-tableau table { border-collapse: collapse; width: 100%; font-size: 0.8rem; }
.ap-tableau th, .ap-tableau td { border: 1px solid #C9A97A; padding: 3px 5px; text-align: left; vertical-align: top; }
.ap-tableau th, .ap-tableau tr.groupe td { background: #D9C3A0; }
.ap-tableau td { background: #F6F0E7; }
.ap-photos { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.ap-photos figure { margin: 0; flex: 0 1 60%; text-align: center; }
.ap-photos figure:not(:only-child) { flex-basis: 48%; }
.ap-photos.grille { flex-wrap: wrap; }
.ap-photos.grille figure { flex-basis: 45%; }
.ap-photos img { max-width: 100%; max-height: 220px; object-fit: contain; }
.ap-photos figcaption { color: #666; font-size: 0.75rem; font-style: italic; }
.ap-espace { background: repeating-linear-gradient(45deg, transparent 0 6px, #F6F0E7 6px 12px); }
.ap-saut { border-top: 2px dashed #C9A97A; color: #8B6F47; font-size: 0.7rem; text-align: center; margin: 14px 0; }
.ap-pdf { background: #F6F0E7; border: 1px dashed #C9A97A; padding: 10px; margin: 8px 0; text-align: center; }
.ap-alerte { color: #c9302c; font-family: system-ui, sans-serif; font-size: 0.8rem; }
.ap-couverture { background: #EEE2CF; padding: 16px; margin-bottom: 14px; text-align: center; white-space: pre-line; }
.ap-sigle { font-size: 1.6rem; font-weight: bold; color: #5C4630; }
.ap-type { font-size: 1.05rem; color: #8B6F47; }
.ap-operation { font-weight: bold; margin: 6px 0; }
.ap-intervenants { display: flex; gap: 8px; margin-top: 10px; text-align: left; }
.ap-intervenant { flex: 1; border: 1px solid #C9A97A; background: #fff; padding: 6px; font-size: 0.78rem; }
/* Page Aide : même rendu que l'aperçu, sans hauteur fixe ni repères de modification */
.apercu.aide { height: auto; min-height: 0; overflow: visible; font-size: 0.95rem; }
.apercu.aide [data-debut] { cursor: auto; }
.apercu.aide [data-debut]:hover { outline: none; }
.apercu.aide .ap-titre-1 { scroll-margin-top: 64px; }
.apercu a { color: #5C4630; }
.fenetre.fenetre-apercu { width: min(1000px, calc(100% - 24px)); height: calc(100% - 24px); }
.fenetre-apercu[open] { display: flex; flex-direction: column; }
.fenetre-apercu iframe { flex: 1; width: 100%; border: 1px solid var(--bord); border-radius: 4px; }
.consigne { white-space: pre-wrap; background: var(--fond); border: 1px solid var(--bord); border-radius: 8px; padding: 10px; font-size: 0.88rem; }

/* Matériel */
.contenu.contenu-large { max-width: 1200px; }
.onglets { display: flex; gap: 6px; overflow-x: auto; margin-top: 4px; padding-bottom: 4px; }
.onglet { flex: none; min-height: 36px; border-radius: 18px; font-size: 0.9rem; text-transform: uppercase; }
.onglet.actif { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.defilement-tableau { overflow-x: auto; }
.tableau-materiel { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.tableau-materiel th { text-align: left; color: var(--texte-doux); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
.tableau-materiel td { padding: 4px 6px; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau-materiel td.modifiable { min-width: 130px; }
.tableau-materiel td:last-child { min-width: 200px; }
.tableau-materiel input, .tableau-materiel select, .tableau-materiel textarea { min-height: 34px; padding: 4px 6px; font-size: 0.92rem; }
.tableau-materiel textarea { min-height: 34px; font-family: inherit; resize: vertical; }
.fenetre { width: min(720px, calc(100% - 24px)); max-height: calc(100% - 24px); border: 1px solid var(--bord); border-radius: 12px;
  background: var(--carte); color: var(--texte); padding: 16px; }
.fenetre::backdrop { background: rgba(0, 0, 0, 0.4); }
.fenetre textarea { min-height: 80px; font-family: inherit; }
.liste-historique { list-style: none; margin: 0; padding: 0; }
.liste-historique li { padding: 6px 0; border-top: 1px solid var(--bord); overflow-wrap: anywhere; }
.liste-historique li:first-child { border-top: none; }
.liste-historique .details { color: var(--texte-doux); font-size: 0.85rem; }

/* Historique des conversations : calendrier à gauche, fil continu (jours chargés en défilant) à droite */
.historique { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.historique .calendrier-carte { position: sticky; top: 68px; }
.historique .fil { max-height: none; overflow: visible; }
.calendrier-entete { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; text-transform: capitalize; }
.calendrier-entete .lien { font-size: 1.3rem; }
.calendrier { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jour-semaine { color: var(--texte-doux); font-size: 0.75rem; padding: 2px 0; }
.jour-calendrier { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 0; border-radius: 50%;
  color: var(--texte-doux); font-size: 0.88rem; opacity: 0.55; border: 1px solid transparent; }
.jour-calendrier.avec-echanges { opacity: 1; color: var(--texte); font-weight: 600; background: var(--fond); }
.jour-calendrier.aujourdhui { border-color: var(--accent); }
.jour-calendrier.actif { background: var(--accent); color: var(--accent-texte); }
.entete-jour { position: sticky; top: 57px; z-index: 5; background: var(--carte); padding: 8px 0 6px; margin-top: 10px;
  border-bottom: 1px solid var(--bord); color: var(--texte-doux); font-size: 0.85rem; font-weight: 600; text-transform: capitalize; }
.jour-fil:first-child .entete-jour { margin-top: 0; }
.charge-plus { text-align: center; margin: 4px 0; min-height: 1em; }
@media (max-width: 760px) {
  .historique { grid-template-columns: 1fr; }
  .historique .calendrier-carte { position: static; }
}

/* Tableau de bord : ligne « Point du jour » (11/11) */
.ligne-point { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; text-decoration: none; color: var(--texte); }
.ligne-point #point-compteurs { flex: 1; min-width: 0; }

/* Tableau de bord : tuiles par groupe (11/11) */
.groupe-tuiles { margin-top: 16px; }
.groupe-tuiles[hidden] { display: none; }
.titre-groupe { font-size: 0.95rem; color: var(--texte-doux); margin: 0 0 8px; font-weight: 600; }
