:root {
    --fond: #f4f3ef;
    --carte: #ffffff;
    --texte: #1f2328;
    --texte-2: #5b6470;
    --bord: #d9d6cf;
    --accent: #2b4c7e;
    --accent-2: #e8eef7;
    --danger: #a33a2c;
    --ok: #2f6b3a;
    --ombre: 0 1px 2px rgba(0,0,0,.06);
    --rayon: 8px;
    --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--police); font-size: 15px; line-height: 1.5; color: var(--texte); background: var(--fond); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .8rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.discret { color: var(--texte-2); font-size: .9em; }
.note { color: var(--texte-2); }
.inline { display: inline; }

.entete { display: flex; justify-content: space-between; align-items: center; padding: .6rem 1.2rem; background: var(--carte); border-bottom: 1px solid var(--bord); gap: 1rem; }
.entete-gauche, .entete-droite { display: flex; align-items: center; gap: 1rem; }
.marque { font-weight: 700; text-decoration: none; color: var(--texte); font-size: 1.05rem; }
.nav a { text-decoration: none; color: var(--texte-2); padding: .3rem .6rem; border-radius: 6px; }
.nav a.actif, .nav a:hover { color: var(--accent); background: var(--accent-2); }
.qui { color: var(--texte-2); }
.lien-discret { color: var(--texte-2); font-size: .9em; }

.contenu { flex: 1; padding: 1.2rem; max-width: 1400px; width: 100%; margin: 0 auto; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1.2rem 1.4rem; box-shadow: var(--ombre); }
.carte-etroite { max-width: 480px; margin: 3rem auto; }
.page-erreur .carte { max-width: 520px; margin: 4rem auto; }

