/* Layout : panneau de navigation vert émeraude à gauche, contenu sur fond blanc.
   Thème unique vert et blanc, choisi volontairement : pas de variante sombre. */
:root {
  color-scheme: light;
  /* Marque */
  --brand: #50C878;        /* vert émeraude */
  --brand-ink: #0B3D22;    /* texte posé sur l'émeraude */
  --brand-deep: #177A43;   /* émeraude assez foncé pour du texte sur blanc */
  --tint: #EEF9F2;         /* fond vert très clair */
  --tint-line: #CDEBD8;
  /* Neutres teintés de vert */
  --page: #FFFFFF;
  --surface: #FFFFFF;
  --sunken: #EEF3F0;
  --ink: #12261B;
  --muted: #5B6B62;
  --line: #DDE7E1;
  /* Catégories : une famille de verts aux teintes distinctes */
  --revenu: #3E5A4B;
  --fixe: #0F5C36;         /* vert forêt */
  --variable: #50C878;     /* émeraude */
  --invest: #1C9A86;       /* vert sarcelle */
  --objectif: #6E8F12;     /* vert olive */
  --libre: #D3EADB;
  /* États */
  --alerte: #C7372F;
  --warn: #B86E0B;
  --ok: #177A43;
  --f-display: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  margin: 0;
  background: var(--page); color: var(--ink);
  font: 15px/1.55 var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 600; }
.sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand); color: var(--brand-ink); }
[hidden] { display: none !important; }

/* Boutons */
.btn-primary, .btn-ghost, .btn-danger { border-radius: 8px; padding: 9px 14px; font-weight: 600; font-size: 14px; }
.btn-primary { border: 0; background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 85%, var(--brand-ink)); }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { background: var(--tint); border-color: var(--tint-line); }
.btn-danger { border: 1px solid color-mix(in srgb, var(--alerte) 40%, transparent); background: none; color: var(--alerte); }
.btn-danger:hover, .btn-danger.armed { background: var(--alerte); color: var(--surface); }
.add-btn { border: 1.5px solid var(--brand); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; color: var(--ink); }
.add-btn:hover { border-color: var(--brand-deep); background: var(--tint); }
.icon-btn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: var(--tint); color: var(--brand-deep); }

:root { --rail-w: 244px; }
/* Le contenu se place juste à droite du menu fixe (24 px d'écart), sans être recentré sur grand écran */
.app { display: grid; grid-template-columns: minmax(0, 1fr); padding-block: 20px 64px; padding-left: calc(var(--rail-w) + 24px - max(16px, env(safe-area-inset-left, 0px))); }
.app > main { width: 100%; max-width: 1240px; justify-self: start; }

/* Panneau de navigation émeraude, collé à gauche sur toute la hauteur de l'écran.
   Il défile seul, sans entraîner la page (et inversement). */
.rail {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 10;
  width: var(--rail-w); height: 100vh; height: 100dvh;
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgb(11 61 34 / .35) transparent;
  display: flex; flex-direction: column; gap: 28px;
  background: var(--brand); color: var(--brand-ink);
  border-radius: 0 18px 18px 0;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 14px calc(env(safe-area-inset-bottom, 0px) + 20px) calc(env(safe-area-inset-left, 0px) + 14px);
}
.rail > * { flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; }
.brand .rail-close { margin-left: auto; }
.rail-close, .menu-btn { display: none; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgb(255 255 255 / .28); color: var(--brand-ink); font-size: 24px; line-height: 1; }
.rail-close:hover, .menu-btn:hover { background: rgb(255 255 255 / .45); }

