:root {
  --fond: #f6f4f1; --carte: #fff; --texte: #1f1a17; --doux: #6b625b; --bord: #e4ded7; --accent: #7a1f1f; --accent2: #9b2c2c; --or: #b7832a;
  --rouge: #b42318; --rouge-bg: #fdecea; --vert: #15803d; --survol: #faf7f3; --tete: #f1ece6;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #141110; --carte: #1d1917; --texte: #ece6e0; --doux: #a59b92; --bord: #332c28; --accent: #b04444; --accent2: #c95a5a; --or: #d9a441;
    --rouge: #f97066; --rouge-bg: #3a1714; --vert: #4ade80; --survol: #241f1c; --tete: #26201d; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fond); color: var(--texte); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.entete { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent); color: #fff; padding: 10px 20px; }
.entete-g { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; min-width: 0; }
.entete-g select { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 3px 8px; }
.entete-g select option { color: #000; }
.entete-d { display: flex; gap: 14px; }
.lien { background: none; border: 0; color: #fff; opacity: .9; text-decoration: none; font-size: 14px; padding: 0; }
.lien:hover { opacity: 1; text-decoration: underline; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 16px; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.carte-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
h2 { margin: 0; font-size: 17px; } h3 { margin: 0 0 12px; }
.doux { color: var(--doux); margin: 2px 0 0; } .petit { font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.principal, .secondaire, .bouton { border-radius: 10px; padding: 8px 14px; border: 1px solid var(--bord); background: var(--carte); text-decoration: none; display: inline-block; font-size: 14px; color: inherit; }
.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.principal:hover:not(:disabled) { background: var(--accent2); }
.secondaire:hover { background: var(--survol); }
button:disabled { opacity: .5; cursor: default; }
.bouton-fichier { cursor: pointer; }

.progression { margin: 8px 0 4px; }
.barre { height: 8px; background: var(--tete); border-radius: 99px; overflow: hidden; }
.barre i { display: block; height: 100%; width: 0; background: var(--or); transition: width .2s; }

.table-boite { overflow: auto; border: 1px solid var(--bord); border-radius: 10px; }
.table-boite.haute { max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
th { background: var(--tete); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.liste tbody tr { cursor: pointer; }
.liste tbody tr:hover { background: var(--survol); }
.liste tbody tr.actif { background: color-mix(in srgb, var(--or) 14%, transparent); }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--tete); color: var(--doux); margin-right: 4px; }
.badge.err { background: var(--rouge-bg); color: var(--rouge); }

.grille { font-size: 13px; }
.grille th.n, .grille td.n { color: var(--doux); text-align: right; background: var(--tete); position: sticky; left: 0; }
.grille td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.grille td.v { text-align: right; font-variant-numeric: tabular-nums; }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.onglets button { border: 1px solid var(--bord); background: var(--carte); border-radius: 99px; padding: 4px 12px; font-size: 13px; }
.onglets button.actif { background: var(--accent); border-color: var(--accent); color: #fff; }

.erreur { color: var(--rouge); background: var(--rouge-bg); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
dialog { border: 1px solid var(--bord); border-radius: 14px; background: var(--carte); color: var(--texte); padding: 20px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog label, .login-carte label { display: grid; gap: 4px; margin-bottom: 12px; font-size: 14px; }
dialog input, .login-carte input { border: 1px solid var(--bord); border-radius: 8px; padding: 9px 10px; background: var(--fond); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 16px; padding: 28px; width: min(380px, 100%); }
.login-carte h1 { font-size: 20px; margin: 10px 0 18px; }
.login-carte button { width: 100%; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px; font-weight: 600; margin-top: 4px; }
.login-carte .petit { color: var(--doux); margin: 14px 0 0; }

@media (max-width: 640px) {
  .entete { padding: 10px 16px; } .entete-d { gap: 10px; }
  .carte { padding: 14px; }
}
