/* Inter Tight (licence SIL Open Font License 1.1), hébergée avec l'appli. */
@font-face { font-family: 'Inter Tight'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/inter-tight-latin.woff2) format('woff2'); }
/* Style « Graphite » : noir, blanc et gris, rouge seulement quand un budget est dépassé. */
:root {
  --fond: #000000;
  --carte: #111111;
  --carte2: #161616;
  --trait: #262626;
  --bord: #333333;
  --gris: #9a9a9a;
  --gris2: #ababab;
  --gris3: #bdbdbd;
  --texte: #f5f5f5;
  --rouge: #ff453a;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
a { color: var(--texte); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.gris { color: var(--gris); }
.gris2 { color: var(--gris2); }
.rouge { color: var(--rouge) !important; }
.petit { font-size: 12px; }
.moyen { font-size: 13px; }
.gras { font-weight: 600; }
.vide { color: var(--gris); font-size: 13px; padding: 14px 0; }
.cache { display: none !important; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
.ecran {
  flex: 1; width: 100%; max-width: 520px; margin: 0 auto;
  padding: calc(var(--haut) + 18px) 20px calc(var(--bas) + 96px);
}
.ecran.sansnav { padding-bottom: calc(var(--bas) + 28px); }

/* En-tête */
.entete { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.entete h1 { font-size: 20px; font-weight: 600; }
.nav-mois { display: flex; align-items: center; gap: 2px; }
.nav-mois button, .iconbtn {
  min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--gris2);
  font-size: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px;
}
.nav-mois .titre { font-size: 17px; font-weight: 600; min-width: 0; padding: 0 2px; }
.retour { min-height: 44px; display: inline-flex; align-items: center; color: var(--gris2); font-size: 15px; padding-right: 8px; }
.badge { font-size: 12px; font-weight: 600; color: var(--gris3); background: var(--trait); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.badge.blanc { background: var(--texte); color: #000; }

/* Gros chiffre */
.etiquette { font-size: 13px; color: var(--gris); }
.gros { font-size: 84px; font-weight: 300; letter-spacing: -0.06em; line-height: 0.95; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gros .unite { font-size: 36px; color: #8a8a8a; letter-spacing: 0; margin-left: 4px; }
.gros.moyen2 { font-size: 64px; }

/* Tuiles */
.tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--trait); border-bottom: 1px solid var(--trait); margin-top: 22px; }
.tuiles > * { padding: 14px 0; display: block; min-width: 0; }
.tuiles > *:first-child { border-right: 1px solid var(--trait); }
.tuiles > *:last-child { padding-left: 16px; }
.tuile-val { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Lignes de catégories avec barres segmentées */
.lignes { display: flex; flex-direction: column; padding-top: 6px; }
.ligne { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; }
.ligne-haut { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.ligne-haut .val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ligne-haut .val b { font-weight: 600; }
.ligne-haut .val span { color: #8a8a8a; }
.segs { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 2px; }
.segs i { height: 4px; border-radius: 1px; background: var(--trait); }
.segs i.on { background: var(--texte); }
.segs.rouge i.on { background: var(--rouge); }

/* Titres de sections */
.section { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 26px 0 10px; }
.section h2 { font-size: 16px; font-weight: 600; }
.aide { font-size: 12px; color: var(--gris2); line-height: 1.45; margin-top: 8px; }

/* Cartes et rangées */
.carte { background: var(--carte); border-radius: 20px; padding: 2px 16px; }
.carte.pleine { padding: 16px; }
.rangee { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; }
.carte > .rangee + .rangee, .carte > * + .rangee { border-top: 1px solid var(--trait); }
.rangee .g { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.rangee .g > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.rangee .d { white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.rangee .sous { font-size: 12px; color: var(--gris); }
a.rangee::after, .fleche::after { content: '›'; color: #6b6b6b; font-size: 20px; margin-left: 4px; }
.calc { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.calc > div { display: flex; justify-content: space-between; gap: 12px; }
.calc > div > span:first-child { color: var(--gris2); }
.calc > div > span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc .total { font-weight: 600; border-top: 1px solid var(--trait); padding-top: 8px; }
.calc .total > span:first-child { color: var(--texte); }

/* Trio VR base / estimé / réel */
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; margin-bottom: 14px; }
.trio > * { padding: 9px 4px; border-radius: 12px; background: #000; display: block; }
.trio > .actif { background: var(--trait); outline: 2px solid var(--texte); }
.trio .petit { color: var(--gris); }
.trio .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Barres de progression */
.barre { position: relative; height: 8px; background: var(--trait); border-radius: 4px; margin-top: 6px; }
.barre > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--texte); border-radius: 4px; }
.barre > b { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--gris2); }

/* Interrupteur */
.inter { flex-shrink: 0; width: 52px; height: 32px; border-radius: 16px; border: 0; padding: 3px; display: flex; justify-content: flex-start; background: var(--bord); transition: background .15s; }
.inter::before { content: ''; width: 26px; height: 26px; border-radius: 13px; background: var(--texte); transition: transform .15s; }
.inter[aria-pressed="true"] { background: var(--texte); }
.inter[aria-pressed="true"]::before { background: #000; transform: translateX(20px); }

/* Boutons */
.btn {
  min-height: 52px; padding: 0 20px; border: 0; border-radius: 16px; background: var(--texte); color: #000;
  font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn.petit { min-height: 40px; width: auto; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn2 {
  white-space: nowrap;
  min-height: 44px; padding: 0 14px; border: 1px solid var(--bord); border-radius: 12px; background: transparent; color: var(--texte);
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn2.large { white-space: normal; text-align: center; width: 100%; min-height: 52px; font-size: 15px; border-radius: 16px; }
.btn2.danger { color: var(--rouge); border-color: #4a1f1c; }
.boutons { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.lien { background: none; border: 0; color: var(--gris2); font-size: 14px; min-height: 44px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

/* Formulaires */
.champ { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.champ label, .champ .lab { font-size: 13px; color: var(--gris); }
.champ input, .champ select, .champ textarea {
  min-height: 48px; border: 1px solid var(--bord); border-radius: 12px; background: var(--carte); color: var(--texte);
  padding: 0 12px; font-size: 16px; width: 100%; -webkit-appearance: none; appearance: none;
}
.champ input[type="date"], .champ input[type="month"] { display: block; line-height: 46px; }
.champ select { background-image: linear-gradient(45deg, transparent 50%, #8a8a8a 50%), linear-gradient(135deg, #8a8a8a 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.champ input:focus, .champ select:focus { outline: 2px solid var(--texte); outline-offset: -1px; border-color: transparent; }
.deux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.montant-geant { font-size: 56px !important; font-weight: 300; letter-spacing: -0.04em; min-height: 84px !important; text-align: left; background: transparent !important; border: 0 !important; border-bottom: 1px solid var(--trait) !important; border-radius: 0 !important; padding: 0 !important; }
.montant-geant:focus { outline: none !important; border-bottom-color: var(--texte) !important; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces label { position: relative; }
.puces input { position: absolute; opacity: 0; pointer-events: none; }
.puces span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--bord); font-size: 14px; color: var(--gris3); }
.puces input:checked + span { background: var(--texte); color: #000; border-color: var(--texte); font-weight: 600; }
.puces input:focus-visible + span { outline: 2px solid var(--texte); outline-offset: 2px; }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.segment label { position: relative; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; border-radius: 12px; border: 1px solid var(--bord); background: var(--carte); font-size: 14px; padding: 0 6px; }
.segment input:checked + span { background: var(--texte); color: #000; border-color: var(--texte); font-weight: 600; }
.ligne-inter { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; margin-top: 10px; }
.erreur { color: var(--rouge); font-size: 14px; margin-top: 10px; min-height: 1em; }
.note { font-size: 13px; color: var(--gris2); line-height: 1.45; margin-top: 12px; }
.bandeau { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--carte2); border: 1px solid var(--trait); border-radius: 16px; padding: 12px 14px; margin-top: 16px; font-size: 14px; }

/* Barre de menu */
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(0,0,0,0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid #1c1c1c;
  padding: 6px 20px calc(var(--bas) + 10px);
}
.menu-in { max-width: 520px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.menu a { min-height: 48px; display: flex; align-items: center; color: #a8a8a8; font-size: 14px; padding: 0 4px; }
.menu a.actif { color: var(--texte); font-weight: 600; }
.menu a.ajout { padding: 0 20px; border-radius: 24px; background: #fff; color: #000; font-weight: 600; }

/* Écran verrouillé */
.verrou { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--haut) + 24px) 24px calc(var(--bas) + 24px); max-width: 460px; margin: 0 auto; width: 100%; }
.verrou h1 { font-size: 40px; font-weight: 300; letter-spacing: -0.04em; }
.verrou .sous { color: var(--gris); margin-top: 6px; font-size: 15px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bas) + 84px); background: var(--texte); color: #000; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; z-index: 30; max-width: calc(100% - 40px); text-align: center; }
