/* ===== css/gestion.css (v1.1.0.4) ===== */
/* Onglet Gestion : mobile d'abord, palette de l'app (beige dore, rose poudre). */

#gestion {
  --ge-ok: #4f8a5b;
  --ge-tendu: #b9852a;
  --ge-alerte: #c0504d;
  --ge-trait: #efe6dd;
  --ge-fond-doux: #fbf8f5;
}

#gestion-host {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ge-chargement {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-light);
}

/* ----- En-tete ----- */
.ge-entete {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ge-entete-haut,
.ge-entete-bas {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.ge-entete h2 {
  font-size: 1.6rem;
  color: var(--text-dark);
}
.ge-segments {
  display: inline-flex;
  background: var(--white);
  border-radius: 999px;
  padding: 0.2rem;
  box-shadow: var(--shadow);
}
.ge-segment {
  border: 0;
  background: transparent;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-light);
  cursor: pointer;
}
.ge-segment.actif {
  background: var(--beige-dore);
  color: var(--white);
}
.ge-mois {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.ge-mois-nom {
  min-width: 8.5rem;
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  text-transform: capitalize;
}
.ge-fleche {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--ge-trait);
  background: var(--white);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-dark);
}
.ge-fleche:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ----- Cartes ----- */
.ge-carte {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ge-carte h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  color: var(--text-dark);
}
.ge-h3-sous {
  margin-top: 1rem;
}
.ge-erreur {
  border-left: 4px solid var(--ge-alerte);
}
.ge-demarrage {
  border-left: 4px solid var(--beige-dore);
  background: var(--ge-fond-doux);
}

