/* ---------- Couleurs (thème clair / sombre) ---------- */

:root {
  color-scheme: light dark;
  --fond: #fbf5ef;
  --carte: #ffffff;
  --bordure: #eee3d9;
  --texte: #2d231c;
  --texte-doux: #7d6b5e;
  --vert: #1f8a4c;
  --rouge: #c9443f;
  --erreur: #b83a35;
  --ombre: 0 12px 32px rgb(45 35 28 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #171310;
    --carte: #231d18;
    --bordure: #362d26;
    --texte: #f4ece5;
    --texte-doux: #a99a8e;
    --erreur: #ff8f87;
    --ombre: none;
  }
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--texte);
  outline-offset: 3px;
}

/* ---------- Accueil ---------- */

.accueil {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  max-width: 26rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.titre {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.cochon {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 3.5rem;
  line-height: 1;
}

.carte-montant {
  padding: 2rem 1rem;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 1.5rem;
  box-shadow: var(--ombre);
  text-align: center;
}

.libelle {
  margin: 0;
  color: var(--texte-doux);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.montant {
  margin: 0.25rem 0 0;
  font-size: clamp(2.75rem, 13vw, 4.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
  transition: opacity 0.2s;
}

.montant.chargement {
  opacity: 0.35;
}

.erreur {
  margin: 0.75rem 0 0;
  color: var(--erreur);
  font-size: 0.95rem;
}

.erreur button {
  margin-left: 0.25rem;
  padding: 0.2rem 0.75rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.bouton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 4rem;
  border-radius: 1rem;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.1s, filter 0.15s;
}

.bouton span {
  font-size: 1.4em;
  line-height: 1;
}

.bouton:hover {
  filter: brightness(1.08);
}

.bouton:active {
  transform: scale(0.97);
}

.bouton-ajouter {
  background: var(--vert);
}

.bouton-depenser {
  background: var(--rouge);
}

.synchro {
  margin: 0;
  color: var(--texte-doux);
  font-size: 0.9rem;
  text-align: center;
}

.synchro a {
  color: var(--texte);
  font-weight: 600;
}

/* ---------- Pages formulaire ---------- */

.page-formulaire {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.entete {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bordure);
}

.entete h1 {
  margin: 0;
  font-size: 1.1rem;
}

.retour {
  flex-shrink: 0;
  padding: 0.5rem 0.9rem;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--texte);
  font-weight: 600;
  text-decoration: none;
}

.page-formulaire iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}
