:root {
  --paper: #F5F4EF;
  --surface: #FFFFFF;
  --ink: #13213A;
  --muted: #5B6778;
  --faint: #8891A0;
  --line: #E2E1DA;
  --line-strong: #CDCCC3;
  --blue: #1D4ED8;
  --blue-ink: #16399E;
  --blue-wash: #EAF0FD;
  --orange: #E8873A;
  --ok: #157A4A;
  --ok-wash: #E7F5ED;
  --bad: #C13B30;
  --bad-wash: #FBEAE8;
  --warn: #A9690B;
  --warn-wash: #FBF0DF;
  --none: #6B7280;
  --none-wash: #EEEFF1;
  --shadow: 0 1px 2px rgba(19,33,58,.04), 0 8px 24px -12px rgba(19,33,58,.16);
  --font-display: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #11161F; --surface: #171D29; --ink: #E9ECF3; --muted: #AAB3C4; --faint: #7C8699;
    --line: #2A3242; --line-strong: #3A4457; --blue: #5B8AF5; --blue-ink: #8FB0F8; --blue-wash: #1C2A4A;
    --orange: #F0A05E; --ok: #4ECB8F; --ok-wash: #163828; --bad: #F08478; --bad-wash: #3A1E1C;
    --warn: #E3B35C; --warn-wash: #3A2E13; --none: #9AA3B3; --none-wash: #232938;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #11161F; --surface: #171D29; --ink: #E9ECF3; --muted: #AAB3C4; --faint: #7C8699;
  --line: #2A3242; --line-strong: #3A4457; --blue: #5B8AF5; --blue-ink: #8FB0F8; --blue-wash: #1C2A4A;
  --orange: #F0A05E; --ok: #4ECB8F; --ok-wash: #163828; --bad: #F08478; --bad-wash: #3A1E1C;
  --warn: #E3B35C; --warn-wash: #3A2E13; --none: #9AA3B3; --none-wash: #232938;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 28px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  display: flex; flex-direction: column; min-height: 100%;
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
a { color: var(--blue); }
.mono { font-family: var(--font-mono); }

.shell { max-width: 980px; margin: 0 auto; padding: 24px 20px 90px; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
}
.topbar .brand { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; }
.topbar .kicker { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--orange); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .78rem; color: var(--muted); }
.btn-ghost-icon {
  background: none; border: 1px solid var(--line-strong); border-radius: 8px;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1; cursor: pointer; color: var(--muted); flex: none;
}
.btn-ghost-icon:hover { border-color: var(--faint); color: var(--ink); }

.btn { font: 600 .82rem/1 var(--font-body); border-radius: 9px; padding: 9px 15px; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-ink); }
.btn-solid { background: var(--ok); color: #fff; }
.btn-line { background: none; border-color: var(--blue); color: var(--blue); }
.btn-line:hover { background: var(--blue-wash); }
.btn-ghost { background: none; border-color: var(--line-strong); color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--faint); }
.btn-danger { background: none; border-color: var(--bad); color: var(--bad); }
button[disabled] { opacity: .5; cursor: default; }

input[type="text"], input[type="email"], input[type="date"], textarea {
  font: 400 .88rem/1.3 var(--font-body); padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%;
}
textarea { resize: vertical; font-family: var(--font-body); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: .8rem; color: var(--muted); }
.project-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.field-group-title { font-size: .78rem; font-weight: 700; color: var(--muted); margin-top: 2px; }
.project-header-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 1.05rem; margin-bottom: 4px; }
.card .sub { font-size: .8rem; color: var(--muted); margin-bottom: 14px; }

.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.project-row:hover { border-color: var(--blue); }
.project-row .name { font-weight: 700; }
.project-row .client { font-size: .8rem; color: var(--muted); }
.project-row .spacer { flex: 1; }
.project-row .arrow { color: var(--faint); }

