:root {
  --bg: #070b14;
  --panel: #0d1424;
  --panel-2: #121b30;
  --line: rgba(255, 255, 255, .12);
  --text: #e9eef8;
  --muted: #a3b0c6;
  --dim: #7d8aa3;
  --gold: #f2b01e;
  --blue: #1c46ad;
  --ok: #2fbf71;
  --ko: #e5484d;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 16px 80px; display: flex; flex-direction: column; gap: 24px; }
.narrow { max-width: 560px; }

/* En-tête */
.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.logo { width: 58px; height: 58px; background: #fff; border-radius: 6px; overflow: hidden; flex: none; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
h1, h2, h3 { font-family: var(--cond); font-weight: 800; margin: 0; line-height: 1.05; color: #fff; }
h1 { font-size: 36px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
.top .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }

/* Panneaux */
.panel { background: var(--panel); border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Boutons */
.btn {
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; min-height: 44px; border: 1px solid var(--line); background: transparent;
  font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; color: var(--text);
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #0a0f1a; border-color: var(--gold); font-weight: 500; }
.btn-primary:hover { background: #ffc437; color: #0a0f1a; }
.btn-danger:hover { border-color: var(--ko); color: var(--ko); }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: 11px; }
.btn-lg { padding: 16px 28px; font-size: 15px; }

/* Formulaires */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--line); padding: 11px 12px; min-height: 44px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .btn:focus-visible, .opt:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.field textarea { min-height: 90px; resize: vertical; }
/* Safari iPad/iPhone : les champs date ont une largeur minimale imposée qui déborde sur la colonne voisine. */
.field, .grid > * { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
input[type=date] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }
input[type=date]::-webkit-datetime-edit { padding: 0; }
.hint { font-size: 13px; color: var(--dim); }
.error { color: #ff8a80; font-size: 14px; }

/* Sélection des tests */
.tests { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.test-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); cursor: pointer; background: var(--bg); }
.test-card:has(input:checked) { border-color: var(--gold); background: rgba(242, 176, 30, .07); }
.test-card-body { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.test-card .inline-select { width: 100%; max-width: 100%; }
.test-card input { width: 20px; height: 20px; accent-color: var(--gold); margin-top: 3px; flex: none; }
.code { font-family: var(--cond); font-weight: 800; font-size: 18px; background: var(--gold); color: #0a0f1a; padding: 1px 8px; display: inline-block; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 400; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.badge { display: inline-block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; padding: 3px 8px; margin: 2px 4px 2px 0; border: 1px solid currentColor; white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.ko { color: var(--ko); }
.badge.wait { color: var(--dim); }
.empty { color: var(--dim); padding: 18px 0; }

/* Écran stagiaire */
.quiz { min-height: 100vh; display: flex; flex-direction: column; }
.quiz-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.quiz-bar .who { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.quiz-bar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.progress { height: 4px; background: var(--panel-2); }
.progress > span { display: block; height: 100%; background: var(--gold); transition: width .2s; }
.quiz-body { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 24px 16px 120px; display: flex; flex-direction: column; gap: 18px; }
.theme-tag { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 8px 12px; background: var(--panel); border-left: 4px solid var(--gold); }
.theme-tag b { font-family: var(--cond); font-size: 18px; color: var(--gold); }
.theme-tag span { font-family: var(--cond); font-weight: 700; font-size: 18px; }
.qnum { font-family: var(--cond); font-weight: 800; font-size: 20px; color: #6f95ff; }
.qsub { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.qtext { font-size: 23px; font-weight: 600; line-height: 1.3; color: #fff; margin: 0; }
.qimgs { display: flex; gap: 12px; flex-wrap: wrap; }
.qimgs img { max-height: 240px; max-width: 100%; object-fit: contain; background: #fff; padding: 6px; border: 1px solid var(--line); }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt { cursor: pointer; display: flex; gap: 14px; align-items: flex-start; text-align: left; padding: 16px; min-height: 60px; background: var(--panel); border: 2px solid var(--line); font-size: 19px; line-height: 1.35; }
.opt:hover { border-color: rgba(242, 176, 30, .6); }
.opt .l { font-family: var(--cond); font-weight: 800; font-size: 20px; width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid var(--muted); flex: none; }
.opt.sel { border-color: var(--gold); background: rgba(242, 176, 30, .1); }
.opt.sel .l { background: var(--gold); border-color: var(--gold); color: #0a0f1a; }
.quiz-foot { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.quiz-foot .mid { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.navgrid button { cursor: pointer; min-height: 44px; background: var(--panel); border: 1px solid var(--line); font-family: var(--cond); font-weight: 700; font-size: 16px; }
.navgrid button.done { background: rgba(242, 176, 30, .18); border-color: rgba(242, 176, 30, .5); }
.navgrid button.cur { outline: 2px solid var(--gold); }
.center { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; padding: 24px 16px; }

/* Résultat */
.verdict { display: inline-block; font-family: var(--cond); font-weight: 800; font-size: 22px; padding: 4px 14px; }
.verdict.ok { background: var(--ok); color: #04150b; }
.verdict.ko { background: var(--ko); color: #fff; }

/* Modale */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--gold); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

/* Aperçu rapport à l'écran */
.report-preview { background: #fff; color: #0a0f1a; padding: 28px; overflow-x: auto; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--gold); padding: 12px 18px; z-index: 60; max-width: calc(100% - 32px); }

/* Stagiaire : connexion et liste des tests */
.code-input { font-family: var(--mono); font-size: 26px !important; letter-spacing: .18em; text-transform: uppercase; text-align: center; min-height: 60px !important; }
.test-list { display: flex; flex-direction: column; gap: 10px; }
.test-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line); background: var(--bg); }

/* Formateur */
.code-chip { font-family: var(--mono); font-weight: 500; font-size: 15px; letter-spacing: .1em; padding: 3px 8px; background: var(--panel-2); border: 1px solid var(--gold); color: var(--gold); white-space: nowrap; }
.code-chip.big { font-size: 22px; padding: 4px 12px; }
.code-preview { font-family: var(--mono); font-size: 22px; letter-spacing: .14em; color: var(--gold); min-height: 44px; display: flex; align-items: center; }
.badge.run { color: #6f95ff; }
.join { flex-direction: row; align-items: center; flex-wrap: wrap; }
.qr { background: #fff; padding: 10px; width: 240px; height: 240px; flex: none; }
.join > div:last-child { flex: 1; min-width: 240px; }
.qr img, .qr canvas { display: block; width: 220px; height: 220px; }
.created { background: rgba(242, 176, 30, .1); border: 1px solid var(--gold); padding: 14px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 17px; }
.date-input, .inline-select { background: var(--bg); border: 1px solid var(--line); padding: 8px; min-height: 34px; color-scheme: dark; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.verdict-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ok-text { color: var(--ok); }
.field input[type=date] { color-scheme: dark; }

/* Espace pro : menu, bandeaux, organisme */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-top: -8px; }
.tab { cursor: pointer; background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; min-height: 44px; font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.on { color: var(--gold); border-bottom-color: var(--gold); }
.who-chip { font-family: var(--mono); font-size: 12px; color: var(--muted); align-self: center; }
.expired { background: rgba(229, 72, 77, .12); border: 1px solid var(--ko); padding: 12px 16px; line-height: 1.45; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.logo-edit { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 160px; height: 110px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.logo-preview img { max-width: 150px; max-height: 100px; object-fit: contain; }
.logo-preview .hint { color: #5a6479; }
.link-box { display: block; width: 100%; margin-top: 8px; background: var(--bg); border: 1px solid var(--line); padding: 8px; font-family: var(--mono); font-size: 12px; color: var(--text); }
.danger-zone { border-color: rgba(229, 72, 77, .5); }
.pdf-frame { background: #525659; border: 1px solid var(--line); min-height: 70vh; display: flex; }
.pdf-frame iframe { flex: 1; width: 100%; min-height: 80vh; border: 0; background: #525659; }
.top .logo { padding: 4px; }

.staff-entry { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.staff-entry p { margin: 6px 0 0; }

.app-foot { max-width: 1100px; margin: 0 auto; padding: 0 16px 28px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--dim); text-align: center; }
.app-foot button { background: none; border: 0; padding: 0; font: inherit; color: var(--gold); text-decoration: underline; cursor: pointer; }
.about-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.about-list dt { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.about-list dd { margin: 0; }
.about-tests { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

.reasons { margin: -4px 0 4px; padding-left: 20px; color: #ff8a80; font-size: 14px; }

.live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--dim); }
.live.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(47, 191, 113, .25); }

.app-mark { width: 52px; height: 52px; flex: none; }

.quick-banner { background: #6f2dbd; color: #fff; text-align: center; padding: 8px 16px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }

#print-area { display: none; }

@media (max-width: 600px) {
  h1 { font-size: 28px; }
  .qtext { font-size: 20px; }
  .opt { font-size: 17px; }
  .report-preview { padding: 14px; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; color: #000; }
  #app { display: none !important; }
  #print-area { display: block !important; }
}
