:root {
  --fond: #f4f5f7; --surface: #fff; --bord: #e2e5ea; --texte: #1c2330; --doux: #667085;
  --accent: #0f5f8c; --accent-fonce: #0b4868; --accent-clair: #e6f1f7;
  --ok: #1a7f4b; --ok-clair: #e4f5eb; --alerte: #b25e09; --alerte-clair: #fdf1df;
  --danger: #b42318; --danger-clair: #fdecea; --nav: #14212e; --nav-texte: #b9c4d0;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte); background: var(--fond); line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doux { color: var(--doux); } .petit { font-size: .86rem; }

/* Structure */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: var(--nav-texte); padding: 1rem .7rem 2rem; position: sticky;
  top: 0; height: 100vh; overflow-y: auto; }
.nav .marque { color: #fff; font-weight: 650; font-size: 1.02rem; padding: .3rem .6rem 1rem;
  display: block; }
.nav .marque small { display: block; font-weight: 400; color: var(--nav-texte); font-size: .78rem; }
.nav h3 { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; margin: 1.1rem .6rem .3rem;
  color: #7d8c9c; font-weight: 600; }
.nav a { display: block; color: var(--nav-texte); padding: .38rem .6rem; border-radius: 6px;
  font-size: .93rem; }
.nav a:hover { background: #1f3042; color: #fff; text-decoration: none; }
.nav a.actif { background: var(--accent); color: #fff; }
.contenu { padding: 1.4rem 2rem 3rem; min-width: 0; }
.barre { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; font-size: .88rem;
  color: var(--doux); margin-bottom: 1rem; }
.barre form { display: inline; }
.entete { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.1rem; }
.entete .actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Composants */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 10px;
  padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.carte.sans-marge { padding: 0; overflow-x: auto; }
.grille { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grille .carte { margin: 0; }
.deux { display: grid; gap: 1.1rem; grid-template-columns: 2fr 1fr; align-items: start; }
.kpi .libelle { font-size: .8rem; color: var(--doux); text-transform: uppercase; letter-spacing: .05em; }
.kpi .valeur { font-size: 1.5rem; font-weight: 650; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .valeur small { font-size: .8rem; color: var(--doux); font-weight: 500; }
.positif { color: var(--ok); } .negatif { color: var(--danger); }

.btn { display: inline-block; border: 1px solid var(--bord); background: var(--surface);
  color: var(--texte); padding: .45rem .85rem; border-radius: 7px; font: inherit; font-size: .9rem;
  font-weight: 550; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primaire:hover { background: var(--accent-fonce); }
.btn.ok { color: var(--ok); border-color: #b5dfc6; }
.btn.danger { color: var(--danger); border-color: #f1c0bb; }
.btn.mini { padding: .22rem .55rem; font-size: .8rem; }
form.inline { display: inline; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--doux); font-weight: 600; padding: .65rem .9rem; border-bottom: 1px solid var(--bord);
  background: #fafbfc; white-space: nowrap; }
td { padding: .6rem .9rem; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
tfoot td { font-weight: 650; background: #fafbfc; border-top: 1px solid var(--bord); }
.vide { padding: 2.2rem; text-align: center; color: var(--doux); }

.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem;
  font-weight: 600; background: #eceff3; color: #475467; white-space: nowrap; }
.badge.validee, .badge.valide, .badge.soumis, .badge.exportee, .badge.deposee { background: var(--accent-clair); color: var(--accent-fonce); }
.badge.payee, .badge.paye, .badge.facture, .badge.acceptee, .badge.rembourse { background: var(--ok-clair); color: var(--ok); }
.badge.partielle, .badge.demande, .badge.a_payer, .badge.retard { background: var(--alerte-clair); color: var(--alerte); }
.badge.annulee, .badge.refuse, .badge.rejetee { background: var(--danger-clair); color: var(--danger); }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .4rem; font-size: .92rem;
  background: var(--ok-clair); color: var(--ok); border: 1px solid #b5dfc6; }
.messages li.error { background: var(--danger-clair); color: var(--danger); border-color: #f1c0bb; }
.note { background: var(--alerte-clair); border: 1px solid #f3d6a6; color: #7a4306; padding: .7rem .9rem;
  border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.note ul { margin: .3rem 0 0; padding-left: 1.1rem; }

/* Formulaires */
.champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .9rem 1.2rem; }
.champ label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: .25rem; }
.champ .aide { font-size: .78rem; color: var(--doux); margin-top: .2rem; }
.champ.case { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; align-self: end;
  padding-bottom: .45rem; }
.champ.case label { margin: 0; order: 2; }
.champ.case .aide { order: 3; flex-basis: 100%; margin: 0; }
.champ.large { grid-column: 1 / -1; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: .48rem .6rem; border: 1px solid #cfd4dc; border-radius: 7px; font: inherit;
  font-size: .93rem; background: #fff; color: var(--texte); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc7de; outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 1rem; height: 1rem; accent-color: var(--accent); }
.errorlist { list-style: none; padding: 0; margin: .25rem 0 0; color: var(--danger); font-size: .82rem; }
.pied-form { display: flex; gap: .6rem; margin-top: 1.2rem; align-items: center; }
.pied-form .droite { margin-left: auto; }
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filtres select, .filtres input { width: auto; min-width: 150px; }
.lignes td { padding: .35rem .3rem; } .lignes th { padding: .5rem .3rem; }
.lignes input, .lignes select { padding: .38rem .45rem; }
.lignes .col-desig { min-width: 240px; } .lignes .col-num { width: 105px; } .lignes .col-art { width: 190px; }

/* Graphique mensuel */
.graphe { display: grid; grid-template-columns: repeat(12, 1fr); gap: .5rem; align-items: end; height: 190px; }
.graphe .mois { display: flex; flex-direction: column; height: 100%; }
.graphe .barres { flex: 1; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--bord); }
.graphe .barre-ca, .graphe .barre-dep { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.graphe .barre-ca { background: var(--accent); } .graphe .barre-dep { background: #d8a25a; }
.graphe .etiquette { text-align: center; font-size: .72rem; color: var(--doux); margin-top: .3rem; }
.legende { display: flex; gap: 1.2rem; font-size: .82rem; color: var(--doux); margin-bottom: .8rem; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; }
.liste-simple { list-style: none; margin: 0; padding: 0; }
.liste-simple li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0;
  border-bottom: 1px solid #eef0f3; font-size: .92rem; }
.liste-simple li:last-child { border: 0; }
dl.fiche { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.2rem; margin: 0; font-size: .92rem; }
dl.fiche dt { color: var(--doux); } dl.fiche dd { margin: 0; }
.totaux { margin-left: auto; width: 340px; max-width: 100%; }
.totaux td { border: 0; padding: .3rem .9rem; }
.totaux tr.fort td { font-weight: 700; font-size: 1.02rem; border-top: 1px solid var(--bord); padding-top: .55rem; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.connexion .carte { width: 100%; max-width: 380px; padding: 1.8rem; }
.connexion h1 { margin-bottom: .3rem; } .connexion .champ { margin-top: .9rem; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { position: static; height: auto; }
  .contenu { padding: 1rem; } .deux { grid-template-columns: 1fr; }
}
@media print { .nav, .barre, .actions { display: none; } .app { display: block; } }
.deux > *, .grille > * { min-width: 0; }
table.compact { font-size: .8rem; }
table.compact th, table.compact td { padding: .5rem .38rem; }
table.compact th { font-size: .66rem; letter-spacing: .02em; }
table.compact td:first-child, table.compact th:first-child { padding-left: .8rem; }
table.compact .badge { font-size: .68rem; padding: .1rem .4rem; }

/* Accueil : liste « À traiter » */
.a-traiter ul { list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .5rem; }
.a-traiter li { border-left: 3px solid var(--accent); background: #f6f8fa; padding: .5rem .7rem;
  border-radius: 4px; display: flex; flex-direction: column; gap: .1rem; }
.a-traiter li.urgent { border-left-color: #c0392b; background: #fdf1ef; }
.a-traiter li a { color: inherit; text-decoration: none; } .a-traiter li a:hover { text-decoration: underline; }
/* Onglets d'un même espace */
.onglets { display: flex; gap: .2rem; border-bottom: 1px solid var(--bord, #dfe3e8); margin-bottom: 1rem; flex-wrap: wrap; }
.onglets a { padding: .5rem .9rem; text-decoration: none; color: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.onglets a.actif { border-bottom-color: var(--accent); font-weight: 600; }

th.triable { cursor: pointer; user-select: none; }
th.triable:hover { text-decoration: underline; }
th.triable[data-sens="asc"]::after { content: " ▲"; font-size: .7em; }
th.triable[data-sens="desc"]::after { content: " ▼"; font-size: .7em; }

/* Commentaires sur les opérations bancaires */
.commentaire { display: inline-block; margin-top: .25rem; padding: .15rem .5rem; border-radius: 4px;
  background: #eef4f8; border-left: 3px solid var(--accent); font-size: .85rem; }
.commentaire.du-comptable { background: #fdf6e7; border-left-color: #d8a25a; }
.ajout-commentaire { display: flex; gap: .3rem; margin-top: .3rem; }
.ajout-commentaire input { flex: 1; min-width: 120px; font-size: .85rem; padding: .2rem .4rem; }
