/* Orchestre : jetons de design (voir le skill orchestre-ci4) */
:root {
    --fond: #EDF0F2;
    --fond-menu: #F8F9FA;
    --surface: #FFFFFF;
    --texte: #151B26;
    --texte-2: #566174;
    --bordure: #D8DEE4;
    --bordure-fine: #E4E8EC;
    --bordure-champ: #B9C2CE;
    --orchestre: #2B3A8C;
    --orchestre-doux: #E3E8F6;

    --ok-fond: #DDF1E7;      --ok-texte: #0B5A3A;
    --degrade-fond: #FBE9CF; --degrade-texte: #6B3F04;
    --erreur-fond: #F8DADA;  --erreur-texte: #7A1B1B;
    --neutre-fond: #E7EAF0;  --neutre-texte: #3A4559;

    --rayon-panneau: 12px;
    --rayon-champ: 8px;
    --police-titre: "Bricolage Grotesque", system-ui, sans-serif;
    --police: "Instrument Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font: 400 15px/1.5 var(--police);
}

a { color: var(--orchestre); }
h1, h2, h3 { font-family: var(--police-titre); font-weight: 600; margin: 0; line-height: 1.2; }
h1 { font-size: 34px; }
h2 { font-size: 20px; }

/* Structure : menu latéral de 240 px, contenu à droite */
.page { display: flex; min-height: 100vh; }

.menu {
    flex: 0 0 240px;
    background: var(--fond-menu);
    border-right: 1px solid var(--bordure);
    padding: 24px 16px;
}
.menu-marque { display: flex; align-items: center; gap: 10px; margin: 0 8px 28px; font-family: var(--police-titre); font-size: 20px; font-weight: 600; }
.menu-groupe { margin-bottom: 22px; }
.menu-groupe-titre { margin: 0 8px 6px; font-size: 13px; font-weight: 600; color: var(--texte-2); }
.menu a {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 8px; border-radius: var(--rayon-champ);
    color: var(--texte); text-decoration: none;
}
.menu a:hover { background: var(--orchestre-doux); }
.menu a[aria-current="page"] { background: var(--orchestre-doux); color: var(--orchestre); font-weight: 600; }
.menu-utilisateur { border-top: 1px solid var(--bordure-fine); padding: 16px 8px 0; font-size: 14px; color: var(--texte-2); }
.menu-utilisateur strong { display: block; color: var(--texte); }

.contenu { flex: 1; min-width: 0; padding: 32px 40px 48px; }

.entete { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.entete p { margin: 8px 0 0; color: var(--texte-2); max-width: 680px; }

@media (max-width: 800px) {
    .page { flex-direction: column; }
    .menu { flex: none; border-right: 0; border-bottom: 1px solid var(--bordure); }
    .contenu { padding: 24px 16px 40px; }
    .entete { flex-direction: column; }
    h1 { font-size: 28px; }
}

/* Panneaux */
.panneau {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-panneau);
    padding: 24px;
    margin-bottom: 24px;
}
.panneau > h2 { margin-bottom: 6px; }
.panneau > .note { margin: 0 0 18px; }
.note { color: var(--texte-2); font-size: 14px; }
.grille-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 1100px) { .grille-2 { grid-template-columns: 1fr; } }

/* Point de couleur d'application */
.point { display: inline-block; width: 10px; height: 10px; border-radius: 999px; flex: none; }

/* Pastilles de statut : toujours un libellé */
.pastille { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pastille-ok { background: var(--ok-fond); color: var(--ok-texte); }
.pastille-degrade { background: var(--degrade-fond); color: var(--degrade-texte); }
.pastille-erreur { background: var(--erreur-fond); color: var(--erreur-texte); }
.pastille-neutre { background: var(--neutre-fond); color: var(--neutre-texte); }
.pastille-orchestre { background: var(--orchestre-doux); color: var(--orchestre); }

/* Tableaux */
.defilement { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--bordure-fine); vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--texte-2); }
tr:last-child td { border-bottom: 0; }
td.etroit, th.etroit { width: 1%; white-space: nowrap; }

/* Formulaires */
label { display: block; font-weight: 500; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
    width: 100%; min-height: 44px; padding: 8px 12px;
    border: 1px solid var(--bordure-champ); border-radius: var(--rayon-champ);
    background: var(--surface); color: var(--texte); font: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
    outline: 2px solid var(--orchestre); outline-offset: 2px;
}
.champ { margin-bottom: 16px; }
.champ-aide { font-size: 13px; color: var(--texte-2); margin-top: 4px; }
.case { display: flex; align-items: center; gap: 10px; min-height: 36px; font-weight: 400; }
.case input { width: 18px; height: 18px; }

