/* Maquette — Finances du foyer
   Palette de tableur pour rester familière : un groupe = une couleur,
   titres orange. Le mois se lit comme une petite feuille de calcul. */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --desk: #f1f3f4;
  --head: #f8f9fa;          /* en-têtes de lignes et colonnes */
  --ink: #202124;
  --muted: #5f6368;
  --faint: #9aa0a6;
  --grid: #e2e3e3;          /* lignes de grille */
  --line: #c8c9ca;
  --track: #eceef0;

  --orange: #b45f06;        /* orange foncé : titres, actions */
  --orange-vif: #e69138;    /* orange vif */
  --orange-pale: #fce5cd;   /* orange clair */
  --orange-wash: #fff8f0;
  --on-orange: #ffffff;

  --ok: #38761d;
  --late: #cc0000;
  --late-pale: #f4cccc;
  --late-ink: #660000;
  --todo-ink: #783f04;

  /* Groupes : fond de cellule (clair 3), texte (foncé 2), barre (foncé 1) */
  --ess: #cfe2f3;  --ess-ink: #0b5394;  --ess-solid: #3d85c6;
  --loi: #ead1dc;  --loi-ink: #741b47;  --loi-solid: #a64d79;
  --epa: #d9ead3;  --epa-ink: #38761d;  --epa-solid: #6aa84f;
  --rev: #fff2cc;  --rev-ink: #7f6000;  --rev-solid: #f1c232;

  --who-0: #d0e0e3; --who-0-ink: #134f5c;
  --who-1: #d9d2e9; --who-1-ink: #351c75;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e;
    --desk: #000000;
    --head: #242426;
    --ink: #f2f2f7;
    --muted: #a1a1a8;
    --faint: #6c6c72;
    --grid: #333336;
    --line: #545458;
    --track: #2c2c2e;

    --orange: #f6b26b;
    --orange-vif: #e69138;
    --orange-pale: rgba(230, 145, 56, 0.2);
    --orange-wash: rgba(230, 145, 56, 0.08);
    --on-orange: #1c1c1e;

    --ok: #93c47d;
    --late: #ff6b6b;
    --late-pale: rgba(224, 102, 102, 0.2);
    --late-ink: #f4cccc;
    --todo-ink: #f9cb9c;

    --ess: rgba(61, 133, 198, 0.24);  --ess-ink: #9fc5e8;  --ess-solid: #6fa8dc;
    --loi: rgba(166, 77, 121, 0.28);  --loi-ink: #d5a6bd;  --loi-solid: #c27ba0;
    --epa: rgba(106, 168, 79, 0.24);  --epa-ink: #b6d7a8;  --epa-solid: #93c47d;
    --rev: rgba(241, 194, 50, 0.2);   --rev-ink: #ffe599;  --rev-solid: #f1c232;

    --who-0: rgba(69, 129, 142, 0.4);  --who-0-ink: #a2c4c9;
    --who-1: rgba(142, 124, 195, 0.4); --who-1-ink: #b4a7d6;
  }
}

html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1e;
  --desk: #000000;
  --head: #242426;
  --ink: #f2f2f7;
  --muted: #a1a1a8;
  --faint: #6c6c72;
  --grid: #333336;
  --line: #545458;
  --track: #2c2c2e;

  --orange: #f6b26b;
  --orange-vif: #e69138;
  --orange-pale: rgba(230, 145, 56, 0.2);
  --orange-wash: rgba(230, 145, 56, 0.08);
  --on-orange: #1c1c1e;

  --ok: #93c47d;
  --late: #ff6b6b;
  --late-pale: rgba(224, 102, 102, 0.2);
  --late-ink: #f4cccc;
  --todo-ink: #f9cb9c;

  --ess: rgba(61, 133, 198, 0.24);  --ess-ink: #9fc5e8;  --ess-solid: #6fa8dc;
  --loi: rgba(166, 77, 121, 0.28);  --loi-ink: #d5a6bd;  --loi-solid: #c27ba0;
  --epa: rgba(106, 168, 79, 0.24);  --epa-ink: #b6d7a8;  --epa-solid: #93c47d;
  --rev: rgba(241, 194, 50, 0.2);   --rev-ink: #ffe599;  --rev-solid: #f1c232;

  --who-0: rgba(69, 129, 142, 0.4);  --who-0-ink: #a2c4c9;
  --who-1: rgba(142, 124, 195, 0.4); --who-1-ink: #b4a7d6;
}

