:root {
  --fond: #f4f6f2;
  --carte: #ffffff;
  --encre: #22301f;
  --gris: #6b7a63;
  --vert: #2e7d43;
  --rouge: #b3402f;
  --bleu: #1f6fb2;
  --ambre: #b7791f;
  --bord: #d8e0d2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--fond);
  color: var(--encre);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.2rem;
  background: var(--encre);
  color: #fff;
}

.entete-gauche { display: flex; align-items: center; gap: 0.7rem; }
header h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }

#bandeau-utilisateur { display: flex; gap: 0.8rem; align-items: center; font-size: 0.9rem; }

main, #connexion { max-width: 1120px; margin: 1.1rem auto; padding: 0 1rem 2.2rem; }

h2 {
  font-size: 0.95rem;
  margin: 1.4rem 0 0.6rem;
  color: var(--gris);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.espace-haut { margin-top: 0.9rem; }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 0.95rem 1.05rem;
}

.entete-carte, .entete-section, .ligne-entre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.entete-carte { margin-bottom: 0.45rem; }
.entete-carte h3, .entete-section h2 { margin: 0; }
.entete-section { margin: 1.4rem 0 0.6rem; }

.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 0.85rem; }
.grille.capteurs { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grille.deux-colonnes { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.carte h3 { margin: 0 0 0.5rem; font-size: 0.96rem; }

.valeur { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.valeur .unite { font-size: 0.95rem; font-weight: 400; color: var(--gris); margin-left: 0.2rem; }

.sous-texte { font-size: 0.8rem; color: var(--gris); margin-top: 0.3rem; }

.gris { color: var(--gris); font-size: 0.88rem; }
.erreur { color: var(--rouge); font-size: 0.88rem; min-height: 1.1em; margin: 0.3rem 0; }
.cache { display: none !important; }

.badge {
  display: inline-block;
  padding: 0.16rem 0.58rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e4e9e1;
  color: var(--gris);
}
.badge.en_ligne, .badge.confirmee, .badge.termine, .badge.locale { background: #d9efd9; color: var(--vert); }
.badge.hors_ligne, .badge.echec, .badge.forte { background: #f6dcd7; color: var(--rouge); }
.badge.ouverte, .badge.reseau { background: #d7e8f7; color: var(--bleu); }
.badge.fermee, .badge.faible { background: #e4e9e1; color: var(--gris); }
.badge.envoyee, .badge.en_cours, .badge.moyenne, .badge.degrade { background: #fef3c7; color: var(--ambre); }

.barre-parcelle {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--bord);
}
.selecteur-bloc { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.libelle-en-ligne { flex-direction: row; font-weight: 600; color: var(--encre); }

.onglets { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.onglet {
  background: var(--carte);
  color: var(--encre);
  border: 1px solid var(--bord);
  padding: 0.42rem 0.85rem;
  font-weight: 600;
  font-size: 0.86rem;
}
.onglet.actif {
  background: var(--vert);
  color: #fff;
  border-color: var(--vert);
}

select {
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: var(--carte);
  font-size: 0.92rem;
}

.barre-historique { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin-bottom: 0.6rem; }
.boutons-periode { display: flex; }
.boutons-periode button {
  border: 1px solid var(--bord);
  background: var(--carte);
  color: var(--encre);
  padding: 0.42rem 0.8rem;
  cursor: pointer;
  font-size: 0.86rem;
  border-radius: 0;
}
.boutons-periode button:first-child { border-radius: 8px 0 0 8px; }
.boutons-periode button:last-child { border-radius: 0 8px 8px 0; }
.boutons-periode button.actif { background: var(--encre); color: #fff; }

button {
  border: none;
  border-radius: 8px;
  padding: 0.48rem 0.9rem;
  background: var(--vert);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}
button.secondaire { background: #5a6b55; }
button.danger { background: var(--rouge); }
button.petit { padding: 0.26rem 0.62rem; font-size: 0.8rem; }
button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.5; cursor: wait; }

#connexion form {
  max-width: 350px;
  margin: 3rem auto;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#connexion h2 { margin: 0 0 0.3rem; }

label { font-size: 0.83rem; color: var(--gris); display: flex; flex-direction: column; gap: 0.25rem; }
label.case-a-cocher { flex-direction: row; align-items: center; gap: 0.45rem; margin: 0.2rem 0; color: var(--encre); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="file"], textarea {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--bord);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
}

.actions-vanne { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.actions-vanne input { width: 5.5rem; }

.formulaire-regle, .formulaire-empile { margin-top: 0.55rem; display: flex; flex-direction: column; gap: 0.55rem; }
.ligne-champs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.ligne-champs input { width: 100%; }
.actions-regle { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.tableau-donnees { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.tableau-donnees th, .tableau-donnees td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--bord);
  vertical-align: middle;
}
.tableau-donnees th { color: var(--gris); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.resultat-diag-bloc { display: flex; gap: 0.9rem; align-items: flex-start; flex-wrap: wrap; }
.apercu-feuille {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--bord);
  background: var(--fond);
}
.details-diag { flex: 1; min-width: 180px; }
.alerte-prudence {
  margin-top: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  background: #fef3c7;
  color: #7c4d08;
  font-size: 0.82rem;
}

.suggestions-rag { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.liste-sources { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.bloc-reponse {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.94rem;
  color: var(--encre);
  min-height: 3.5rem;
  padding: 0.5rem 0;
}

.carte-geo {
  height: 340px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--bord);
  background: #dfece6;
}
