/* Mon budget — lumineux, doux, girly, lisible (contrastes AA, textes ≥ 16 px) */
:root {
  --rose: #c2185b;          /* texte/accents sur blanc : 5,9:1 */
  --rose-vif: #e84a8a;
  --rose-doux: #ffd6e7;
  --rose-pale: #fff0f6;
  --lavande: #6f42c1;       /* 6,6:1 */
  --lavande-doux: #e9defd;
  --peche: #ffb38a;
  --peche-doux: #ffe8da;
  --menthe: #0f7a5c;        /* positif : 5,4:1 */
  --menthe-doux: #d4f5ea;
  --corail: #c62b3c;        /* négatif : 5,6:1 */
  --corail-doux: #ffe1e4;
  --ambre: #8a5a00;
  --ambre-doux: #fff1cc;
  --encre: #3a2342;         /* texte principal : 12:1 */
  --encre-2: #6b5470;       /* texte secondaire : 6,3:1 */
  --ligne: #f0dbe6;
  --carte: #ffffff;
  --fond: #fff7fb;
  --ombre: 0 10px 30px -12px rgba(194, 24, 91, .22), 0 2px 6px rgba(111, 66, 193, .06);
  --ombre-forte: 0 22px 50px -18px rgba(194, 24, 91, .38);
  --rayon: 24px;
  --rayon-s: 14px;
  --degrade: linear-gradient(135deg, #ff8fb8 0%, #f06aa4 35%, #b388f5 100%);
  --degrade-fonce: linear-gradient(135deg, #c8256f 0%, #b0339a 50%, #7445cc 100%); /* texte blanc ≥ 4,8:1 */
  --degrade-doux: linear-gradient(135deg, #fff0f6 0%, #f5eeff 55%, #fff3ea 100%);
  --police: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --nav-h: 76px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--police); font-size: 17px; line-height: 1.55; color: var(--encre);
  background: var(--fond);
  background-image:
    radial-gradient(1200px 600px at 110% -10%, #ffe0ee 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 10%, #efe4ff 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 120%, #ffeadd 0%, transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--rose); text-underline-offset: 3px; }
small, .petit { font-size: .9rem; color: var(--encre-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

:focus-visible { outline: 3px solid var(--lavande); outline-offset: 3px; border-radius: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.cote {
  position: sticky; top: 0; height: 100vh; padding: 28px 18px; display: flex; flex-direction: column; gap: 6px;
  background: rgba(255, 255, 255, .6); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--ligne);
}
.logo { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; font-weight: 800; font-size: 1.25rem; color: var(--encre); text-decoration: none; }
.logo .pastille { width: 44px; height: 44px; border-radius: 15px; background: var(--degrade); display: grid; place-items: center; color: #fff; font-size: 1.4rem; box-shadow: var(--ombre); }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; color: var(--encre);
  text-decoration: none; font-weight: 650; transition: background .2s, color .2s, transform .2s;
}
.nav a .ico { font-size: 1.25rem; width: 28px; text-align: center; }
.nav a:hover { background: var(--rose-pale); }
.nav a[aria-current="page"] { background: var(--carte); color: var(--rose); box-shadow: var(--ombre); }
.nav .badge { margin-left: auto; }
.cote .bas { margin-top: auto; font-size: .9rem; color: var(--encre-2); padding: 10px 14px; }

main { padding: 32px clamp(16px, 4vw, 48px) 60px; max-width: 1240px; width: 100%; min-width: 0; }
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.entete p { color: var(--encre-2); margin: 0; }

/* Barre du bas (mobile) */
.barre { display: none; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .cote { display: none; }
  main { padding: 20px 16px calc(var(--nav-h) + 34px + env(safe-area-inset-bottom)); }
  .barre {
    display: flex; position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    height: var(--nav-h); border-radius: 26px; padding: 8px; justify-content: space-around; align-items: center;
    background: rgba(255, 255, 255, .86); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--ombre-forte); border: 1px solid rgba(255, 255, 255, .9);
  }
  .barre a, .barre button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none;
    color: var(--encre-2); font: 650 .78rem/1.1 var(--police); background: none; border: 0; padding: 6px 0; border-radius: 18px;
  }
  .barre .ico { font-size: 1.45rem; }
  .barre a[aria-current="page"] { color: var(--rose); }
  .barre .central { flex: 0 0 64px; }
  .barre .central .rond {
    width: 58px; height: 58px; border-radius: 22px; background: var(--degrade-fonce); color: #fff; display: grid; place-items: center;
    font-size: 1.7rem; box-shadow: var(--ombre-forte); margin-top: -26px; border: 4px solid #fff;
  }
}

/* ---------- Cartes ---------- */
.grille { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

.carte {
  background: var(--carte); border-radius: var(--rayon); padding: 22px; box-shadow: var(--ombre);
  border: 1px solid rgba(240, 219, 230, .7); min-width: 0;
  animation: monte .45s cubic-bezier(.2, .8, .2, 1) both;
}
.carte + .carte, .grille + .carte, .carte + .grille, .grille + .grille { margin-top: 18px; }
.grille > .carte { margin-top: 0; }
.carte-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.carte-titre h2, .carte-titre h3 { margin: 0; }

.heros {
  background: var(--degrade-fonce); color: #fff; border: 0; position: relative; overflow: hidden; padding: 28px;
  box-shadow: var(--ombre-forte);
}
.heros::after {
  content: ""; position: absolute; width: 340px; height: 340px; right: -90px; top: -120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.35), rgba(255,255,255,0) 70%);
}
.heros .etiquette { font-weight: 700; opacity: .95; }
.heros .gros { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 10px; }
.heros p { color: #fff; opacity: .95; }
.heros .ligne-mini { display: flex; gap: 22px; flex-wrap: wrap; position: relative; z-index: 1; }
.heros .ligne-mini div { font-weight: 650; }
.heros .ligne-mini strong { display: block; font-size: 1.15rem; }

.tuile { padding: 18px; }
.tuile .etiquette { font-size: .92rem; color: var(--encre-2); font-weight: 650; display: flex; gap: 8px; align-items: center; }
.tuile .valeur { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 800; margin-top: 4px; letter-spacing: -.01em; }
.tuile .sous { font-size: .9rem; color: var(--encre-2); }
.tuile .ico { width: 34px; height: 34px; border-radius: 12px; display: inline-grid; place-items: center; font-size: 1.05rem; }
.t-rose .ico { background: var(--rose-doux); } .t-lav .ico { background: var(--lavande-doux); }
.t-peche .ico { background: var(--peche-doux); } .t-menthe .ico { background: var(--menthe-doux); }

/* ---------- Boutons, pastilles, champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 20px;
  border-radius: 999px; border: 0; font: 700 1rem/1.2 var(--police); cursor: pointer; text-decoration: none;
  background: var(--degrade-fonce); color: #fff; box-shadow: 0 8px 20px -8px rgba(194, 24, 91, .6);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-1px); filter: saturate(1.1); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.doux { background: var(--rose-pale); color: var(--rose); box-shadow: none; border: 1.5px solid var(--rose-doux); }
.btn.blanc { background: #fff; color: var(--rose); box-shadow: var(--ombre); }
.btn.fantome { background: transparent; color: var(--encre-2); box-shadow: none; }
.btn.danger { background: var(--corail-doux); color: var(--corail); box-shadow: none; }
.btn.petit { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-icone { width: 42px; height: 42px; border-radius: 14px; border: 0; background: var(--rose-pale); color: var(--rose); font-size: 1.1rem; cursor: pointer; display: inline-grid; place-items: center; }
.btn-icone:hover { background: var(--rose-doux); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: var(--rose-pale); color: var(--rose); white-space: nowrap; }
.badge.lav { background: var(--lavande-doux); color: var(--lavande); }
.badge.ok { background: var(--menthe-doux); color: var(--menthe); }
.badge.ko { background: var(--corail-doux); color: var(--corail); }
.badge.ambre { background: var(--ambre-doux); color: var(--ambre); }
.badge.gris { background: #f3eef4; color: var(--encre-2); }

label { font-weight: 650; display: block; margin-bottom: 6px; }
.champ { margin-bottom: 14px; }
.champ .aide { font-size: .88rem; color: var(--encre-2); margin-top: 4px; font-weight: 400; }
input, select, textarea {
  font: 500 1rem/1.3 var(--police); color: var(--encre); width: 100%; min-height: 46px; padding: 10px 14px;
  border-radius: var(--rayon-s); border: 1.5px solid var(--ligne); background: #fff; transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--rose-vif); box-shadow: 0 0 0 4px rgba(232, 74, 138, .15); outline: none; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--rose); }
select { appearance: none; -webkit-appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none'%3E%3Cpath stroke='%23c2185b' stroke-width='2' stroke-linecap='round' d='m1 1.5 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.select-pastille { min-height: 38px; padding: 5px 34px 5px 12px; border-radius: 999px; font-size: .92rem; font-weight: 650; width: auto; max-width: 100%; background-color: var(--rose-pale); border-color: transparent; }
.select-pastille.aclasser { background-color: var(--ambre-doux); color: var(--ambre); }
.champs-ligne { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }

/* ---------- Barres de progression ---------- */
.barre-p { height: 12px; border-radius: 99px; background: #f6e8f0; overflow: hidden; position: relative; }
.barre-p > span { display: block; height: 100%; border-radius: 99px; background: var(--degrade); width: 0; animation: remplit .9s cubic-bezier(.2, .8, .2, 1) forwards; }
.barre-p.depasse > span { background: linear-gradient(90deg, #ff8a8a, #c62b3c); }
.barre-p.estime > span { background: repeating-linear-gradient(45deg, #f2b8d2 0 8px, #f7cfe1 8px 16px); }
@keyframes remplit { from { width: 0; } to { width: var(--w); } }
@keyframes monte { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Listes de postes ---------- */
.postes { display: flex; flex-direction: column; }
.poste { display: grid; grid-template-columns: 42px 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--ligne); text-decoration: none; color: inherit; border-radius: 12px; }
.poste:last-child { border-bottom: 0; }
a.poste:hover { background: var(--rose-pale); }
.poste .emo { width: 42px; height: 42px; border-radius: 14px; background: var(--degrade-doux); display: grid; place-items: center; font-size: 1.25rem; grid-row: span 3; align-self: start; }
.poste .nom { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.poste .montants { text-align: right; font-weight: 700; }
.poste .barre-p { grid-column: 2 / 4; height: 9px; }
.poste .reste { font-size: .88rem; font-weight: 600; }
.pos { color: var(--menthe); } .neg { color: var(--corail); }

/* ---------- Opérations ---------- */
.ops { display: flex; flex-direction: column; }
.jour { font-size: .92rem; font-weight: 750; color: var(--encre-2); padding: 16px 4px 6px; }
.jour::first-letter { text-transform: uppercase; }
.op { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 12px; border-radius: 16px; background: #fff; border: 1px solid var(--ligne); margin-bottom: 8px; }
.op .lib { font-weight: 650; overflow-wrap: anywhere; }
.op .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; grid-column: 1 / 3; }
.op .mt { font-weight: 800; font-size: 1.05rem; text-align: right; }
.op.nouveau { animation: eclat 1.2s ease; }
@keyframes eclat { 0% { background: var(--rose-doux); } 100% { background: #fff; } }

.filtres { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 8px; }
.puces { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.puce { border: 1.5px solid var(--ligne); background: #fff; color: var(--encre); border-radius: 999px; padding: 7px 14px; font: 650 .92rem var(--police); cursor: pointer; }
.puce[aria-pressed="true"] { background: var(--encre); color: #fff; border-color: var(--encre); }

/* ---------- Import ---------- */
.depot {
  border: 2.5px dashed #f2b3cf; border-radius: var(--rayon); padding: 38px 20px; text-align: center; background: var(--degrade-doux);
  cursor: pointer; transition: transform .2s, border-color .2s, background .2s; display: block;
}
.depot:hover, .depot.survol { border-color: var(--rose-vif); transform: scale(1.01); }
.depot .gros-ico { font-size: 2.8rem; display: block; margin-bottom: 6px; }
.depot strong { font-size: 1.15rem; display: block; }
.depot input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.tableau-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .98rem; }
th { text-align: left; font-size: .88rem; color: var(--encre-2); font-weight: 750; padding: 10px 10px; border-bottom: 1.5px solid var(--ligne); white-space: nowrap; background: #fff; }
td { padding: 9px 10px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
tr.exclu td { opacity: .45; }
tr.incertain td { background: #fffaf0; }
td.droite, th.droite { text-align: right; }
.tableau-annee th:first-child, .tableau-annee td:first-child { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 210px; }
.tableau-annee tr.groupe td { background: var(--rose-pale); font-weight: 800; color: var(--rose); }
.tableau-annee tr.total td { font-weight: 800; }

/* ---------- Anneau ---------- */
.anneau { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; position: relative; z-index: 1; background: rgba(255,255,255,.12); }
.anneau::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.28) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px)); }
.anneau span { position: relative; font-weight: 800; font-size: 1.5rem; text-align: center; line-height: 1.1; }
.anneau small { display: block; font-size: .78rem; color: #fff; font-weight: 650; }
.heros-flex { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; position: relative; z-index: 1; }

/* ---------- Graphique mois ---------- */
.graph { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(2px, 1vw, 8px); align-items: end; height: 190px; padding-top: 10px; }
.graph .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.graph .barres { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.graph .b { width: 42%; max-width: 18px; border-radius: 8px 8px 4px 4px; min-height: 3px; transform-origin: bottom; animation: pousse .8s cubic-bezier(.2,.8,.2,1) both; }
.graph .b.rev { background: linear-gradient(180deg, #b388f5, #8b5cf6); }
.graph .b.dep { background: linear-gradient(180deg, #ff9cc2, #e84a8a); }
.graph .m { font-size: clamp(.62rem, 2.4vw, .8rem); color: var(--encre-2); font-weight: 650; }
@keyframes pousse { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.legende { display: flex; gap: 16px; font-size: .9rem; color: var(--encre-2); }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Alerte / info ---------- */
.info { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: 18px; background: var(--lavande-doux); color: #3d2370; }
.info.ambre { background: var(--ambre-doux); color: #5c3c00; }
.info.rose { background: var(--rose-pale); color: #7a1040; }
.info .ico { font-size: 1.4rem; line-height: 1; }
.info p:last-child { margin: 0; }

/* ---------- Nav mois ---------- */
.nav-mois { display: inline-flex; align-items: center; gap: 6px; background: #fff; border-radius: 999px; padding: 5px; box-shadow: var(--ombre); }
.nav-mois strong { min-width: 150px; text-align: center; font-size: 1.05rem; }
.nav-mois .btn-icone { border-radius: 999px; }

/* ---------- Enveloppes ---------- */
.enveloppe { position: relative; overflow: hidden; }
.enveloppe .emo-grand { font-size: 2rem; width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; background: var(--degrade-doux); margin-bottom: 10px; }

/* ---------- Fenêtre modale ---------- */
dialog { border: 0; border-radius: 28px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--ombre-forte); color: var(--encre); }
dialog::backdrop { background: rgba(58, 35, 66, .35); backdrop-filter: blur(4px); }
dialog[open] { animation: pop .3s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-corps { padding: 26px; overflow-y: auto; max-height: calc(100vh - 40px); }
.modal-corps .actions { justify-content: flex-end; margin-top: 18px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 30px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 24px)); }
@media (min-width: 861px) { #toasts { bottom: 28px; } }
.toast { background: var(--encre); color: #fff; padding: 14px 18px; border-radius: 18px; box-shadow: var(--ombre-forte); font-weight: 600; animation: monte .3s both; display: flex; gap: 10px; align-items: center; }

.vide { text-align: center; padding: 34px 16px; color: var(--encre-2); }
.vide .gros-ico { font-size: 2.6rem; display: block; margin-bottom: 8px; }
hr { border: 0; border-top: 1px solid var(--ligne); margin: 18px 0; }
details > summary { cursor: pointer; font-weight: 700; color: var(--rose); padding: 6px 0; }
.colonne-droite { text-align: right; }
.vue { animation: fondu .35s ease both; }
@keyframes fondu { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
