:root {
  --violet: #230981;
  --violet-soft: #ece9f6;
  --sage: #93a786;
  --sage-soft: #eef2ea;
  --navy: #263964;
  --ink: #1d1d27;
  --muted: #676779;
  --line: #dddbe6;
  --bg: #f7f6fa;
  --card: #ffffff;
  --err: #b3261e;
  --err-soft: #fbeaea;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Calibri, "Segoe UI", Carlito, system-ui, sans-serif;
}
h1, h2, h3, h4 { font-family: Georgia, "Times New Roman", serif; color: var(--violet); line-height: 1.25; font-weight: normal; }
h1 { font-size: 1.9rem; margin: .2em 0 .4em; }
h2 { font-size: 1.4rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1.15rem; margin: 1.2em 0 .3em; color: var(--navy); }
a { color: var(--violet); }
.topbar { background: var(--violet); color: #fff; }
.topbar .inner { max-width: 1040px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { font-family: Georgia, serif; font-size: 1.25rem; letter-spacing: .02em; color: #fff; text-decoration: none; }
.brand small { opacity: .75; font-family: Calibri, sans-serif; font-size: .85rem; margin-left: 6px; }
.topbar nav { display: flex; gap: 14px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.topbar nav a { color: #fff; text-decoration: none; opacity: .9; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.topbar form { margin: 0; }
.topbar button.link { background: none; border: 0; color: #fff; opacity: .9; cursor: pointer; font: inherit; padding: 0; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
main.narrow { max-width: 780px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; margin: 16px 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 10px 0; background: var(--sage-soft); border: 1px solid var(--sage); }
.flash.err { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .82rem; background: var(--violet-soft); color: var(--violet); }
.badge.open { background: var(--sage-soft); color: #3f5a33; }
.badge.closed { background: #e6e8ef; color: var(--navy); }
.badge.done { background: var(--sage-soft); color: #3f5a33; }
.btn, button.btn {
  display: inline-block; background: var(--violet); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 16px; font: inherit; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: #fff; color: var(--violet); border: 1px solid var(--violet); }
.btn.sage { background: var(--sage); color: #1d2a17; }
.btn.small { padding: 5px 10px; font-size: .88rem; }
.btn.danger { background: #fff; color: var(--err); border: 1px solid var(--err); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=email], input[type=password], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%;
}
textarea { width: 100%; min-height: 110px; resize: vertical; }
label { font-weight: 600; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--navy); font-size: .92rem; }
.table-wrap { overflow-x: auto; }
.progress { height: 8px; background: var(--violet-soft); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--sage); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 1.6rem; font-family: Georgia, serif; color: var(--violet); font-weight: normal; }

/* ---- Questionnaire ---- */
.oscar { background: var(--sage-soft); border-left: 4px solid var(--sage); padding: 12px 16px; border-radius: 6px; }
.oscar b { color: var(--navy); }
.scale-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .9rem; color: var(--muted); }
.value-head { border-top: 3px solid var(--violet); padding-top: 12px; margin-top: 30px; }
.value-head p { margin: 0; color: var(--muted); font-style: italic; }
.group { margin: 18px 0 8px; }
.group .def { color: var(--muted); font-size: .92rem; margin: 0 0 6px; }
.question { padding: 12px 0; border-bottom: 1px solid var(--line); }
.question:last-child { border-bottom: 0; }
.question .qtext { margin-bottom: 8px; }
.question .qid { color: var(--muted); font-size: .85rem; margin-right: 6px; }
.question.missing { background: var(--err-soft); border-radius: 8px; padding: 12px 10px; }
.question.missing .qtext::after { content: " - réponse attendue"; color: var(--err); font-size: .88rem; }
.choices { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.choices input { position: absolute; opacity: 0; pointer-events: none; }
.choices label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  font-weight: normal; border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; cursor: pointer;
  background: #fff; min-height: 58px; font-size: .78rem; color: var(--muted); line-height: 1.15;
}
.choices label b { font-size: 1.1rem; color: var(--ink); font-weight: 600; }
.choices input:checked + label { background: var(--violet); border-color: var(--violet); color: #fff; }
.choices input:checked + label b { color: #fff; }
.choices input.na:checked + label { background: var(--navy); border-color: var(--navy); }
.choices input:focus-visible + label { outline: 2px solid var(--sage); outline-offset: 2px; }
.verb { margin: 18px 0; }
.verb label { display: block; margin-bottom: 4px; }
.verb .hint { color: var(--muted); font-size: .92rem; margin-bottom: 6px; }
.submitbar {
  position: sticky; bottom: 0; background: rgba(247,246,250,.96); border-top: 1px solid var(--line);
  padding: 12px 0; margin-top: 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.todo-list li:last-child { border-bottom: 0; }

/* ---- Rapport ---- */
.bar-row { display: grid; grid-template-columns: minmax(140px, 2fr) 3fr 64px; gap: 12px; align-items: center; padding: 6px 0; }
.bar { position: relative; height: 14px; background: var(--violet-soft); border-radius: 99px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--violet); border-radius: 99px; }
.bar .self { position: absolute; top: -4px; width: 4px; height: 22px; background: var(--sage); border-radius: 2px; margin-left: -2px; }
.legend { display: flex; gap: 18px; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.gap-pos { color: #8a5a00; }
.gap-neg { color: var(--navy); }
.verbatim { border-left: 3px solid var(--sage); padding: 6px 12px; margin: 10px 0; white-space: pre-wrap; background: #fbfbfd; }
.verbatim.hidden { opacity: .5; text-decoration: line-through; }
.dist { display: inline-flex; gap: 2px; align-items: flex-end; height: 22px; }
.dist span { width: 7px; background: var(--sage); border-radius: 2px 2px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 1fr 56px; }
  .bar-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .two-col { grid-template-columns: 1fr; }
  .topbar nav { margin-left: 0; }
}
@media print {
  .topbar, .no-print, .submitbar { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; margin: 10px 0; }
  h2 { break-after: avoid; }
  .group-block, .verbatim { break-inside: avoid; }
  .bar, .bar .fill, .bar .self, .dist span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.qtable { table-layout: fixed; min-width: 620px; }
.qtable th:nth-child(1) { width: auto; }
.qtable th:nth-child(2), .qtable th:nth-child(3), .qtable th:nth-child(4) { width: 64px; }
.qtable th:nth-child(5) { width: 120px; }
.qtable th:nth-child(6) { width: 48px; }