/* ----- A declarer ----- */
.ge-declarer {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.ge-declarer > div:first-child {
  display: flex;
  flex-direction: column;
}
.ge-declarer-montant {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
}
.ge-declarer .ge-info {
  flex-basis: 100%;
}
.ge-petit {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ----- Les 4 chiffres ----- */
.ge-tuiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.ge-tuile {
  appearance: none;
  border: 2px solid transparent;
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  text-align: left;
  font: inherit;
  color: var(--text-dark);
  cursor: pointer;
  min-height: 7.5rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.ge-tuile:hover {
  transform: translateY(-2px);
}
.ge-tuile:focus-visible {
  outline: 3px solid var(--rose-accent);
  outline-offset: 2px;
}
.ge-tuile.ouverte {
  border-color: var(--beige-dore);
}
.ge-tuile-titre {
  font-size: 0.82rem;
  line-height: 1.25;
  color: var(--text-light);
}
.ge-tuile-valeur {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--beige-dore);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ge-tuile-note {
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.3;
  margin-top: auto;
}
/* Ma reserve : monte ou descend depuis la fin du mois d'avant */
.ge-variation { font-weight: 600; white-space: nowrap; }
.ge-variation.hausse { color: var(--ge-ok); }
.ge-variation.baisse { color: var(--ge-alerte); }
/* « sur 900 € » sous le montant : tient dans une tuile etroite (2 colonnes sur telephone) */
.ge-sur {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-light);
}
.ge-tuile.negatif .ge-tuile-valeur {
  color: var(--ge-alerte);
}
.ge-tuile.statut-ok {
  background: linear-gradient(160deg, #eef6ef 0%, var(--white) 70%);
}
.ge-tuile.statut-ok .ge-tuile-valeur,
.ge-tuile.statut-ok strong { color: var(--ge-ok); }
.ge-tuile.statut-tendu {
  background: linear-gradient(160deg, #fbf1df 0%, var(--white) 70%);
}
.ge-tuile.statut-tendu .ge-tuile-valeur,
.ge-tuile.statut-tendu strong { color: var(--ge-tendu); }
.ge-tuile.statut-alerte {
  background: linear-gradient(160deg, #f9e6e5 0%, var(--white) 70%);
}
.ge-tuile.statut-alerte .ge-tuile-valeur,
.ge-tuile.statut-alerte strong { color: var(--ge-alerte); }

.ge-jauge {
  display: block;
  width: 100%;
  height: 0.45rem;
  border-radius: 999px;
  background: var(--ge-trait);
  overflow: hidden;
}
.ge-jauge > span {
  display: block;
  height: 100%;
  background: var(--beige-dore);
  border-radius: inherit;
}
/* Jauge vers le besoin du mois : couleur du verdict une fois le mois termine */
.ge-tuile.statut-ok .ge-jauge > span { background: var(--ge-ok); }
.ge-tuile.statut-tendu .ge-jauge > span { background: var(--ge-tendu); }
.ge-tuile.statut-alerte .ge-jauge > span { background: var(--ge-alerte); }

/* ----- Lignes de detail ----- */
.ge-ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--ge-trait);
}
.ge-ligne:last-of-type {
  border-bottom: 0;
}
.ge-ligne-libelle {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ge-ligne-note {
  font-size: 0.75rem;
  color: var(--text-light);
}
.ge-ligne-montant {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.ge-ligne.ge-sous {
  font-size: 0.88rem;
  color: var(--text-light);
  padding-left: 0.75rem;
}
/* Releve saisi entre le 1er et le 4 : l'URSSAF d'il y a deux mois est-elle deja passee ? */
.ge-question {
  margin: 0;
  border: 1px solid var(--ge-trait);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  background: var(--ge-fond-doux);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.ge-question legend {
  font-weight: 600;
  padding: 0 0.3rem;
}
.ge-question label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ge-ligne.ge-total {
  border-top: 1px solid var(--beige-dore);
  border-bottom: 0;
}
.ge-mini {
  border: 1px solid var(--ge-trait);
  background: var(--white);
  color: var(--text-dark);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}
.ge-mini:hover {
  border-color: var(--beige-dore);
}
.ge-lien {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: #9a6a42;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.ge-aide {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.45;
  margin-top: 0.3rem;
}
.ge-info {
  font-size: 0.85rem;
  line-height: 1.4;
  background: #fbf1df;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  color: #6d5020;
}
.ge-statut {
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}
.ge-statut.statut-ok { background: #eef6ef; color: var(--ge-ok); }
.ge-statut.statut-tendu { background: #fbf1df; color: #8a6219; }
.ge-statut.statut-alerte { background: #f9e6e5; color: var(--ge-alerte); }

.ge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.ge-danger {
  color: var(--ge-alerte) !important;
  border-color: var(--ge-alerte) !important;
  margin-right: auto;
}

/* ----- Courbe ----- */
.ge-courbe {
  min-height: 260px;
}

/* ----- Perso ----- */
.ge-pastilles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ge-pastille {
  background: var(--white);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
}

/* ----- Formulaires ----- */
.ge-grille-champs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}
.ge-champ {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--text-light);
}
.ge-champ input,
.ge-champ select {
  width: 100%;
  min-width: 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid #e3d7cc;
  border-radius: 8px;
  font: inherit;
  font-size: 1rem;
  color: var(--text-dark);
  background: var(--white);
}
.ge-champ small {
  font-size: 0.75rem;
  line-height: 1.35;
}
.ge-champ-large {
  grid-column: 1 / -1;
}

/* v1.1.2.0 : liste de categories (remplace le <datalist> qui ne s'ouvrait pas) */
.ge-choix {
  position: relative;
}
.ge-champ .ge-choix input {
  padding-right: 2.4rem;
}
.ge-choix-fleche {
  position: absolute;
  top: 0;
  right: 0;
  width: 2.4rem;
  height: 2.6rem;
  border: 0;
  background: none;
  color: #a08d7c;
  font-size: 0.95rem;
  cursor: pointer;
}
/* Flottante, rattachee a <body> (position calculee par placerChoix) : dans la fenetre, elle
   l'agrandissait (le champ sautait sous le doigt) ou s'y faisait couper (ascenseur force) */
.ge-choix-liste {
  position: fixed;
  z-index: 1100;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  max-height: 320px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid #e3d7cc;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(122, 82, 54, 0.12);
}
.ge-choix-liste li {
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  font-size: 0.95rem;
  color: var(--text-dark);
  cursor: pointer;
}
.ge-choix-liste li:hover,
.ge-choix-liste li.is-actif {
  background: #f6eee5;
}
.ge-choix-liste li.is-choisi {
  font-weight: 600;
  color: #7a5236;
}
.ge-choix-liste li.ge-choix-ajout {
  margin-top: 0.2rem;
  border-top: 1px dashed #ece1d5;
  border-radius: 0 0 7px 7px;
  color: #8a6a4f;
  font-weight: 500;
}
.ge-formulaire {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ge-reglages h3 + .ge-grille-champs,
.ge-reglages .ge-champ-large {
  margin-bottom: 0.4rem;
}
.ge-groupe {
  padding: 0.5rem 0;
  border-top: 1px solid var(--ge-trait);
}
.ge-groupe-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.ge-groupe-tete h4 {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
}

/* ----- Ecrans plus larges ----- */
@media (min-width: 900px) {
  #gestion-host { padding: 1.5rem 1.5rem 3rem; }
  .ge-tuiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
  .ge-tuile { padding: 1.1rem 1rem; min-height: 8.5rem; }
  .ge-tuile-valeur { font-size: 1.75rem; }
  .ge-grille-champs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .ge-tuile-valeur { font-size: 1.25rem; }
  .ge-grille-champs { grid-template-columns: minmax(0, 1fr); }
  .ge-ligne { grid-template-columns: minmax(0, 1fr) auto; }
  .ge-ligne .ge-mini { grid-column: 1 / -1; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  .ge-tuile { transition: none; }
  .ge-tuile:hover { transform: none; }
}
