:root {
  --red: #d62828;
  --red-dark: #a61e1e;
  --orange: #f08c00;
  --violet: #7b2cbf;
  --green: #2b8a3e;
  --ink: #1b1b1f;
  --muted: #5f6368;
  --line: #e3e3e8;
  --bg: #f6f6f8;
  --card: #fff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--violet); }
.hidden { display: none !important; }

/* ---------- Écrans auth / attente ---------- */
.screen { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 48px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 8px 0 20px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; }
.brand h1 { font-size: 26px; margin: 0; letter-spacing: -0.5px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.card { width: 100%; max-width: 420px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card h2 { margin: 0 0 6px; font-size: 20px; }
.card p.lead { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.tabs { display: flex; background: #ececf1; border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
label small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea {
  width: 100%; padding: 12px 13px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 16px;
}
select {
  width: 100%; padding: 12px 38px 12px 13px; border: 1.5px solid var(--line); border-radius: 10px; font-size: 16px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6368' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 14px center;
  -webkit-appearance: none; appearance: none;
}
select:invalid { color: var(--muted); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--violet); }
textarea { resize: vertical; min-height: 70px; }
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: 16px; margin-top: 18px; background: var(--ink); color: #fff; }
.btn.secondary { background: #ececf1; color: var(--ink); }
.btn:disabled { opacity: .55; }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.msg.err { background: #fde8e8; color: var(--red-dark); }
.msg.ok { background: #e6f4ea; color: var(--green); }
.ts { margin-top: 14px; min-height: 0; }
.status-icon { font-size: 44px; text-align: center; margin: 4px 0 8px; }
.foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; max-width: 420px; }

/* ---------- Guide d'installation ---------- */
.step { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-top: 10px; }
.step .btn { margin-top: 10px; padding: 12px; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-num { flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.step-body { font-size: 14px; line-height: 1.5; margin-top: 8px; color: #333; }
.step-body ol { margin: 4px 0 0; padding-left: 20px; }
.step-body li { margin: 3px 0; }
.step.done { border-color: #b7dfc2; background: #f1faf3; }
.step.done .step-num { background: var(--green); }
.step.done .step-num::before { content: '✓'; }
.step.done .step-num span { display: none; }
.step.locked { opacity: .55; }
.share-ico { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; }

/* ---------- Pages légales et check-list ---------- */
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 13px; line-height: 1.45; margin-top: 16px; }
label.check input { width: 20px; height: 20px; flex: 0 0 20px; margin: 1px 0 0; accent-color: var(--ink); }
.legal-links a { color: var(--muted); }
.legal { max-width: 720px; margin: 0 auto; padding: 18px 16px 48px; line-height: 1.6; font-size: 15px; }
.legal h1 { font-size: 26px; margin: 8px 0 2px; line-height: 1.2; }
.legal h2 { font-size: 18px; margin: 26px 0 6px; }
.legal-date, .legal-back { color: var(--muted); font-size: 13px; margin: 0; }
.legal ul { padding-left: 20px; }
.legal .todo { background: #fff4e0; color: #9a5b00; font-weight: 700; padding: 0 4px; border-radius: 4px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; display: block; overflow-x: auto; }
.legal-table th, .legal-table td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.legal-table th { background: #ececf1; }
.legal-nav { margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.legal-nav a { color: var(--muted); }
.golden { background: var(--red); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; }
.golden > strong { display: block; font-size: 18px; margin-bottom: 4px; }
.golden ul { margin: 6px 0 0; padding-left: 20px; }
.progress { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 6px rgba(0,0,0,.07); position: sticky; top: 8px; z-index: 5; font-weight: 700; font-size: 14px; }
.progress .bar { height: 8px; border-radius: 4px; background: #ececf1; margin-top: 8px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s; }
.checklist { list-style: none; padding: 0 !important; margin: 0; }
.checklist li { background: #fff; border-radius: 12px; margin: 8px 0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.checklist label { display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 14px; font-weight: 400; font-size: 15px; cursor: pointer; }
.checklist input { width: 22px; height: 22px; flex: 0 0 22px; margin: 1px 0 0; accent-color: var(--green); }
.checklist small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.phase { display: flex; align-items: center; gap: 8px; }
.phase span { font-size: 12px; font-weight: 700; color: var(--muted); background: #ececf1; border-radius: 6px; padding: 2px 7px; }
.note-box { background: #fff; border-left: 4px solid var(--violet); border-radius: 8px; padding: 10px 14px; font-size: 14px; margin: 12px 0; }

/* ---------- Démo ---------- */
.demo-banner { position: fixed; z-index: 2000; top: 0; left: 0; right: 0; background: repeating-linear-gradient(45deg, #ffd43b, #ffd43b 12px, #fcc419 12px, #fcc419 24px); color: #1b1b1f; font-weight: 800; font-size: 11px; text-align: center; padding: 3px 8px calc(3px); letter-spacing: .3px; padding-top: max(3px, env(safe-area-inset-top)); }
body.is-demo .screen, body.is-demo .admin, body.is-demo .legal { padding-top: 34px; }
body.is-demo .bulletin { top: calc(max(10px, env(safe-area-inset-top)) + 22px); }
.demo-btn { display: block; text-align: left; margin-top: 10px; background: #fff; color: var(--ink); border: 2px solid var(--line); }
.demo-btn small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 2px; }
.demo-btn:hover { border-color: var(--ink); }
.demo-reset { border: 0; border-radius: 9px; padding: 8px 12px; font-weight: 700; }

/* ---------- Réglages ---------- */
.settings-head { width: 100%; max-width: 420px; display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.settings-head h1 { margin: 0; font-size: 24px; }
.back-btn { border: 0; background: #ececf1; border-radius: 10px; padding: 9px 12px; font-weight: 700; }
.set-card { margin-bottom: 14px; }
.set-card h2 { font-size: 17px; margin-bottom: 4px; }
.info { font-size: 13px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.set-card .btn { margin-top: 12px; }
.device { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.device div { flex: 1; min-width: 0; }
.device small { display: block; color: var(--muted); font-size: 12px; }
.device button { border: 0; background: #fde8e8; color: var(--red-dark); border-radius: 8px; padding: 7px 10px; font-weight: 700; font-size: 13px; }
.device .here { font-size: 12px; font-weight: 700; color: var(--green); }
.danger { border: 1.5px solid #f3c4c4; }
.danger-btn { background: var(--red); }

/* ---------- Carte ---------- */
#mapScreen { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: #eef0f3; }
.bulletin {
  position: absolute; z-index: 1000; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px;
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 11px 14px 11px 14px; color: #fff;
  display: flex; gap: 12px; align-items: center; background: var(--green);
}
.bulletin.vigilance { background: var(--orange); }
.bulletin.alerte { background: var(--red); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(214,40,40,.25), var(--shadow); } }
.bulletin .ico { font-size: 26px; line-height: 1; }
.bulletin .txt { flex: 1; min-width: 0; }
.bulletin strong { display: block; font-size: 15px; }
.bulletin span { display: block; font-size: 13px; opacity: .95; }
.bulletin .menu-btn { border: 0; background: rgba(255,255,255,.22); color: #fff; width: 38px; height: 38px; border-radius: 10px; font-size: 20px; }
.live { position: absolute; z-index: 1000; left: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); background: #fff; border-radius: 20px; padding: 5px 10px; font-size: 12px; box-shadow: var(--shadow); color: var(--muted); }
.live::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #bbb; margin-right: 6px; vertical-align: 1px; }
.live.on::before { background: #2fb344; }
.action-bar { position: fixed; z-index: 1001; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.calm-btn { flex: 0 0 34%; border: 0; border-radius: 16px; background: var(--green); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 8px 24px rgba(43,138,62,.35); line-height: 1.15; }
.calm-btn:active { transform: translateY(1px); }
.btn.calm-confirm { background: var(--green); }
.legend i.l-calme { background: var(--green); }
.report-btn {
  flex: 1;
  background: var(--red); color: #fff; border: 0; border-radius: 16px; padding: 19px; font-size: 18px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(214, 40, 40, .45); letter-spacing: .2px; line-height: 1.15;
}
.report-btn:active { background: var(--red-dark); transform: translateY(1px); }
.todo-btn { position: absolute; z-index: 1000; left: 12px; bottom: calc(132px + env(safe-area-inset-bottom)); border: 0; background: #fff; border-radius: 20px; padding: 7px 12px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); }
.todo-btn b { display: inline-block; min-width: 0; margin-left: 2px; color: var(--muted); font-weight: 700; }
.todo-btn.vigilance { background: var(--orange); color: #fff; }
.todo-btn.alerte { background: var(--red); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.todo-btn.vigilance b, .todo-btn.alerte b { color: rgba(255,255,255,.85); }
.todo-btn.all-done b { color: var(--green); }
#todoSheet .checklist li { box-shadow: none; border: 1.5px solid var(--line); }
.todo-full { text-align: center; text-decoration: none; }
.legend-btn { position: absolute; z-index: 1000; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); border: 0; background: #fff; border-radius: 20px; padding: 6px 11px; font-size: 12px; box-shadow: var(--shadow); }
.legend { position: absolute; z-index: 1000; right: 12px; bottom: calc(132px + env(safe-area-inset-bottom)); background: #fff; border-radius: 12px; padding: 10px 12px; font-size: 12px; box-shadow: var(--shadow); line-height: 1.9; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.l-pillage { background: var(--red); }
.legend i.l-groupe { background: var(--orange); }
.legend i.l-track { background: var(--violet); border-radius: 2px; height: 4px; vertical-align: 3px; }
.legend i.l-shop { background: var(--ink); }

/* ---------- Feuilles (formulaire, menu) ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.35); }
.sheet {
  position: fixed; z-index: 1101; left: 0; right: 0; bottom: 0; max-height: 92%; overflow: auto;
  background: #fff; border-radius: 20px 20px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0,0,0,.2); max-width: 560px; margin: 0 auto;
}
.sheet .grip { width: 44px; height: 5px; border-radius: 3px; background: #d5d5db; margin: 0 auto 10px; }
.sheet h2 { margin: 2px 0 2px; font-size: 20px; }
.sheet p.lead { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices.three { grid-template-columns: 1fr 1fr 1fr; }
.choice { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 13px 8px; font-weight: 700; font-size: 14px; text-align: center; }
.choice .e { display: block; font-size: 22px; margin-bottom: 3px; }
.choice.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.choice.on.pillage { border-color: var(--red); background: var(--red); }
.choice.on.groupe { border-color: var(--orange); background: var(--orange); }
.hint { margin: -2px 0 8px; font-size: 13px; color: var(--muted); }
.hint.done { color: var(--violet); font-weight: 700; }
#dirMap { height: 230px; border-radius: 12px; border: 2px solid var(--line); overflow: hidden; }
#dirMap.picked { border-color: var(--violet); }
.dir-unknown { display: block; width: 100%; margin-top: 8px; }
.dir-target { background: var(--violet); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 6px rgba(0,0,0,.4); }
.count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 15px 4px; font-size: 16px; border-bottom: 1px solid var(--line); }
.menu-list button:last-child { border-bottom: 0; }
.toast { position: fixed; z-index: 1200; left: 50%; transform: translateX(-50%); top: calc(90px + env(safe-area-inset-top)); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* ---------- Éléments Leaflet ---------- */
.tiles-light { filter: grayscale(1) brightness(1.08) contrast(.82); }
.shop-icon { background: var(--ink); border: 4px solid #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.leaflet-tooltip.shop-label { background: var(--ink); color: #fff; border: 0; font-weight: 700; font-size: 12px; padding: 3px 7px; border-radius: 7px; box-shadow: none; }
.leaflet-tooltip.shop-label::before { display: none; }
.pos-icon { background: var(--violet); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 0 rgba(123,44,191,.6); animation: ring 1.8s infinite; }
@keyframes ring { 70% { box-shadow: 0 0 0 16px rgba(123,44,191,0); } 100% { box-shadow: 0 0 0 0 rgba(123,44,191,0); } }
.eta-label { background: var(--violet); color: #fff; font-size: 11px; font-weight: 800; border-radius: 8px; padding: 2px 6px; white-space: nowrap; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.4; }
.pop strong { display: block; font-size: 15px; }
.pop .meta { color: var(--muted); font-size: 12px; }
.pop .conf { display: inline-block; margin-top: 6px; background: #e6f4ea; color: var(--green); border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 700; }
.pop .det { margin-top: 6px; font-style: italic; }
.pop button { margin-top: 8px; border: 0; background: #fde8e8; color: var(--red-dark); border-radius: 8px; padding: 7px 10px; font-weight: 700; font-size: 13px; }

/* ---------- Admin ---------- */
.admin { max-width: 980px; margin: 0 auto; padding: 16px; }
.admin header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.admin header h1 { font-size: 22px; margin: 0; flex: 1; }
.admin .tabs { max-width: 560px; }
@media (max-width: 480px) { .admin .tabs button { font-size: 13px; padding: 9px 4px; } }
.admin .tabs { flex-wrap: wrap; gap: 2px; }
.admin .tabs button { flex: 1 1 auto; }
.set-form label { margin-top: 12px; }
.inst-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inst-bar label { margin: 0; }
.inst-bar select { width: auto; flex: 1 1 180px; }
.inst-bar .btn { width: auto; margin: 0; padding: 11px 14px; font-size: 14px; text-decoration: none; text-align: center; flex: 1 1 220px; }
.inst-bar .meta { flex-basis: 100%; }
.inst-h { font-size: 16px; margin: 22px 4px 10px; }
.ann-body { white-space: pre-wrap; margin-top: 8px; color: var(--ink); }
.set-form .meta { margin-bottom: 4px; }
.warn, .warn-box { color: #9a5b00; }
.warn-box { background: #fff4e0; border-radius: 8px; padding: 9px 11px; margin-top: 12px; }
.warn-box code, .admin code { font-size: 12px; background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.row { background: #fff; border-radius: 12px; box-shadow: 0 1px 6px rgba(0,0,0,.07); padding: 14px; margin-bottom: 10px; }
.row h3 { margin: 0 0 4px; font-size: 16px; }
.row .meta { color: var(--muted); font-size: 13px; line-height: 1.55; }
.row .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row .acts button { border: 0; border-radius: 9px; padding: 9px 14px; font-weight: 700; }
.b-ok { background: var(--green); color: #fff; }
.b-no { background: #fde8e8; color: var(--red-dark); }
.b-neutral { background: #ececf1; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #ececf1; margin-left: 6px; vertical-align: 2px; }
.pill.approved { background: #e6f4ea; color: var(--green); }
.pill.suspended, .pill.rejected { background: #fde8e8; color: var(--red-dark); }
.pill.pending { background: #fff4e0; color: #9a5b00; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (min-width: 720px) {
  .bulletin { left: 50%; right: auto; transform: translateX(-50%); width: 520px; }
  .action-bar { left: 50%; right: auto; transform: translateX(-50%); width: 520px; }
}
