/* COMPTA — feuille de style unique. Thème clair / sombre selon le système. */
:root {
  --fond: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --bord: #e2e5ea;
  --texte: #1c2330; --muet: #6b7280; --accent: #0f766e; --accent-fort: #0b5f59; --accent-doux: #e6f4f2;
  --vert: #15803d; --rouge: #b91c1c; --orange: #b45309;
  --b-ok: #dcfce7; --b-ok-t: #166534; --b-err: #fee2e2; --b-err-t: #991b1b;
  --b-av: #fef3c7; --b-av-t: #92400e; --b-info: #e0f2fe; --b-info-t: #075985; --b-gris: #eef0f3; --b-gris-t: #4b5563;
  --ombre: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  --rayon: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1318; --surface: #171c23; --surface-2: #1d232b; --bord: #2a313b;
    --texte: #e5e7eb; --muet: #9aa3af; --accent: #2dd4bf; --accent-fort: #5eead4; --accent-doux: #12302d;
    --vert: #4ade80; --rouge: #f87171; --orange: #fbbf24;
    --b-ok: #123222; --b-ok-t: #86efac; --b-err: #3a1717; --b-err-t: #fca5a5;
    --b-av: #3a2c0f; --b-av-t: #fcd34d; --b-info: #0f2a3a; --b-info-t: #7dd3fc; --b-gris: #252b33; --b-gris-t: #cbd5e1;
    --ombre: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); color: var(--texte);
       font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muet { color: var(--muet); }
