/* CRM CLENAF — feuille de style unique. Couleurs et polices du site clenaf.fr. */
:root {
    --marine: #0d2032;
    --marine-clair: #1e3a5f;
    --bleu: #005ee9;
    --fond: #f5f8fc;
    --carte: #ffffff;
    --texte: #0f172a;
    --discret: #5b6676;
    --trait: #e2e8f0;
    --vert: #0f7b4f;
    --vert-fond: #e3f5ec;
    --orange: #a85a05;
    --orange-fond: #fdf0dc;
    --rouge: #b42318;
    --rouge-fond: #fde8e6;
    --bleu-fond: #e5efff;
    --rayon: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--texte);
    background: var(--fond);
}
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-family: Fraunces, Georgia, serif; font-weight: 600; font-size: 28px; margin-bottom: 20px; color: var(--marine); }
h2 { font-size: 17px; font-weight: 650; margin-bottom: 12px; color: var(--marine); }
h3 { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
p { margin: 0 0 10px; }
small, .discret { color: var(--discret); font-size: 13px; }

/* ---------- Structure ---------- */
.entete {
    position: fixed; inset: 0 auto 0 0; width: 216px;
    background: var(--marine); color: #fff;
    display: flex; flex-direction: column; padding: 22px 12px 16px;
}
.marque { color: #fff; font-family: Fraunces, Georgia, serif; font-size: 22px; font-weight: 600; padding: 0 10px 18px; letter-spacing: .5px; }
.marque span { font-family: Inter, "Segoe UI", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: 2px; opacity: .65; margin-left: 4px; }
.marque:hover { text-decoration: none; }
.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu a, .sortie {
    color: #c9d5e3; padding: 9px 10px; border-radius: 9px; font-weight: 500;
    display: flex; justify-content: space-between; align-items: center; white-space: nowrap;
}
.menu a:hover, .sortie:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.menu a.actif { background: var(--bleu); color: #fff; }
.compteur { background: #fff; color: var(--marine); border-radius: 20px; font-size: 12px; font-weight: 700; padding: 0 7px; min-width: 22px; text-align: center; }
.sortie { font-size: 13px; opacity: .8; }
main { padding: 28px 32px 60px; max-width: 1280px; }
.avec-menu main { margin-left: 216px; }
.sans-menu main { max-width: 440px; margin: 8vh auto 0; }

/* ---------- Cartes et grilles ---------- */
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 18px 20px; margin-bottom: 18px; }
.carte > :last-child { margin-bottom: 0; }
.grille { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.grille .carte { margin-bottom: 0; }
.grille + .carte, .grille + .grille, .carte + .grille { margin-top: 18px; }
.tuiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.tuile { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px 16px; }
.tuile .libelle { color: var(--discret); font-size: 13px; }
.tuile .valeur { font-size: 24px; font-weight: 650; color: var(--marine); font-variant-numeric: tabular-nums; }
.tuile .note { font-size: 12.5px; color: var(--discret); }
.barre-titre { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.barre-titre h2 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Tableaux ---------- */
.defilement { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--trait); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--discret); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 2px solid var(--trait); }
.vide { color: var(--discret); padding: 6px 0; }

/* ---------- Formulaires ---------- */
form.fiche { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.champ { display: flex; flex-direction: column; gap: 4px; }
.champ.large, form.fiche .large { grid-column: 1 / -1; }
.champ > span { font-size: 13px; font-weight: 600; color: var(--marine-clair); }
input, select, textarea {
    font: inherit; color: inherit; background: #fff; border: 1px solid #cbd5e1; border-radius: 9px;
    padding: 8px 10px; width: 100%; min-height: 38px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--bleu); outline-offset: 1px; }
input[type=checkbox] { width: auto; min-height: 0; }
.bouton, button {
    font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--bleu); background: var(--bleu); color: #fff;
    border-radius: 9px; padding: 8px 14px; display: inline-block; min-height: 38px; line-height: 20px;
}
.bouton:hover, button:hover { background: #0050c7; text-decoration: none; }
.secondaire { background: #fff; color: var(--bleu); }
.secondaire:hover { background: var(--bleu-fond); }
.danger { background: #fff; color: var(--rouge); border-color: #e7b3ae; }
.danger:hover { background: var(--rouge-fond); }
.petit { padding: 4px 10px; min-height: 30px; font-size: 13px; }
form.en-ligne { display: inline; }
.pied-formulaire { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
details > summary { cursor: pointer; font-weight: 600; color: var(--bleu); margin-bottom: 10px; }

/* ---------- Pastilles, messages ---------- */
.pastille { display: inline-block; border-radius: 20px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef2f6; color: #475569; }
.pastille.bleu { background: var(--bleu-fond); color: #0b4bb3; }
.pastille.vert { background: var(--vert-fond); color: var(--vert); }
.pastille.orange { background: var(--orange-fond); color: var(--orange); }
.pastille.rouge { background: var(--rouge-fond); color: var(--rouge); }
.message { border-radius: 10px; padding: 10px 14px; border: 1px solid; margin-bottom: 14px; }
.message.ok { background: var(--vert-fond); border-color: #b5e2cb; color: #0a5a39; }
.message.alerte { background: var(--orange-fond); border-color: #f2d3a2; color: #7a4204; }
.message.erreur { background: var(--rouge-fond); border-color: #f1bcb7; color: #8f1c13; }
.nd { color: var(--orange); font-weight: 600; }

/* ---------- Graphiques en barres ---------- */
.barres { display: grid; gap: 8px; }
.barres .ligne { display: grid; grid-template-columns: 150px 1fr 120px; gap: 10px; align-items: center; font-size: 14px; }
.barres .piste { background: #edf1f6; border-radius: 6px; height: 14px; overflow: hidden; display: flex; }
.barres .rempli { background: var(--bleu); height: 100%; }
.barres .rempli.second { background: #7fb0ff; }
.barres .rempli.vert { background: #2f9e6d; }
.barres .rempli.rouge { background: #d9534a; }
.barres .rempli.orange { background: #e0962f; }
.barres .montant { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legende { display: flex; gap: 14px; font-size: 12.5px; color: var(--discret); margin-top: 10px; flex-wrap: wrap; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ---------- Pipeline ---------- */
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(210px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.colonne { background: #eaf0f7; border-radius: var(--rayon); padding: 10px; min-height: 120px; }
.colonne > header { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 8px; font-weight: 650; color: var(--marine); }
.colonne > header small { font-weight: 500; }
.fiche-opp { background: #fff; border: 1px solid var(--trait); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: block; color: inherit; }
.fiche-opp:hover { border-color: var(--bleu); text-decoration: none; }
.fiche-opp strong { display: block; }
.fiche-opp .bas { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--discret); margin-top: 4px; }

/* ---------- Liste « à faire » ---------- */
.taches { list-style: none; margin: 0; padding: 0; }
.taches li { display: grid; grid-template-columns: 200px 1fr auto; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--trait); align-items: start; }
.taches li:last-child { border-bottom: 0; padding-bottom: 0; }
.taches .detail { text-align: right; white-space: nowrap; }

/* ---------- Fil d'activité ---------- */
.fil { list-style: none; margin: 0; padding: 0; }
.fil li { padding: 9px 0; border-bottom: 1px solid var(--trait); display: grid; grid-template-columns: 92px 1fr; gap: 10px; }
.fil li:last-child { border-bottom: 0; }
.fil .quand { color: var(--discret); font-size: 13px; }
.fil .extrait { color: var(--discret); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
dl.infos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.infos dt { color: var(--discret); }
dl.infos dd { margin: 0; overflow-wrap: anywhere; }
pre.apercu { background: #f8fafc; border: 1px solid var(--trait); border-radius: 10px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0 0 10px; }
.recherche { display: flex; gap: 8px; }
.recherche input { flex: 1; min-width: 0; }
.recherche button { white-space: nowrap; }
.resultats-siren { display: grid; gap: 6px; margin-top: 8px; }
.resultats-siren button { text-align: left; background: #fff; color: var(--texte); border-color: var(--trait); font-weight: 500; }
.resultats-siren button:hover { background: var(--bleu-fond); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .entete { position: sticky; inset: 0 0 auto 0; width: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; z-index: 5; }
    .marque { padding: 0 6px; font-size: 18px; }
    .marque span { display: none; }
    .menu { flex-direction: row; overflow-x: auto; gap: 4px; scrollbar-width: none; }
    .menu::-webkit-scrollbar { display: none; }
    .menu a { padding: 7px 10px; gap: 6px; font-size: 14px; }
    .sortie { display: none; }
    .avec-menu main { margin-left: 0; }
    main { padding: 18px 14px 50px; }
    h1 { font-size: 23px; margin-bottom: 14px; }
    .barres .ligne { grid-template-columns: 96px 1fr 96px; font-size: 13px; }
    .grille { grid-template-columns: 1fr; }
    .pipeline { grid-template-columns: repeat(5, 78vw); }
    .fil li { grid-template-columns: 1fr; gap: 2px; }
    .taches li { grid-template-columns: 1fr; }
    .taches .detail { text-align: left; white-space: normal; color: var(--discret); }
    /* Tableaux : lignes sur une seule ligne, défilement horizontal dans la carte. */
    .defilement th, .defilement td { white-space: nowrap; }
    .carte { padding: 14px; }
    .tuiles { grid-template-columns: 1fr 1fr; gap: 10px; }
    .tuile .valeur { font-size: 19px; }
}
