:root {
  --navy: #26325e; --navy-2: #1b2447; --coral: #e5483b; --coral-2: #c93a2e;
  --ink: #1d2233; --muted: #667089; --line: #e1e4ec; --bg: #f4f5f9; --card: #fff;
  --green: #1d7a4f; --green-bg: #e3f4ea; --red: #b4271c; --red-bg: #fde7e5;
  --shadow: 0 1px 2px rgba(20,28,60,.05), 0 6px 20px rgba(20,28,60,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0 0 .5rem; color: var(--navy-2); text-wrap: balance; }
h2 { font-size: 1.08rem; margin: 0 0 1rem; color: var(--navy-2); }
.muted { color: var(--muted); } .small { font-size: .86rem; } .center { text-align: center; } .mt { margin-top: 1rem; }

.top { background: #fff; border-bottom: 1px solid var(--line); padding: .7rem max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.logo { height: 52px; display: block; }
.center-block { margin: 1.5rem auto 1rem; height: 70px; }
.progress { list-style: none; display: flex; gap: .4rem; margin: 0; padding: 0; flex-wrap: wrap; }
.progress li { display: flex; align-items: center; gap: .45rem; font-size: .88rem; color: var(--muted); padding: .35rem .75rem .35rem .4rem; border-radius: 999px; background: var(--bg); }
.progress li span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #dfe3ec; color: var(--muted); font-weight: 700; font-size: .8rem; }
.progress li.current { background: #eceff8; color: var(--navy-2); font-weight: 600; }
.progress li.current span { background: var(--coral); color: #fff; }
.progress li.done span { background: var(--green); color: #fff; }

.wrap { max-width: 860px; margin: 0 auto; padding: 1.75rem max(16px, env(safe-area-inset-right)) 3rem max(16px, env(safe-area-inset-left)); }
.wrap.narrow { max-width: 520px; }
.intro { margin-bottom: 1.2rem; }
.intro p { color: #3b4258; margin: .4rem 0; }
.notice { background: #fff6f5; border: 1px solid #f6cfcb; border-left: 4px solid var(--coral); padding: .75rem 1rem; border-radius: 8px; color: #7a2a22 !important; }
.alert { background: var(--red-bg); color: var(--red); border: 1px solid #f4c3be; padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem 1.5rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.stack { display: grid; gap: 1rem; }
.stack label { display: grid; gap: .35rem; font-weight: 600; font-size: .9rem; }
.stack label .muted { font-weight: 400; }

.grid { display: grid; gap: 0 1rem; }
.g-2 { grid-template-columns: repeat(2, 1fr); } .g-3 { grid-template-columns: repeat(3, 1fr); } .g-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
.field { margin: 0 0 1rem; border: 0; padding: 0; min-width: 0; }
.field > label, .field legend { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; color: #2c3350; padding: 0; }
.req { color: var(--coral); }
input[type=text], input[type=email], input[type=tel], input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid #cdd2df; border-radius: 9px; background: #fff; font: inherit; color: var(--ink);
}
textarea { font: .9rem/1.5 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(38,50,94,.15); }
.has-error input, .has-error select { border-color: var(--red); }
.hint { display: block; color: var(--muted); font-size: .84rem; margin-top: .3rem; }
.error { display: block; color: var(--red); font-size: .84rem; margin-top: .3rem; font-weight: 500; }
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-block; padding: .55rem 1rem; border: 1px solid #cdd2df; border-radius: 999px; background: #fff; font-size: .95rem; }
.choice input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px rgba(38,50,94,.25); }
.has-error .choice span { border-color: var(--red); }
.check { display: flex; gap: .65rem; align-items: flex-start; cursor: pointer; margin: .4rem 0; }
.check input { width: 20px; height: 20px; margin: .15rem 0 0; accent-color: var(--navy); flex: none; }
.check.has-error span { color: var(--red); }
.upload { border: 1.5px dashed #c6ccda; border-radius: 10px; padding: .9rem 1rem; background: #fafbfd; margin-bottom: 1rem; }
.upload label { font-weight: 600; display: block; margin-bottom: .4rem; }
.upload input[type=file] { width: 100%; font-size: .9rem; }
.upload-status { display: block; margin-top: .4rem; font-size: .86rem; }
.upload-status.ok { color: var(--green); } .upload-status.error { color: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: .75rem 1.25rem; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--navy-2); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c3c9d8; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn.accent:hover { background: var(--coral-2); }
.btn.small { padding: .35rem .7rem; font-size: .85rem; font-weight: 500; }
.btn:focus-visible { outline: 3px solid rgba(38,50,94,.35); outline-offset: 2px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; font-size: .86rem; }
.actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.2rem; }

.paper { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.8rem 2rem; box-shadow: var(--shadow); margin-bottom: 1rem; line-height: 1.65; }
.paper p { margin: 0 0 .8rem; }
.paper .choices { margin-bottom: 1.2rem; }
.fill { color: #0d1f73; border-bottom: 1px solid #b9c0d6; padding: 0 .2rem; }
.mandat-list { padding-left: 1.2rem; margin: 0 0 1rem; } .mandat-list li { margin-bottom: .45rem; }
.date-line { margin-top: 1.2rem !important; }
.sigpad { position: relative; height: 210px; border: 1.5px solid #cdd2df; border-radius: 10px; background: #fff linear-gradient(transparent 160px, #dfe3ec 160px, #dfe3ec 161px, transparent 161px); touch-action: none; }
.sigpad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.sig-placeholder { position: absolute; left: 1rem; bottom: 56px; color: #b6bccb; pointer-events: none; font-style: italic; }
.sigpad.signed .sig-placeholder { display: none; }
.sigpad.sig-error { border-color: var(--red); }
.sig-tools { display: flex; justify-content: flex-end; margin-top: .4rem; }

.done { padding: 2.5rem 1.5rem; }
.done-icon { width: 68px; height: 68px; margin: 0 auto 1rem; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; font-size: 2rem; font-weight: 700; }
.done-icon.ko { background: var(--red-bg); color: var(--red); }
#busy { position: fixed; inset: 0; background: rgba(20,26,50,.55); display: grid; place-items: center; z-index: 20; padding: 16px; }
.busy-box { background: #fff; border-radius: 12px; padding: 1.6rem 2rem; text-align: center; max-width: 320px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid #e3e6ef; border-top-color: var(--coral); margin: 0 auto .8rem; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 2rem; }

/* admin */
.ok-card { border-color: #bfe3cd; }
.copy-row { display: flex; gap: .5rem; margin: .8rem 0 1.2rem; }
.copy-row input { flex: 1; min-width: 0; font-size: .85rem; }
.ok-card h2 { margin-top: .5rem; }

@media (max-width: 640px) {
  .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } .span-2, .span-3 { grid-column: auto; }
  .card { padding: 1.1rem 1rem .8rem; } .paper { padding: 1.2rem 1rem; }
  .logo { height: 42px; } h1 { font-size: 1.3rem; }
  .progress li { font-size: 0; padding: .3rem; } .progress li span { font-size: .8rem; }
  .progress li.current { font-size: .82rem; padding-right: .7rem; }
  .actions .btn { flex: 1 1 100%; }
  .copy-row { flex-direction: column; }
}

/* admin : liens installateurs */
.narrow-card { max-width: 480px; margin-left: auto; margin-right: auto; }
.ok-msg { background: var(--green-bg); color: var(--green); border: 1px solid #bfe3cd; padding: .7rem 1rem; border-radius: 8px; font-weight: 500; }
.inline-grid { display: grid; grid-template-columns: 1.2fr 1.2fr .7fr auto; gap: .8rem; align-items: end; margin: 1rem 0 1.2rem; }
.inline-grid label { display: grid; gap: .35rem; font-weight: 600; font-size: .88rem; }
.inline-grid label .muted { font-weight: 400; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .6rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .65rem .6rem; border-bottom: 1px solid #eef0f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.linkcell { display: flex; gap: .4rem; min-width: 260px; }
.linkcell input { font-size: .8rem; padding: .4rem .5rem; min-width: 0; }
.badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: .18rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.grey { background: #eceef3; color: #545c72; }
.btn.danger { color: var(--red); border-color: #f0c4bf; }
form.inline { display: inline-flex; gap: .6rem; align-items: center; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 1rem; border: 1px dashed var(--line); border-radius: 10px; }
details.card summary { cursor: pointer; }
@media (max-width: 760px) { .inline-grid { grid-template-columns: 1fr; } }

.wrap.wide { max-width: 1100px; }
#liste, #liste:target, #liste:focus { outline: none; }

.kvtable td:first-child { color: var(--muted); width: 45%; }
.kvtable { margin-bottom: 1rem; }

/* admin : onglets */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 0 0 1.2rem; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy-2); border-bottom-color: var(--coral); }
.stack .check { font-weight: 400; display: flex; }
.stack h2 { margin: .6rem 0 0; }
code { background: #eef0f6; padding: 1px 5px; border-radius: 4px; font-size: .88em; }

.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.narrow-card a { color: var(--navy); }

/* Afficher / masquer le mot de passe */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 5.5rem; }
.pw-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); background: #eef0f6; border: 0; border-radius: 6px; padding: .35rem .6rem; font: inherit; font-size: .8rem; font-weight: 600; color: var(--navy-2); cursor: pointer; }
.pw-toggle:hover { background: #e1e5f0; }
.pw-toggle:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }

.secu-live { display: block; font-size: .84rem; margin-top: .3rem; color: var(--muted); }
.secu-live.ok { color: var(--green); font-weight: 600; }
.secu-live.error { color: var(--red); font-weight: 500; }

/* Prolonger un lien installateur */
details.extend { display: inline-block; margin-left: .4rem; vertical-align: middle; }
details.extend > summary { list-style: none; display: inline-flex; }
details.extend > summary::-webkit-details-marker { display: none; }
details.extend[open] > summary { background: var(--navy); color: #fff; border-color: var(--navy); }
.extend-form { display: grid; gap: .5rem; margin-top: .5rem; padding: .8rem; background: #f7f8fb; border: 1px solid var(--line); border-radius: 10px; min-width: 240px; white-space: normal; }
.extend-form label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 600; }
.extend-form label.check { display: flex; font-weight: 400; }
details.extend { position: relative; }
.extend-form { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 270px; box-shadow: 0 10px 30px rgba(20,28,60,.15); background: #fff; }
@media (min-width: 900px) { #liste.table-wrap { overflow: visible; } }