.login-wrap { min-height: 78vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { max-width: 380px; width: 100%; }

.tag { display: inline-flex; align-items: center; gap: 5px; font: 600 .68rem/1 var(--font-mono); padding: 4px 8px; border-radius: 999px; }
.tag.locked { background: var(--none-wash); color: var(--none); }
.tag.open { background: var(--blue-wash); color: var(--blue-ink); }

.version-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.version-tab { font: 600 .78rem/1 var(--font-mono); padding: 7px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.version-tab.is-active { background: var(--blue-wash); border-color: var(--blue); color: var(--blue-ink); }

.progress-bar { height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; margin: 10px 0; }
.progress-bar span { display: block; height: 100%; }

.module { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; overflow: hidden; }
.module-head { padding: 12px 15px; font-weight: 700; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; font-size: .9rem; }
.test-row { padding: 12px 15px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.test-row:last-child { border-bottom: none; }
.test-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.test-title { font-weight: 600; font-size: .88rem; }
.test-desc { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.status-group { display: flex; gap: 6px; flex: none; }

.comments { display: flex; flex-direction: column; gap: 8px; }
.comment { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: .8rem; }
.comment-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 3px; }
.comment-author { font-weight: 600; font-size: .78rem; color: var(--ink); }
.comment-email { color: var(--faint); font-size: .7rem; font-family: var(--font-mono); }
.comment-date { color: var(--faint); font-size: .68rem; font-family: var(--font-mono); margin-left: auto; }
.comment-text { color: var(--muted); white-space: pre-wrap; }
.add-comment { display: flex; gap: 8px; align-items: flex-end; }
.add-comment .comment-input {
  flex: 1; font: 400 .82rem/1.4 var(--font-body); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; resize: vertical; min-height: 36px;
}
.add-comment .comment-input::placeholder { color: var(--faint); }
.add-comment .comment-input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }
.add-comment button { flex: none; }
.status-btn { font: 600 .72rem/1 var(--font-mono); padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.status-btn[data-s="C"].is-active { background: var(--ok-wash); border-color: var(--ok); color: var(--ok); }
.status-btn[data-s="NC"].is-active { background: var(--bad-wash); border-color: var(--bad); color: var(--bad); }
.status-btn[data-s="P"].is-active { background: var(--warn-wash); border-color: var(--warn); color: var(--warn); }
.status-btn[data-s="I"].is-active { background: var(--none-wash); border-color: var(--none); color: var(--none); }
.status-badge { font: 600 .72rem/1 var(--font-mono); padding: 6px 10px; border-radius: 7px; }
.status-badge.C { background: var(--ok-wash); color: var(--ok); }
.status-badge.NC { background: var(--bad-wash); color: var(--bad); }
.status-badge.P { background: var(--warn-wash); color: var(--warn); }
.status-badge.I { background: var(--none-wash); color: var(--none); }
.status-badge.none { background: var(--none-wash); color: var(--faint); }

.invitee-row, .signer-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.invitee-row:last-child, .signer-row:last-child { border-bottom: none; }
.invitee-row .spacer, .signer-row .spacer { flex: 1; }
.signer-row .state.pending { color: var(--faint); font-family: var(--font-mono); font-size: .72rem; }
.signer-row .state.signed { color: var(--ok); font-family: var(--font-mono); font-size: .72rem; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input { flex: 1; min-width: 140px; }

.empty-hint { color: var(--faint); font-size: .82rem; }
.error-box { background: var(--bad-wash); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: .82rem; margin: 10px 0; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); font: 500 .8rem/1 var(--font-body);
  padding: 10px 16px; border-radius: 999px; opacity: 0; transition: opacity .2s ease;
  pointer-events: none; z-index: 20;
}

@media (max-width: 640px) {
  .shell { padding: 16px 14px 90px; }
  .test-row { flex-direction: column; }
}

/* ---------- Fiche de référence (printable) ---------- */
.fiche, .fiche * {
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.fiche {
  background: #fff; color: #1a1a1a; max-width: 760px; margin: 0 auto;
  padding: 28px 32px; border-radius: 10px; border: 1px solid var(--line);
  font-family: var(--font-body); font-size: .92rem; line-height: 1.5;
}
.fiche-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.fiche-name { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: #C2185B; }
.fiche-title { font-size: .8rem; color: #444; margin-top: 2px; }
.fiche-ref { text-align: right; font-size: .72rem; font-weight: 700; color: #C2185B; letter-spacing: .03em; }
.fiche-ref-code { font-weight: 600; color: #444; margin-top: 2px; }
.fiche-rule { border: none; border-top: 2px solid #C2185B; margin: 14px 0; }
.fiche-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.fiche-table th, .fiche-table td { border: 1px solid #ddd; padding: 8px 12px; text-align: left; font-size: .86rem; vertical-align: top; }
.fiche-table th { width: 220px; font-weight: 700; background: #faf7f8; }
.fiche-project-name { font-weight: 700; color: #fff; background: #C2185B; text-align: center; font-size: .95rem; }
.fiche-section-title { font-weight: 700; color: #C2185B; font-size: .88rem; margin: 14px 0 4px; }
.fiche-prose { font-size: .86rem; color: #222; margin: 0; }
.fiche-list { margin: 4px 0 0; padding-left: 20px; font-size: .86rem; color: #222; }
.fiche-list li { margin-bottom: 4px; }
.fiche-footer { font-size: .72rem; color: #555; text-align: center; }

#app { flex: 1 0 auto; }
.invite-banner { background: var(--blue-wash); color: var(--blue-ink); border-radius: 10px; padding: 10px 12px; font-size: .84rem; margin: 6px 0 12px; line-height: 1.45; }
.section-title { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; font-family: var(--font-mono); }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--none-wash); border-radius: 10px; margin: 8px 0 12px; }
.seg-btn { flex: 1; border: 0; background: transparent; color: var(--muted); font: 600 .78rem var(--font-body); padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.shell { width: 100%; }
.site-footer { flex-shrink: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); }
.site-footer-inner { max-width: 980px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; font-size: .78rem; color: var(--muted); }
.site-footer-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer-links a { color: var(--muted); text-decoration: none; }
.site-footer-links a:hover { color: var(--blue); text-decoration: underline; }
.legal-card { margin-top: 14px; }
.legal-card h3 { font-size: .95rem; margin: 18px 0 4px; }
.legal-card p, .legal-card li { font-size: .88rem; color: var(--ink); max-width: 72ch; }
.legal-card ul { padding-left: 20px; margin: 6px 0; }
/* Printable test sheet: always paper-like, whatever the screen theme. */
.sheet { background: #fff; color: #111; max-width: 900px; margin: 12px auto 0; padding: 28px 30px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; line-height: 1.4; }
.sheet h1 { font: 800 1.35rem var(--font-display); margin: 2px 0 0; color: #111; }
.sheet h2 { font: 800 1rem var(--font-display); margin: 22px 0 4px; color: #111; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 12px; }
.sheet-brand { font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: #E8873A; }
.sheet-meta { font-size: .72rem; color: #555; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { border: 1px solid #555; padding: 5px 7px; vertical-align: top; text-align: left; }
.sheet .info th { width: 14%; background: #f0f0f0; font-weight: 600; }
.sheet .legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0; font-size: .74rem; }
.sheet .summary { margin: 0 0 10px; padding: 6px 8px; border: 1px solid #555; background: #f7f7f7; }
.sheet .tests { margin: 12px 0 0; }
.sheet .module-row th { background: #13213A; color: #fff; font-size: .8rem; }
.sheet .cols th { background: #f0f0f0; font-size: .7rem; text-transform: uppercase; }
.sheet .c-num { width: 5%; white-space: nowrap; }
.sheet .c-box { width: 4.6%; text-align: center; }
.sheet .c-obs { width: 26%; }
.sheet .tests td { height: 30px; }
.sheet .t { font-weight: 600; }
.sheet .d { color: #444; font-size: .72rem; margin-top: 1px; }
.sheet .d.ok { color: #157A4A; font-weight: 600; }
.sheet .obs { font-size: .72rem; margin-bottom: 2px; }
.sheet .box { display: inline-block; width: 15px; height: 15px; border: 1.5px solid #111; line-height: 12px; text-align: center; font-weight: 800; font-size: 12px; }
.sheet .approval { margin-top: 18px; break-inside: avoid; }
.sheet .approval .place { margin: 10px 0; }
.sheet .signers th { background: #f0f0f0; font-size: .72rem; }
.sheet .s-who { width: 38%; }
.sheet .s-date { width: 18%; }
.sheet .s-sign { height: 62px; }
.sheet-foot { margin-top: 16px; font-size: .68rem; color: #666; text-align: center; border-top: 1px solid #ccc; padding-top: 6px; }
@media print {
  @page { size: A4; margin: 12mm 10mm 14mm; }
  .site-footer { display: none !important; }
  .sheet { border: none; border-radius: 0; margin: 0; padding: 0; max-width: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet thead { display: table-header-group; }
  .sheet tr { break-inside: avoid; }
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .shell { padding: 0; max-width: none; }
  .fiche { border: none; border-radius: 0; max-width: none; padding: 0; }
}
