:root {
  --bg: #f4f5f8; --card: #fff; --txt: #1d2433; --muted: #667085; --line: #e3e6ec;
  --brand: #2f5bea; --brand-d: #2347c0; --ok: #1f9d55; --ko: #d64545; --warn: #d98a00;
  --a1: #2f5bea; --a2: #0e9384; --a3: #b54ad1; --a4: #e0702a; --b4: #c2410c;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--txt); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.12rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; }

/* ---------- structure ---------- */
.topbar { display: flex; align-items: center; gap: 1.5rem; background: #141b2d; color: #fff; padding: .6rem 1.2rem; position: sticky; top: 0; z-index: 10; }
.topbar a { color: #c9d4ff; }
.brand { font-weight: 700; color: #fff !important; font-size: 1.05rem; }
.logo { display: inline-block; background: var(--brand); color: #fff; border-radius: 6px; padding: 2px 7px; font-weight: 800; letter-spacing: .5px; }
.entreprise-badge { display: flex; flex-direction: column; line-height: 1.2; font-size: .9rem; }
.entreprise-badge span { color: #aab6d3; font-size: .82rem; }
.user { margin-left: auto; font-size: .88rem; color: #aab6d3; }
.wrap { display: flex; min-height: calc(100vh - 52px); }
.sidenav { width: 230px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 1rem .6rem; }
.sidenav a { display: block; padding: .45rem .7rem; border-radius: 8px; color: var(--txt); font-size: .93rem; }
.sidenav a:hover { background: #f0f3fa; text-decoration: none; }
.sidenav a.actif { background: #e8eeff; color: var(--brand-d); font-weight: 600; }
.nav-titre { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1rem .7rem .3rem; }
.contenu { flex: 1; padding: 1.4rem 1.8rem 3rem; max-width: 1250px; min-width: 0; }
@media (max-width: 860px) {
  .wrap { flex-direction: column; }
  .sidenav { width: auto; display: flex; flex-wrap: wrap; gap: .2rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-titre { display: none; }
  .contenu { padding: 1rem; }
  .topbar { flex-wrap: wrap; gap: .5rem; }
}

/* ---------- composants ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.1rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card.narrow { max-width: 560px; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.1rem; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-d); text-decoration: none; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid #c8d3f5; }
.btn.ghost:hover { background: #f0f4ff; }
.actions-bar { display: flex; flex-wrap: wrap; gap: .6rem; margin: .4rem 0 1.2rem; align-items: center; }
form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #e7f6ec; border: 1px solid #b6e3c5; }
.flash.err { background: #fdecec; border-color: #f3c0c0; }
.tag { display: inline-block; font-size: .72rem; background: #eef1f6; color: var(--muted); border-radius: 20px; padding: 0 .5rem; vertical-align: middle; }
.alerte { color: var(--warn); font-weight: 600; }

.pastille { display: inline-block; min-width: 2.1rem; text-align: center; font-size: .75rem; font-weight: 700; color: #fff; border-radius: 6px; padding: 1px 6px; background: #888; }
.pastille.a1 { background: var(--a1); } .pastille.a2 { background: var(--a2); } .pastille.a3 { background: var(--a3); }
.pastille.a4 { background: var(--a4); } .pastille.b4 { background: var(--b4); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin: 1rem 0 1.2rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .2rem; }
.kpi-label { font-size: .8rem; color: var(--muted); }
.kpi-val { font-size: 1.5rem; font-weight: 700; }
.kpi-val.small { font-size: 1rem; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.jauge { display: inline-block; width: 100%; max-width: 160px; height: 7px; background: #edf0f5; border-radius: 6px; overflow: hidden; vertical-align: middle; }
.jauge span { display: block; height: 100%; }
.jauge .bas { background: var(--ko); } .jauge .moyen { background: var(--warn); } .jauge .haut { background: var(--ok); }

.liste-taches { list-style: none; margin: 0; padding: 0; }
.liste-taches li a { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "p t" "p r" "p e"; column-gap: .8rem; padding: .7rem .6rem; border-bottom: 1px solid var(--line); color: var(--txt); border-radius: 8px; }
.liste-taches li a:hover { background: #f6f8fc; text-decoration: none; }
.liste-taches .pastille { grid-area: p; align-self: start; margin-top: 2px; }
.lt-titre { grid-area: t; font-weight: 600; }
.lt-resume { grid-area: r; color: var(--muted); font-size: .87rem; }
.lt-ech { grid-area: e; font-size: .8rem; color: var(--muted); }
.lt-ech.urgent { color: var(--ko); font-weight: 600; }
.modules-mini { display: grid; gap: .5rem; }
.mod-mini { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem .8rem; border-radius: 8px; border-left: 5px solid; background: #fafbfd; color: var(--txt); font-size: .9rem; }
.mod-mini.a1 { border-color: var(--a1); } .mod-mini.a2 { border-color: var(--a2); } .mod-mini.a3 { border-color: var(--a3); } .mod-mini.a4 { border-color: var(--a4); } .mod-mini.b4 { border-color: var(--b4); }
.mod-mini span { color: var(--muted); font-size: .82rem; }
.journal { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.journal li { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.journal.grand li { padding: .5rem 0; }

.table-wrap { overflow-x: auto; }
.table, .ctx-table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td, .ctx-table th, .ctx-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th, .ctx-table th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #f8f9fc; }
.table.small td, .ctx-table.small td { font-size: .85rem; padding: .35rem .5rem; }
.num { text-align: right !important; white-space: nowrap; }
tr.ko td { background: #fff3f3; }
tr.ok td { background: #f1fbf4; }
.statut { font-size: .78rem; padding: 1px 8px; border-radius: 20px; background: #eef1f6; white-space: nowrap; }
.st-afaire { background: #e8eeff; color: var(--brand-d); }
.st-ok, .st-rdv, .st-qualifie { background: #e3f6ea; color: #136c3a; }
.st-exp, .st-a_relancer { background: #fdecec; color: #a12d2d; }
.filtres { display: flex; gap: .6rem; margin-bottom: 1rem; }
select, input, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid #ccd3df; border-radius: 7px; background: #fff; max-width: 100%; }
textarea { width: 100%; }
.form { display: flex; flex-direction: column; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.form label.opt { flex-direction: row; font-weight: 400; }
.form fieldset { border: 1px solid var(--line); border-radius: 8px; }
.opt.inline { display: inline-flex !important; margin-right: .8rem; }
.aide { color: var(--muted); font-size: .84rem; margin: .2rem 0; }

/* ---------- tâches / fiches ---------- */
.tache-head { display: flex; align-items: center; gap: 1rem; background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--brand); border-radius: var(--radius); padding: .9rem 1.2rem; margin-bottom: .8rem; }
.tache-head.a2 { border-left-color: var(--a2); } .tache-head.a3 { border-left-color: var(--a3); } .tache-head.a4 { border-left-color: var(--a4); } .tache-head.b4 { border-left-color: var(--b4); }
.tache-head h1 { margin: 0; font-size: 1.3rem; }
.tache-head p { margin: .2rem 0 0; }
.tache-head .pastille { font-size: 1rem; padding: 4px 10px; }
.score-box { margin-left: auto; font-size: 1.8rem; font-weight: 800; color: var(--brand-d); white-space: nowrap; }
.score-box small { font-size: 1rem; color: var(--muted); }
.refs { margin: 0 0 1rem; font-size: .88rem; }
.refs summary { cursor: pointer; color: var(--muted); }
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 1rem; gap: .3rem; counter-reset: s; flex-wrap: wrap; }
.stepper li { counter-increment: s; flex: 1; min-width: 120px; font-size: .8rem; padding: .4rem .6rem; background: #eef1f6; border-radius: 6px; color: var(--muted); }
.stepper li::before { content: counter(s) ". "; font-weight: 700; }
.stepper li.fait { background: #e3f6ea; color: #136c3a; }
.stepper li.courant { background: var(--brand); color: #fff; font-weight: 600; }
.etape.courante { border: 2px solid #c8d3f5; }
.etape details summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin-bottom: .5rem; }
.ctx-texte { margin: .4rem 0 .8rem; }
.ctx-info { background: #f3f6ff; border-left: 4px solid var(--brand); padding: .6rem .9rem; border-radius: 6px; margin: .6rem 0; font-size: .92rem; white-space: pre-line; }
.ctx-message { border: 1px solid var(--line); border-radius: 8px; margin: .6rem 0 1rem; background: #fcfcfe; }
.msg-head { padding: .5rem .8rem; border-bottom: 1px solid var(--line); font-size: .9rem; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.msg-canal { background: #141b2d; color: #fff; border-radius: 4px; font-size: .72rem; padding: 1px 6px; }
.msg-objet { padding: .4rem .8rem 0; font-weight: 600; }
.msg-corps { padding: .6rem .8rem .9rem; }
.etoiles { color: #f5a623; letter-spacing: 1px; }
.ctx-dialogue { display: flex; flex-direction: column; gap: .5rem; margin: .8rem 0; }
.bulle { max-width: 78%; padding: .6rem .9rem; border-radius: 14px; background: #eef1f6; }
.bulle .qui { display: block; font-size: .75rem; font-weight: 700; color: var(--muted); }
.bulle.client { align-self: flex-start; border-bottom-left-radius: 4px; }
.bulle.vous { align-self: flex-end; background: #dfe8ff; border-bottom-right-radius: 4px; }
.ctx-fiche { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; padding: .7rem 1rem; margin: .6rem 0; font-size: .9rem; }
.ctx-fiche dt { color: var(--muted); }
.ctx-fiche dd { margin: 0; font-weight: 600; }
.ctx-table caption { text-align: left; font-weight: 600; padding: .3rem 0; }
.question { border: 1px solid var(--line); border-radius: 9px; padding: .8rem 1rem 1rem; margin: 1rem 0; }
.question legend { font-weight: 600; padding: 0 .4rem; }
.qnum { display: inline-block; background: var(--brand); color: #fff; border-radius: 50%; width: 1.5rem; height: 1.5rem; text-align: center; font-size: .8rem; line-height: 1.5rem; margin-right: .2rem; }
.pts { font-size: .75rem; color: var(--muted); font-weight: 400; margin-left: .3rem; }
.opt { display: flex; gap: .5rem; align-items: flex-start; padding: .45rem .6rem; border-radius: 7px; cursor: pointer; }
.opt:hover { background: #f4f6fb; }
.opt input { margin-top: .25rem; }
.cartes-produits { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.carte-produit { position: relative; border: 1px solid var(--line); border-radius: 9px; padding: .7rem .8rem .7rem 2.2rem; cursor: pointer; display: flex; flex-direction: column; gap: .2rem; }
.carte-produit input { position: absolute; left: .7rem; top: .85rem; }
.carte-produit:has(input:checked) { border-color: var(--brand); background: #f3f6ff; }
.cp-nom { font-weight: 600; }
.cp-prix { color: var(--brand-d); font-weight: 700; }
.cp-desc { color: var(--muted); font-size: .82rem; }
input.num { width: 9rem; text-align: right; }
.ctx-table input.num { width: 7rem; }
.nombre { display: flex; align-items: center; gap: .4rem; }

.corr { border-left: 4px solid var(--line); padding: .6rem .9rem; margin: .7rem 0; border-radius: 0 8px 8px 0; background: #fafbfd; }
.corr-ok { border-color: var(--ok); } .corr-ko { border-color: var(--ko); } .corr-partiel { border-color: var(--warn); }
.corr-attente { border-color: #8a94a6; } .corr-valide { border-color: var(--a3); }
.corr-head { font-weight: 600; }
.corr-rep, .corr-bonne, .corr-expl, .corr-info, .corr-prof { font-size: .9rem; margin-top: .3rem; }
.corr-bonne { color: #136c3a; }
.corr-expl { color: var(--muted); white-space: pre-line; }
.corr-info { color: var(--muted); font-style: italic; }
.corr-prof { background: #f6ecfb; padding: .4rem .6rem; border-radius: 6px; }
.corr blockquote { margin: .3rem 0; padding: .5rem .8rem; background: #fff; border: 1px solid var(--line); border-radius: 6px; white-space: pre-wrap; }
.corr-modele { font-size: .87rem; margin-top: .3rem; }
.form-valider { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; background: #fff; padding: .5rem; border: 1px dashed #c9b3d9; border-radius: 8px; }
.form-valider input[name=commentaire] { flex: 1; min-width: 200px; }
.bilan-tache { background: #e3f6ea; border-color: #b6e3c5; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* ---------- prof ---------- */
.cartes-classes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.classe-carte { color: var(--txt); }
.classe-carte:hover { border-color: var(--brand); text-decoration: none; }
.classe-carte p { margin: .3rem 0; font-size: .9rem; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; }
.grid-form fieldset, .grid-form .btn, .grid-form .opt { grid-column: 1 / -1; }
.matrice th.vert { height: 130px; white-space: nowrap; vertical-align: bottom; padding: 0 .2rem; }
.matrice th.vert span { display: inline-block; transform: rotate(-60deg); transform-origin: left bottom; width: 1.6rem; margin-left: 1rem; }
.matrice tr.sep td { background: #f3f5fa; font-weight: 600; }
.cell { text-align: center; font-weight: 600; font-size: .85rem; min-width: 2rem; }
.c0 { background: #f7f7f9; } .c1 { background: #fbd5d5; } .c2 { background: #fde9bf; } .c3 { background: #c8efd5; }
.legende .cell { display: inline-block; width: 1.4rem; border-radius: 3px; margin: 0 .2rem 0 .8rem; }
.couv tr.vide td { color: var(--muted); }

/* ---------- connexion / impression ---------- */
body.simple { display: flex; flex-direction: column; align-items: center; padding-top: 6vh; }
.login-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 2rem; width: min(420px, 92vw); box-shadow: 0 10px 30px rgba(16, 24, 40, .08); }
.login-head { text-align: center; margin-bottom: 1.2rem; }
.login-head .logo { font-size: 1.4rem; padding: 4px 12px; }
.login-head p { color: var(--muted); }
.login-box form { display: flex; flex-direction: column; gap: .8rem; }
.login-box label { display: flex; flex-direction: column; gap: .2rem; font-weight: 600; }
.impression { width: min(1000px, 95vw); }
.etiquettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.etiquette { border: 1px dashed #999; padding: .7rem; font-size: .9rem; break-inside: avoid; }
@media print { .no-print { display: none; } body.simple { padding: 0; } }

/* ---------- graphiques ---------- */
.grid-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 1.1rem; }
@media (max-width: 600px) { .grid-charts { grid-template-columns: 1fr; } }
.grid-charts .card { margin: 0; }
.chart { width: 100%; height: auto; display: block; font-family: inherit; }
.chart .ax { font-size: 11px; fill: #667085; }
.chart .lab { font-size: 12px; fill: #344054; }
.chart .val { font-size: 12px; fill: #1d2433; font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: #98a2b3; stroke-width: 1; pointer-events: none; }
.chart .crossdot { fill: #2a78d6; stroke: #fff; stroke-width: 2; pointer-events: none; }
.chart-tip { position: absolute; display: none; background: #141b2d; color: #fff; font-size: .8rem; padding: .3rem .6rem; border-radius: 6px; pointer-events: none; z-index: 50; white-space: nowrap; }
.chart-data { margin-top: .4rem; font-size: .85rem; }
.chart-data summary { cursor: pointer; color: var(--muted); }
.legende-chart { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: #344054; margin-bottom: .4rem; }
.legende-chart i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }

/* ---------- épreuves / équipes ---------- */
.badge { display: inline-block; background: var(--ko); color: #fff; border-radius: 20px; font-size: .72rem; padding: 0 .45rem; margin-left: .2rem; font-weight: 700; }
.bandeau-epreuve { display: block; background: #fff4e5; border: 1px solid #f5c98a; color: #8a4b00; padding: .7rem 1rem; border-radius: 8px; margin: .5rem 0 1rem; font-weight: 600; }
.chrono { position: sticky; top: 56px; z-index: 5; background: #141b2d; color: #fff; padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 1rem; }
.chrono strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.chrono.urgent { background: var(--ko); }
.ligne-epreuve { display: flex; gap: .6rem; flex-wrap: wrap; margin: .4rem 0; }
.ligne-epreuve select { min-width: 260px; }
.sujet-tache { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin: .6rem 0; }
.sujet-tache summary { cursor: pointer; }
.sujet-etape { border-top: 1px dashed var(--line); margin-top: .7rem; padding-top: .4rem; }
.corrige li { margin: .4rem 0; }
details.card > summary { cursor: pointer; }
.grid2 > * { min-width: 0; }
.form select { width: 100%; }