/* Couleurs d'interface personnalisées */
html[data-accent="ocean"] { --orange: #0b57d0; --orange-vif: #3b82f6; --orange-pale: #dbeafe; --orange-wash: #eff6ff; --todo-ink: #1e40af; }
html[data-accent="emeraude"] { --orange: #15803d; --orange-vif: #10b981; --orange-pale: #dcfce7; --orange-wash: #f0fdf4; --todo-ink: #166534; }
html[data-accent="corail"] { --orange: #be123c; --orange-vif: #f43f5e; --orange-pale: #ffe4e6; --orange-wash: #fff1f2; --todo-ink: #9f1239; }
html[data-accent="lavande"] { --orange: #6d28d9; --orange-vif: #8b5cf6; --orange-pale: #ede9fe; --orange-wash: #f5f3ff; --todo-ink: #5b21b6; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"])[data-accent="ocean"] { --orange: #7cacf8; --orange-vif: #3b82f6; --orange-pale: rgba(59, 130, 246, 0.22); --orange-wash: rgba(59, 130, 246, 0.09); --todo-ink: #93c5fd; }
  html:not([data-theme="light"])[data-accent="emeraude"] { --orange: #6ee7b7; --orange-vif: #10b981; --orange-pale: rgba(16, 185, 129, 0.22); --orange-wash: rgba(16, 185, 129, 0.09); --todo-ink: #a7f3d0; }
  html:not([data-theme="light"])[data-accent="corail"] { --orange: #fda4af; --orange-vif: #f43f5e; --orange-pale: rgba(244, 63, 94, 0.22); --orange-wash: rgba(244, 63, 94, 0.09); --todo-ink: #fecdd3; }
  html:not([data-theme="light"])[data-accent="lavande"] { --orange: #c4b5fd; --orange-vif: #8b5cf6; --orange-pale: rgba(139, 92, 246, 0.22); --orange-wash: rgba(139, 92, 246, 0.09); --todo-ink: #ddd6fe; }
}
html[data-theme="dark"][data-accent="ocean"] { --orange: #7cacf8; --orange-vif: #3b82f6; --orange-pale: rgba(59, 130, 246, 0.22); --orange-wash: rgba(59, 130, 246, 0.09); --todo-ink: #93c5fd; }
html[data-theme="dark"][data-accent="emeraude"] { --orange: #6ee7b7; --orange-vif: #10b981; --orange-pale: rgba(16, 185, 129, 0.22); --orange-wash: rgba(16, 185, 129, 0.09); --todo-ink: #a7f3d0; }
html[data-theme="dark"][data-accent="corail"] { --orange: #fda4af; --orange-vif: #f43f5e; --orange-pale: rgba(244, 63, 94, 0.22); --orange-wash: rgba(244, 63, 94, 0.09); --todo-ink: #fecdd3; }
html[data-theme="dark"][data-accent="lavande"] { --orange: #c4b5fd; --orange-vif: #8b5cf6; --orange-pale: rgba(139, 92, 246, 0.22); --orange-wash: rgba(139, 92, 246, 0.09); --todo-ink: #ddd6fe; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 16px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--orange); }
:focus-visible { outline: 2px solid var(--orange-vif); outline-offset: 2px; }
button { font: inherit; }

.app {
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
@media (min-width: 480px) { .app { border-inline: 1px solid var(--grid); } }

.dev-note { margin: 0; padding: 5px 16px; font-size: 12px; font-weight: 600; color: var(--todo-ink); background: var(--orange-pale); }

/* ---------- Montants ---------- */

.amt {
  font-family: var(--rounded);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.amt small { font-size: 0.74em; font-weight: inherit; }
.pos { color: var(--ok); }
.neg { color: var(--late); }

/* ---------- En-tête ---------- */

.top { padding: calc(8px + env(safe-area-inset-top)) 16px 0; }
.month-nav { display: flex; justify-content: space-between; font-size: 15px; }
.month-nav a { padding: 6px 0; text-decoration: none; }
h1 {
  margin: 4px 0 0;
  font: 800 40px/1.05 var(--rounded);
  letter-spacing: -0.02em;
  color: var(--orange);
}
.sub { margin: 2px 0 0; font-size: 15px; color: var(--muted); }

h2.section {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 32px 16px 10px;
  font: 700 21px/1.2 var(--rounded);
  color: var(--orange);
}
h2.section .count {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--orange-pale);
  font: 700 13px/22px var(--sans);
  text-align: center;
}
.lead { margin: -4px 16px 10px; font-size: 14px; color: var(--muted); }
.note { margin: 10px 16px 0; font-size: 13px; color: var(--muted); }

/* ---------- Calendrier du mois, façon feuille ---------- */

/* Masqué par défaut ; le bouton se place à droite du titre du mois. */
.top { position: relative; }
.calbox > summary { list-style: none; }
.calbox > summary::-webkit-details-marker { display: none; }
.cal-btn, .sync-btn {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--track);
  color: var(--muted);
  cursor: pointer;
}
.sync-form { margin: 0; }
.sync-btn { right: 68px; }
.sync-btn:hover, .sync-btn:active { background: var(--orange-pale); color: var(--orange); }
.cal-btn svg, .sync-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cal-btn circle { fill: currentColor; stroke-width: 1.2; }
.calbox[open] > .cal-btn { background: var(--orange-pale); color: var(--orange); }
.calbox .cal { margin-inline: 0; }
.calbox .legend { margin-inline: 0; }
@media (prefers-reduced-motion: no-preference) {
  .calbox[open] > .cal, .calbox[open] > .legend { animation: unfold 200ms ease-out; }
}

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin: 16px 16px 0;
  border: 1px solid var(--grid);
  border-radius: 10px;
  overflow: hidden;
}
.cal .wd {
  padding: 3px 0;
  background: var(--head);
  border-bottom: 1px solid var(--grid);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.cal .d {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 48px;
  padding-top: 5px;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  color: var(--ink);
  text-decoration: none;
}
.cal > :nth-child(7n) { border-right: 0; }
.cal > :nth-last-child(-n + 7) { border-bottom: 0; }
.cal .d.off { background: var(--head); }             /* week-end ou férié */
.cal .d b {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font: 600 14px/24px var(--rounded);
  text-align: center;
}
.cal .d.out b { color: var(--faint); font-weight: 400; }
.cal .d.today b { background: var(--orange); color: var(--on-orange); }
.cal .dots { display: flex; gap: 3px; }

.dot {
  display: inline-block;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot.ok { background: var(--ok); }
.dot.todo { background: var(--orange-vif); }
.dot.late { background: var(--late); }
.dot.next { box-shadow: inset 0 0 0 1.5px var(--faint); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 16px 0;
  font-size: 12px;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Barre d'enveloppe ---------- */

.env { margin: 22px 16px 0; }
.env-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.env-head p { margin: 0; font-size: 15px; color: var(--muted); }
.env-head .env-title { font-weight: 600; color: var(--ink); }
.env-head .amt { font-size: 24px; font-weight: 800; color: var(--ok); }
.env-head .env-left.neg, .env-head .env-left.neg .amt { color: var(--late); }
.env-head .of { font-size: 15px; color: var(--muted); }
.env-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.env-sub b { font-weight: 600; color: var(--ink); }
.env-sub b.pos, .amt.pos { color: var(--ok); }
.env-sub .of { color: var(--muted); }

.track {
  display: flex;
  height: 12px;
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--track);
}
.track i { display: block; height: 100%; width: var(--w); }
.track i + i { box-shadow: inset 1.5px 0 0 var(--bg); }
.track .ess { background: var(--ess-solid); }
.track .loi { background: var(--loi-solid); }
.track .epa { background: var(--epa-solid); }
.track .rev { background: var(--rev-solid); }
.track .due { background: repeating-linear-gradient(-45deg, var(--orange-vif) 0 2px, transparent 2px 5px); }
.track .new { background: var(--orange-vif); }
.track .over { background: var(--late); }

@media (prefers-reduced-motion: no-preference) {
  .env .track i, .groups .track i {
    transform-origin: left;
    animation: fill 650ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 90ms + 150ms);
  }
}
@keyframes fill { from { transform: scaleX(0); } }

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}
.keys li { display: inline-flex; align-items: center; gap: 5px; }
.keys .amt { color: var(--ink); font-weight: 600; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.sw.ess { --c: var(--ess-solid); }
.sw.loi { --c: var(--loi-solid); }
.sw.epa { --c: var(--epa-solid); }
.sw.rev { --c: var(--rev-solid); }
.sw.due { background: repeating-linear-gradient(-45deg, var(--orange-vif) 0 2px, transparent 2px 4px); box-shadow: inset 0 0 0 1px var(--orange-vif); }
.sw.free { background: var(--track); }

.balances { display: flex; gap: 18px; margin: 14px 16px 0; font-size: 13px; color: var(--muted); }
.balances span { display: inline-flex; align-items: center; gap: 6px; }
.balances .amt { color: var(--ink); font-weight: 600; }

/* ---------- Bandeaux ---------- */

.flag {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 10px;
  align-items: baseline;
  margin: 10px 16px 0;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--late-pale);
  color: var(--late-ink);
  font-size: 14px;
  text-decoration: none;
}
.flag .dot { align-self: center; }
.flag b { font-weight: 600; color: var(--ink); }
.flag .amt { font-weight: 600; color: var(--ink); }
.flag p { grid-column: 2 / -1; margin: 0; }
.flag.todo { background: var(--orange-pale); color: var(--todo-ink); }
.flag .go { color: var(--orange); font-weight: 600; }

/* ---------- Filtres ---------- */

.seg {
  display: flex;
  margin: 22px 16px 4px;
  padding: 2px;
  border-radius: 9px;
  background: var(--track);
}
.seg a {
  flex: 1;
  padding: 6px 0;
  border-radius: 7px;
  font-size: 14px;
  color: var(--ink);
  text-align: center;
  text-decoration: none;
}
.seg a[aria-current] { background: var(--bg); color: var(--orange); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

/* ---------- Journal du mois ---------- */

.day h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 7px 16px;
  background: var(--head);
  border-block: 1px solid var(--grid);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.day h3 .amt { font-weight: 600; }
.day + .day h3 { border-top: 0; }

.ops { list-style: none; margin: 0; padding: 0; }
.op {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
}
.op:last-child { border-bottom: 0; }
.op .what { min-width: 0; }
.op .label { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.op .meta > span { display: inline-flex; align-items: center; gap: 5px; }
.op .alert { margin: 3px 0 0; font-size: 13px; color: var(--late); }
.op > .amt, .op .op-right .amt { font-size: 17px; font-weight: 600; }
.op-right { display: inline-flex; align-items: center; gap: 8px; }
.op-right form { margin: 0; position: relative; z-index: 2; }
.op-right .x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--track); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.month-add { margin-top: 12px; }
.month-reset { margin-top: 28px; }

.who {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font: 700 14px/1 var(--rounded);
  font-style: normal;
}
.who.u0 { background: var(--who-0); color: var(--who-0-ink); }
.who.u1 { background: var(--who-1); color: var(--who-1-ink); }
.who.sm { width: 20px; height: 20px; font-size: 11px; }

/* Ce qui est passé est plein, ce qui est prévu est en pointillés. */
.op.ghost { background: repeating-linear-gradient(-45deg, transparent 0 8px, var(--head) 8px 9px); }
.op.ghost .who { background: transparent; border: 1.5px dashed currentColor; }
.op.ghost .label, .op.ghost > .amt, .op.ghost .op-right .amt { color: var(--muted); }

.st { font-weight: 600; white-space: nowrap; }
.st.ok { color: var(--ok); }
.st.todo { color: var(--orange); }
.st.late { color: var(--late); }
.st.next { color: var(--muted); font-weight: 500; }
.st.paused { color: var(--muted); font-style: italic; }
.dot.paused { background: var(--muted); opacity: 0.5; }
.fixes > li.is-paused summary { opacity: 0.55; }
a.st { text-decoration: none; }

.today {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 8px;
  font: 700 13px var(--sans);
  color: var(--orange);
}
.today::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: var(--orange-vif); }

/* ---------- Budget ---------- */

.cells {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 16px 16px 0;
  border: 1px solid var(--grid);
  border-radius: 10px;
  overflow: hidden;
}
.cell { min-width: 0; padding: 9px 10px 10px; border-left: 1px solid var(--grid); }
.cell:first-child { border-left: 0; }
.cell dt { font-size: 12px; color: var(--muted); }
.cell dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; }

.groups { list-style: none; margin: 16px 16px 0; padding: 0; border: 1px solid var(--grid); border-radius: 10px; overflow: hidden; }
.groups li + li { border-top: 1px solid var(--grid); }
.groups a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 10px 12px 12px 16px;
  color: var(--ink);
  text-decoration: none;
  box-shadow: inset 5px 0 0 var(--g);
}
.groups .name { font-weight: 600; color: var(--g-ink); }
.groups .nums { font-size: 14px; color: var(--muted); }
.groups .nums .amt:first-child { color: var(--ink); font-weight: 600; }
.groups .track { grid-column: 1 / -1; height: 8px; margin: 0; }
.groups .track i { background: var(--g); }
.groups .track i.over { background: var(--late); }
.g-ess { --g: var(--ess-solid); --g-ink: var(--ess-ink); --g-fill: var(--ess); }
.g-loi { --g: var(--loi-solid); --g-ink: var(--loi-ink); --g-fill: var(--loi); }
.g-epa { --g: var(--epa-solid); --g-ink: var(--epa-ink); --g-fill: var(--epa); }
.g-rev { --g: var(--rev-solid); --g-ink: var(--rev-ink); --g-fill: var(--rev); }

.sheet { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td { padding: 8px 5px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.sheet th:first-child { padding-left: 16px; }
.sheet td:last-child, .sheet th:last-child { padding-right: 16px; }
.sheet thead th:first-child { width: 100%; text-align: left; }
.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: 5px;
  background: var(--head);
  border-block: 1px solid var(--grid);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
}
.sheet td { text-align: right; white-space: nowrap; }
.sheet tbody th { font-weight: 400; text-align: left; }
.sheet tbody { scroll-margin-top: 28px; }
.sheet .gh th { padding-block: 10px 8px; background: var(--g-fill); color: var(--g-ink); font: 700 15px/1.2 var(--rounded); border-bottom: 0; }
.sheet .total th, .sheet .total td { font-weight: 700; border-bottom: 2px solid var(--grid); }
.sheet .total th { color: var(--g-ink); }
.sheet .zero th, .sheet .zero td { color: var(--faint); }
.sheet .grand th, .sheet .grand td { padding-top: 12px; border-top: 2px solid var(--orange-vif); border-bottom: 0; font: 800 14px/1.3 var(--rounded); }
.sheet .grand th { color: var(--orange); }

.bar { display: block; height: 3px; margin-top: 5px; border-radius: 2px; background: var(--track); overflow: hidden; }
.bar i { display: block; width: var(--p); height: 100%; background: var(--g); }
.bar.over i { background: var(--late); }

/* ---------- Boutons et champs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--orange);
  color: var(--on-orange);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn.soft { background: var(--track); color: var(--ink); }
.btn.danger { background: var(--late-pale); color: var(--late); }
.btn.wide { width: calc(100% - 32px); margin: 14px 16px 0; }

select, input[type="text"], input[type="number"], input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 16px var(--sans); /* 16 px : évite le zoom automatique de Safari */
}

/* ---------- Import ---------- */

.drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 18px 16px 0;
  padding: 22px 16px 20px;
  border: 2px dashed var(--orange-vif);
  border-radius: 14px;
  background: var(--orange-wash);
  text-align: center;
  cursor: pointer;
}
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--orange-vif); outline-offset: 2px; }
.drop svg { width: 30px; height: 30px; fill: none; stroke: var(--orange); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop strong { font-size: 17px; color: var(--orange); }
.drop span { font-size: 13px; color: var(--muted); }
.owner { display: flex; align-items: center; gap: 10px; margin: 12px 16px 0; font-size: 15px; color: var(--ink); }
.owner input { width: 20px; height: 20px; margin: 0; accent-color: var(--orange-vif); }

.receipt { margin: 0 16px; padding: 14px; border: 1px solid var(--grid); border-radius: 12px; }
.receipt header { display: grid; grid-template-columns: 30px 1fr; gap: 0 10px; align-items: center; }
.receipt h3 { margin: 0; font-size: 16px; }
.receipt .file { grid-column: 2; margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.badge-ok, .badge-err {
  display: grid;
  place-items: center;
  grid-row: span 2;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--bg);
  font-weight: 800;
}
.badge-err { background: var(--late); }
.receipt .summary { margin: 14px 0 0; font-size: 15px; }
.receipt .summary b { font-family: var(--rounded); }
.receipt .track { height: 8px; margin-top: 8px; }
.checks { margin: 12px 0 0; padding: 12px 0 0; list-style: none; border-top: 1px solid var(--grid); font-size: 14px; }
.checks li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; margin-top: 6px; }
.checks li:first-child { margin-top: 0; }
.checks .y { color: var(--ok); font-weight: 700; }
.checks .i { color: var(--muted); font-style: italic; font-weight: 700; text-align: center; }
.checks .w { color: var(--todo-ink); font-weight: 700; text-align: center; }
.receipt.err { border-color: var(--late-pale); background: var(--late-pale); }
.receipt.err p { margin: 10px 0 0; font-size: 14px; color: var(--late-ink); }

.task { margin: 0 16px 12px; border: 1px solid var(--grid); border-radius: 14px; overflow: hidden; }
.task .kind {
  display: inline-block;
  margin: 12px 12px 0;
  padding: 2px 9px;
  border-radius: 11px;
  background: var(--orange-pale);
  color: var(--orange);
  font-size: 12px;
  font-weight: 700;
}
.task.alert .kind { background: var(--late-pale); color: var(--late); }
.task .op { padding: 10px 12px 0; border: 0; }
.task .op .label { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.task .q { margin: 10px 12px 0; font-size: 15px; }
.task .hint { margin: 6px 12px 0; font-size: 13px; color: var(--muted); }
.task fieldset { margin: 8px 12px 0; padding: 0; border: 0; }
.task legend { padding: 0; font-size: 15px; }
.choice {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--orange-vif); background: var(--orange-wash); }
.choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--orange-vif); }
.choice small { font-size: 13px; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 12px 12px; }
.actions.one, .actions.stack { grid-template-columns: 1fr; }

.catrow { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--grid); }
.catrow:first-of-type { border-top: 1px solid var(--grid); }
.catrow .label { margin: 0; font-weight: 500; }
.catrow .label small { font-weight: 400; color: var(--muted); }
.catrow .amt { font-weight: 600; }
.catrow select { grid-column: 1 / -1; }
.catrow .from { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

details.fold { margin: 0 16px; border: 1px solid var(--grid); border-radius: 12px; overflow: hidden; }
details.fold > summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "Afficher"; flex: none; font-size: 14px; font-weight: 600; color: var(--orange); }
details.fold[open] > summary::after { content: "Masquer"; }
details.fold .ops { border-top: 1px solid var(--grid); }

.log { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--grid); }
.log li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
  font-size: 14px;
}
.log .f { grid-column: 2 / -1; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.log .n { font-variant-numeric: tabular-nums; color: var(--muted); }
.log .n b { color: var(--ink); }

/* ---------- Dépenses fixes ---------- */

.status { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 14px 16px 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.status li { display: inline-flex; align-items: center; gap: 6px; }
.status b { color: var(--ink); font-family: var(--rounded); }

.fixes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--grid); }
.fixes > li { border-bottom: 1px solid var(--grid); }
.fixes summary {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  list-style: none;
}
.fixes summary::-webkit-details-marker { display: none; }

