:root {
  --accent: #1d5c87;
  --accent-ink: #ffffff;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5a6675;
  --line: #cfd6de;
  --ok: #1b7a3d;
  --warn: #8a5a00;
  --warn-bg: #fff6df;
  --err: #b3261e;
  --err-bg: #fdeceb;
  --info: #2b5a8a;
  --radius: 8px;
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }
.loading { padding: 32px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pre { white-space: pre-wrap; margin: 4px 0 0; }

/* en-tête */
.hdr { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px; }
.hdr-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1100px; margin: 0 auto; }
.brand { white-space: nowrap; font-weight: 700; color: var(--accent); font-size: 18px; letter-spacing: .2px; }
.input.lang-select { width: auto; min-width: 110px; }
.ref-meta { max-width: 1100px; margin: 8px auto 0; display: flex; gap: 12px; align-items: center; }
.ref-photo { border-radius: 6px; object-fit: cover; border: 1px solid var(--line); }
.ref-list { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 24px; }
.ref-list div { min-width: 0; }
.ref-list dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.ref-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* mise en page */
.layout { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.side { position: sticky; top: 8px; display: flex; flex-direction: column; gap: 12px; }
.topbar, .steps { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.progress-row { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.bar { background: #e3e8ee; border-radius: 99px; height: 8px; overflow: hidden; }
.bar-big { height: 12px; }
.bar-fill { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.save-status { margin-top: 8px; font-size: 14px; color: var(--muted); min-height: 21px; }
.save-saved { color: var(--ok); }
.save-offline { color: var(--err); font-weight: 600; }
.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.step-btn { width: 100%; min-height: var(--tap); display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; cursor: pointer; font: inherit; color: inherit; }
.step-btn:hover { background: #eef2f6; }
.step-btn[aria-current="step"] { background: #e6eef5; border-color: var(--accent); }
.step-num { grid-row: 1 / span 2; align-self: center; width: 26px; height: 26px; border-radius: 50%; background: #e3e8ee; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.step-title { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.step-state { font-size: 13px; color: var(--muted); grid-column: 2; }
.step-btn[data-state="complete"] .step-num { background: var(--ok); color: #fff; }
.step-btn[data-state="progress"] .step-num { background: #f2b84b; }
.step-btn[data-state="fix"] .step-num { background: var(--err); color: #fff; }
.step-btn[data-state="fix"] .step-state { color: var(--err); font-weight: 600; }
.step-btn[data-state="complete"] .step-state { color: var(--ok); }
.nav-toggle { display: none; width: 100%; min-height: var(--tap); background: transparent; border: 0; font: inherit; font-weight: 600; text-align: left; cursor: pointer; padding: 0 4px; color: var(--ink); }
.nav-toggle::after { content: " ▾"; }

.content { min-width: 0; outline: none; }
.step-h { font-size: 22px; line-height: 1.3; margin: 0 0 8px; }
.step-kicker { display: block; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.intro { color: var(--muted); margin: 0 0 16px; }
.notice { background: #eaf1f8; border-left: 4px solid var(--info); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 14px; }
.notice p { margin: 4px 0 0; }
.notice-warn { background: var(--warn-bg); border-color: #d99a00; }
.card, .recap-card, .fields { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.fields { padding: 4px 16px; }

/* champs */
.field { padding: 14px 0; border-bottom: 1px solid #e8ecf0; }
.field:last-child { border-bottom: 0; }
.field.has-error { background: linear-gradient(90deg, var(--err-bg), transparent 60%); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-left: 4px solid var(--err); }
.field-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 6px; }
.field-label { font-weight: 600; display: block; overflow-wrap: anywhere; }
.req { color: var(--err); }
.help-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; min-height: 32px; padding: 0 2px; }
.help-box { background: #f1f4f7; border-radius: 6px; padding: 8px 12px; margin: 0 0 8px; font-size: 15px; }
.help-box p { margin: 4px 0; }
.help-example { color: var(--muted); }
.input { width: 100%; min-height: var(--tap); padding: 8px 10px; border: 1px solid #8793a1; border-radius: 6px; background: #fff; color: var(--ink); font: inherit; }
textarea.input { min-height: 96px; resize: vertical; }
.input:disabled, .is-unknown { background: #eef0f3; color: #6b7686; opacity: .8; }
.input.invalid { border-color: var(--err); background: var(--err-bg); }
.num-row { display: flex; align-items: center; gap: 8px; max-width: 320px; }
.unit { color: var(--muted); font-weight: 600; white-space: nowrap; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: var(--tap); padding: 8px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; flex: 0 0 24px; margin: 2px 0 0; accent-color: var(--accent); }
.check span { overflow-wrap: anywhere; }
.check-big { background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.checks { display: flex; flex-direction: column; }
.unknown { margin-top: 4px; color: var(--muted); font-size: 15px; min-height: var(--tap); padding: 4px 0; }
.field-error { color: var(--err); font-weight: 600; font-size: 14px; margin-top: 6px; }

/* fichiers */
.dropzone { border: 2px dashed #8793a1; border-radius: var(--radius); padding: 14px; text-align: center; background: #fafbfc; position: relative; }
.dropzone.drag { border-color: var(--accent); background: #eaf1f8; }
.drop-title { margin: 0; font-weight: 600; }
.drop-or { margin: 2px 0 6px; color: var(--muted); }
.dropzone .small { margin: 8px 0 0; }
.file-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-item { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: #fff; }
.file-item.file-error { border-color: var(--err); background: var(--err-bg); }
.file-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; justify-content: space-between; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-item .bar { margin-top: 6px; }
.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.badge-ok { background: #dff3e5; color: #145c2d; }
.badge-info { background: #e1ecf8; color: #1f4b78; }
.badge-wait { background: #fff0cc; color: #6e4a00; }
.badge-err { background: #f9d6d3; color: #8c1c14; }
.badge-warn { background: var(--warn-bg); color: var(--warn); margin: 0 0 12px; }

/* boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 8px 18px; border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: #9aa6b3; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--accent); border-color: var(--accent); }
.btn-link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 8px 4px; }
.btn-danger-link { background: none; border: 0; color: var(--err); text-decoration: underline; padding: 8px 4px; min-height: var(--tap); font: inherit; cursor: pointer; }
.btn-lg { min-width: 200px; font-size: 18px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 16px 0; }
.pager .btn { min-width: 130px; }

/* tableau composants */
.table-scroll { overflow-x: auto; margin-bottom: 10px; }
.ctab { width: 100%; border-collapse: collapse; min-width: 880px; }
.ctab th { text-align: left; font-size: 13px; color: var(--muted); padding: 4px 6px; border-bottom: 2px solid var(--line); vertical-align: bottom; }
.ctab td { padding: 6px; vertical-align: top; border-bottom: 1px solid #e8ecf0; }
.ctab .rownum { font-weight: 700; color: var(--muted); width: 28px; white-space: nowrap; }
.ctab .input-num { min-width: 80px; }
.mat-other { margin-top: 6px; }
.weight-check { margin: 6px 0 10px; font-size: 14px; color: var(--muted); min-height: 1px; }
.weight-check.warn { color: var(--warn); font-weight: 600; background: var(--warn-bg); padding: 6px 10px; border-radius: 6px; }
.ctable > .btn { margin-top: 4px; }

/* récapitulatif */
.recap-card { padding: 12px 16px; margin-bottom: 12px; border-left: 6px solid var(--line); }
.recap-card.ok { border-left-color: var(--ok); }
.recap-card.warn { border-left-color: #d99a00; }
.recap-card.ko { border-left-color: var(--err); }
.recap-card.commit { border-left-color: var(--accent); }
.recap-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.recap-head h2, .recap-card.commit h2 { font-size: 18px; margin: 0; }
.ok-line { color: var(--ok); margin: 6px 0; }
.missing-title { font-weight: 700; margin: 8px 0 2px; }
.missing-title.blocking, .missing.blocking { color: var(--err); }
.missing { margin: 0 0 8px; padding-left: 22px; }
.missing.blocking li { font-weight: 600; }
.answers summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--accent); font-weight: 600; }
.answers dl { margin: 0 0 8px; }
.answers dt { font-size: 14px; color: var(--muted); margin-top: 8px; }
.answers dd { margin: 0; overflow-wrap: anywhere; }
.submit-row { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 16px 0; }
.submit-hint { color: var(--err); font-weight: 600; }
.block-line { display: block; font-weight: 400; }

/* écrans simples */
.screen { max-width: 640px; margin: 24px auto; padding: 0 16px; outline: none; }
.screen-card { padding: 24px; }
.screen-card h1 { font-size: 22px; margin: 0 0 12px; }
.big-ok { font-size: 48px; color: var(--ok); margin: 0; line-height: 1; }
.nl-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.form-msg { min-height: 24px; margin: 0; }
.form-msg.err { color: var(--err); font-weight: 600; }
.form-msg.ok { color: var(--ok); font-weight: 600; }
.footer-note { margin-top: 20px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 12px; max-width: 520px; margin: 0 auto; background: #2a1210; color: #fff; padding: 12px 16px; border-radius: 8px; z-index: 50; }

/* mobile */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  .side { position: static; gap: 8px; }
  .nav-toggle { display: block; }
  .step-list { display: none; margin-top: 6px; }
  .step-list.open { display: flex; }
  .steps { padding: 4px 8px; }
  .fields { padding: 2px 12px; }
  .field.has-error { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
  .ref-list { gap: 4px 16px; }
  .ref-list dd { font-size: 15px; }
}
@media (max-width: 1180px) {
  /* le tableau de composants devient une liste de cartes */
  .table-scroll { overflow: visible; }
  .ctab, .ctab tbody, .ctab tr, .ctab td { display: block; width: 100%; min-width: 0; }
  .ctab thead { display: none; }
  .ctab tr.crow { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; background: #fafbfc; }
  .ctab td { border: 0; padding: 6px 0; }
  .ctab td[data-label]::before { content: attr(data-label); display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
  .ctab td.rownum { width: auto; font-size: 16px; color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 4px; }
  .ctab td.rownum::before { display: none !important; }
  .ctab td.td-act { text-align: right; }
  .ctab td.rownum { display: block; }
}
@media (max-width: 760px) {
  .pager .btn { min-width: 0; flex: 1; }
}
@media (max-width: 400px) {
  .brand { font-size: 16px; }
  .step-h { font-size: 20px; }
  .btn-lg { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .bar-fill { transition: none; } }
