:root {
  --fond: #f4f6f8; --carte: #fff; --texte: #1c2733; --discret: #627080; --bord: #d9dfe6;
  --accent: #0b5cad; --ok: #1a7f4b; --ok-fond: #e3f4ea; --attention: #9a6200; --attention-fond: #fdf1d7;
  --alerte: #b3261e; --alerte-fond: #fce4e2;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1rem; margin: 0 0 .8rem; }
.retour { text-decoration: none; }

.barre { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.2rem; background: #12283d; color: #fff; flex-wrap: wrap; }
.barre a { color: #cfe0f1; text-decoration: none; }
.barre .marque { color: #fff; font-weight: 600; }
.barre nav { display: flex; gap: 1.1rem; flex: 1; flex-wrap: wrap; }
.barre nav a.actif { color: #fff; border-bottom: 2px solid #fff; }
.compte { display: flex; gap: .8rem; align-items: center; font-size: .85rem; }
.compte .lien { color: #cfe0f1; }

main { max-width: 1200px; margin: 0 auto; padding: 1.2rem; }
main.large { max-width: 1700px; }
main.etroit { max-width: 380px; margin-top: 12vh; }
.entete { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.actions, .ligne { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.ligne { margin-top: .8rem; }
.ligne input:not([type=checkbox]) { flex: 1; min-width: 10rem; }
.ajout { margin: 1rem 0; }

.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; padding: 1rem 1.1rem; margin-bottom: 1rem; }
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.deux-colonnes { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 1rem; align-items: start; }
.apercu { width: 100%; height: calc(100vh - 140px); min-height: 500px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; position: sticky; top: 1rem; }
@media (max-width: 900px) { .deux-colonnes { grid-template-columns: 1fr; } .apercu { position: static; height: 70vh; } }

label { display: block; font-size: .82rem; color: var(--discret); margin-bottom: .7rem; }
input, select, button, .bouton { font: inherit; }
input:not([type=checkbox]):not([type=file]), select { display: block; width: 100%; margin-top: .2rem; padding: .45rem .55rem; border: 1px solid var(--bord); border-radius: 6px; background: #fff; color: var(--texte); }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled input, fieldset:disabled select { background: #f1f3f5; }
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.case { display: flex; gap: .5rem; align-items: flex-start; color: var(--texte); font-size: .9rem; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; }

button, .bouton { display: inline-block; padding: .45rem .9rem; border: 1px solid var(--bord); border-radius: 6px; background: #fff; color: var(--texte); cursor: pointer; text-decoration: none; }
button:hover, .bouton:hover { background: #eef2f6; }
button.primaire, .bouton.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primaire:hover, .bouton.primaire:hover { background: #094a8c; }
button.danger { color: var(--alerte); border-color: var(--alerte); }
button.danger:hover { background: var(--alerte-fond); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.lien { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.carte > form + form { margin-top: .7rem; }

table { width: 100%; border-collapse: collapse; background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; overflow: hidden; }
.carte table { border: 0; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--discret); background: #f8fafb; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.retard { color: var(--alerte); font-weight: 600; }
.discret { color: var(--discret); font-size: .85rem; }
.vide { color: var(--discret); padding: 2rem; text-align: center; }

.onglets { display: flex; gap: .3rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.onglets a { padding: .4rem .8rem; border-radius: 999px; text-decoration: none; color: var(--texte); border: 1px solid transparent; }
.onglets a.actif { background: var(--carte); border-color: var(--bord); font-weight: 600; }
.compteur { color: var(--discret); font-size: .8rem; margin-left: .2rem; }
.recherche { margin-left: auto; }
.recherche input { margin: 0; min-width: 15rem; }
.import input { max-width: 16rem; }

.pastille { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e8ecf0; color: #3a4755; white-space: nowrap; }
.pastille.ok, .statut-payee, .lot-paye { background: var(--ok-fond); color: var(--ok); }
.pastille.attention, .statut-a_verifier, .lot-genere { background: var(--attention-fond); color: var(--attention); }
.pastille.alerte, .statut-rejetee { background: var(--alerte-fond); color: var(--alerte); }
.statut-validee, .statut-en_paiement { background: #dfeaf7; color: var(--accent); }

.message { padding: .7rem .9rem; border-radius: 6px; margin-bottom: .8rem; background: var(--ok-fond); color: #114d2e; border: 1px solid #b9e0c8; }
.message.attention { background: var(--attention-fond); color: #5c3b00; border-color: #f0d79a; }
.message.alerte { background: var(--alerte-fond); color: #7a1a14; border-color: #f2b8b3; }

.rib { border-left: 5px solid var(--bord); }
.rib.ok { border-left-color: var(--ok); }
.rib.attention { border-left-color: #d99a1c; }
.rib.alerte { border-left-color: var(--alerte); }
.verdict { font-weight: 600; }
.rib.alerte .verdict { color: var(--alerte); }
dl { margin: 0 0 .6rem; }
dt { font-size: .78rem; color: var(--discret); margin-top: .5rem; }
dd { margin: .1rem 0 0; }
.verif { border-top: 1px solid var(--bord); padding-top: .8rem; margin-top: .8rem; }
.verif button { margin: .3rem .4rem 0 0; }
.consigne { font-size: .9rem; margin-top: 0; }
.historique { list-style: none; padding: 0; margin: 0; }
.historique li { padding: .45rem 0; border-top: 1px solid var(--bord); font-size: .9rem; }
.connexion h1 { margin-bottom: 1rem; }
.connexion button { width: 100%; }