/* Feuille d'éphéméride : bandeau à la couleur du groupe, jour prévu dessous */
.leaf {
  display: block;
  width: 40px;
  border: 1px solid var(--grid);
  border-radius: 7px;
  overflow: hidden;
  background: var(--bg);
  text-align: center;
}
.leaf::before { content: ""; display: block; height: 7px; background: var(--g); }
.leaf b { display: block; font: 700 17px/32px var(--rounded); font-variant-numeric: tabular-nums; }
.leaf sup { font-size: 10px; }
details[open] > summary .leaf { border-color: var(--orange-vif); }

.fixes .label { margin: 0; font-weight: 500; }
.fixes .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.fixes .meta .unlearned { font-style: italic; }
.fixes .right { text-align: right; }
.fixes .right .amt { display: block; font-size: 17px; font-weight: 600; }
.fixes .right .st { display: block; margin-top: 2px; font-size: 13px; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px 16px 68px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form .full { grid-column: 1 / -1; }
.form .help { font-size: 12px; }
.form .trace { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }
.form .actions { grid-column: 1 / -1; padding: 0; }

.add { margin: 18px 16px 0; border: 1px solid var(--grid); border-radius: 12px; overflow: hidden; }
.add > summary { padding: 12px 14px; font-weight: 600; color: var(--orange); cursor: pointer; list-style: none; }
.add > summary::-webkit-details-marker { display: none; }
.add > summary::before { content: "+ "; }
.add .form { padding: 0 14px 14px; }

@media (prefers-reduced-motion: no-preference) {
  details[open] > .form, details.fold[open] .ops { animation: unfold 180ms ease-out; }
}
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Barre d'onglets ---------- */

.tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  max-width: 430px;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-top: 1px solid var(--grid);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 0;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--orange); font-weight: 600; }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] svg { stroke-width: 2.2; }
.tabs .badge {
  position: absolute;
  top: -2px;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--late);
  color: #fff;
  font: 700 11px/17px var(--sans);
  text-align: center;
}

