:root {
  --bg: #f2f3ef;
  --card: #ffffff;
  --ink: #16201c;
  --muted: #6a736e;
  --line: #e3e6e0;
  --soft: #eef1ec;
  --accent: #16624f;
  --accent-ink: #ffffff;
  --t: #3d63dd;
  --t-soft: #e7ecfd;
  --r: #d6457a;
  --r-soft: #fbe7ef;
  --caf: #b5740a;
  --caf-soft: #fbf0db;
  --pos: #1b7f4b;
  --pos-soft: #e1f3e8;
  --neg: #c2412d;
  --neg-soft: #fbe6e1;
  --shadow: 0 1px 2px rgb(20 30 25 / .05), 0 4px 16px rgb(20 30 25 / .05);
  --radius: 18px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --card: #1b1f1d;
    --ink: #e9ece9;
    --muted: #9aa39e;
    --line: #2a302d;
    --soft: #232926;
    --accent: #4cc59a;
    --accent-ink: #0b1a13;
    --t: #8aa4ff;
    --t-soft: #232b47;
    --r: #ff86ae;
    --r-soft: #3b2330;
    --caf: #f0b54a;
    --caf-soft: #3a2f1a;
    --pos: #5fd394;
    --pos-soft: #1d3327;
    --neg: #ff8a73;
    --neg-soft: #3d2420;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
  min-height: 100dvh;
}
main, .top { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1, h2, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.zero { color: var(--muted); }
small { font-size: .8em; color: var(--muted); font-weight: 400; }

/* ---------- En-tête ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 16px; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.top h1 { font-size: 1.6rem; letter-spacing: -.02em; line-height: 1.2; }

.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 700; text-decoration: none; flex: none; }
.avatar.sm { width: 36px; height: 36px; font-size: .9rem; }
.avatar.xs { width: 26px; height: 26px; font-size: .75rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.3rem; }
.avatar-t { background: var(--t-soft); color: var(--t); }
.avatar-r { background: var(--r-soft); color: var(--r); }
.avatar-caf { background: var(--caf-soft); color: var(--caf); }
.top .avatar.is-current { outline: 2px solid currentColor; outline-offset: 2px; }

/* ---------- Cartes ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); }
@media (prefers-color-scheme: light) { .card { border-color: transparent; } }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin-bottom: 12px; }
.card-title .ico { width: 19px; height: 19px; color: var(--muted); }
.label { font-size: .85rem; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.month-name { font-size: 1.3rem; text-transform: capitalize; letter-spacing: -.01em; }
.note { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: 12px; font-size: .9rem; }
.hint { font-size: .85rem; margin-top: 8px; }
.hint.ok { color: var(--pos); }
.hint.warn { color: var(--neg); }

.hero { background: var(--accent); color: var(--accent-ink); border: 0; }
.hero .label { color: inherit; opacity: .8; }
.hero .big { font-size: 2.4rem; font-weight: 700; letter-spacing: -.03em; margin: 2px 0 6px; }
.hero .big.neg { color: inherit; }
.hero-sub { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .9rem; text-decoration: none; opacity: .92; }
.hero-sub .ico { width: 16px; height: 16px; }
.hero-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / .2); }
@media (prefers-color-scheme: dark) { .hero-flow { border-top-color: rgb(0 0 0 / .15); } }
.hero-flow dt { font-size: .75rem; opacity: .75; }
.hero-flow dd { margin: 0; font-weight: 600; font-size: .86rem; white-space: nowrap; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip-ok, .chip-pos { background: var(--pos-soft); color: var(--pos); }
.chip-warn, .chip-neg { background: var(--neg-soft); color: var(--neg); }
.chip-zero { background: var(--soft); color: var(--muted); }
.hero .chip { background: rgb(255 255 255 / .18); color: inherit; }
@media (prefers-color-scheme: dark) { .hero .chip { background: rgb(0 0 0 / .14); } }

.todo ul { list-style: none; margin: 0; padding: 0; }
.todo li + li { border-top: 1px solid var(--line); }
.linkish { all: unset; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 0; font-size: .95rem; }
.linkish .ico { width: 18px; height: 18px; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.kpis div { background: var(--soft); border-radius: 12px; padding: 9px 10px; }
.kpis span { display: block; font-size: .72rem; color: var(--muted); }
.kpis b { font-size: .88rem; white-space: nowrap; }

.split { display: flex; height: 10px; border-radius: 99px; overflow: hidden; margin: 18px 0 6px; gap: 3px; }
.split-t { background: var(--t); border-radius: 99px; }
.split-r { background: var(--r); border-radius: 99px; }
.split-legend { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }

.people { display: grid; gap: 8px; margin-top: 14px; }
.person { border-radius: 14px; padding: 11px 12px; background: var(--soft); }
.person-name { display: flex; align-items: center; gap: 7px; font-weight: 650; margin-bottom: 4px; font-size: .92rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; flex: none; }
.person-name .dot { margin: 0; }
.person-t .dot, .dot-t { background: var(--t); }
.person-r .dot, .dot-r { background: var(--r); }
.person dl { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.person dt { color: var(--muted); font-size: .72rem; }
.person dd { margin: 0; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.person .ecart { text-align: right; }
.person .ecart dd { font-weight: 750; }
.person .ecart.pos dt, .person .ecart.pos dd { color: var(--pos); }
.person .ecart.neg dt, .person .ecart.neg dd { color: var(--neg); }
.card-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.card-foot b { font-size: 1.1rem; }

.years { display: grid; gap: 10px; }
.year { background: var(--soft); border-radius: 14px; padding: 12px 14px; }
.year-name { font-weight: 700; margin-bottom: 4px; }
.year dl, .lines { margin: 0; }
.year dl div, .lines div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 3px 0; font-size: .92rem; }
.year dt, .lines dt { color: var(--muted); display: flex; align-items: center; }
.year dd, .lines dd { margin: 0; font-weight: 600; text-align: right; }
.lines .strong dt, .lines .strong dd { color: var(--ink); font-weight: 700; }
.lines .strong dd.pos { color: var(--pos); }
.lines .strong dd.neg { color: var(--neg); }

/* ---------- Mois ---------- */
.year-block { margin-bottom: 22px; }
.year-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 10px; gap: 10px; }
.year-head h2 { font-size: 1.25rem; }
.year-head p { font-size: .85rem; color: var(--muted); text-align: right; }
.year-head b { display: block; font-size: 1rem; }
details.month { padding: 0; margin-bottom: 8px; }
details.month summary { list-style: none; display: grid; grid-template-columns: 1fr auto 20px; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details > summary .ico { width: 18px; height: 18px; color: var(--muted); transition: transform .2s; }
details[open] > summary .ico:last-child { transform: rotate(90deg); }
.month-title { font-weight: 650; }
.month-title small { display: block; font-size: .8rem; }
.month-body { padding: 0 16px 16px; }
.grid { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 10px; }
.grid th, .grid td { padding: 7px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.grid th:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.grid thead th { font-size: .8rem; font-weight: 650; }
.col-t { color: var(--t); }
.col-r { color: var(--r); }
.grid .strong th, .grid .strong td { border-bottom: 0; font-weight: 700; }
.grid .strong th { color: var(--ink); }
.month-body .btn { margin-top: 12px; width: 100%; }

/* ---------- Recettes ---------- */
.filters { display: grid; gap: 8px; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-size: .88rem; white-space: nowrap; cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-btn.chip-t[aria-pressed="true"] { background: var(--t); border-color: var(--t); color: #fff; }
.chip-btn.chip-r[aria-pressed="true"] { background: var(--r); border-color: var(--r); color: #fff; }
.chip-btn.chip-caf[aria-pressed="true"] { background: var(--caf); border-color: var(--caf); color: #fff; }
@media (prefers-color-scheme: dark) { .chip-btn[aria-pressed="true"]:is(.chip-t, .chip-r, .chip-caf) { color: var(--bg); } }
.group-title { font-size: .85rem; font-weight: 650; color: var(--muted); padding: 6px 4px 8px; }
.list { list-style: none; padding: 4px 0; }
.list li + li .rec { border-top: 1px solid var(--line); }
.list li[hidden] + li .rec { border-top: 0; }
.rec { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 16px; }
.rec:active { background: var(--soft); }
.rec-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rec-title { font-weight: 600; font-size: .95rem; }
.rec-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-sub em { font-style: normal; color: var(--r); }
.rec-amount { font-weight: 650; white-space: nowrap; }
.rec-amount.type-salaire { color: var(--muted); font-weight: 500; }
.rec-group[hidden] { display: none; }

/* ---------- Contrôle ---------- */
.ledger div { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.ledger div:last-child { border-bottom: 0; }
.ledger dt { flex-direction: column; align-items: flex-start; }
.ledger .total dt, .ledger .total dd { color: var(--ink); font-weight: 700; }
.ledger .total dd.pos { color: var(--pos); }
.ledger .total dd.neg { color: var(--neg); }

/* ---------- Compte ---------- */
.profile { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile form { width: 100%; }
.profile form .btn { width: 100%; }
.profile > div { flex: 1; }
.profile-name { font-weight: 700; font-size: 1.15rem; }
details.card > summary { list-style: none; cursor: pointer; margin: 0; }
details.card > summary .ico:last-child { margin-left: auto; }
details.card[open] > summary { margin-bottom: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.journal { list-style: none; margin: 0; padding: 0; }
.journal li { display: flex; gap: 10px; padding: 8px 0; font-size: .9rem; align-items: flex-start; }
.journal li + li { border-top: 1px solid var(--line); }
.journal small { display: block; }

/* ---------- Formulaires ---------- */
.stack { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span:first-child { font-size: .85rem; color: var(--muted); font-weight: 500; }
.field input, .field textarea {
  width: 100%; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.field input[type="date"] { min-height: 48px; }
.money-input { position: relative; display: block; }
.money-input input { padding-right: 34px; font-weight: 600; }
.money-input b { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 500; pointer-events: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--neg); font-size: .9rem; }

.seg { border: 0; padding: 0; margin: 0; min-width: 0; }
.seg legend { font-size: .85rem; color: var(--muted); font-weight: 500; padding: 0; margin-bottom: 5px; }
.seg-opts { display: flex; gap: 6px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: block; text-align: center; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: .9rem; font-weight: 550; cursor: pointer; transition: all .15s; }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg .seg-t input:checked + span { background: var(--t); border-color: var(--t); color: #fff; }
.seg .seg-r input:checked + span { background: var(--r); border-color: var(--r); color: #fff; }
.seg .seg-caf input:checked + span { background: var(--caf); border-color: var(--caf); color: #fff; }
@media (prefers-color-scheme: dark) { .seg :is(.seg-t, .seg-r, .seg-caf) input:checked + span { color: var(--bg); } }
.seg input:disabled + span { opacity: .35; cursor: not-allowed; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 0; font-weight: 650; cursor: pointer; text-decoration: none; font-size: .95rem; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-danger { background: transparent; color: var(--neg); padding-left: 4px; padding-right: 4px; }
.btn-block { width: 100%; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .6; }
.icon-btn { all: unset; cursor: pointer; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: var(--ink); flex: none; }
.icon-btn .ico { width: 18px; height: 18px; }

/* ---------- Feuilles modales ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  background: var(--card); color: var(--ink); border-radius: 22px 22px 0 0; overflow: auto;
}
dialog.sheet[open] { animation: sheet-in .22s cubic-bezier(.2, .8, .3, 1); }
dialog.sheet::backdrop { background: rgb(0 0 0 / .4); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 600px) {
  dialog.sheet { margin: auto; border-radius: 22px; }
}
.sheet-body { display: grid; gap: 16px; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.sheet-actions .btn-primary { flex: 1; max-width: 260px; margin-left: auto; }
[data-mc] { margin-top: -8px; }
[data-mc] b { color: var(--ink); }

/* ---------- Navigation ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; max-width: 160px; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs .ico { width: 24px; height: 24px; }
.fab {
  position: fixed; z-index: 11; right: max(18px, calc(50vw - 320px + 18px)); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent);
}
.fab .ico { width: 26px; height: 26px; stroke-width: 2.3; }
.fab:active { transform: scale(.95); }

.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%);
  max-width: calc(100% - 32px); width: max-content; padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: .9rem; font-weight: 550; box-shadow: 0 8px 24px rgb(0 0 0 / .18);
  animation: toast-in .25s ease-out; transition: opacity .3s, transform .3s;
}
.toast-err { background: var(--neg); color: #fff; }
.toast.hide { opacity: 0; transform: translate(-50%, -10px); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

/* ---------- Connexion ---------- */
.page-login { padding-bottom: 24px; }
.login { max-width: 380px; padding-top: max(10vh, 40px); text-align: center; }
.login-logo { border-radius: 18px; margin-bottom: 14px; }
.login h1 { font-size: 1.7rem; letter-spacing: -.02em; }
.login form { margin-top: 22px; text-align: left; }
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--line); cursor: pointer; font-weight: 650; transition: border-color .15s; }
.who input { position: absolute; opacity: 0; }
.who-t:has(input:checked) { border-color: var(--t); }
.who-r:has(input:checked) { border-color: var(--r); }
.who:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

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

/* ======================================================================
   Téléphone (< 900 px) : consultation seule — Ordinateur : vue complète
   ====================================================================== */
.dot-caf { background: var(--caf); }

@media (max-width: 899px) {
  .only-desktop { display: none !important; }
  .todo .linkish { pointer-events: none; }
  .todo .linkish .ico { display: none; }
}

@media (min-width: 900px) {
  .only-mobile { display: none !important; }
  body { padding-bottom: 48px; }
  main, .top { max-width: 1440px; padding-left: 28px; padding-right: 28px; }
  .top { padding-top: 18px; padding-bottom: 20px; gap: 28px; }
  .top h1 { font-size: 1.4rem; }
  .topnav { display: flex; gap: 2px; margin-right: auto; padding: 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
  .topnav a { text-decoration: none; padding: 8px 18px; border-radius: 10px; font-weight: 600; font-size: .92rem; color: var(--muted); }
  .topnav a:hover { color: var(--ink); background: var(--soft); }
  .topnav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
  .fab { right: 32px; bottom: 32px; }

  /* Accueil : trois colonnes */
  .page-home main { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .page-home main > .card { margin: 0; }
  .page-home .hero, .page-home .todo, .page-home .pending-card { grid-column: 1; }
  .page-home .month-card { grid-column: 2; grid-row: 1 / span 4; }
  .page-home .years-card { grid-column: 3; grid-row: 1 / span 4; }
  .todo .linkish:hover { color: var(--accent); }

  /* Contrôle : deux colonnes */
  .desk-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; max-width: 1000px; }
  .desk-cols > .card { margin: 0; }
  .page-controle main > .hint { max-width: 1000px; text-align: left; margin-top: 14px; }

  /* Filtres sur une ligne */
  .filters { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 14px; }
  .chips { margin: 0; padding: 0; overflow: visible; }
  .chip-btn { padding: 5px 12px; font-size: .84rem; }
  .chip-btn:hover { border-color: var(--muted); }

  /* Recettes : feuille + contrôle */
  .desk-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
  .ctrl-side { position: sticky; top: 16px; margin: 0; }
  .ctrl-side .ledger div { padding: 7px 0; font-size: .88rem; }
  .inline-form { display: flex; gap: 8px; align-items: end; margin-top: 14px; }
  .inline-form .field { flex: 1; }
  .inline-form input { padding: 9px 12px; }
  .desk-split .xl-scroll { max-height: calc(100dvh - 250px); }
  .xl-mois-card .xl-scroll { max-height: calc(100dvh - 170px); }
  .toast { top: auto; bottom: 28px; }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }
}

/* ---------- Tableaux façon tableur ---------- */
.xl-card { padding: 0; overflow: hidden; }
.xl-card > .hint { margin: 0; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.xl-scroll { overflow: auto; }
table.xl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }
.xl th, .xl td { padding: 0 10px; height: 36px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.xl thead th { position: sticky; top: 0; z-index: 3; background: var(--card); color: var(--muted); font-size: .76rem; font-weight: 650; height: 34px; }
.xl .num { text-align: right; }
.xl tbody tr:hover > * { background: var(--soft); }
.xl .strong { font-weight: 700; }
.xl .pos { color: var(--pos); }
.xl .neg { color: var(--neg); }
.xl .zero { color: var(--muted); }
.xl .dot { margin-right: 7px; }
.xl .mc { color: var(--muted); }
.xl .mc.shifted { color: var(--r); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .78rem; font-weight: 600; background: var(--soft); color: var(--muted); }
.tag-apport { background: var(--pos-soft); color: var(--pos); }
.tag-caf { background: var(--caf-soft); color: var(--caf); }
.note-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.xl .act { width: 1%; text-align: right; padding-right: 8px; }
.xl .act > * { vertical-align: middle; }
.icon-btn.sm { display: inline-grid; width: 30px; height: 30px; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { background: var(--card); color: var(--ink); }
.icon-btn.sm.danger:hover { color: var(--neg); }
.xl-rec tbody .act .icon-btn { opacity: 0; }
.xl-rec tbody tr:hover .act .icon-btn, .xl-rec tbody tr:focus-within .act .icon-btn { opacity: 1; }
.xl-rec tbody tr.is-editing { display: none; }
.xl-rec tbody tr[data-edit] { cursor: default; }
.btn-sm { padding: 7px 12px; font-size: .84rem; border-radius: 9px; gap: 5px; }
.btn-sm .ico { width: 16px; height: 16px; }

/* ligne de saisie (toujours visible en haut) et ligne en cours de modification */
.xl tr.entry > td { background: var(--soft); padding: 6px 4px; height: auto; }
.xl thead tr.entry > td { position: sticky; top: 34px; z-index: 2; border-bottom: 2px solid var(--line); }
.xl tr.entry > td:first-child { padding-left: 8px; }
.xl tr.entry input, .xl tr.entry select {
  width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: .86rem; outline: none;
}
.xl tr.entry input:focus, .xl tr.entry select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.xl tr.entry input[type="date"] { min-width: 138px; }
.xl tr.entry select { min-width: 112px; }
.xl tr.entry input.num { min-width: 96px; text-align: right; }
.xl tr.entry input[name="note"] { min-width: 180px; }
.xl tr.editing > td { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.xl tfoot th, .xl tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--card); font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }

/* feuille Dépenses : 15 colonnes, compactes pour tenir sur un écran d'ordinateur */
.xl-mois { font-size: .82rem; }
.xl-mois th, .xl-mois td { padding: 0 7px; height: 34px; }
.xl-mois thead th { font-size: .72rem; white-space: normal; line-height: 1.15; vertical-align: bottom; padding-bottom: 6px; }
.xl-mois thead tr.groups th { height: 26px; text-align: center; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 0; }
.xl-mois thead tr:nth-child(2) th { top: 26px; height: 44px; }
.xl-mois thead .g-t { color: var(--t); }
.xl-mois thead .g-r { color: var(--r); }
.xl-mois th.month-cell { position: sticky; left: 0; z-index: 1; background: var(--card); color: var(--ink); font-weight: 650; }
.xl-mois th.month-cell small { display: block; font-size: .7rem; color: var(--caf); line-height: 1; margin-top: -2px; }
.xl-mois tr.pending th.month-cell { line-height: 1.2; }
.xl-mois tr.year-start > * { border-top: 2px solid var(--line); }
.xl-mois tbody tr:first-child > * { border-top: 0; }
.xl-mois td.in { padding: 2px 4px; }
input.cell {
  width: 100%; min-width: 82px; padding: 5px 7px; border-radius: 7px; border: 1px solid transparent; background: transparent;
  font-size: .82rem; outline: none; font-weight: 600;
}
input.cell.num { text-align: right; }
input.cell[data-col="note"] { min-width: 150px; font-weight: 400; }
input.cell::placeholder { color: var(--caf); font-weight: 500; }
input.cell:hover { border-color: var(--line); background: var(--card); }
input.cell:focus { border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.xl-mois td.year-total { text-align: center; vertical-align: middle; font-size: 1rem; font-weight: 750; background: var(--soft); border-left: 1px solid var(--line); }
.xl-mois tbody tr:hover > td.year-total { background: var(--soft); }
.xl-mois td.year-total span { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }

/* ---------- Mois provisoires ---------- */
.pending + .pending { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.pending-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pending .lines { margin-top: 8px; }
.pending .people { margin-top: 10px; }
.pending .hint .dot { margin: 0 4px 0 0; }
.year-excl { font-size: .75rem; color: var(--muted); margin: -2px 0 4px; }
.year-head small { display: block; font-size: .72rem; }
.est { font-style: italic; color: var(--muted); }
.xl td.est.neg, .grid td.est.neg { color: color-mix(in srgb, var(--neg) 75%, var(--muted)); }
.xl td.est.pos, .grid td.est.pos { color: color-mix(in srgb, var(--pos) 75%, var(--muted)); }
.xl-mois td.year-total small { display: block; font-size: .66rem; color: var(--muted); font-weight: 500; white-space: normal; }

/* ---------- Tableau de synthèse ---------- */
.summary-grid { display: grid; gap: 14px; }
.summary-grid p { margin: 2px 0; font-size: .95rem; }
.summary-grid .label { margin-bottom: 4px; }
.summary-grid .dot { margin-right: 6px; }
@media (min-width: 900px) { .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .summary-grid > div + div { border-left: 1px solid var(--line); padding-left: 16px; } }
.year-pick { margin: 0 0 12px; }
.year-pick .chip-btn { text-decoration: none; }
.xl-tab { font-size: .8rem; }
.xl-tab th, .xl-tab td { padding: 0 6px; }
.xl-tab thead tr.groups th { height: 26px; text-align: center; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 0; }
.xl-tab thead tr:nth-child(2) th { top: 26px; height: 44px; white-space: normal; line-height: 1.15; vertical-align: bottom; padding-bottom: 6px; font-size: .72rem; }
.xl-tab thead .g-t { color: var(--t); background: color-mix(in srgb, var(--t) 8%, var(--card)); }
.xl-tab thead .g-r { color: var(--r); background: color-mix(in srgb, var(--r) 8%, var(--card)); }
.xl-tab th.month-cell { position: sticky; left: 0; z-index: 1; background: var(--card); color: var(--ink); font-weight: 650; }
.xl-tab th.month-cell small { display: block; font-size: .68rem; color: var(--caf); font-weight: 500; line-height: 1.1; }
.xl-tab tbody tr.st-provisoire > *, .xl-tab tbody tr.st-en_cours > * { background: color-mix(in srgb, var(--caf) 6%, var(--card)); }
.xl-tab td.cum { font-weight: 700; border-right: 1px solid var(--line); }
.xl-tab td:nth-child(5) { border-right: 1px solid var(--line); }
.xl-tab tr.note-row td { height: auto; padding: 0 8px 8px; font-size: .76rem; color: var(--muted); white-space: normal; border-top: 0; }
.xl-tab tbody tr:has(+ .note-row) > * { border-bottom: 0; }
.xl-tab tfoot th small { display: block; font-size: .68rem; color: var(--muted); font-weight: 500; }
.xl-tab td[data-corr], .corr-sample { background: color-mix(in srgb, var(--caf) 22%, var(--card)) !important; box-shadow: inset 0 -2px 0 var(--caf); cursor: help; }
.corr-sample { padding: 0 6px; border-radius: 4px; }
.xl-tab sup { font-size: .62rem; margin-left: 2px; }
.xl-tab sup a { color: var(--caf); text-decoration: none; font-weight: 700; }
.legend { padding: 10px 16px 14px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); display: grid; gap: 4px; }
.legend b { color: var(--ink); }
.corr-list { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.corr-list li { font-size: .9rem; padding-left: 4px; }
.corr-list li::marker { color: var(--caf); font-weight: 700; }
.corr-list li > span { display: block; }
.corr-list li:target { background: color-mix(in srgb, var(--caf) 15%, transparent); border-radius: 8px; }
.corr-what { font-weight: 650; }
.corr-val s { color: var(--muted); }
.corr-why { font-size: .82rem; }
.reserve dt small { display: block; font-size: .76rem; color: var(--muted); }
.reserve dt { flex-direction: column; align-items: flex-start; }
.reserve dd { white-space: nowrap; }