.bouton {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 8px 18px;
    border: 1px solid var(--orchestre); border-radius: var(--rayon-champ);
    background: var(--orchestre); color: #fff; font: 600 15px var(--police);
    cursor: pointer; text-decoration: none;
}
.bouton-secondaire { background: var(--surface); color: var(--orchestre); }
.bouton-lien { border: 0; background: none; color: var(--orchestre); padding: 0; min-height: 0; font: inherit; text-decoration: underline; cursor: pointer; }

/* Messages */
.message { padding: 12px 16px; border-radius: var(--rayon-champ); margin-bottom: 20px; }
.message-ok { background: var(--ok-fond); color: var(--ok-texte); }
.message-erreur { background: var(--erreur-fond); color: var(--erreur-texte); }
.message ul { margin: 0; padding-left: 18px; }

.vide { padding: 24px; text-align: center; color: var(--texte-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.app-nom { display: inline-flex; align-items: center; gap: 8px; }
.pastilles { display: flex; flex-wrap: wrap; gap: 6px; }
.filtre { display: flex; gap: 12px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filtre .champ { margin: 0; flex: 1; min-width: 220px; }
.filtre-utilisateurs .champ { flex: 1 1 160px; min-width: 150px; }
.filtre-utilisateurs .champ-large { flex: 2 1 240px; }

/* Chiffres clés */
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.chiffre { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon-panneau); padding: 18px 20px; }
.chiffre p { margin: 0; }
.chiffre-libelle { font-weight: 500; color: var(--texte-2); }
.chiffre-valeur { font-family: var(--police-titre); font-weight: 600; font-size: 40px; line-height: 1.15; margin: 4px 0 6px !important; font-variant-numeric: tabular-nums; }

/* Matrice : une seule teinte, du clair au foncé (5 paliers) */
:root {
    --seq-1: #E3E8F6; --seq-2: #C3CDEC; --seq-3: #93A3D8; --seq-4: #4A5BAA; --seq-5: #2B3A8C;
}
.matrice th, .matrice td { border-bottom: 2px solid var(--surface); }
.matrice td.nombre, .matrice th.nombre { text-align: center; min-width: 72px; }
.matrice td.case-1 { background: var(--seq-1); }
.matrice td.case-2 { background: var(--seq-2); }
.matrice td.case-3 { background: var(--seq-3); }
.matrice td.case-4 { background: var(--seq-4); }
.matrice td.case-5 { background: var(--seq-5); }
.matrice td.case-1, .matrice td.case-2, .matrice td.case-3 { border-left: 2px solid var(--surface); }
.matrice td.case-4, .matrice td.case-5 { border-left: 2px solid var(--surface); color: #fff; }
.matrice td.case-4 a, .matrice td.case-5 a { color: #fff; }
.matrice td a { color: inherit; font-weight: 600; }
.matrice .zero { color: var(--texte-2); }
.matrice .total { font-weight: 600; background: var(--fond-menu); }
.matrice tfoot th, .matrice tfoot td { border-top: 1px solid var(--bordure); }

/* Barres horizontales : marque fine, extrémité arrondie, valeur en texte */
.grille-egale { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.barre-ligne { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 40px; align-items: center; gap: 12px; min-height: 32px; }
.barre-libelle { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-piste { height: 12px; }
.barre { display: block; height: 12px; min-width: 2px; background: var(--orchestre); border-radius: 0 4px 4px 0; }
.barre-valeur { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.barre-ligne:hover .barre-libelle { color: var(--orchestre); }

.a-traiter { list-style: none; margin: 0; padding: 0; }
.a-traiter li { padding: 10px 0; border-top: 1px solid var(--bordure-fine); }
.a-traiter li:first-child { border-top: 0; }

/* État global : couleur + libellé, jamais la couleur seule */
.etat-global {
    display: flex; align-items: center; gap: 18px;
    padding: 20px 24px; margin-bottom: 24px;
    border-radius: var(--rayon-panneau); border: 1px solid transparent;
}
.etat-global p { margin: 0; }
.etat-pastille { width: 22px; height: 22px; border-radius: 999px; flex: none; }
.etat-titre { font-family: var(--police-titre); font-weight: 600; font-size: 26px; line-height: 1.2; }
.etat-phrase { margin-top: 4px !important; }
.etat-ok { background: var(--ok-fond); color: var(--ok-texte); border-color: #B7E0CB; }
.etat-ok .etat-pastille { background: #1E8A5A; }
.etat-degrade { background: var(--degrade-fond); color: var(--degrade-texte); border-color: #F1D3A6; }
.etat-degrade .etat-pastille { background: #C77A0F; }
.etat-erreur { background: var(--erreur-fond); color: var(--erreur-texte); border-color: #EDB8B8; }
.etat-erreur .etat-pastille { background: #C23434; }

/* Contrôles de santé : une carte par groupe, une ligne par contrôle */
.sante { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 1100px) { .sante { grid-template-columns: 1fr; } }
.sante-carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon-panneau); padding: 20px 24px 8px; }
.sante-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--bordure-fine); }
.sante-entete h2 { font-size: 18px; }
.sante-liste { list-style: none; margin: 0; padding: 0; }
.sante-liste li {
    display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: center;
    padding: 12px 0; border-top: 1px solid var(--bordure-fine);
}
.sante-liste li:first-child { border-top: 0; }
.sante-icone {
    display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px;
    font-size: 12px; font-weight: 700; line-height: 1;
}
.sante-ok .sante-icone { background: var(--ok-fond); color: var(--ok-texte); }
.sante-degrade .sante-icone { background: var(--degrade-fond); color: var(--degrade-texte); }
.sante-erreur .sante-icone { background: var(--erreur-fond); color: var(--erreur-texte); }
.sante-texte { min-width: 0; }
.sante-libelle { display: block; font-weight: 500; }
.sante-detail { display: block; font-size: 13px; color: var(--texte-2); overflow-wrap: anywhere; }
.sante-valeur { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sante-degrade .sante-valeur { color: var(--degrade-texte); }
.sante-erreur .sante-valeur { color: var(--erreur-texte); }
.sante-note { margin: 10px 0 24px; }

/* Page de connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.connexion .panneau { width: 100%; max-width: 420px; margin: 0; }
.connexion h1 { font-size: 28px; margin-bottom: 6px; }

/* Lien vers l'état du serveur, en haut de la Vue d'ensemble */
.etat-lien {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px;
    border-radius: 999px; border: 1px solid transparent; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.etat-lien .sante-icone { background: var(--surface); }
.etat-lien-ok { background: var(--ok-fond); color: var(--ok-texte); border-color: #B7E0CB; }
.etat-lien-degrade { background: var(--degrade-fond); color: var(--degrade-texte); border-color: #F1D3A6; }
.etat-lien-erreur { background: var(--erreur-fond); color: var(--erreur-texte); border-color: #EDB8B8; }
.etat-lien:hover { text-decoration: underline; }
code { font-size: 13px; }

/* Mes applications : une tuile par application ouverte */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; max-width: 1100px; }
.tuile {
    --app: var(--orchestre);
    position: relative; display: flex; flex-direction: column; gap: 14px; min-height: 210px;
    padding: 24px; overflow: hidden;
    background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon-panneau);
    color: var(--texte); text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
/* Filet de la couleur de l'application en haut de la tuile */
.tuile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--app); }
.tuile:hover { border-color: var(--app); box-shadow: 0 8px 24px rgba(21, 27, 38, .08); transform: translateY(-2px); }
.tuile:focus-visible { outline: 2px solid var(--app); outline-offset: 3px; }
.tuile-tete { display: flex; align-items: center; gap: 14px; }
.tuile-badge {
    display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 12px;
    background: var(--app); color: #fff; font-family: var(--police-titre); font-weight: 600; font-size: 22px;
}
.tuile-nom { font-family: var(--police-titre); font-weight: 600; font-size: 22px; line-height: 1.2; }
.tuile-texte { flex: 1; color: var(--texte-2); }
.tuile-pied {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding-top: 14px; border-top: 1px solid var(--bordure-fine);
}
.tuile-acces { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--texte-2); }
.tuile-ouvrir { font-weight: 600; color: var(--app); white-space: nowrap; }
.tuile:hover .tuile-ouvrir span { margin-left: 4px; }
@media (prefers-reduced-motion: reduce) { .tuile { transition: none; } .tuile:hover { transform: none; } }
.connexion-app { display: flex; align-items: center; gap: 10px; }
.connexion-app .point { width: 14px; height: 14px; }