/* ---------- Spécifique à l'appli ---------- */

.cal a.d:not([href]) { cursor: default; }

.drop input[type="file"] {
  max-width: 100%;
  margin: 6px 0 2px;
  font: 14px var(--sans);
  color: var(--muted);
}
.drop input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--orange-pale);
  color: var(--orange);
  font: 600 14px var(--sans);
}

.empty { margin: 28px 16px; padding: 22px 16px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; }
.empty p { margin: 0 0 14px; color: var(--muted); }

a.flag { color: inherit; }
a.flag.late { color: var(--late-ink); }
a.flag.todo { color: var(--todo-ink); }
.flag .amt { font-weight: 600; color: var(--ink); }
.drop input[type="file"] { position: static; width: auto; height: auto; opacity: 1; }

.remaining { margin: 14px 16px 0; font-size: 14px; color: var(--muted); }
.remaining b { color: var(--ink); font-weight: 700; }

.form-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--late-pale);
  color: var(--late-ink);
  font-size: 14px;
}

.confirm-delete { display: contents; }
.confirm-delete > summary { list-style: none; }
.confirm-delete > summary::-webkit-details-marker { display: none; }
.confirm-delete[open] > summary { display: none; }
.confirm-delete > button { width: 100%; }

form.actions { margin: 0; }
.task form { margin: 0; }

