:root {
  /* Couleurs CongoSchool pendant l'accès ; remplacées par celles de l'école une fois connecté (app.js). */
  --cs-blue: #007cfd;
  --cs-navy: #082967;
  --cs-yellow: #fdbb05;
  --school-primary: var(--cs-blue);
  --school-accent: var(--cs-yellow);
  --bg: #f5f3ef;
  --surface: #fffdf9;
  --field: #fffdf9;
  --text: #292b34;
  --muted: #6b6970;
  --line: #e7e1d7;
  --primary-text: var(--school-primary);
  --ok: #187a50;
  --warn: #9a6400;
  --bad: #b3261e;
  --radius: 14px;
  --tap: 48px;
  color-scheme: light;
}
/* Écrans d'accès (personne connectée) : identité CongoSchool. */
:root[data-auth]:not([data-theme="dark"]) { --bg: #f3f7fd; --surface: #ffffff; --field: #ffffff; --text: var(--cs-navy); --muted: #52607a; --line: #d9e3f2; }
/* Mode sombre : mêmes formules que theme.css du dashboard central (teinte de l'école sur fond noir). */
:root[data-theme="dark"] {
  --bg: color-mix(in srgb, var(--school-primary) 7%, #0b0a0c);
  --surface: color-mix(in srgb, var(--school-primary) 9%, #18161a);
  --surface-2: color-mix(in srgb, var(--school-primary) 11%, #201d22);
  --field: color-mix(in srgb, var(--school-primary) 8%, #121114);
  --line: color-mix(in srgb, var(--school-accent) 20%, #2e2b31);
  --text: #f4f1ec;
  --muted: #bdb7b0;
  --primary-text: color-mix(in srgb, var(--school-primary) 45%, #fff);
  --ok: #57c997;
  --warn: color-mix(in srgb, var(--school-accent) 82%, #fff);
  --bad: #ef8a83;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 20; }
:focus-visible { outline: 3px solid var(--school-accent); outline-offset: 2px; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); border-top: 4px solid var(--school-primary);
}
.logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; }
.identity { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.identity strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.identity span { font-size: 13px; color: var(--muted); }
.net { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.net.offline { color: var(--warn); border-color: currentColor; }

.banner { margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--bad); color: var(--bad); background: var(--surface); }
main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 10px; }
.motto { font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-weight: 700; color: var(--primary-text); }
p.muted, .muted { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 14px; color: var(--muted); }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=search], input[type=tel], input[type=email], select {
  width: 100%; min-height: var(--tap); padding: 10px 12px; font: inherit; color: inherit;
  background: var(--field); border: 1px solid var(--line); border-radius: 11px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--school-primary); border-color: var(--school-primary); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.filters { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } .filters .full { grid-column: 1 / -1; } }
.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.row .who { flex: 1; min-width: 0; }
.row .who strong { display: block; overflow-wrap: anywhere; }
.row .who span { font-size: 14px; color: var(--muted); }
.avatar { width: 44px; height: 55px; border-radius: 8px; background: var(--line); object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.badge { font-size: 13px; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); } .badge.none { color: var(--muted); }

.camera { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; max-width: 520px; margin: 0 auto; }
.camera video { display: block; width: 100%; height: 100%; object-fit: cover; }
.camera .frame { position: absolute; inset: 0; border: 3px solid rgba(255,255,255,.85); border-radius: var(--radius); pointer-events: none; }
.editor { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.editor canvas { border-radius: var(--radius); border: 1px solid var(--line); background: #fff; max-width: 100%; }
.editor input[type=range] { width: min(520px, 100%); min-height: var(--tap); }
.existing { width: 120px; border-radius: 10px; border: 1px solid var(--line); }
.studenthead { display: flex; gap: 14px; align-items: center; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 60px; justify-content: center; color: var(--muted); text-decoration: none; font-size: 13px; }
.tabs a span { font-size: 20px; line-height: 1; }
.tabs a[aria-current=page] { color: var(--primary-text); font-weight: 700; box-shadow: inset 0 3px 0 var(--school-primary); }
.tabs .count { position: absolute; top: 6px; right: calc(50% - 26px); background: var(--school-accent); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 6px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 9; max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg); }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.neutral-mark { width: 64px; height: 64px; border-radius: 16px; background: var(--school-primary); color: #fff; display: grid; place-items: center; font-size: 30px; margin-bottom: 12px; }
/* Accès CongoSchool */
.auth-shell { max-width: 560px; margin: 0 auto; }
.brand-hero { text-align: center; padding: 8px 0 14px; }
.brand-emblem { width: 96px; height: 96px; object-fit: contain; border-radius: 22px; background: #fff; padding: 6px; box-shadow: 0 6px 24px rgba(8, 41, 103, .14); }
.brand-name { margin: 10px 0 4px; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.brand-name span:first-child { color: var(--cs-navy); } .brand-name span:last-child { color: var(--cs-blue); }
:root[data-theme="dark"] .brand-name span:first-child { color: #f4f1ec; }
:root[data-theme="dark"] .brand-name span:last-child { color: color-mix(in srgb, var(--cs-blue) 70%, #fff); }
.brand-hero h1 { font-size: 22px; margin: 6px 0; }
.school-card { border-color: var(--school-accent); }
.logo-avatar { object-fit: contain; background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0; }
.small { font-size: 14px; }
.center { text-align: center; }
.link { color: var(--primary-text); font-weight: 600; display: inline-block; padding: 12px 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin-top: 16px; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--school-primary); }
.id-photo { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; margin-top: 8px; }
.id-photo img { display: block; max-width: 100%; max-height: 220px; margin: 12px auto 0; border-radius: 10px; }
.status-line { font-weight: 700; font-size: 18px; margin: 8px 0; }
.status-line.bad { color: var(--bad); }
.spinner { width: 44px; height: 44px; margin: 6px auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--school-primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; font-weight: 600; cursor: pointer; }
.segmented input:checked + span { background: var(--school-primary); color: #fff; }
.segmented input:focus-visible + span { outline: 3px solid var(--school-accent); outline-offset: 2px; }
/* Capture intelligente */
.face-guide { position: absolute; left: 22%; right: 22%; top: 12%; bottom: 30%; border: 3px dashed rgba(255,255,255,.75); border-radius: 50%; pointer-events: none; }
.camera.ready .face-guide { border-color: #57c997; border-style: solid; }
.live-hint { position: absolute; left: 8px; right: 8px; bottom: 8px; margin: 0; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.62); color: #fff; font-weight: 600; text-align: center; }
.live-hint.ok { background: rgba(24,122,80,.85); }
.retake-required { border-color: var(--bad); }
.retake-required h2 { color: var(--bad); margin-top: 0; }
.retake-required li { margin: 6px 0; }
.result-grid { display: grid; grid-template-columns: 1fr; gap: 14px; justify-items: center; }
@media (min-width: 640px) { .result-grid { grid-template-columns: auto 1fr; align-items: start; } }
.result-grid figure { margin: 0; text-align: center; }
.result-grid figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.portrait-result { width: 220px; border-radius: 12px; border: 1px solid var(--line); }
.card-preview { width: 100%; max-width: 420px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.queue-line { font-weight: 700; color: var(--primary-text); margin: 0 0 6px; }
.locked { border-style: dashed; }
.lock { font-size: 22px; padding: 0 10px; }
.banner.warn { border-color: var(--warn); color: var(--warn); }
.list-tools { margin: 0 0 10px; }
.notes li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.scan-dialog { width: min(480px, 94vw); border: 0; border-radius: 16px; padding: 12px; background: var(--surface); color: var(--text); }
.scan-dialog video { width: 100%; border-radius: 12px; background: #000; }
.scan-dialog::backdrop { background: rgba(0,0,0,.6); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Mot de passe temporaire affiché une seule fois */
.temp-password { font: 700 1.6rem/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .08em;
  margin: .4rem 0 1rem; padding: .7rem 1rem; border-radius: 12px; background: color-mix(in srgb, var(--school-primary) 10%, var(--surface));
  user-select: all; -webkit-user-select: all; }
