:root {
  --bg: #f4f6fa; --card: #fff; --text: #1b2333; --muted: #6b7489; --line: #dfe3ec;
  --primary: #1f4fd1; --primary-ink: #fff; --ok: #1a8a4a; --ok-bg: #e5f5ec; --danger: #c62e2e;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
body.public main { max-width: 560px; }
h1 { font-size: 1.5rem; margin: .4em 0; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .6em; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .9em; word-break: break-all; }
.big { font-size: 1.15rem; }
.error { color: var(--danger); font-weight: 600; }
.center { text-align: center; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: var(--text); }
.topbar .brand { display: flex; align-items: center; gap: 14px; color: #fff; font-weight: 800; font-size: 1.1rem; text-decoration: none; }
.topbar .brand-logo { height: 32px; width: auto; padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .25); }
@media (max-width: 560px) { .topbar .brand-logo { height: 20px; padding-left: 10px; } .topbar .brand { gap: 10px; font-size: 1rem; } }
.login-logo { display: block; width: 100%; max-width: 300px; margin: 0 auto 8px; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a, .topbar .link { color: #cfd6e6; text-decoration: none; font-size: .95rem; }
.topbar nav a:hover, .topbar .link:hover { color: #fff; }
.success { color: var(--ok); font-weight: 600; }
.card.notice { background: var(--ok-bg); border-color: #b5e2c6; margin-bottom: 16px; line-height: 1.8; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; margin-right: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.narrow { max-width: 380px; margin: 10vh auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input:not([type=checkbox]), textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
textarea { resize: vertical; }
input[type=search] { margin-bottom: 10px; font-size: 1.05rem; }

.btn { display: inline-block; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); text-decoration: none; cursor: pointer; text-align: center; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .5; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
button.link.danger { color: var(--danger); }

table { border-collapse: collapse; width: 100%; }
table.list td, table.list th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list tr.past td { color: var(--muted); }
.creneaux tr.open td { background: var(--ok-bg); }
.creneaux .state { white-space: nowrap; font-size: .9rem; }
.creneaux tr.open .state { color: var(--ok); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: .85rem; padding: 5px 10px; border: 0; background: #fff; cursor: pointer; }
.seg button + button { border-left: 1px solid rgba(255, 255, 255, .25); }
.seg button.on { background: var(--text); color: #fff; }

.qr-card { text-align: center; }
.qr-card .qr { width: 100%; max-width: 260px; }

.table-scroll { overflow-x: auto; }
table.grille th, table.grille td { border: 1px solid var(--line); padding: 4px 6px; text-align: center; font-size: .85rem; }
table.grille th.open { background: var(--ok-bg); color: var(--ok); }
table.grille td.name { text-align: left; white-space: nowrap; font-size: .95rem; }
table.grille td.sig { width: 110px; min-width: 110px; }
table.grille td.sig img { display: block; width: 100px; height: 45px; object-fit: contain; margin: 0 auto; }
table.grille td.sig small { color: var(--muted); }
table.grille td.empty { color: var(--line); }
.tag { font-size: .7rem; background: #fff3d6; color: #8a5a00; padding: 1px 6px; border-radius: 6px; }

.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.title-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
details.left { text-align: left; margin-top: 8px; }
details summary { cursor: pointer; font-weight: 600; }
select { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.add-creneau { margin-top: 12px; align-items: center; }
.add-creneau > * { flex: 0 1 auto; }
.add-creneau input { width: auto; }
table.grille tfoot .formateur-row td { background: #f7f8fb; }
table.grille a.small { font-size: .85rem; }

/* --- Double authentification --- */
input.code-2fa { font-size: 1.6rem; letter-spacing: .3em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.qr-2fa { width: 220px; max-width: 100%; align-self: center; border: 1px solid var(--line); border-radius: 8px; }
.cle-2fa { font-size: 1.05rem; letter-spacing: .05em; }
.codes-secours { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-width: 360px; }
.codes-secours span { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; text-align: center; font-size: 1.05rem; }
.card .row input[type=password] { flex: 1 1 180px; }

/* --- Clôture --- */
.btn.success { background: #1f8a4c; border-color: #1f8a4c; color: #fff; }
.btn.success:hover { background: #18703d; }
.tag-cloture { display: inline-block; font-size: .8rem; font-weight: 600; color: #1f6b3e; background: var(--ok-bg); border: 1px solid #b5e2c6; border-radius: 6px; padding: 2px 8px; align-self: center; }
ul.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
ul.checklist li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.checklist li.ok { color: var(--ok); }
ul.checklist li.warn { color: #9a5b00; }
.warn-text { color: #9a5b00; font-weight: 600; }

/* --- Onglets d'une formation --- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 0 0 16px; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--primary); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--line); color: var(--text); font-size: .8rem; text-align: center; }
.dot { color: var(--ok); }
.tab-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.statut-q { font-weight: 700; color: var(--muted); }
.statut-q.on { color: var(--ok); }
.qr-card form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.kpis > div { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.kpis span { display: block; font-size: .8rem; color: var(--muted); }
.kpis strong { font-size: 1.3rem; }
table.stats td { font-size: .9rem; }
table.stats td.zero { color: #c3c8d4; }
table.stats tr.bar-dark td { background: #a6a6a6; font-weight: 700; text-align: center; }
table.stats tr.bar-light td { background: #e3e5ea; font-weight: 700; text-align: center; }
ul.comments { margin: 0; padding-left: 20px; }
ul.comments li { margin-bottom: 8px; }

/* --- Questionnaire (téléphone) --- */
.q-info { display: grid; gap: 4px; margin-bottom: 12px; }
.q-info span { display: inline-block; min-width: 80px; color: var(--muted); font-size: .9rem; }
.q-intro { font-size: .95rem; }
.q-section { background: #8f97a8; color: #fff; text-align: center; padding: 8px; border-radius: 8px; font-size: 1rem; margin: 24px 0 8px; }
.q-group { text-align: center; font-size: .95rem; margin: 16px 0 8px; color: var(--muted); }
fieldset.crit { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 10px 12px 12px; margin: 0 0 10px; }
fieldset.crit.manque { border-color: var(--danger); box-shadow: 0 0 0 2px #f6d5d5; }
fieldset.crit legend { font-weight: 600; padding: 0 4px; }
.opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
@media (max-width: 480px) { .opts { grid-template-columns: repeat(2, 1fr); } }
.opt { display: block; font-weight: 400; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; background: #fff; }
.opt input:checked + span { color: #fff; font-weight: 700; border-color: transparent; }
.opt-1 input:checked + span { background: #c62e2e; }
.opt-2 input:checked + span { background: #e08a1e; }
.opt-3 input:checked + span { background: #3f8f5a; }
.opt-4 input:checked + span { background: #1a6b3c; }
.opt input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.q-libre { margin: 20px 0 12px; }

/* --- Projection plein écran --- */
.projection { text-align: center; padding-top: 2vh; }
.projection h1 { font-size: 2.4rem; }
.projection img { width: min(70vh, 90vw); }

/* --- Pages participant --- */
.pub-head { background: var(--primary); color: #fff; margin: -16px -16px 16px; padding: 16px; }
.pub-head h1 { font-size: 1.25rem; margin: 0 0 4px; }
.pub-head p { margin: 0; opacity: .9; }
ul.names { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
ul.names li a, ul.names li.done { display: flex; justify-content: space-between; padding: 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); font-size: 1.1rem; font-weight: 600; text-decoration: none; color: var(--text); }
ul.names li.done { color: var(--muted); background: var(--ok-bg); font-weight: 400; }
ul.names li.done span:last-child { color: var(--ok); }
.check-big { font-size: 4rem; color: var(--ok); line-height: 1; margin-top: 8px; }

/* --- Écran de signature (plein écran) --- */
.sign-page { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); gap: 10px; }
.sign-text { font-size: 1rem; }
.sign-area { position: relative; flex: 1; background: #fff; border: 2px dashed #b9c2d6; border-radius: var(--radius); overflow: hidden; }
.sign-area canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.sign-hint { position: absolute; left: 0; right: 0; bottom: 30%; text-align: center; color: #b9c2d6; font-size: 1.2rem; pointer-events: none; border-top: 1px solid #e3e7ef; margin: 0 10%; padding-top: 6px; }
.sign-actions { display: flex; gap: 10px; }
.sign-actions .btn { flex: 1; padding: 14px; font-size: 1.05rem; }