.vert { color: var(--vert); } .rouge { color: var(--rouge); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.petit-texte, small { font-size: 12px; }
.inline { display: inline; }
.centre { text-align: center; margin-top: 14px; }

/* ── Barre ── */
.barre { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
         padding: 0 20px; height: 54px; background: var(--surface); border-bottom: 1px solid var(--bord); }
.marque { font-weight: 700; font-size: 16px; color: var(--texte); text-decoration: none; white-space: nowrap; }
.marque small { color: var(--muet); font-weight: 500; }
.logo { color: var(--accent); }
.menu { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.menu a { padding: 7px 11px; border-radius: 8px; color: var(--texte); text-decoration: none; white-space: nowrap; }
.menu a:hover { background: var(--surface-2); }
.menu a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.pastille { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--rouge);
            color: #fff; font-size: 11px; text-align: center; line-height: 18px; }
.qui { display: flex; gap: 12px; align-items: center; font-size: 13px; white-space: nowrap; }
.menu-bouton { display: none; }
.page { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }

/* ── Éléments ── */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
         padding: 18px; margin-bottom: 18px; box-shadow: var(--ombre); }
.carte.mince { padding: 10px 14px; }
.titre-ligne { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.titre-ligne h1, .titre-ligne h2 { margin-bottom: 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; width: auto;
       border: 1px solid var(--bord); background: var(--surface); color: var(--texte); font: inherit; font-weight: 500;
       cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.plein { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.plein:hover { background: var(--accent-fort); }
@media (prefers-color-scheme: dark) { .btn.plein { color: #04201d; } }
.btn.danger { color: var(--rouge); } .btn.plein.danger { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn.petit { padding: 3px 9px; font-size: 12px; }
.btn.icone { padding: 3px 7px; }
.lien { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--bord);
       border-radius: 8px; padding: 7px 10px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label { display: block; margin-bottom: 12px; font-weight: 500; }
label > input:not([type=checkbox]), label > select, label > textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
label.case { display: flex; gap: 8px; align-items: center; font-weight: 400; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; padding: 10px 14px 4px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; }
.aide { font-size: 12px; color: var(--muet); margin: -4px 0 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.alerte { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; }
.alerte.ok { background: var(--b-ok); color: var(--b-ok-t); }
.alerte.err { background: var(--b-err); color: var(--b-err-t); }
.alerte.avert { background: var(--b-av); color: var(--b-av-t); }
.alerte.info { background: var(--b-info); color: var(--b-info-t); }
code.mdp { font-size: 16px; padding: 2px 8px; background: var(--surface); border-radius: 6px; user-select: all; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-valide { background: var(--b-ok); color: var(--b-ok-t); }
.b-auto { background: var(--b-info); color: var(--b-info-t); }
.b-a_classer { background: var(--b-gris); color: var(--b-gris-t); }
.b-a_justifier { background: var(--b-av); color: var(--b-av-t); }

/* ── Tableaux ── */
.table-defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tableau { width: 100%; border-collapse: collapse; background: var(--surface); }
.tableau th, .tableau td { padding: 8px 10px; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; }
.tableau th { font-size: 12px; color: var(--muet); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.tableau th.num, .tableau td.num { text-align: right; }
.tableau.compact th, .tableau.compact td { padding: 5px 8px; }
.tableau tr.vide td { color: var(--muet); }
.tableau tr.groupe th { background: transparent; color: var(--texte); padding-top: 12px; }
.tableau.brut td { font-size: 12px; color: var(--muet); white-space: nowrap; }
.tableau.mois td:first-child a { font-weight: 600; text-decoration: none; }
.transactions td.desc { min-width: 220px; }
.transactions .sel-cat { min-width: 190px; padding: 4px 6px; }
.note-justif { font-size: 12px; color: var(--muet); margin-top: 3px; }
.piece { font-size: 12px; display: inline-block; margin-top: 3px; }
tr.douteux td { background: var(--b-av); }
tr.exclu td { opacity: .45; text-decoration: line-through; }

.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tuile { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; box-shadow: var(--ombre);
         color: inherit; text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.tuile span { color: var(--muet); font-size: 12px; }
.tuile b { font-size: 20px; font-variant-numeric: tabular-nums; }
.tuile small { color: var(--muet); }
.alerte-tuile { border-color: var(--orange); }

.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.onglets { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.onglets a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--texte); border: 1px solid var(--bord); background: var(--surface); }
.onglets a.actif { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-mois { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.releve-puce { display: inline-flex; gap: 6px; align-items: center; margin: 2px 12px 2px 6px; }

/* ── Import ── */
.grille-import { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grille-import .large { grid-column: 1 / -1; }
.section-import { border-top: 1px solid var(--bord); padding-top: 14px; margin-top: 14px; }
.section-tete { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.section-tete h3 { margin: 0; }
.soldes { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.soldes label { width: 200px; }
.controle { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; background: var(--surface-2);
            border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.controle div { display: flex; flex-direction: column; gap: 2px; }
.controle span { font-size: 12px; }
.mapping { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.mapping summary, details summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.grille-mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; margin: 10px 0; }

/* ── Modal / toast ── */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-fond { position: absolute; inset: 0; background: rgba(10, 14, 20, .55); }
.modal-boite { position: relative; background: var(--surface); border-radius: 14px; padding: 22px; width: min(520px, 100%);
               max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-boite.large { width: min(720px, 100%); }
.modal-boite h2 { margin-top: 0; }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; color: var(--muet); cursor: pointer; width: auto; }
body.modal-ouvert { overflow: hidden; }
.resume-tx { display: flex; gap: 10px; flex-wrap: wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.grille-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grille-form .large { grid-column: 1 / -1; }
.ligne-champs { display: flex; gap: 8px; margin-top: 4px; }
.ligne-champs select { width: auto; flex: 0 0 auto; }
.ligne-champs input { flex: 1; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120; max-width: min(620px, calc(100% - 32px));
         background: #1c2330; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
         display: flex; gap: 12px; align-items: center; }
.toast[hidden] { display: none; }
.toast.err { background: #991b1b; }
.toast .btn { flex: 0 0 auto; }

/* ── Porte (connexion) ── */
body.porte { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.carte-porte { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--bord); border-radius: 16px;
               padding: 30px 28px; box-shadow: var(--ombre); }
.porte-logo { font-size: 38px; text-align: center; color: var(--accent); line-height: 1; }
.carte-porte h1 { text-align: center; margin: 8px 0 2px; }
.carte-porte .sous { text-align: center; color: var(--muet); margin: 0 0 22px; font-size: 13px; }
.carte-porte .btn.plein { width: 100%; justify-content: center; padding: 10px; }
.carte-porte .note { font-size: 12px; color: var(--muet); text-align: center; margin: 14px 0 0; }
input.code { font-size: 24px; letter-spacing: 8px; text-align: center; }

/* ── Petits écrans ── */
@media (max-width: 960px) {
  .deux-colonnes { grid-template-columns: 1fr; }
  .menu-bouton { display: block; margin-left: auto; background: none; border: 1px solid var(--bord); border-radius: 8px;
                 padding: 4px 10px; font-size: 18px; color: var(--texte); width: auto; }
  .menu, .qui { display: none; }
  body.menu-ouvert .barre { height: auto; flex-wrap: wrap; padding-bottom: 10px; }
  body.menu-ouvert .menu { display: flex; flex-direction: column; width: 100%; order: 3; }
  body.menu-ouvert .qui { display: flex; width: 100%; order: 4; }
}
@media (max-width: 640px) {
  .page { padding: 16px 16px 50px; }
  .grille-import, .grille-form { grid-template-columns: 1fr; }
  .tuile b { font-size: 17px; }
}
