:root {
  --fond: #f6f7f9; --surface: #ffffff; --surface-2: #f1f3f6; --bord: #e3e6eb; --texte: #15181d; --doux: #5d6673; --tres-doux: #8a929e;
  --ok: #1f9d55; --ok-fond: #e6f6ec; --echec: #d63a3a; --echec-fond: #fdeaea; --retard: #c77a06; --retard-fond: #fdf3e1;
  --cours: #2f6fde; --cours-fond: #e8f0fd; --neutre: #8a929e; --neutre-fond: #eef0f3; --accent: #15181d;
  --ombre: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --rayon: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1115; --surface: #171a20; --surface-2: #1e222a; --bord: #2a2f38; --texte: #e8eaed; --doux: #a3abb7; --tres-doux: #77808c;
    --ok: #3fbf74; --ok-fond: #15301f; --echec: #f06464; --echec-fond: #3a1a1a; --retard: #e6a23c; --retard-fond: #36290f;
    --cours: #6aa1ff; --cours-fond: #172640; --neutre: #77808c; --neutre-fond: #23272f; --accent: #e8eaed;
    --ombre: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.page { max-width: 1240px; margin: 0 auto; padding: 20px 16px 60px; }

/* En-tête */
.entete { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.titre { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.titre h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.titre .meta { color: var(--tres-doux); font-size: 13px; }
.sante { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.jauge { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--bord); border-radius: 999px; padding: 5px 12px 5px 10px; font-size: 12.5px; color: var(--doux); }
.jauge b { color: var(--texte); font-weight: 600; font-variant-numeric: tabular-nums; }
.barre { width: 46px; height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.barre i { display: block; height: 100%; background: var(--ok); }
.barre i.haut { background: var(--retard); } .barre i.critique { background: var(--echec); }
.bouton-discret { background: none; border: 1px solid var(--bord); border-radius: 8px; padding: 5px 10px; color: var(--doux); font-size: 12.5px; }
.bouton-discret:hover { background: var(--surface-2); color: var(--texte); }

/* Synthèse */
.synthese { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); }
.compteur { padding: 12px 14px; text-align: left; border: 1px solid var(--bord); background: var(--surface); border-radius: var(--rayon); box-shadow: var(--ombre); }
.compteur:hover { border-color: var(--tres-doux); }
.compteur.actif { outline: 2px solid var(--accent); outline-offset: -1px; }
.compteur .n { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.compteur .l { color: var(--doux); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.compteur.echec .n { color: var(--echec); } .compteur.retard .n { color: var(--retard); } .compteur.cours .n { color: var(--cours); }
.compteur.zero .n { color: var(--tres-doux); }

/* Barre d'outils */
.outils { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.recherche { flex: 1 1 220px; max-width: 340px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte); font: inherit; }
.recherche:focus { outline: 2px solid var(--cours); outline-offset: -1px; }
.onglets { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.onglets button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; color: var(--doux); font-size: 13px; }
.onglets button.actif { background: var(--surface); color: var(--texte); box-shadow: var(--ombre); font-weight: 550; }
.puces { display: flex; gap: 6px; flex-wrap: wrap; }
.puce { border: 1px solid var(--bord); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; color: var(--doux); }
.puce.actif { background: var(--accent); color: var(--fond); border-color: var(--accent); }

/* Groupes et lignes */
.groupe { margin-bottom: 14px; overflow: hidden; }
.groupe > h2 { margin: 0; padding: 10px 14px; font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--bord); background: var(--surface-2); }
.groupe > h2 .compte { color: var(--tres-doux); font-weight: 500; }
.ligne { display: grid; grid-template-columns: 112px minmax(0, 2.4fr) minmax(0, 1.3fr) minmax(0, 1.25fr) minmax(0, 1fr) 116px 150px; gap: 14px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--bord); }
.ligne:last-child { border-bottom: 0; }
.ligne:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.entetes { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--tres-doux); padding-top: 8px; padding-bottom: 8px; }
.entetes:hover { background: none; }
.nom { font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.nom span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desc { color: var(--doux); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.code { font-family: var(--mono); font-size: 11.5px; color: var(--tres-doux); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.attention { color: var(--retard); font-size: 12px; margin-top: 4px; display: flex; gap: 5px; align-items: flex-start; }
.petit { color: var(--doux); font-size: 12.5px; }
.fort { font-variant-numeric: tabular-nums; }
.sous { color: var(--tres-doux); font-size: 12px; font-variant-numeric: tabular-nums; }

.etat { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 9px 3px 8px; white-space: nowrap; }
.etat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.etat.ok { color: var(--ok); background: var(--ok-fond); }
.etat.echec { color: var(--echec); background: var(--echec-fond); }
.etat.retard { color: var(--retard); background: var(--retard-fond); }
.etat.en-cours { color: var(--cours); background: var(--cours-fond); }
.etat.en-cours::before { animation: pulse 1.2s ease-in-out infinite; }
.etat.jamais, .etat.saute, .etat.inconnu { color: var(--neutre); background: var(--neutre-fond); }
@keyframes pulse { 50% { opacity: .25; } }

.histo { display: flex; gap: 2px; align-items: flex-end; height: 18px; }
.histo i { width: 4px; height: 100%; border-radius: 1.5px; background: var(--ok); opacity: .85; }
.histo i.ko { background: var(--echec); opacity: 1; }
.histo i.saute { background: var(--neutre); opacity: .5; }
.histo .vide { color: var(--tres-doux); font-size: 12px; }

.actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn { border: 1px solid var(--bord); background: var(--surface); border-radius: 7px; padding: 5px 10px; font-size: 12.5px; }
.btn:hover { background: var(--surface-2); }
.btn.primaire { background: var(--accent); color: var(--fond); border-color: var(--accent); }
.btn.primaire:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Applications */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.app { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.app .haut { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.app .nomapp { font-weight: 600; }
.app .details { display: flex; gap: 10px; flex-wrap: wrap; color: var(--doux); font-size: 12px; font-variant-numeric: tabular-nums; }
.app .bas { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.app a { font-size: 12.5px; color: var(--doux); text-decoration: none; }
.app a:hover { color: var(--texte); text-decoration: underline; }
.titre-section { font-size: 15px; margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.titre-section .meta { color: var(--tres-doux); font-size: 13px; font-weight: 400; }
.vide-etat { padding: 28px; text-align: center; color: var(--doux); }

/* Panneau journal */
.voile { position: fixed; inset: 0; background: rgba(10, 12, 16, .35); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 10; }
.voile.ouvert { opacity: 1; pointer-events: auto; }
.panneau { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--surface); border-left: 1px solid var(--bord); transform: translateX(100%); transition: transform .2s ease; z-index: 11; display: flex; flex-direction: column; }
.panneau.ouvert { transform: none; }
.panneau header { padding: 16px 18px 12px; border-bottom: 1px solid var(--bord); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.panneau h3 { margin: 0 0 4px; font-size: 16px; }
.panneau .corps { overflow: auto; padding: 14px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.passages { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.passages td, .passages th { padding: 5px 8px; border-bottom: 1px solid var(--bord); text-align: left; }
.passages th { color: var(--tres-doux); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
pre.log { margin: 0; background: var(--surface-2); border: 1px solid var(--bord); border-radius: 8px; padding: 12px; font: 11.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }
.etiquette { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--tres-doux); margin-bottom: 6px; }

dialog { border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--texte); padding: 20px; max-width: 420px; width: calc(100vw - 32px); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 12, 16, .4); }
dialog h3 { margin: 0 0 8px; font-size: 16px; }
dialog p { margin: 0 0 16px; color: var(--doux); }
dialog .boutons { display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--accent); color: var(--fond); padding: 10px 16px; border-radius: 9px; font-size: 13px; opacity: 0; transition: all .2s; z-index: 20; pointer-events: none; }
.toast.visible { opacity: 1; transform: translateX(-50%); }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion form { width: 100%; max-width: 340px; padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.connexion h1 { font-size: 18px; margin: 0; }
.connexion p { margin: 0; color: var(--doux); font-size: 13px; }
.connexion input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte); font: inherit; }
.connexion .erreur { color: var(--echec); font-size: 13px; }
.connexion button { padding: 10px; border-radius: 8px; border: 0; background: var(--accent); color: var(--fond); font-weight: 600; }

/* Mobile */
@media (max-width: 980px) {
  .synthese { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ligne { grid-template-columns: 1fr auto; grid-template-areas: "nom etat" "freq freq" "dernier prochain" "histo actions"; gap: 6px 12px; }
  .ligne > :nth-child(1) { grid-area: etat; justify-self: end; } .ligne > :nth-child(2) { grid-area: nom; }
  .ligne > :nth-child(3) { grid-area: freq; } .ligne > :nth-child(4) { grid-area: dernier; }
  .ligne > :nth-child(5) { grid-area: prochain; text-align: right; } .ligne > :nth-child(6) { grid-area: histo; }
  .ligne > :nth-child(7) { grid-area: actions; }
  .entetes { display: none; }
}
@media (max-width: 560px) { .synthese { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sante { width: 100%; } }