label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--bord); border-radius: 6px; font: inherit; background: #fff; color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.bouton { display: inline-block; padding: .5rem .9rem; border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 6px; font: inherit; cursor: pointer; text-decoration: none; margin-top: .8rem; }
.bouton:hover { filter: brightness(1.08); }
.bouton-secondaire { background: #fff; color: var(--accent); }
.bouton-danger { background: var(--danger); border-color: var(--danger); }
.bouton-petit { padding: .25rem .55rem; font-size: .85em; margin-top: 0; }
.alerte { background: #fbe9e6; border: 1px solid #efc2bb; color: var(--danger); padding: .6rem .8rem; border-radius: 6px; }
.succes { background: #e6f3e8; border: 1px solid #bfdcc5; color: var(--ok); padding: .6rem .8rem; border-radius: 6px; }

.filtres { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: flex-end; margin-bottom: 1rem; }
.filtres label { margin: 0; min-width: 160px; }
.filtres .bouton { margin-top: 0; }
.tableau-conteneur { overflow-x: auto; }
.tableau { border-collapse: collapse; width: 100%; font-size: .93em; }
.tableau th, .tableau td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau th { background: var(--fond); font-weight: 600; white-space: nowrap; }
.tableau tr:hover td { background: #fafaf7; }
.pagination { display: flex; gap: 1rem; margin-top: 1rem; }
.num { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.extrait { color: var(--texte-2); }
.extrait mark { background: #fff1a8; padding: 0 .1em; }
.badge { display: inline-block; font-size: .78em; padding: .05rem .45rem; border-radius: 999px; background: var(--accent-2); color: var(--accent); white-space: nowrap; }
.badge-pj { background: #fdf1dc; color: #8a5a00; }

/* Visionneuse */
.piece-entete { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin-bottom: 1rem; }
.piece-entete dt { color: var(--texte-2); }
.piece-entete dd { margin: 0; word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 1rem; }
.actions .bouton { margin-top: 0; }
.corps { white-space: pre-wrap; word-wrap: break-word; font-family: var(--police); background: #fbfaf7; border: 1px solid var(--bord); border-radius: 6px; padding: 1rem; max-height: 70vh; overflow: auto; }
.liste-pj { list-style: none; padding: 0; margin: 0; }
.liste-pj li { padding: .35rem 0; border-bottom: 1px dashed var(--bord); display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.nav-fil { display: flex; justify-content: space-between; margin-top: 1rem; }

/* Chat */
.chat { display: grid; grid-template-columns: 260px 1fr 300px; gap: 1rem; height: calc(100vh - 100px); min-height: 500px; }
.chat-colonne { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); display: flex; flex-direction: column; min-height: 0; }
.chat-colonne h2 { margin: 0; padding: .8rem 1rem; border-bottom: 1px solid var(--bord); font-size: 1rem; display: flex; justify-content: space-between; align-items: center; }
.liste-discussions { list-style: none; margin: 0; padding: .4rem; overflow-y: auto; flex: 1; }
.liste-discussions li a { display: block; padding: .5rem .6rem; border-radius: 6px; color: var(--texte); text-decoration: none; }
.liste-discussions li a:hover { background: var(--fond); }
.liste-discussions li.actif a { background: var(--accent-2); color: var(--accent); }
.liste-discussions .quand { display: block; font-size: .8em; color: var(--texte-2); }
.echanges { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.echange { max-width: 100%; }
.echange-user { align-self: flex-end; background: var(--accent-2); border-radius: 12px 12px 2px 12px; padding: .6rem .9rem; max-width: 85%; white-space: pre-wrap; }
.echange-assistant { background: #fbfaf7; border: 1px solid var(--bord); border-radius: 12px 12px 12px 2px; padding: .8rem 1rem; }
.echange-assistant h2 { font-size: 1.05rem; margin: .8rem 0 .4rem; }
.echange-assistant h3 { font-size: 1rem; margin: .7rem 0 .3rem; }
.echange-assistant p { margin: .4rem 0; }
.echange-assistant ul, .echange-assistant ol { margin: .3rem 0 .5rem 1.2rem; padding: 0; }
.echange-assistant table { border-collapse: collapse; margin: .5rem 0; font-size: .93em; }
.echange-assistant th, .echange-assistant td { border: 1px solid var(--bord); padding: .3rem .5rem; }
.echange-erreur { border-color: #efc2bb; background: #fbe9e6; }
.citation { display: inline-block; font-family: var(--mono); font-size: .85em; background: #fff; border: 1px solid var(--bord); border-radius: 4px; padding: 0 .3em; text-decoration: none; color: var(--accent); }
.citation:hover { background: var(--accent-2); }
.etapes { margin-top: .6rem; font-size: .85em; color: var(--texte-2); }
.etapes summary { cursor: pointer; }
.etapes ul { margin: .3rem 0 0 1rem; padding: 0; }
.etapes li.en-cours::before { content: "… "; }
.etapes li.faite::before { content: "✓ "; color: var(--ok); }
.saisie { border-top: 1px solid var(--bord); padding: .8rem 1rem; display: flex; gap: .6rem; align-items: flex-end; }
.saisie textarea { flex: 1; min-height: 60px; max-height: 200px; resize: vertical; }
.saisie .bouton { margin-top: 0; white-space: nowrap; }
.pieces-citees { list-style: none; margin: 0; padding: .6rem; overflow-y: auto; flex: 1; }
.pieces-citees li { padding: .45rem .5rem; border-bottom: 1px solid var(--bord); }
.pieces-citees a { text-decoration: none; color: var(--texte); display: block; }
.pieces-citees a:hover { background: var(--fond); }
.pieces-citees .objet { display: block; font-size: .9em; color: var(--texte-2); }
.vide { color: var(--texte-2); padding: 1rem; text-align: center; }
.titre-discussion { font-weight: 600; cursor: text; }
.titre-discussion:focus { outline: 2px solid var(--accent); border-radius: 4px; }
.en-attente { color: var(--texte-2); font-style: italic; }

/* Dialogue de confirmation */
.dialogue { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 100; }
.dialogue-boite { background: var(--carte); padding: 1.2rem 1.4rem; border-radius: var(--rayon); max-width: 420px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.dialogue-actions { display: flex; gap: .6rem; justify-content: flex-end; }

@media (max-width: 1000px) {
    .chat { grid-template-columns: 1fr; height: auto; }
    .chat-colonne { max-height: 60vh; }
}

/* check.php */
.carte-check { max-width: 860px; margin: 2rem auto; }
.etat-ok { color: var(--ok); font-weight: 600; }
.etat-bloquant { color: var(--danger); font-weight: 600; }
.etat-attention { color: #8a5a00; font-weight: 600; }

[hidden] { display: none !important; }

/* synthese et resumes */
.carte-lecture { max-width: 900px; margin: 0 auto; }
.synthese-corps { margin-top: 1rem; }
.resume { font-size: .9em; color: var(--texte-2); max-width: 360px; }
.resume-fil { background: #fbfaf7; border: 1px solid var(--bord); border-radius: 6px; padding: .6rem .8rem; }