/* Barre du haut et fond assombri : seulement sur mobile */
.mbar { display: none; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 20; align-items: center; gap: 12px; background: var(--brand); color: var(--brand-ink); border-radius: 14px; padding: 8px 14px 8px 8px; box-shadow: 0 2px 8px rgb(11 61 34 / .12); }
.mbar .menu-btn { display: grid; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(11 61 34 / .4); }
body.menu-open { overflow: hidden; }
.brand .logo { display: block; width: 140px; height: auto; margin: -6px auto -4px; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--brand-ink); text-decoration: none; font-weight: 500; }
.rail a:hover { background: rgb(255 255 255 / .28); }
.rail a[aria-current] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 2px rgb(11 61 34 / .12); }
.nav-custom { display: contents; }
.nav-add { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 10px; border: 1.5px dashed rgb(11 61 34 / .35); border-radius: 10px; background: none; color: var(--brand-ink); font-weight: 500; text-align: left; }
.nav-add span { font-size: 18px; line-height: 1; font-weight: 600; }
.nav-add:hover { background: rgb(255 255 255 / .28); border-color: rgb(11 61 34 / .55); }
.add-btn.tab-edit { border-color: var(--line); color: var(--muted); }
.add-btn.tab-edit:hover { border-color: var(--alerte); color: var(--alerte); background: none; }
.tools { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; border-top: 1px solid rgb(11 61 34 / .2); padding: 16px 10px 0; }
.tools .eyebrow { color: var(--brand-ink); opacity: .75; }
.tools button { border: 0; background: none; padding: 3px 0; color: var(--brand-ink); font-size: 13.5px; font-weight: 500; text-decoration: underline; text-decoration-color: rgb(11 61 34 / .3); text-underline-offset: 3px; }
.tools button:hover { text-decoration-color: var(--brand-ink); }
.tools .sub { margin: 6px 0 0; color: var(--brand-ink); opacity: .8; }
.account { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid rgb(11 61 34 / .2); width: 100%; }
.acc-mail { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.sync { font-size: 12.5px; opacity: .8; }
.tools .btn-signout { width: 100%; margin-top: 14px; padding: 10px 14px; border: 0; border-radius: 10px; background: var(--alerte); color: var(--surface); font-size: 14px; font-weight: 600; text-decoration: none; }
.tools .btn-signout:hover { background: color-mix(in srgb, var(--alerte) 85%, black); }

/* Connexion */
.auth { min-height: 100dvh; display: grid; place-items: center; padding-block: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--brand); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgb(11 61 34 / .08); }
.auth-logo { display: block; width: 120px; height: 120px; margin: 0 auto 4px; }
.auth h1 { font-size: 22px; }
.auth-lede { margin: 0; color: var(--muted); }
#auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
#auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
#auth-form input { background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; color: var(--ink); width: 100%; }
#auth-submit { padding-block: 11px; }
#auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-ok { margin: 0; color: var(--ok); font-size: 13px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.auth-links:empty { display: none; }
.auth-links button { border: 0; background: none; padding: 2px 0; color: var(--brand-deep); font-size: 13.5px; font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand-deep) 35%, transparent); text-underline-offset: 3px; }
.auth-links button:hover { text-decoration-color: var(--brand-deep); }

