:root {
  --bleu: #1d4ed8;
  --bleu-clair: #eef2ff;
  --gris-fond: #f4f5f7;
  --gris-bordure: #d9dce1;
  --gris-texte: #5b616e;
  --texte: #1f2430;
  --vert: #16a34a;
  --orange: #d97706;
  --rouge: #dc2626;
  --rayon: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--gris-fond);
  color: var(--texte);
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Écran de connexion ---------- */

.ecran-centre {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.carte-connexion {
  background: #fff;
  border-radius: var(--rayon);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.carte-connexion h1 {
  font-size: 1.25rem;
  margin: 0 0 1.5rem;
  text-align: center;
}

/* ---------- Champs de formulaire ---------- */

label {
  display: block;
  font-size: 0.8rem;
  color: var(--gris-texte);
  margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gris-bordure);
  border-radius: var(--rayon);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--texte);
}

textarea {
  resize: vertical;
}

.champ {
  margin-bottom: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.bouton {
  display: inline-block;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--rayon);
  border: 1px solid var(--gris-bordure);
  background: #fff;
  color: var(--texte);
  font-size: 0.95rem;
  text-align: center;
}

.bouton-principal {
  background: var(--bleu);
  border-color: var(--bleu);
  color: #fff;
  font-weight: 600;
}

.bouton-danger {
  border-color: var(--rouge);
  color: var(--rouge);
}

.bouton-discret {
  border: none;
  background: none;
  color: var(--gris-texte);
  width: auto;
  padding: 6px 10px;
}

.erreur {
  color: var(--rouge);
  font-size: 0.85rem;
  margin-top: 8px;
}

.info {
  color: var(--gris-texte);
  font-size: 0.9rem;
}

/* ---------- Groupes de boutons (toggle) ---------- */

.groupe-toggle {
  display: flex;
  gap: 8px;
}

.groupe-toggle button {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--rayon);
  border: 1px solid var(--gris-bordure);
  background: #fff;
  color: var(--texte);
  font-size: 0.9rem;
}

.groupe-toggle button.actif {
  background: var(--bleu-clair);
  border-color: var(--bleu);
  color: var(--bleu);
  font-weight: 600;
}

/* ---------- En-tête / navigation ---------- */

.entete {
  background: #fff;
  border-bottom: 1px solid var(--gris-bordure);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.entete-titre {
  font-weight: 600;
}

.entete-utilisateur {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--gris-texte);
}

.conteneur {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Liste des bons ---------- */

.barre-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.barre-actions select {
  width: auto;
}

.barre-actions .bouton-principal {
  width: auto;
  margin-left: auto;
}

.ligne-bon {
  display: block;
  background: #fff;
  border: 1px solid var(--gris-bordure);
  border-radius: var(--rayon);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.ligne-principale {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.numero {
  font-weight: 600;
}

.ligne-details {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--gris-texte);
}

.badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.badge-brouillon { background: #f1f2f4; color: var(--gris-texte); }
.badge-en_cours { background: #fef3c7; color: var(--orange); }
.badge-signe { background: #dcfce7; color: var(--vert); }
.badge-archive { background: #e5e7eb; color: var(--gris-texte); }

/* ---------- Formulaire du bon ---------- */

.entete-bon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.entete-bon .numero-bon {
  font-size: 1.1rem;
  font-weight: 600;
}

.carte {
  background: #fff;
  border: 1px solid var(--gris-bordure);
  border-radius: var(--rayon);
  padding: 20px;
  margin-bottom: 16px;
}

.carte h2 {
  font-size: 0.95rem;
  margin: 0 0 14px;
}

.grille-champs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .grille-champs {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  .grille-champs .pleine-largeur {
    grid-column: 1 / -1;
  }
}

.zone-signature {
  border: 1px dashed var(--gris-bordure);
  border-radius: var(--rayon);
  background: #fafafa;
  touch-action: none;
}

.zone-signature canvas {
  width: 100%;
  height: 150px;
  display: block;
}

.signature-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

.signature-statut {
  font-size: 0.8rem;
  color: var(--vert);
}

.actions-bas {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.actions-bas > * {
  flex: 1;
  min-width: 160px;
}
