/* GONATA : mise en page et composants. Aucune couleur en dur : tout vient de theme.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--police);
  color: var(--texte);
  background: var(--fond);
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
.cache { display: none !important; }
.ico { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.ico-grand { width: 22px; height: 22px; }

/* Barre du haut */
.barre {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.marque { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .04em; color: var(--texte); text-decoration: none; }
.marque svg { color: var(--accent); }
.marque small { font-weight: 400; color: var(--texte-faible); letter-spacing: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a, .nav button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--rayon-petit);
  color: var(--texte-doux); text-decoration: none; font-size: .9rem;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav a:hover, .nav button:hover { background: var(--surface-3); color: var(--texte); }
.nav a.actif { background: var(--accent-doux); color: var(--accent-fort); }
.nav .libelle-nav { display: none; }
@media (min-width: 720px) { .nav .libelle-nav { display: inline; } }

main { max-width: 1180px; margin: 0 auto; padding: 14px 12px 80px; }
@media (min-width: 720px) { main { padding: 20px 20px 80px; } }

/* Cartes et grilles */
.carte-bloc {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--ombre);
  min-width: 0;
}
.carte-bloc > h2:first-child, .carte-bloc > h3:first-child { margin-top: 0; }
.grille { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grille-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grille-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grille-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ligne > .pousse { margin-left: auto; }
.pile > * + * { margin-top: 10px; }
.discret { color: var(--texte-doux); font-size: .88rem; }
.faible { color: var(--texte-faible); font-size: .85rem; }
.chiffre { font-family: var(--police-chiffres); font-variant-numeric: tabular-nums; }

/* Boutons */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  border-radius: var(--rayon-petit);
  border: 1px solid var(--bordure-forte);
  background: var(--surface);
  color: var(--texte);
  font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none;
}
.bouton:hover { background: var(--surface-3); }
.bouton:disabled { opacity: .55; cursor: not-allowed; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.principal:hover { background: var(--accent-fort); }
.bouton.danger { color: var(--danger); border-color: var(--danger); }
.bouton.danger:hover { background: var(--danger-doux); }
.bouton.petit { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
.bouton.icone { padding: 6px; min-width: 36px; min-height: 36px; }
.bouton.plein { width: 100%; }

/* Champs */
.champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.champ > label, .champ > .etiquette { font-size: .86rem; color: var(--texte-doux); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], input[type="tel"], input[type="email"], select, textarea {
  width: 100%; min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-petit);
  background: var(--surface-2);
  color: var(--texte);
  font: inherit; font-size: 16px;
}
textarea { min-height: 90px; resize: vertical; font-family: var(--police-chiffres); font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.champ.fixe input, .champ.fixe select { border-color: var(--accent); background: var(--surface); }
.case { display: flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }
.case input { width: 18px; height: 18px; accent-color: var(--accent); }
.aide { font-size: .8rem; color: var(--texte-faible); }

/* États verrouillé et proposé */
.etat { display: inline-flex; align-items: center; gap: 3px; font-size: .72rem; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.etat.fixe { background: var(--accent-doux); color: var(--accent-fort); }
.etat.propose { background: var(--surface-3); color: var(--texte-doux); }
.etat .ico { width: 12px; height: 12px; vertical-align: -1px; }
.propose-valeur { font-size: .8rem; color: var(--chaud); }

/* Pastilles de statut */
.pastille { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--texte-doux); }
.pastille.demande { background: var(--chaud-doux); color: var(--chaud); }
.pastille.ok { background: var(--ok-doux); color: var(--ok); }
.pastille.danger { background: var(--danger-doux); color: var(--danger); }
.pastille.alerte { background: var(--alerte-doux); color: var(--alerte); }

/* Onglets du projet */
.entete-projet { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.entete-projet h1 { flex: 1 1 220px; margin: 0; word-break: break-word; }
.onglets { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--bordure); padding-bottom: 6px; }
.onglets a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--rayon-petit);
  color: var(--texte-doux); text-decoration: none; font-size: .9rem;
}
.onglets a .num { font-size: .72rem; color: var(--texte-faible); }
.onglets a:hover { background: var(--surface-3); }
.onglets a.actif { background: var(--accent); color: var(--accent-texte); }
.onglets a.actif .num { color: inherit; opacity: .75; }

/* Tableaux */
.tableau-defile { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--bordure); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--texte-doux); background: var(--surface-2); font-size: .8rem; }
td.nombre, th.nombre { text-align: right; font-family: var(--police-chiffres); font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--bordure-forte); }
tr.groupe td { background: var(--surface-2); font-weight: 600; }

