/* ============================================================
   BudgetÉtudiant — styles
   Parti pris : un carnet de comptes moderne, tout en orange. Les
   montants sont composés en chiffres à chasse fixe (effet « grand
   livre »), une rampe de tons chauds distingue les catégories.
   Aucune ressource externe : polices système uniquement.
   ============================================================ */

:root {
  --paper:      #F5F4EF;
  --carte:      #FFFFFF;
  --ink:        #211A14;
  --muted:      #6F665E;
  --ligne:      #E7E1D6;

  --orange:       #D9650F;   /* primaire */
  --orange-fonce: #B0500A;   /* survol    */
  --orange-clair: #FAE8D6;   /* halo focus / fond de piste */
  --ambre:        #9C4710;   /* accent foncé (intitulés)   */
  --ambre-clair:  #F6E6D3;
  --rouge:        #B23A3A;   /* erreurs / suppression */

  --r:          14px;
  --r-sm:       9px;
  --ombre:      0 1px 2px rgba(26, 30, 27, .05), 0 8px 24px rgba(26, 30, 27, .06);

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 100% -10%, #FBFAF6 0%, rgba(251,250,246,0) 60%),
    var(--paper);
  line-height: 1.5;
  min-height: 100vh;
}

.lien-evitement {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 10;
}
.lien-evitement:focus { left: 0; }

/* ---------- En-tête + héro ---------- */
.entete {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
}

.entete__marque { display: flex; align-items: center; gap: .85rem; }

.entete__logo {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  background: var(--orange);
  color: #fff;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  box-shadow: var(--ombre);
}

.entete__nom { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }
.entete__sous { margin: .1rem 0 0; color: var(--muted); font-size: .9rem; }

.hero { text-align: right; }
.hero__label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .72rem;
  font-weight: 600;
  color: var(--ambre);
}
.hero__montant {
  margin: .1rem 0;
  font-family: var(--mono);
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hero__montant.est-negatif { color: var(--rouge); }
.hero__detail {
  margin: .2rem 0 0;
  display: flex;
  gap: 1.1rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .85rem;
}
.hero__poste { display: inline-flex; align-items: center; gap: .4rem; }
.hero__poste b {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.hero__pastille { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.hero__pastille--rec { background: var(--orange); }
.hero__pastille--dep { background: var(--ink); }
.hero__compte { margin: .25rem 0 0; color: var(--muted); font-size: .8rem; }

/* ---------- Bandeau mois ---------- */
.mois {
  max-width: 1080px;
  margin: .5rem auto 0;
  padding: 0 1.25rem;
}
.mois__liste {
  list-style: none;
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .25rem 0 .75rem;
  margin: 0;
  scrollbar-width: thin;
}
.mois__chip {
  flex: 0 0 auto;
  border: 1px solid var(--ligne);
  background: var(--carte);
  border-radius: 999px;
  padding: .45rem .85rem;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
  color: var(--muted);
  display: flex;
  gap: .5rem;
  align-items: baseline;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.mois__chip:hover { border-color: var(--orange); color: var(--ink); }
.mois__chip[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.mois__chip-total {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: inherit;
}
.mois__chip[aria-pressed="true"] .mois__chip-total { color: #fff; }

/* ---------- Grille principale ---------- */
.grille {
  max-width: 1080px;
  margin: .5rem auto 0;
  padding: 0 1.25rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.colonne-analyse { display: grid; gap: 1.25rem; }

.carte {
  background: var(--carte);
  border: 1px solid var(--ligne);
  border-radius: var(--r);
  padding: 1.25rem;
  box-shadow: var(--ombre);
}
.carte--saisie { position: sticky; top: 1rem; }

.carte__titre {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.carte__titre--liste { margin-bottom: .5rem; }

/* ---------- Formulaire ---------- */
.seg {
  display: flex;
  gap: .35rem;
  background: var(--paper);
  border: 1px solid var(--ligne);
  border-radius: var(--r-sm);
  padding: .25rem;
  margin-bottom: 1.1rem;
}
.seg__btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: .5rem .4rem;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-pressed="true"] { background: var(--orange); color: #fff; }
.seg__btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.champ { margin-bottom: 1rem; }
.champ label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .35rem;
}

input, select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--ligne);
  border-radius: var(--r-sm);
  padding: .65rem .8rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-clair);
}

.champ__montant { position: relative; }
.champ__montant input {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  padding-right: 2.2rem;
}
.champ__unite {
  position: absolute;
  right: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-family: var(--mono);
  pointer-events: none;
}

.erreur {
  margin: 0 0 .9rem;
  color: var(--rouge);
  font-size: .85rem;
  background: #FBE9E8;
  border: 1px solid #F1C7C4;
  border-radius: var(--r-sm);
  padding: .55rem .7rem;
}

.btn {
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--r-sm);
  padding: .75rem 1rem;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn--principal {
  width: 100%;
  background: var(--orange);
  color: #fff;
}
.btn--principal:hover { background: var(--orange-fonce); }
.btn--principal:active { transform: translateY(1px); }

/* ---------- Barre de filtres ---------- */
.barre-filtres {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filtres { display: flex; gap: 1rem; flex-wrap: wrap; }
.filtre { display: flex; align-items: center; gap: .5rem; }
.filtre label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}
.filtre select { width: auto; min-width: 130px; padding: .5rem .7rem; }
.filtre select:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Graphique (barres horizontales) ---------- */
.graphique { display: grid; gap: .7rem; }
.barre {
  display: grid;
  grid-template-columns: 132px 1fr auto;
  align-items: center;
  gap: .75rem;
}
.barre__nom {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pastille {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.barre__piste {
  background: var(--paper);
  border-radius: 6px;
  height: 22px;
  overflow: hidden;
}
.barre__rempli {
  height: 100%;
  border-radius: 6px;
  min-width: 3px;
  transition: width .35s ease;
}
.barre__val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* ---------- Liste des dépenses ---------- */
.liste { list-style: none; margin: 0; padding: 0; }
.ligne {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: .75rem;
  padding: .7rem 0;
  border-top: 1px solid var(--ligne);
}
.liste .ligne:first-child { border-top: none; }

.ligne__date {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.ligne__cat { display: flex; align-items: center; gap: .5rem; font-size: .92rem; min-width: 0; }
.ligne__cat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne__montant {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.ligne__montant.est-recette { color: var(--orange); }
.ligne__montant.est-depense { color: var(--ink); }
.mois__chip-total.est-negatif { color: var(--rouge); }
.ligne__suppr {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: .25rem .4rem;
  border-radius: 6px;
}
.ligne__suppr:hover { color: var(--rouge); background: #FBE9E8; }
.ligne__suppr:focus-visible { outline: 2px solid var(--rouge); outline-offset: 1px; }

.vide { color: var(--muted); font-size: .9rem; padding: .5rem 0; }

/* ---------- Pied ---------- */
.pied {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grille { grid-template-columns: 1fr; }
  .carte--saisie { position: static; }
  .entete { align-items: flex-start; }
  .hero { text-align: left; }
  .hero__detail { justify-content: flex-start; }
  .barre { grid-template-columns: 112px 1fr auto; gap: .5rem; }
  .barre__nom { font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
