:root {
  color-scheme: light dark;
  --fond: #f4f5f7;
  --carte: #ffffff;
  --texte: #14181f;
  --discret: #5c6470;
  --bord: #e2e5ea;
  --accent: #0f172a;
  --positif: #10704a;
  --negatif: #a4232b;
  --alerte-fond: #fdf2e2;
  --alerte-bord: #e8b862;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0d1117;
    --carte: #161b22;
    --texte: #e6edf3;
    --discret: #9aa4b2;
    --bord: #262d38;
    --accent: #e6edf3;
    --positif: #56d39a;
    --negatif: #ff7b72;
    --alerte-fond: #2b2113;
    --alerte-bord: #7a5a21;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  background: var(--carte);
  border-bottom: 1px solid var(--bord);
  position: sticky;
  top: 0;
  z-index: 10;
}

.marque { font-weight: 650; letter-spacing: -0.01em; }

.lien {
  background: none;
  border: none;
  color: var(--discret);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem;
  text-decoration: underline;
}
.lien:hover { color: var(--texte); }

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; letter-spacing: -0.01em; text-transform: capitalize; }
h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--discret);
  margin: 1.5rem 0 0.5rem;
}

.chiffres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
}
.chiffres > div {
  border: 1px solid var(--bord);
  border-radius: 9px;
  padding: 0.6rem 0.75rem;
}
.etiquette {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--discret);
  margin-bottom: 0.2rem;
}
.chiffres strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.positif { color: var(--positif); }
.negatif { color: var(--negatif); }

.soldes { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.solde strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--bord); }
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--discret);
  font-weight: 600;
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.depasse { color: var(--negatif); font-weight: 600; }
.vide { color: var(--discret); font-size: 0.9rem; margin: 0.25rem 0; }

.alerte {
  background: var(--alerte-fond);
  border: 1px solid var(--alerte-bord);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

details { margin-top: 1.25rem; }
summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--discret);
  padding: 0.4rem 0;
}
.operations { margin-top: 0.5rem; }
.operations .date { color: var(--discret); font-size: 0.8rem; white-space: nowrap; }
.categorie {
  display: block;
  font-size: 0.72rem;
  color: var(--discret);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.connexion {
  max-width: 22rem;
  margin: 12vh auto 0;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 1.75rem;
}
.connexion form { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-size: 0.82rem; color: var(--discret); margin-top: 0.6rem; }
input[type="text"], input[type="password"] {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--bord);
  border-radius: 8px;
  background: var(--fond);
  color: var(--texte);
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.case {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.9rem 0 0.3rem;
  font-size: 0.9rem;
  color: var(--texte);
}
button[type="submit"], .bouton {
  margin-top: 0.9rem;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--carte);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.erreur {
  background: var(--alerte-fond);
  border: 1px solid var(--negatif);
  color: var(--negatif);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
}

.pied { color: var(--discret); font-size: 0.8rem; text-align: center; }

@media (max-width: 30rem) {
  .operations .date { font-size: 0.72rem; }
  table { font-size: 0.86rem; }
  th, td { padding: 0.4rem 0.3rem; }
}

.banque .ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.banque form { margin: 0; }
.banque button[type="submit"], .banque .bouton { margin-top: 0; }
.etat { font-size: 0.88rem; color: var(--discret); }
.alerte-texte { color: var(--negatif); }
.avis {
  background: var(--alerte-fond);
  border: 1px solid var(--alerte-bord);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
}

.comptes { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.comptes li { padding: 0.35rem 0; border-bottom: 1px solid var(--bord); font-size: 0.92rem; }
.comptes li:last-child { border-bottom: none; }
.etiquette-en-ligne { color: var(--discret); font-variant-numeric: tabular-nums; }