main { display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.empty.swap { animation: swap .25s ease; }
@keyframes swap { from { opacity: .35; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; background: var(--tint); border: 1px solid var(--tint-line); border-radius: 12px; padding: 14px 18px; }
.banner p { margin: 0; max-width: 65ch; font-size: 14px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* En-tête */
.top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.top h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.1; }
.month-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.month { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.month button { border: 0; background: none; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; line-height: 1; }
.month button:hover { background: var(--tint); color: var(--brand-deep); }
.month { position: relative; }
.month .m-pick-btn { width: auto; height: 34px; border-radius: 999px; padding: 0 12px; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-width: 11ch; justify-content: center; }
.m-pick-btn .caret { font-size: 11px; color: var(--muted); transition: transform .15s ease; }
.m-pick-btn[aria-expanded="true"] { background: var(--tint); color: var(--brand-deep); }
.m-pick-btn[aria-expanded="true"] .caret { transform: rotate(180deg); color: var(--brand-deep); }

/* Calendrier des mois */
.mpick { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: min(296px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 36px rgb(11 61 34 / .16); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.mpick-head { display: flex; align-items: center; justify-content: space-between; }
.mpick-head b { font-family: var(--f-display); font-size: 19px; font-variant-numeric: tabular-nums; }
.mpick .mpick-head button { width: 34px; height: 34px; }
.mpick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.month .mcell { position: relative; width: auto; height: 42px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 500; }
.month .mcell:hover { background: var(--tint); color: var(--brand-deep); }
.mcell.has::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--brand); }
.mcell.today { border-color: var(--brand); color: var(--brand-deep); font-weight: 600; }
.month .mcell[aria-current="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 600; border-color: var(--brand); }
.mcell[aria-current="true"].has::after { background: var(--brand-ink); }
.mpick-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.mpick-foot .key { display: inline-flex; align-items: center; gap: 6px; }
.mpick-foot .key::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.month .mpick-foot button { width: auto; height: auto; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; color: var(--brand-deep); }

.empty { background: var(--surface); border: 1.5px dashed var(--tint-line); border-radius: 14px; padding: 32px 24px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.empty h2 { font-size: 22px; }
.empty p { margin: 0; color: var(--muted); max-width: 60ch; }

/* Synthèse */
.summary { background: var(--tint); border: 1px solid var(--tint-line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 22px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-family: var(--f-num); font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 13px; color: var(--muted); }
.kpi.hero .v { color: var(--brand-deep); }
.kpi .v.neg { color: var(--alerte); }

/* Pages */
section.page { display: flex; flex-direction: column; gap: 16px; }
section.page[data-page="tableau"] { gap: 20px; }
.page.swap { animation: swap .25s ease; }

/* Tableau de bord : une carte par catégorie, la carte des dépenses variables prend toute la largeur */
.dash { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dcard { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; color: var(--ink); text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
.dcard:hover { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); }
.dcard.wide { grid-column: 1 / -1; }
.dcard-head { display: flex; align-items: center; gap: 10px; }
.dcard-head h2 { font-size: 17px; }
.dcard .go { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--muted); }
.dcard:hover .go { color: var(--ink); }
.dcard-big { font-family: var(--f-num); font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dlist li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.dlist li span { overflow-wrap: anywhere; }
.dlist li b { font-family: var(--f-num); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dlist li.hl span, .dlist li.hl b { color: var(--c); font-weight: 600; }
.dlist li.more span { color: var(--muted); font-size: 13px; }
.goals-mini li { flex-wrap: wrap; row-gap: 6px; }
.goals-mini li .bar { flex-basis: 100%; height: 6px; }
.dcard .bar { display: block; height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.dcard .bar.is-over i { background: var(--alerte); }
.dmini { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 20px; }
.mini { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.mini-top { display: flex; justify-content: space-between; gap: 8px; }
.mini-top span { font-weight: 600; overflow-wrap: anywhere; }
.mini-top b { font-family: var(--f-num); font-weight: 400; font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mini.is-over .mini-top b { color: var(--alerte); }
.mini .bar { height: 6px; }
.dnote { margin: 0; font-size: 13px; color: var(--muted); }
.dnote b { font-family: var(--f-num); font-weight: 500; color: var(--ink); }
.dnote.alert { color: var(--alerte); font-weight: 500; }

/* Sections */
.sec-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; border-bottom: 2px solid var(--c); padding-bottom: 10px; }
.sec-head h2 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
.sec-side { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.sec-head .tot { font-family: var(--f-num); font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.sec-head .tot b { color: var(--ink); font-weight: 500; font-size: 16px; }
.lede { margin: 0; color: var(--muted); max-width: 65ch; font-size: 14px; }
.none { color: var(--muted); font-size: 14px; padding: 4px 0; }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.panel h3 { font-size: 15px; }

/* Tableaux */
.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
th.act, td.act { width: 48px; padding-left: 0; padding-right: 8px; text-align: right; }
td.none { padding: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--sunken); color: var(--muted); white-space: nowrap; }
.pill.paid { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.pill.soon { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.pill.over { color: var(--alerte); background: color-mix(in srgb, var(--alerte) 13%, transparent); }
.pill.goal-ok { color: var(--objectif); background: color-mix(in srgb, var(--objectif) 15%, transparent); }

/* Enveloppes */
.envs { display: flex; flex-direction: column; gap: 6px; }
.env { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; margin: 0 -10px; width: calc(100% + 20px); border-radius: 8px; }
.env:hover { background: var(--sunken); }
.env .name { font-weight: 600; overflow-wrap: anywhere; }
.env .amt { font-family: var(--f-num); font-variant-numeric: tabular-nums; font-size: 13.5px; text-align: right; }
.env .amt small { color: var(--muted); }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; }
.env:hover .bar { background: var(--surface); }
.bar i { display: block; height: 100%; background: var(--c); border-radius: 4px; transition: width .4s ease; }
.env.is-over .bar i { background: var(--alerte); }
.env .meta { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.env.is-over .meta { color: var(--alerte); font-weight: 500; }

form.add { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
form.add label, .fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
form.add input, form.add select, .fields input, .fields select { background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--ink); min-width: 0; width: 100%; }
.full { grid-column: 1 / -1; }
.err { grid-column: 1 / -1; color: var(--alerte); font-size: 13px; margin: 0; }

.tx { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 380px; overflow-y: auto; }
.tx li + li { border-top: 1px solid var(--line); }
.tx-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 6px; width: 100%; border: 0; background: none; text-align: left; border-radius: 6px; }
.tx-row:hover { background: var(--sunken); }
.tx .day { font-family: var(--f-num); font-size: 12.5px; color: var(--muted); }
.tx .lbl { overflow-wrap: anywhere; }
.tx .amt { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.tx li.new .tx-row { animation: flash 1.2s ease; }
@keyframes flash { from { background: color-mix(in srgb, var(--variable) 18%, transparent); } to { background: transparent; } }

/* Investissements */
.cards3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.inv { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.inv .kind { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inv .kind h3 { overflow-wrap: anywhere; }
.inv .bal { font-family: var(--f-num); font-size: 22px; font-variant-numeric: tabular-nums; }
.inv dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 12px; font-size: 13px; }
.inv dt { color: var(--muted); }
.inv dd { margin: 0; text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 44px; display: block; }

/* Objectifs */
.goals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.goal { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; align-items: start; }
.ring { width: 64px; height: 64px; }
.ring text { font-family: var(--f-num); font-size: 15px; fill: var(--ink); }
.goal-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.goal h3 { font-size: 16px; overflow-wrap: anywhere; }
.goal .line { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.goal .line b { color: var(--ink); font-weight: 500; font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.goal .need { margin-top: 6px; font-size: 13px; }
.goal .need b { font-family: var(--f-num); color: var(--objectif); font-weight: 500; }
.goal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }

/* Fenêtre de saisie */
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 22px; width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(11 61 34 / .4); }
dialog form { display: flex; flex-direction: column; gap: 16px; }
dialog h2 { font-size: 20px; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.fields label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13.5px; }
.fields label.check input { width: auto; }
.fields .note { margin: 0; color: var(--muted); font-size: 14px; }
.fields fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fields legend { font-size: 12.5px; color: var(--muted); font-weight: 500; padding: 0; margin-bottom: 6px; }
.fields label.choice { flex-direction: row; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); font-size: 14px; cursor: pointer; }
.fields label.choice:has(input:checked) { border-color: var(--ink); background: var(--sunken); }
.fields label.choice input { width: auto; accent-color: var(--ink); }
.fields label.choice small { margin-left: auto; color: var(--muted); font-family: var(--f-num); font-size: 12.5px; }
/* Rapport du mois */
.report-verdict { --tone: var(--ok); display: flex; flex-direction: column; gap: 4px; border-radius: 10px; padding: 12px 14px; background: color-mix(in srgb, var(--tone) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); }
.report-verdict.tone-alert { --tone: var(--alerte); }
.report-verdict.tone-warn { --tone: var(--warn); }
.report-verdict strong { color: var(--tone); font-family: var(--f-display); font-size: 16px; line-height: 1.3; }
.report-verdict p { margin: 0; font-size: 14px; }
/* Confirmation d'ajout d'une charge */
.added { display: flex; align-items: center; gap: 10px; }
.added .pill { font-size: 13.5px; padding: 4px 12px; }
.added span:last-child { color: var(--muted); font-size: 14px; }
.report-advice { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; border: 1.5px solid var(--alerte); border-radius: 10px; background: color-mix(in srgb, var(--alerte) 8%, var(--surface)); color: var(--alerte); font-size: 14px; }
.report-advice p { margin: 0; }
.report-advice p:last-child { font-weight: 600; }
.report-advice[hidden] { display: none; }
#envs-over { margin-top: 12px; }
#envs-over p { font-weight: 400; }
table.report { min-width: 0; }
.report td { padding: 7px 0; font-size: 14px; }
.report td.r { font-family: var(--f-num); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.report tr.subtotal td, .report tr.total td { font-weight: 600; border-top: 1px solid var(--ink); }
.report tr.total td { font-size: 15.5px; }
.report .neg { color: var(--alerte); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dlg-actions .spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: var(--brand-ink); color: var(--surface); padding: 10px 18px; border-radius: 999px; font-weight: 500; opacity: 0; transition: .25s ease; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .cards3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-block: 12px 48px; padding-left: 0; }
  /* Barre collée en haut, d'un bord à l'autre : rien ne défile au-dessus.
     Les marges négatives annulent l'espace autour de la page ; la zone de l'encoche est couverte. */
  .mbar {
    display: flex; top: 0; border-radius: 0;
    margin-top: calc(-12px - env(safe-area-inset-top, 0px));
    margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
    padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  }
  .rail-close { display: grid; }
  .brand { align-items: flex-start; }
  .brand .logo { width: 120px; margin: -4px 0 -4px; }
  /* Menu latéral qui s'ouvre par-dessus la page */
  .rail {
    position: fixed; top: 0; bottom: auto; left: 0; z-index: 40;
    /* Hauteur de l'écran visible (barres du navigateur mobile comprises), contenu défilant au-delà */
    width: min(300px, 86vw); height: 100vh; height: 100dvh; min-height: 0; max-height: 100dvh; gap: 22px;
    overflow-y: auto; overscroll-behavior: contain;
    border-radius: 0 18px 18px 0;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 14px calc(env(safe-area-inset-bottom, 0px) + 18px);
    box-shadow: 8px 0 30px rgb(11 61 34 / .2);
    transform: translateX(-105%); visibility: hidden;
    transition: transform .25s ease, visibility 0s .25s;
  }
  .rail.open { transform: none; visibility: visible; transition: transform .25s ease; }
  /* Au toucher : même fond qu'au survol sur ordinateur, le temps de l'appui */
  .rail a:active { background: rgb(255 255 255 / .28); }
  .rail a[aria-current] { background: var(--surface); }
  .grid2, .goals, .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .mpick { right: auto; left: 0; }
  .cards3 { grid-template-columns: minmax(0, 1fr); }
  .summary { padding: 18px; }
  .kpi .v { font-size: 20px; }
  form.add { grid-template-columns: minmax(0, 1fr); }
}
/* Écrans tactiles : Safari (iPhone, iPad) zoome sur un champ dont le texte fait moins de 16 px.
   À 16 px, la page ne s'agrandit plus quand on touche un champ, et le zoom manuel reste possible. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
