/* Suivi jetons — page unique saisie + dashboard. */

:root {
  --fond: #f4f2ee;
  --carte: #ffffff;
  --encre: #1c1b1a;
  --encre-2: #6b675f;
  --trait: #e2ddd4;
  --rouge: #c0392b;
  --rouge-fonce: #96281b;
  --bleu: #2c5f8a;
  --vert: #2e7d4f;
  --vert-clair: #e3f1e8;
  --rayon: 10px;
  --ombre: 0 1px 3px rgba(28, 27, 26, 0.08), 0 4px 14px rgba(28, 27, 26, 0.05);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--fond);
  color: var(--encre);
  font-size: 16px;
  line-height: 1.45;
}

/* ------------------------------------------------------------- entête */

header {
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  padding: 14px 0;
  letter-spacing: 0.2px;
}

header h1 .pastille {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 34%, var(--rouge) 36%);
  border: 2px solid var(--rouge);
  margin-right: 8px;
  vertical-align: -1px;
}

main { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }

.carte {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 22px;
  margin-bottom: 22px;
}

h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.8px;
     color: var(--encre-2); margin: 0 0 16px; }

/* ------------------------------------------------------------- saisie */

.ligne { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > label { font-size: 13px; font-weight: 600; color: var(--encre-2); }

input[type="date"], input[type="text"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: #fdfcfa;
  min-width: 120px;
}

input:focus { outline: 2px solid var(--bleu); outline-offset: 1px; }

.boutons-ref { display: flex; gap: 14px; margin-bottom: 16px; }

.bouton-ref {
  flex: 1;
  font: inherit;
  text-align: left;
  padding: 16px 18px;
  border: 2px solid var(--trait);
  border-radius: var(--rayon);
  background: #fdfcfa;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.bouton-ref .nom { font-size: 19px; font-weight: 700; display: block; }
.bouton-ref .detail { font-size: 13px; color: var(--encre-2); }

.bouton-ref.choisi[data-code="BOISSON"] { border-color: var(--bleu); background: #eaf1f7; }
.bouton-ref.choisi[data-code="REPAS"] { border-color: var(--rouge); background: #f9ece9; }
.bouton-ref:disabled { opacity: 0.45; cursor: not-allowed; }

.bouton-principal {
  font: inherit; font-size: 18px; font-weight: 700;
  width: 100%;
  padding: 15px;
  border: none; border-radius: var(--rayon);
  background: var(--rouge); color: #fff;
  cursor: pointer;
}

.bouton-principal:hover { background: var(--rouge-fonce); }

.confirmation {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 600;
  display: none;
}

.confirmation.ok { display: block; background: var(--vert-clair); color: var(--vert); }
.confirmation.erreur { display: block; background: #f9e3e0; color: var(--rouge-fonce); }

/* --------------------------------------------------- liste des saisies */

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th { text-align: left; font-size: 12px; text-transform: uppercase;
     letter-spacing: 0.6px; color: var(--encre-2); padding: 8px 10px;
     border-bottom: 2px solid var(--trait); }

td { padding: 9px 10px; border-bottom: 1px solid var(--trait); vertical-align: middle; }

tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px;
         font-size: 13px; font-weight: 600; }
.badge.boisson { background: #eaf1f7; color: var(--bleu); }
.badge.repas { background: #f9ece9; color: var(--rouge); }

.actions { display: flex; gap: 6px; justify-content: flex-end; }

.actions button {
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--trait); border-radius: 7px;
  background: #fdfcfa; color: var(--encre-2);
  cursor: pointer;
}

.actions button:hover { border-color: var(--rouge); color: var(--rouge); }

.note-cellule { color: var(--encre-2); font-size: 13px; max-width: 260px;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------- dashboard */

.bande-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 16px 18px;
}

.kpi .etiquette { font-size: 12px; text-transform: uppercase;
                  letter-spacing: 0.7px; color: var(--encre-2); }
.kpi .valeur { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .sous-texte { font-size: 13px; color: var(--encre-2); margin-top: 2px; }

/* La date de fin occupe toute la ligne de la bande. */
.kpi.fin { background: var(--encre); border-color: var(--encre); color: #fff;
           grid-column: 1 / -1; }
.kpi.fin .etiquette { color: #cfcabf; }
.kpi.fin .valeur { font-size: 34px; }
.kpi.fin .sous-texte { color: #cfcabf; }

.barre-conteneur { margin-bottom: 14px; }
.barre-titre { display: flex; justify-content: space-between;
               font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.barre-titre .chiffres { color: var(--encre-2); font-weight: 500; }

.barre { height: 14px; background: #edeae3; border-radius: 99px; overflow: hidden; }
.barre > div { height: 100%; border-radius: 99px; transition: width 0.4s; }
.barre.boisson > div { background: var(--bleu); }
.barre.repas > div { background: var(--rouge); }

.graphique-conteneur { position: relative; height: 340px; }

.note-bas { font-size: 13px; color: var(--encre-2); margin-top: 10px; }

.lien-export {
  display: inline-block;
  font-weight: 600; font-size: 14px;
  color: var(--bleu); text-decoration: none;
  border: 1px solid var(--trait); border-radius: 8px;
  padding: 8px 14px; background: var(--carte);
}
.lien-export:hover { border-color: var(--bleu); }

@media (max-width: 640px) {
  .boutons-ref { flex-direction: column; }
  main { padding: 16px 12px 40px; }
  .carte { padding: 16px; }
}