/* Liste de projets */
.liste { list-style: none; padding: 0; margin: 0; }
.liste > li { border-bottom: 1px solid var(--bordure); padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.liste > li:last-child { border-bottom: 0; }
.liste .titre { font-weight: 600; flex: 1 1 200px; min-width: 0; word-break: break-word; }
.liste .titre a { color: var(--texte); text-decoration: none; }
.liste .titre a:hover { color: var(--accent); }
.liste .actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Chiffres clés */
.chiffres-cles { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .chiffres-cles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.chiffre-cle { background: var(--surface); border: 1px solid var(--bordure); border-left: 4px solid var(--accent); border-radius: var(--rayon); padding: 12px 14px; }
.chiffre-cle:nth-child(2) { border-left-color: var(--chaud); }
.chiffre-cle:nth-child(3) { border-left-color: var(--ok); }
.chiffre-cle .valeur { font-size: 1.4rem; font-weight: 700; font-family: var(--police-chiffres); font-variant-numeric: tabular-nums; word-break: break-word; }
.chiffre-cle .nom { font-size: .82rem; color: var(--texte-doux); }
.mini-chiffres { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .mini-chiffres { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mini-chiffres div { background: var(--surface-2); border-radius: var(--rayon-petit); padding: 8px 10px; }
.mini-chiffres b { display: block; font-family: var(--police-chiffres); font-size: 1rem; }
.mini-chiffres span { font-size: .78rem; color: var(--texte-doux); }

/* Alertes et hypothèses */
.messages { list-style: none; padding: 0; margin: 0; }
.messages li { display: flex; gap: 8px; padding: 8px 10px; border-radius: var(--rayon-petit); margin-bottom: 6px; font-size: .9rem; }
.messages.alertes li { background: var(--alerte-doux); color: var(--texte); }
.messages.alertes .ico { color: var(--alerte); }
.messages.hypotheses li { background: var(--info-doux); }
.messages.hypotheses .ico { color: var(--accent); }
.bandeau { padding: 10px 12px; border-radius: var(--rayon-petit); font-size: .9rem; margin-bottom: 12px; display: flex; gap: 8px; align-items: flex-start; }
.bandeau.info { background: var(--info-doux); }
.bandeau.alerte { background: var(--alerte-doux); }
.bandeau.danger { background: var(--danger-doux); color: var(--danger); }
.bandeau.ok { background: var(--ok-doux); }

/* Carte Leaflet */
.carte-leaflet { width: 100%; height: 360px; border-radius: var(--rayon); border: 1px solid var(--bordure); z-index: 1; }
@media (min-width: 720px) { .carte-leaflet { height: 460px; } }
.legende-variantes { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.legende-variantes .ligne { font-size: .88rem; }
.puce-couleur { display: inline-block; width: 14px; height: 14px; border-radius: 3px; flex: none; }

/* Graphiques */
.graphe { width: 100%; height: 300px; }
.graphe.haut { height: 420px; }

/* Créneaux et sources éditables */
.sous-bloc { border: 1px dashed var(--bordure-forte); border-radius: var(--rayon-petit); padding: 10px; margin-bottom: 10px; background: var(--surface-2); }
.sous-bloc .entete { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.sous-bloc .entete strong { flex: 1; }

/* Fenêtre modale et messages éphémères */
.voile { position: fixed; inset: 0; background: var(--voile); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modale { background: var(--surface); border-radius: var(--rayon); max-width: 460px; width: 100%; padding: 18px; box-shadow: var(--ombre); max-height: 90vh; overflow: auto; }
.modale .ligne { justify-content: flex-end; margin-top: 14px; }
.toasts { position: fixed; bottom: 14px; left: 12px; right: 12px; z-index: 2100; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--texte); color: var(--surface); padding: 9px 14px; border-radius: var(--rayon-petit); font-size: .9rem; max-width: 520px; box-shadow: var(--ombre); }
.toast.erreur { background: var(--danger); color: #fff; }
.secret { font-family: var(--police-chiffres); background: var(--surface-3); padding: 8px 10px; border-radius: var(--rayon-petit); word-break: break-all; user-select: all; }

/* Connexion */
.page-connexion { max-width: 380px; margin: 8vh auto 0; }
.page-connexion .marque { justify-content: center; font-size: 1.4rem; margin-bottom: 4px; }

/* Barre d'enregistrement */
.non-enregistre { color: var(--chaud); font-size: .85rem; }
.chargement { padding: 30px; text-align: center; color: var(--texte-doux); }
details > summary { cursor: pointer; color: var(--texte-doux); font-size: .9rem; padding: 4px 0; }
code { font-family: var(--police-chiffres); font-size: .85em; background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
pre.json { max-height: 320px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: var(--rayon-petit); font-size: .78rem; white-space: pre-wrap; word-break: break-word; }

/* Champ de mot de passe avec bouton afficher ou masquer */
.mot-de-passe { position: relative; display: flex; }
.mot-de-passe input { flex: 1; padding-right: 44px; min-width: 0; }
.bouton-oeil { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 40px; height: 36px;
  display: flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 6px;
  color: var(--texte-doux); cursor: pointer; }
.bouton-oeil:hover, .bouton-oeil:focus-visible { color: var(--accent); background: var(--surface); }
