:root {
  --fond: #f6f3ee;
  --carte: #ffffff;
  --texte: #2b2620;
  --doux: #7a7066;
  --trait: #e6dfd5;
  --accent: #2f6f5e;
  --accent-clair: #e3efe9;
  --chaud: #c2622d;
  --chaud-clair: #f8e6db;
  --rouge: #b3261e;
  --barre: #d8cfc2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1b1916; --carte: #25221e; --texte: #ece6dd; --doux: #a59a8d;
    --trait: #3a352f; --accent: #6fbfa5; --accent-clair: #233a33;
    --chaud: #e48b56; --chaud-clair: #40291c; --rouge: #f08a82; --barre: #4a443c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #1b1916; --carte: #25221e; --texte: #ece6dd; --doux: #a59a8d;
  --trait: #3a352f; --accent: #6fbfa5; --accent-clair: #233a33;
  --chaud: #e48b56; --chaud-clair: #40291c; --rouge: #f08a82; --barre: #4a443c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
.doux { color: var(--doux); font-size: .9em; }
.erreur { color: var(--rouge); }
.avert { background: var(--chaud-clair); color: var(--texte); padding: .6em .9em; border-radius: 10px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.neg { color: var(--texte); }
.pos { color: var(--accent); }

.ecran { min-height: 100vh; }
.carte {
  background: var(--carte); border: 1px solid var(--trait); border-radius: 14px;
  padding: 16px; margin-bottom: 16px;
}
.carte.accent { border-color: var(--accent); background: var(--accent-clair); }

.connexion { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: .92em; }
label.case { display: flex; gap: 8px; align-items: center; }
input, select {
  font: inherit; color: inherit; background: var(--carte);
  border: 1px solid var(--trait); border-radius: 9px; padding: 8px 10px; min-width: 0;
}
.btn {
  font: inherit; border: 1px solid var(--trait); background: var(--carte); color: inherit;
  border-radius: 9px; padding: 8px 14px; cursor: pointer;
}
.btn.plein { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.rond { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 1.3rem; }

.entete {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--carte); border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 2;
}
.marque { font-weight: 700; }
#onglets { display: flex; gap: 4px; overflow-x: auto; }
#onglets button {
  font: inherit; border: 0; background: none; color: var(--doux); padding: 6px 10px;
  border-radius: 8px; cursor: pointer; white-space: nowrap;
}
#onglets button.actif { background: var(--accent-clair); color: var(--accent); font-weight: 600; }
.qui { font-size: .9em; color: var(--doux); }

main { max-width: 1040px; margin: 0 auto; padding: 16px; }
.barre-mois { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
.barre-mois h2 { margin: 0; min-width: 9em; text-align: center; text-transform: capitalize; }

.grille-comptes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grille-comptes .carte { margin: 0; }
.deux { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.deux .carte { margin-bottom: 0; }
.deux { margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px 4px; border-bottom: 1px solid var(--trait); vertical-align: top; }
th { text-align: left; font-weight: 600; color: var(--doux); font-size: .85em; }
tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; border-top: 2px solid var(--trait); }
tr.eteint td { opacity: .45; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--fond); }

.flambe-ligne { display: grid; grid-template-columns: minmax(110px, 1.2fr) 3fr 150px; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.flambe-ligne:hover { background: var(--fond); }
.jauge { position: relative; height: 14px; background: var(--fond); border-radius: 7px; overflow: visible; }
.jauge > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: var(--barre); }
.jauge > i.plus { background: var(--chaud); }
.jauge > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--texte); opacity: .55; }
.flambe-detail { padding: 4px 0 10px 12px; border-left: 3px solid var(--trait); margin: 0 0 6px 4px; }
.ecart-plus { color: var(--chaud); font-size: .85em; }
.ecart-moins { color: var(--accent); font-size: .85em; }

.pastille { display: inline-block; font-size: .78em; padding: 1px 8px; border-radius: 99px; background: var(--fond); border: 1px solid var(--trait); white-space: nowrap; }
.pastille.alerte { background: var(--chaud-clair); border-color: var(--chaud); }
.pastille.joint { background: var(--accent-clair); border-color: var(--accent); }

.bilan { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.bilan .chiffre { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.filtres { display: flex; flex-wrap: wrap; gap: 8px; }
.filtres > * { flex: 1 1 160px; }

.depot { display: block; border: 2px dashed var(--trait); border-radius: 14px; padding: 28px; text-align: center; cursor: pointer; margin: 12px 0; }
.depot.survol { border-color: var(--accent); background: var(--accent-clair); }

dialog { border: 0; border-radius: 16px; padding: 0; max-width: 440px; width: calc(100% - 32px); background: var(--carte); color: var(--texte); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.fenetre { padding: 18px; display: grid; gap: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 600px) {
  main { padding: 12px 16px; }
  .flambe-ligne { grid-template-columns: 1fr auto; }
  .flambe-ligne .jauge { grid-column: 1 / -1; grid-row: 2; }
  .masque-mobile { display: none; }
}

.charge { opacity: .45; transition: opacity .2s; pointer-events: none; }
h4 { margin: 14px 0 4px; }

select.vide { border-color: var(--chaud); background: var(--chaud-clair); }
#totaux .chiffre { font-size: 1.35rem; }
#fixes td, #variables td { vertical-align: middle; }
input.montant { width: 5.5em; text-align: right; padding: 5px 7px; }
input.montant.main { border-color: var(--accent); background: var(--accent-clair); font-weight: 600; }
