:root {
  --ink: #1b2233;
  --muted: #5d6679;
  --line: #e3e6ee;
  --bg: #f5f6f9;
  --card: #ffffff;
  --brand: #1f3a68;
  --brand-2: #2f5596;
  --ok: #1f7a4d;
  --warn: #b45309;
  --danger: #b42318;
  --gA: #1f7a4d; --gA-bg: #e3f3ea;
  --gB: #2f6fb3; --gB-bg: #e4eefa;
  --gC: #b45309; --gC-bg: #fdf0e1;
  --gD: #6b7280; --gD-bg: #eef0f3;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.45; }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
h1 { font-size: 1.4rem; margin: 4px 0 2px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .85rem; }
.top { background: var(--brand); color: #fff; padding: 18px 16px 22px; }
.top .inner { max-width: 760px; margin: 0 auto; }
.top .muted { color: #c9d4ea; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
button, .btn {
  appearance: none; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 16px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 8px 10px; }
button.danger { background: #fff; color: var(--danger); border-color: #f1c4c0; }
button:disabled { opacity: .55; cursor: default; }
button.block, .btn.block { width: 100%; }
label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 4px; }
label .muted { font-weight: 400; }
input[type=text], input[type=date], textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfd4df; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid #bcd0f2; border-color: var(--brand-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--gD-bg); color: var(--gD); }
.pill.ok { background: var(--gA-bg); color: var(--gA); }
.pill.wait { background: var(--gC-bg); color: var(--gC); }
.pill.late { background: #fde8e7; color: var(--danger); }

.progress { height: 8px; background: #2c4a7f; border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; background: #9fc0f2; }

/* Grille de notation */
.task { padding: 12px 0; border-top: 1px solid var(--line); }
.task:first-of-type { border-top: 0; }
.task .lbl { font-size: .95rem; margin-bottom: 8px; }
.task .prev { font-size: .8rem; color: var(--muted); margin-left: 4px; }
.task.changed .lbl::after { content: "modifié"; margin-left: 8px; font-size: .72rem; font-weight: 700; color: var(--brand-2); background: #e4eefa; padding: 1px 7px; border-radius: 99px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button { background: #fff; color: var(--ink); border: 1px solid #cfd4df; font-weight: 600; padding: 6px 4px; min-height: 48px; flex-direction: column; gap: 0; line-height: 1.1; }
.seg button small { font-weight: 400; font-size: .68rem; color: var(--muted); }
.seg button[aria-pressed=true][data-v=A] { background: var(--gA); border-color: var(--gA); color: #fff; }
.seg button[aria-pressed=true][data-v=B] { background: var(--gB); border-color: var(--gB); color: #fff; }
.seg button[aria-pressed=true][data-v=C] { background: var(--gC); border-color: var(--gC); color: #fff; }
.seg button[aria-pressed=true][data-v=D] { background: var(--gD); border-color: var(--gD); color: #fff; }
.seg button[aria-pressed=true] small { color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .82rem; color: var(--muted); }

.g { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.gA { background: var(--gA-bg); color: var(--gA); } .gB { background: var(--gB-bg); color: var(--gB); }
.gC { background: var(--gC-bg); color: var(--gC); } .gD { background: var(--gD-bg); color: var(--gD); }
.g0 { background: transparent; color: #c3c8d2; }

/* Signature */
.sigwrap { position: relative; border: 1px dashed #aab2c3; border-radius: 12px; background: #fff; touch-action: none; }
.sigwrap canvas { display: block; width: 100%; height: 170px; border-radius: 12px; }
.sigwrap .hint { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; color: #b7bdc9; pointer-events: none; font-size: .9rem; }
.sigwrap .base { position: absolute; left: 18px; right: 18px; bottom: 30px; border-bottom: 1px solid #e0e3ea; pointer-events: none; }
.sigimg { max-height: 60px; max-width: 180px; }

.points .pt { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.points .pt:first-child { border-top: 0; }
.pt .when { min-width: 64px; text-align: center; font-weight: 700; }
.pt .when small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }

.sheet { position: fixed; inset: 0; background: rgba(15, 22, 40, .45); display: none; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet.open { display: flex; }
.sheet .panel { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px 24px; max-height: 92vh; overflow: auto; }
@media (min-width: 600px) { .sheet { align-items: center; } .sheet .panel { border-radius: 18px; } }
.qr { display: flex; justify-content: center; margin: 8px 0; }
.qr svg, .qr img { width: 200px; height: 200px; }
.linkbox { font-size: .8rem; word-break: break-all; background: var(--bg); padding: 8px 10px; border-radius: 8px; }
.choice { display: grid; gap: 8px; }
.choice button { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; gap: 0; }
.choice button small { font-weight: 400; opacity: .85; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1b2233; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: .92rem; display: none; max-width: 90vw; }
.toast.show { display: block; }
.err { color: var(--danger); font-size: .9rem; margin-top: 8px; }
.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: .95rem; background: #fff7e6; border: 1px solid #f3d9a6; padding: 10px; border-radius: 8px; word-break: break-all; }
details summary { cursor: pointer; font-weight: 600; }