.track .unc, .sw.unc { background: var(--faint); }

.op .label a { color: inherit; text-decoration: none; }
.op .label a:active { color: var(--orange); }

/* Toute la ligne ouvre la fiche de l'opération. Safari ne déclenche le lien que sur un
   appui franc : faire défiler la liste ne l'ouvre pas. */
.op.tap { position: relative; grid-template-columns: 32px 1fr auto 7px; }
.op.tap .label a::after { content: ""; position: absolute; inset: 0; }
.op.tap .label a { -webkit-tap-highlight-color: rgba(230, 145, 56, .18); }
.op.tap .meta a, .op.tap .alert { position: relative; z-index: 1; }
.op.tap::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: -4px;
  border-top: 1.5px solid var(--faint);
  border-right: 1.5px solid var(--faint);
  transform: rotate(45deg);
}

.sheet .uncat th a { color: var(--orange); }
.sheet .uncat small { color: var(--muted); font-size: 12px; }
.advances b { color: var(--ink); }

.h1-small { font-size: 30px; overflow-wrap: anywhere; }

.facts { margin: 16px 16px 0; border: 1px solid var(--grid); border-radius: 10px; overflow: hidden; }
.facts > div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--grid); font-size: 14px; }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.form.one-col { grid-template-columns: 1fr; padding: 16px; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.form .check input { width: 18px; height: 18px; accent-color: var(--orange-vif); }

.budget-form { padding: 16px 16px 0; }
.budget-form .form-error { margin-bottom: 12px; }
.budget-form .payday { display: grid; gap: 4px; margin-bottom: 18px; font-size: 14px; color: var(--muted); }
.budget-form .payday input { max-width: 120px; }
.budget-form .help { font-size: 12px; }
.budget-form fieldset { margin: 0 0 16px; padding: 0; border: 1px solid var(--grid); border-radius: 10px; overflow: hidden; }
.budget-form legend { width: 100%; padding: 8px 12px; background: var(--g-fill); color: var(--g-ink); font: 700 15px var(--rounded); }
.budget-form .brow { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; padding: 6px 12px; border-top: 1px solid var(--grid); font-size: 15px; }
.budget-form .brow input { text-align: right; font-variant-numeric: tabular-nums; }
.budget-form .btn.wide { width: 100%; margin: 4px 0 0; }

/* ---------- Prévu modifiable et règle 60 / 25 / 15 ---------- */

.sheet td.in { padding: 3px 4px; }
.sheet td.in input {
  width: 86px;
  min-height: 34px;
  padding: 4px 6px;
  border-color: var(--grid);
  background: var(--orange-wash);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sheet td.in input:focus { outline: 2px solid var(--orange-vif); outline-offset: 0; border-color: transparent; }
.sheet td.in input[aria-invalid="true"] { border-color: var(--late); background: var(--late-pale); }
.sheet .zero td.in input { color: var(--muted); }
.plan .form-error { margin: 12px 16px 0; }

/* Barre d'enregistrement : toujours visible sans JavaScript, sinon dès qu'un montant change. */
.savebar {
  position: sticky;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 5;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.savebar .btn { width: 100%; }
.plan.clean .savebar { display: none; }

.shares { margin: 16px 16px 0; padding: 10px 12px 8px; border: 1px solid var(--grid); border-radius: 10px; }
.shares h2 { margin: 0 0 6px; font: 700 15px/1.2 var(--rounded); color: var(--ink); }
.shares h2 small { font: 400 12px var(--sans); color: var(--muted); }
.shares table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.shares th, .shares td { padding: 5px 0; text-align: right; white-space: nowrap; }
.shares thead th { font-size: 12px; font-weight: 400; color: var(--muted); }
.shares tbody th { text-align: left; font-weight: 600; color: var(--g-ink); }
.shares tbody th .sw { margin-right: 6px; }
.shares td:nth-child(2) { color: var(--muted); }
.shares td.neg { color: var(--late); font-weight: 700; }

/* ---------- Épargne ---------- */

.who.uc { background: var(--track); color: var(--muted); }
.sub .who { display: inline-grid; vertical-align: -4px; }
input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; }

.sv-total {
  margin: 16px 16px 0;
  padding: 16px 18px 14px;
  border: 1px solid var(--orange-pale);
  border-radius: 14px;
  background: linear-gradient(145deg, var(--orange-wash), var(--head) 70%);
}
.sv-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sv-total .k { margin: 0; font: 700 12px/1.3 var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--orange); }
.sv-total .k small { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.sv-pill { padding: 2px 9px; border-radius: 99px; background: var(--orange-pale); color: var(--orange); font: 600 12px/1.4 var(--sans); white-space: nowrap; }
.sv-total .v { margin: 6px 0 2px; font: 800 36px/1.05 var(--rounded); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.sv-total .v .amt small { color: var(--muted); font-weight: 700; }
.sv-total .chg { margin: 4px 0 0; font-size: 13px; color: var(--ok); }
.sv-total .chg.neg { color: var(--late); }
.sv-total .sv-head + .chg { margin-top: 6px; color: var(--muted); }
.sv-total .track { margin-top: 12px; }

.chart-box { margin-top: 12px; }
.chart { display: block; width: 100%; height: 110px; overflow: visible; }
.chart .line { fill: none; stroke: var(--orange-vif); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--orange-pale); opacity: .55; stroke: none; }
.chart-axis { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--faint); }

.sv-list { list-style: none; margin: 8px 0 0; padding: 0; }
.sv-list a {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--grid);
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(230, 145, 56, .18);
}
.sv-list .what { min-width: 0; }
.sv-list .label { margin: 0; font-size: 16px; font-weight: 600; }
.sv-list .meta { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.sv-list .right { display: grid; justify-items: end; gap: 2px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sv-list .right .chart { width: 72px; height: 22px; }
.sv-list .right .chart .area { display: none; }
.sv-list .right .chart .line { stroke-width: 1.6; }

.sv-balance { padding: 4px 16px 0; }
.sv-events { list-style: none; margin: 0; padding: 0; }
.sv-events li { display: grid; grid-template-columns: 1fr auto 28px; gap: 10px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--grid); }
.sv-events li:not(.snap) { grid-template-columns: 1fr auto; padding-right: 54px; }
.sv-events .label { margin: 0; font-size: 15px; }
.sv-events .snap .label { font-weight: 600; }
.sv-events .meta { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.sv-events form { margin: 0; }
.sv-events .x { width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--track); color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }

.sec-head { display: flex; justify-content: space-between; align-items: center; margin: 28px 16px 10px; }
.sec-head h2.section { margin: 0; }
.sec-head form { margin: 0; }
.btn.sm-btn { min-height: 32px; padding: 4px 10px; font-size: 13px; }

.stock-list { list-style: none; margin: 0 16px; padding: 0; display: grid; gap: 12px; }
.stock-card { border: 1px solid var(--grid); border-radius: 12px; overflow: hidden; background: var(--head); }
.stock-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--grid); }
.stock-top .label { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stock-top .ticker { padding: 1px 6px; border-radius: 5px; background: var(--track); font: 700 11px/1.4 var(--sans); color: var(--muted); }
.stock-top .meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.stock-top .meta b { color: var(--ink); }
.stock-val { text-align: right; white-space: nowrap; }
.stock-val .v { margin: 0; font: 800 18px/1.1 var(--rounded); }
.stock-val .gain { margin: 3px 0 0; font: 600 12px var(--rounded); }

.lot-list { list-style: none; margin: 0; padding: 0; background: var(--bg); }
.lot-list li { display: grid; grid-template-columns: 1fr auto 28px; gap: 10px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--grid); font-size: 13px; }
.lot-list li:last-child { border-bottom: 0; }
.lot-list .lot-qty { display: block; font-weight: 500; color: var(--ink); }
.lot-list .meta { display: block; font-size: 12px; color: var(--muted); }
.lot-list form { margin: 0; }
.lot-list .x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--track); color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }

