:root {
  --fond: #f4f6f9; --carte: #fff; --texte: #1d2330; --doux: #5d6677; --bord: #dde1e8;
  --accent: #2459c4; --accent-doux: #e8eefb; --ok: #1f7a3a; --att: #9a6200; --err: #b3261e; --encours: #2459c4;
  --ombre: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #14171d; --carte: #1c2029; --texte: #e6e9ef; --doux: #9aa3b5; --bord: #2d3340;
          --accent: #7aa2f7; --accent-doux: #222c42; --ok: #6cc085; --att: #e0b050; --err: #f08080; --encours: #7aa2f7;
          --ombre: none; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--fond); color: var(--texte); }
header { display: flex; gap: 24px; align-items: center; padding: 10px 16px; background: var(--carte); border-bottom: 1px solid var(--bord); flex-wrap: wrap; }
header .logo { font-weight: 700; font-size: 17px; color: var(--texte); text-decoration: none; }
header nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
header nav a { text-decoration: none; }
header .moi { color: var(--doux); font-size: 13px; }
a { color: var(--accent); }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
footer { padding: 16px; color: var(--doux); text-align: center; font-size: 12px; }
h1 { font-size: 22px; margin: 8px 0 16px; } h2 { font-size: 17px; margin-top: 32px; }
.centre { text-align: center; }
.fil { color: var(--doux); font-size: 13px; margin: 0; }
.fil a { color: var(--doux); }
.regle { margin: 0; padding: 6px 16px; background: color-mix(in srgb, var(--ok) 12%, var(--carte)); color: var(--ok); font-weight: 600; font-size: 13px; }
.petit { color: var(--doux); font-size: 12px; }
code { background: var(--accent-doux); padding: 1px 5px; border-radius: 4px; }

/* ---------- tuiles ---------- */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin: 12px 0 20px; }
.tuiles.grandes { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); max-width: 1000px; margin: 24px auto; }
.tuiles.petites { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tuile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 170px; padding: 18px 14px; border-radius: 14px; border: 1px solid var(--bord); border-top: 4px solid var(--bord);
  background: var(--carte); color: var(--texte); box-shadow: var(--ombre); text-decoration: none; font: inherit; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.tuiles.grandes .tuile { min-height: 220px; }
.tuiles.petites .tuile { min-height: 120px; padding: 12px; }
.tuile:hover:not([disabled]) { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 4px 16px rgba(36, 89, 196, .15); }
.tuile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tuile[disabled] { cursor: default; opacity: .85; }
.tuile strong { font-size: 16px; }
.tuiles.grandes .tuile strong { font-size: 19px; }
.tuile span { color: var(--doux); font-size: 13px; }
.tuile em { font-style: normal; font-size: 12px; color: var(--doux); word-break: break-all; }
.tuile .icone { width: 38px; height: 38px; color: var(--accent); }
.tuiles.grandes .tuile .icone { width: 54px; height: 54px; }
.tuiles.petites .tuile .icone { width: 26px; height: 26px; }
.tuile.principale { background: var(--accent-doux); border-top-color: var(--accent); }
.tuile.etat-termine { border-top-color: var(--ok); }
.tuile.etat-en_cours, .tuile.etat-en_attente { border-top-color: var(--encours); }
.tuile.etat-en_cours .icone { animation: pulse 1.4s ease-in-out infinite; }
.tuile.etat-erreur { border-top-color: var(--err); }
.tuile.etat-en_pause, .tuile.etat-pause_demandee { border-top-color: var(--att); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .tuile, .tuile .icone { transition: none; animation: none !important; } }

/* ---------- recherche et listes ---------- */
.recherche { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.recherche input { flex: 1; min-width: 240px; padding: 10px 12px; font: inherit; border-radius: 8px; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); }
.indicateur { display: none; color: var(--doux); font-size: 13px; }
.htmx-request.indicateur, .htmx-request .indicateur { display: inline; }
.liste { list-style: none; padding: 0; margin: 8px 0; background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; }
.liste li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 14px; border-bottom: 1px solid var(--bord); }
.liste li:last-child { border-bottom: none; }
.liste li a { text-decoration: none; color: var(--texte); flex: 1; }
.liste li:hover { background: var(--accent-doux); }

/* ---------- formulaires, boutons ---------- */
button, .bouton { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button.secondaire, .bouton.secondaire { background: transparent; color: var(--accent); }
button .icone { width: 18px; height: 18px; }
.boutons { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 14px 18px; margin: 16px 0; }
.formulaire { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.formulaire label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.formulaire input[type=text], .formulaire input:not([type]), .formulaire input[type=password] { padding: 9px 11px; font: inherit; border-radius: 8px; border: 1px solid var(--bord); background: var(--fond); color: var(--texte); font-weight: 400; }
.formulaire button { align-self: flex-start; }
fieldset { border: 1px solid var(--bord); border-radius: 8px; }
label.case { display: flex; flex-direction: row; gap: 8px; font-weight: 400; }
.connexion { max-width: 380px; margin: 40px auto; background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.connexion label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.connexion input { padding: 10px 12px; font: inherit; border-radius: 8px; border: 1px solid var(--bord); background: var(--fond); color: var(--texte); }
details summary { cursor: pointer; font-weight: 600; }

/* ---------- tableaux et états ---------- */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--carte); border: 1px solid var(--bord); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--bord); text-align: left; vertical-align: top; font-size: 13px; }
th { font-size: 12px; color: var(--doux); font-weight: 600; }
.pastille { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 9px; border: 1px solid currentColor; }
.pastille.ok, .ok { color: var(--ok); }
td.etat-termine { color: var(--ok); }
td.etat-en_cours, td.etat-en_attente { color: var(--encours); }
td.etat-erreur { color: var(--err); }
td.etat-en_pause, td.etat-pause_demandee { color: var(--att); }
td.etat-termine div, td.etat-en_cours div, td.etat-en_attente div, td.etat-erreur div, td.etat-en_pause div { color: var(--texte); }
.err, .niveau-erreur { color: var(--err) !important; }
.att, .niveau-avertissement { color: var(--att) !important; }
.compte-pret, .compte-existant { color: var(--ok); }
.alerte { margin: 8px 16px; padding: 9px 13px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 14%, var(--carte)); border: 1px solid var(--ok); }
.alerte.erreur { background: color-mix(in srgb, var(--err) 14%, var(--carte)); border-color: var(--err); }
main .alerte { margin: 8px 0; }

@media (max-width: 600px) {
  .tuiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tuiles.grandes { grid-template-columns: 1fr; }
  .tuile { min-height: 140px; }
}
