:root {
  --bg: #f2f5f2; --surface: #fff; --text: #17201b; --muted: #5d6963; --border: #d8dfda;
  --primary: #1f5c43; --primary-ink: #fff; --accent: #f2c230;
  --ok: #138a45; --bad: #c62b1f; --warn: #d98b00; --info: #1d5fa8; --gray: #6c757d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101512; --surface: #19201c; --text: #e7ede9; --muted: #9aa6a0; --border: #2c3630;
    --primary: #3f9f74; --primary-ink: #fff; color-scheme: dark;
  }
}
:root[data-theme="dark"] { --bg: #101512; --surface: #19201c; --text: #e7ede9; --muted: #9aa6a0; --border: #2c3630; --primary: #3f9f74; color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 system-ui, -apple-system, Roboto, "Segoe UI", Arial, sans-serif; }
main { padding: 16px; max-width: 560px; margin: 0 auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.loading { text-align: center; padding: 40px; color: var(--muted); }

.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: #173f2f; color: #fff; }
.bar h1 { font-size: 18px; margin: 0; flex: 1; }
.bar .logo { font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.bar .back { background: none; border: none; color: #fff; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; cursor: pointer; }
#net { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
#net.online { background: rgba(255,255,255,.15); }
#net.offline { background: var(--warn); color: #000; }

button { font: inherit; cursor: pointer; border-radius: 12px; padding: 12px 16px; border: 2px solid var(--primary); }
button:disabled { opacity: .5; }
button.primary { background: var(--primary); color: var(--primary-ink); font-weight: 700; }
button.secondary { background: var(--surface); color: var(--primary); font-weight: 600; width: 100%; }
button.big { width: 100%; padding: 14px; font-size: 18px; }
button.huge { width: 100%; padding: 26px 16px; font-size: 22px; margin: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 6px; border-radius: 18px; }
button.huge .ico { font-size: 40px; line-height: 1; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; width: 100%; margin-top: 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.hello { font-size: 18px; margin: 4px 0; }

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 15px; }
.panel label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.panel label.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; }
input, select, textarea { font: inherit; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: 100%; font-weight: 400; }
fieldset { border: 1px dashed var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; margin: 0; }
fieldset[hidden] { display: none; }
legend { font-size: 14px; color: var(--muted); padding: 0 6px; }

.login { min-height: 100vh; display: flex; align-items: center; background: linear-gradient(170deg, #173f2f, #2c7a58); max-width: none; }
.login .panel { background: var(--surface); padding: 24px; border-radius: 18px; width: 100%; max-width: 420px; margin: 0 auto; }
.hero { display: flex; flex-direction: column; align-items: center; margin-bottom: 6px; }
.hero strong { font-size: 34px; letter-spacing: 3px; color: var(--primary); }
.hero span { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stats div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.stats strong { font-size: 24px; }
.stats span { font-size: 12px; color: var(--muted); }
.sync { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.sync button { margin-top: 6px; }

.note { padding: 10px 12px; border-radius: 10px; background: var(--surface); border-left: 4px solid var(--gray); font-size: 15px; margin: 10px 0; }
.note.warn { border-color: var(--warn); }
.note.bad { border-color: var(--bad); }
.note.info { border-color: var(--info); }

.scan { display: flex; flex-direction: column; gap: 12px; }
.viewfinder { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame { position: absolute; inset: 18%; border: 4px solid var(--accent); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-msg { text-align: center; color: var(--muted); margin: 0; }

.verdict { border-radius: 18px; padding: 26px 16px; text-align: center; color: #fff; display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.verdict strong { font-size: 30px; letter-spacing: 1px; }
.verdict .amount { font-size: 22px; font-weight: 700; }
.verdict.ok { background: var(--ok); } .verdict.bad { background: var(--bad); } .verdict.warn { background: var(--warn); color: #111; }
.verdict.info { background: var(--info); } .verdict.muted { background: var(--gray); }
.merchant { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 0; }
.merchant dt { color: var(--muted); }
.merchant dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 100; padding: 14px; border-radius: 12px; background: var(--ok); color: #fff; font-weight: 600; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.warn { background: var(--warn); color: #111; } .toast.bad { background: var(--bad); }

/* --- Recensement (assistant en 7 étapes) --- */
.hero em { color: var(--muted); font-size: 14px; margin-top: 6px; text-align: center; }
.panel h2 { font-size: 18px; margin: 0; color: var(--primary); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 0; }
.label { font-weight: 600; font-size: 15px; margin: 0; }
.wizard-bar small { display: block; opacity: .8; font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.pct { font-size: 12px; background: rgba(255,255,255,.18); padding: 3px 8px; border-radius: 999px; }
.progress { height: 5px; background: var(--border); position: sticky; top: 0; z-index: 9; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
main.with-footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
main.with-nav { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.wizard-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.wizard-nav button { width: 100%; }
.wizard-nav .save { background: var(--ok); border-color: var(--ok); }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex !important; flex-direction: row !important; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); font-weight: 500 !important; }
.choice input { width: 22px; height: 22px; flex: none; }
.choice:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.radio-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-weight: 600; font-size: 15px; }
.radio-row .check { font-weight: 400; display: flex; flex-direction: row; gap: 6px; align-items: center; }
.radio-row input { width: 20px; height: 20px; }
.segmented { display: flex; border: 2px solid var(--primary); border-radius: 12px; overflow: hidden; }
.segmented label { flex: 1; display: flex !important; flex-direction: row !important; justify-content: center; align-items: center; gap: 8px; padding: 12px 6px; }
.segmented label + label { border-left: 2px solid var(--primary); }
.segmented label:has(input:checked) { background: var(--primary); color: var(--primary-ink); }
.segmented input { width: auto; }
[hidden] { display: none !important; }
.photo-box { border: 2px dashed var(--border); border-radius: 14px; min-height: 180px; display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; background: var(--surface); }
.photo-box img { width: 100%; max-height: 320px; object-fit: contain; display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
label.button { display: block !important; text-align: center; border: 2px solid var(--primary); border-radius: 12px; padding: 12px; color: var(--primary); background: var(--surface); }
canvas.signature { width: 100%; aspect-ratio: 5 / 2; background: #fff; border: 2px solid var(--border); border-radius: 12px; touch-action: none; }
.recap { font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }

/* --- Mes recensements --- */
.section-title { font-size: 15px; color: var(--muted); margin: 18px 0 0; text-transform: uppercase; letter-spacing: .4px; }
.as-button { width: 100%; text-align: left; cursor: pointer; font: inherit; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; }
.chip { flex: none; padding: 8px 12px; border-radius: 999px; font-size: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.chip.sync { background: var(--ok); color: #fff; border-color: var(--ok); }
.cards { display: flex; flex-direction: column; gap: 10px; }
.census-card { text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 3px; color: var(--text); }
.census-card small { color: var(--muted); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.top h2 { margin: 6px 0; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: #dff3e6; color: #0f6b35; } .pill.warn { background: #fff0cc; color: #7a5300; }
.pill.bad { background: #fde2df; color: #9a1f15; } .pill.muted { background: #e9ecea; color: #555; }
.bad-text { color: var(--bad) !important; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button { border: none; background: none; border-radius: 0; padding: 8px 2px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottom-nav .ico { font-size: 22px; line-height: 1; }
.bottom-nav button.active { color: var(--primary); font-weight: 700; }
.note ul { margin: 6px 0; padding-left: 18px; }

.photo-box.portrait { aspect-ratio: 3 / 4; max-width: 240px; margin: 0 auto; width: 100%; min-height: 0; }
.photo-box.portrait img { width: 100%; height: 100%; object-fit: cover; max-height: none; }
.recap { display: flex; gap: 12px; align-items: center; }
.recap-photo { width: 64px; height: 85px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: none; }
.id-photo { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0 0 14px; }
.id-photo img { width: 150px; height: 200px; object-fit: cover; border-radius: 12px; border: 3px solid var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.2); background: var(--border); }
.id-photo small { color: var(--muted); text-align: center; }

/* Paiement mobile money */
button.pay { background: var(--accent); color: #2b2100; border-color: var(--accent); font-weight: 800; width: 100%; }
button.pay.big { padding: 14px; font-size: 18px; }
.ops { border: none; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.ops legend { font-weight: 600; margin-bottom: 8px; }
.op { display: flex !important; flex-direction: row !important; align-items: center; gap: 12px; padding: 14px; border: 2px solid var(--border);
  border-radius: 12px; background: var(--surface); font-weight: 700; }
.op input { width: 22px; height: 22px; flex: none; }
.op:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.op-wave span { color: #1a8fd6; } .op-orange_money span { color: #f07c00; } .op-free_money span { color: #c4161c; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0; text-align: center; }
.qr-box img { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
.qr-box small { color: var(--muted); }