/* ---------- Connexion et appareils ---------- */

.auth { display: grid; justify-items: center; gap: 6px; padding: calc(56px + env(safe-area-inset-top)) 16px 24px; text-align: center; }
.auth-icon { border-radius: 16px; margin-bottom: 8px; }
.auth h1 { margin: 0; font: 800 28px/1.15 var(--rounded); color: var(--orange); }
.auth .sub { max-width: 340px; margin: 4px 0 8px; }
.auth .btn.wide { width: 100%; max-width: 360px; margin: 10px 0 0; }
.auth .note { max-width: 340px; margin-top: 18px; }
.auth-msg { min-height: 1.3em; margin: 8px 16px 0; font-size: 14px; color: var(--late); text-align: center; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }

.whoami { display: flex; justify-content: space-between; gap: 10px; margin: 28px 16px 0; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 12px; color: var(--muted); }
.whoami a { color: var(--orange); }

.dev-list { list-style: none; margin: 0; padding: 0; }
.dev-list li { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--grid); }
.dev-list .label { margin: 0; font-size: 15px; font-weight: 600; }
.dev-list .meta { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.dev-list form { margin: 0; }
.dev-list .confirm-delete[open] { grid-column: 1 / -1; }

.invite { margin: 16px 16px 0; padding: 12px 14px; border: 2px solid var(--orange-vif); border-radius: 12px; background: var(--orange-wash); }
.invite h2 { margin: 0 0 6px; font: 700 16px var(--rounded); color: var(--orange); }
.invite p { margin: 0 0 10px; font-size: 13px; color: var(--ink); }
.invite input { font-size: 13px; }
.invite .actions { display: flex; gap: 8px; margin-top: 10px; }
.invite-forms { display: grid; }

/* ---------- Ordinateur : menu à gauche, contenu plus large ---------- */

.drop.over { background: var(--orange-pale); }

@media (min-width: 900px) {
  .app:has(.tabs) {
    max-width: 860px;
    margin-left: max(232px, calc(50% - 430px + 116px));
    padding-bottom: 48px;
  }
  .tabs {
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 216px;
    max-width: none;
    padding: calc(24px + env(safe-area-inset-top)) 12px 24px;
    transform: none;
    border-top: 0;
    border-right: 1px solid var(--grid);
  }
  .tabs::before {
    content: "Finances du foyer";
    margin: 0 12px 16px;
    font: 800 18px/1.2 var(--rounded);
    color: var(--orange);
  }
  .tabs a {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 15px;
  }
  .tabs a:hover { background: var(--head); }
  .tabs a[aria-current="page"] { background: var(--orange-wash); }
  .tabs svg { width: 22px; height: 22px; }
  .tabs .badge { position: static; margin-left: auto; }
  .tabs a.nav-settings { margin-top: auto; }
  .savebar { bottom: 0; }
  .sheet td.in input { width: 110px; }
  .chart { height: 160px; }
  .auth { padding-top: 96px; }
}

/* ---------- Catégories ---------- */

.cat-error { margin: 14px 16px 0; }
.cat-group { margin: 18px 16px 0; border: 1px solid var(--grid); border-radius: 10px; overflow: hidden; }
.cat-group h2 { margin: 0; padding: 8px 12px; background: var(--g-fill); color: var(--g-ink); font: 700 15px var(--rounded); }
.cat-group.g-hb h2 { background: var(--head); color: var(--muted); }
.cat-group ul { list-style: none; margin: 0; padding: 0; }
.cat-group li { padding: 6px 12px; border-top: 1px solid var(--grid); }
.cat-group li.cat-row-del { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.cat-group form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin: 0; }
.cat-group form.cat-del { display: block; }
.cat-group .cat-del .x {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--track);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.cat-group .cat-del .x:hover { background: var(--late-pale); color: var(--late); }
.cat-group input { min-height: 38px; padding: 6px 10px; }
.cat-group input[aria-invalid="true"] { border-color: var(--late); background: var(--late-pale); }

/* ---------- Banque ---------- */

.bank-conns > li.bank-conn { grid-template-columns: 1fr; gap: 8px; }
.bank-accs { list-style: none; margin: 4px 0 0; padding: 8px 10px; border: 1px solid var(--grid); border-radius: 8px; background: var(--head); }
.bank-accs li { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.bank-accs li:last-child { border-bottom: 0; padding-bottom: 0; }
.bank-accs li:first-child { padding-top: 0; }
.bank-acc-role { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin: 0; }
.bank-acc-role select { min-height: 36px; padding: 4px 8px; font-size: 14px; }
.bank-connect { padding: 8px 16px 0; }
.bank-connect .btn.wide { width: 100%; margin-top: 8px; }
.env-head a.of { color: var(--orange); text-decoration: none; }

/* ---------- Réglages ---------- */

.settings-list { list-style: none; margin: 18px 16px 0; padding: 0; border: 1px solid var(--grid); border-radius: 14px; overflow: hidden; background: var(--head); }
.settings-list li { border-top: 1px solid var(--grid); }
.settings-list li:first-child { border-top: 0; }
.settings-list a {
  display: grid;
  grid-template-columns: 38px 1fr 12px;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  color: var(--ink);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(230, 145, 56, .18);
}
.settings-list a:hover { background: var(--orange-wash); }
.settings-list a::after {
  content: "";
  width: 7px;
  height: 7px;
  border-top: 1.5px solid var(--faint);
  border-right: 1.5px solid var(--faint);
  transform: rotate(45deg);
}
.set-ic {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--orange-pale);
  color: var(--orange);
}
.set-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.settings-list .what { min-width: 0; }
.settings-list .label { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.settings-list .label .badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--late);
  color: #fff;
  font: 700 11px/18px var(--sans);
  text-align: center;
}
.settings-list .meta { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

.appearance-form {
  margin: 0 16px;
  padding: 14px;
  border: 1px solid var(--grid);
  border-radius: 14px;
  background: var(--head);
}
.app-label { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.app-label:not(:first-child) { margin-top: 14px; }
.seg-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pill {
  padding: 8px 10px;
  border: 1px solid var(--grid);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.pill.active {
  border-color: var(--orange-vif);
  background: var(--orange-pale);
  color: var(--orange);
  font-weight: 700;
}
.accent-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.accent-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--grid);
  border-radius: 99px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.accent-pill .swatch { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.accent-pill.active {
  border-color: var(--orange-vif);
  background: var(--orange-pale);
  color: var(--orange);
  font-weight: 700;
}
